diff --git a/src/parser_impl.c b/src/parser_impl.c index 24abcde7..0c2721fa 100644 --- a/src/parser_impl.c +++ b/src/parser_impl.c @@ -192,7 +192,7 @@ parser_error_t json_matchToken(const parsed_json_t *parsedJson, return PARSER_UNEXPECTED_TYPE; } - if (token.end < token.start || strlen(expectedValue) != (size_t)(token.end - token.start)) { + if (token.end < token.start || strlen(expectedValue) != (size_t) (token.end - token.start)) { return PARSER_UNEXPECTED_VALUE; } @@ -211,7 +211,7 @@ parser_error_t json_matchNull(const parsed_json_t *parsedJson, uint16_t tokenIdx return PARSER_UNEXPECTED_TYPE; } - if (token.end < token.start || 4 != (size_t)(token.end - token.start)) { + if (token.end < token.start || 4 != (size_t) (token.end - token.start)) { return PARSER_UNEXPECTED_VALUE; } @@ -581,7 +581,7 @@ parser_error_t _countArgumentItems(const flow_argument_list_t *v, void checkAddressUsedInTx() { addressUsedInTx = 0; uint16_t authCount = parser_tx_obj.authorizers.authorizer_count; - for (uint16_t i = 0; i < (uint16_t)(authCount + 2); i++) { //+2 for proposer and payer + for (uint16_t i = 0; i < (uint16_t) (authCount + 2); i++) { //+2 for proposer and payer parser_context_t *ctx = NULL; if (i > authCount) ctx = &parser_tx_obj.payer.ctx; if (i == authCount) ctx = &parser_tx_obj.proposalKeyAddress.ctx; diff --git a/src/parser_tx.c b/src/parser_tx.c index 15ace777..03444c14 100644 --- a/src/parser_tx.c +++ b/src/parser_tx.c @@ -658,6 +658,9 @@ parser_error_t parser_getItem_internal(int8_t *displayIdx, return PARSER_OK; } } else { + if (!app_mode_expert()) { + return PARSER_UNEXPECTED_ERROR; + } // Arbitrary message signing SCREEN(true) { snprintf(outKey, outKeyLen, "Script hash"); @@ -812,6 +815,9 @@ parser_error_t parser_getItem_internal(int8_t *displayIdx, return PARSER_OK; } for (size_t i = 0; i < parser_tx_obj.arguments.argCount; i++) { + if (!app_mode_expert()) { + return PARSER_UNEXPECTED_ERROR; + } SCREEN(true) { return parser_printArbitraryArgument(&parser_tx_obj.arguments, i, diff --git a/unit-tests/parser.c b/unit-tests/parser.c index 3a5bf86e..0f9503a6 100644 --- a/unit-tests/parser.c +++ b/unit-tests/parser.c @@ -82,6 +82,7 @@ const char *token7b = "fe314dba5363c81654595d64884b1ecad1512a64e65e020164\"}]," "\"type\": \"Array\"}"; +const char *dummy = ""; const char *token2c = "{\"value\":\"1\",\"type\":\"UInt8\"}"; const char *token3c = "{\"value\":\"2\",\"type\":\"UInt8\"}"; const char *token4c = "{\"value\":\"3\",\"type\":\"UInt8\"}"; @@ -94,7 +95,7 @@ flow_argument_list_t arg_list_b; flow_argument_list_t arg_list_c; void createArgList() { - const parser_context_t context0; + const parser_context_t context0 = {(const uint8_t *) dummy, strlen(dummy), 0}; const parser_context_t context2 = {(const uint8_t *) token2, strlen(token2), 0}; const parser_context_t context3 = {(const uint8_t *) token3, strlen(token3), 0}; const parser_context_t context4 = {(const uint8_t *) token4, strlen(token4), 0}; @@ -107,7 +108,7 @@ void createArgList() { 6}; memcpy(&arg_list, &new_arg_list, sizeof(arg_list)); - const parser_context_t context0b; + const parser_context_t context0b = {(const uint8_t *) dummy, strlen(dummy), 0}; const parser_context_t context2b = {(const uint8_t *) token2b, strlen(token2b), 0}; const parser_context_t context3b = {(const uint8_t *) token3b, strlen(token3b), 0}; const parser_context_t context4b = {(const uint8_t *) token4b, strlen(token4b), 0}; @@ -120,7 +121,7 @@ void createArgList() { 6}; memcpy(&arg_list_b, &new_arg_list_b, sizeof(arg_list_b)); - const parser_context_t context0c; + const parser_context_t context0c = {(const uint8_t *) dummy, strlen(dummy), 0}; const parser_context_t context2c = {(const uint8_t *) token2c, strlen(token2c), 0}; const parser_context_t context3c = {(const uint8_t *) token3c, strlen(token3c), 0}; const parser_context_t context4c = {(const uint8_t *) token4c, strlen(token4c), 0};