Skip to content

Commit

Permalink
Merge pull request #159 from Zondax/improve_cbor_parser
Browse files Browse the repository at this point in the history
Improve cbor parser
  • Loading branch information
ftheirs authored May 9, 2022
2 parents fef51ca + 23726f6 commit fea25e5
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ endif

APPVERSION_M=2
APPVERSION_N=0
APPVERSION_P=5
APPVERSION_P=6

$(info COIN = [$(COIN)])

Expand Down
11 changes: 11 additions & 0 deletions deps/tinycbor/src/cborparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,24 @@ uint64_t _cbor_value_decode_int64_internal(const CborValue *value)
*/
CborError cbor_parser_init(const uint8_t *buffer, size_t size, uint32_t flags, CborParser *parser, CborValue *it)
{
#ifdef __SIZEOF_INT128__
if ((UINT64_MAX - (uint64_t) buffer < (uint64_t) size)) {
return CborErrorUnknownLength;
}
#else
if (((uint64_t) size + (uint64_t) buffer) > UINT32_MAX) {
return CborErrorUnknownLength;
}
#endif

memset(parser, 0, sizeof(*parser));
parser->end = buffer + size;
parser->flags = flags;
it->parser = parser;
it->ptr = buffer;
it->remaining = 1; /* there's one type altogether, usually an array or map */
it->flags = 0;

return preparse_value(it);
}

Expand Down
Binary file modified tests_zemu/snapshots/s-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fea25e5

Please sign in to comment.