Skip to content

Commit

Permalink
Audit related minor code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
relatko committed Jun 5, 2024
1 parent 0f7d03a commit 2bf13a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/parser_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions unit-tests/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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\"}";
Expand All @@ -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};
Expand All @@ -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};
Expand All @@ -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};
Expand Down

0 comments on commit 2bf13a8

Please sign in to comment.