Skip to content

Commit

Permalink
Add quotation marks when printing optional block strings
Browse files Browse the repository at this point in the history
  • Loading branch information
leonlynch committed Apr 30, 2023
1 parent 6baf43e commit 14b97f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ if(TARGET tr31-tool AND BUILD_TESTING)
".*"
"Optional blocks \\[2\\]:[\r\n]"
"\t\\[KS\\] Key Set Identifier: 1ED9D500000001200000[\r\n]"
"\t\\[PB\\] Padding Block: nD8U[\r\n]"
"\t\\[PB\\] Padding Block: \"nD8U\"[\r\n]"
"Key length: 16[\r\n]"
"Key value: 4AC3A7637268E618C52C97CE7766F26A \\(KCV: 72098B\\)[\r\n]"
)
Expand Down
8 changes: 4 additions & 4 deletions src/tr31-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static error_t argp_parser_helper(int key, char* arg, struct argp_state* state);
static void* read_file(FILE* file, size_t* len);
static int parse_hex(const char* hex, void* bin, size_t bin_len);
static void print_hex(const void* buf, size_t length);
static void print_str(const void* buf, size_t length);
static void print_str_with_quotes(const void* buf, size_t length);

// argp option keys
enum tr31_tool_option_keys_t {
Expand Down Expand Up @@ -426,7 +426,7 @@ static void print_hex(const void* buf, size_t length)
}
}

static void print_str(const void* buf, size_t length)
static void print_str_with_quotes(const void* buf, size_t length)
{
char* str;

Expand All @@ -437,7 +437,7 @@ static void print_str(const void* buf, size_t length)
str = malloc(length + 1);
memcpy(str, buf, length);
str[length] = 0;
printf("%s", str);
printf("\"%s\"", str);
free(str);
}

Expand Down Expand Up @@ -561,7 +561,7 @@ static int do_tr31_import(const struct tr31_tool_options_t* options)

case TR31_OPT_BLOCK_PB:
case TR31_OPT_BLOCK_TS:
print_str(tr31_ctx.opt_blocks[i].data, tr31_ctx.opt_blocks[i].data_length);
print_str_with_quotes(tr31_ctx.opt_blocks[i].data, tr31_ctx.opt_blocks[i].data_length);
break;

// print all other optional blocks, including proprietary ones, as hex
Expand Down

0 comments on commit 14b97f0

Please sign in to comment.