diff --git a/src/tss2-fapi/ifapi_policy_json_serialize.c b/src/tss2-fapi/ifapi_policy_json_serialize.c index 34f5813fd..415a85b55 100644 --- a/src/tss2-fapi/ifapi_policy_json_serialize.c +++ b/src/tss2-fapi/ifapi_policy_json_serialize.c @@ -693,6 +693,13 @@ ifapi_json_TPMS_POLICYAUTHORIZE_serialize(const TPMS_POLICYAUTHORIZE *in, json_object_object_add(*jso, "rsaScheme", jso2); + /* Check whether only one condition field found in policy. */ + if (cond_cnt > 1) { + return_error(TSS2_FAPI_RC_BAD_VALUE, + "Exactly one conditional is allowed for policy " + "duplication select."); + } + return TSS2_RC_SUCCESS; } diff --git a/src/tss2-fapi/tpm_json_deserialize.c b/src/tss2-fapi/tpm_json_deserialize.c index e039dd8b9..fe1a794be 100644 --- a/src/tss2-fapi/tpm_json_deserialize.c +++ b/src/tss2-fapi/tpm_json_deserialize.c @@ -34,9 +34,11 @@ json_object* ifapi_parse_json(const char *jstring) { json_object *jso = NULL; enum json_tokener_error jerr; +#if MAXLOGLEVEL > 0 int line = 1; int line_offset = 0; int char_pos; +#endif struct json_tokener* tok = json_tokener_new(); if (!tok) { LOG_ERROR("Could not allocate json tokener"); @@ -45,6 +47,7 @@ ifapi_parse_json(const char *jstring) { jso = json_tokener_parse_ex(tok, jstring, -1); jerr = json_tokener_get_error(tok); if (jerr != json_tokener_success) { +#if MAXLOGLEVEL > 0 for (char_pos = 0; char_pos <= tok->char_offset; char_pos++) { if (jstring[char_pos] == '\n') { line++; @@ -55,6 +58,7 @@ ifapi_parse_json(const char *jstring) { } LOG_ERROR("Invalid JSON at line %i column %i: %s.", line, line_offset, json_tokener_error_desc(jerr)); +#endif json_tokener_free(tok); return NULL; }