Skip to content

Commit

Permalink
When parsing a number at the top level, validate name
Browse files Browse the repository at this point in the history
If a string starting with an integer (but not solely an integer) is
passed as an argument to be decoded by the JSON parser, the parser will
crash because NULL is eventually handed to strcmp(3). Integers aren't
valid at the top level anyway.
  • Loading branch information
kattrali committed Dec 16, 2017
1 parent 556ae89 commit 9b08b9c
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,9 @@ int bsg_ksjsoncodec_i_decodeElement(const char **ptr, const char *const end,
}

if (!isFPChar(**ptr) && accum >= 0) {
if (name == NULL) {
return BSG_KSJSON_ERROR_INCOMPLETE;
}
accum *= sign;
return callbacks->onIntegerElement(name, accum, userData);
}
Expand Down

0 comments on commit 9b08b9c

Please sign in to comment.