mirror of
https://github.com/json-c/json-c.git
synced 2026-09-08 17:16:49 +08:00
reject negative after whitespace in json_parse_uint64
This commit is contained in:
+7
-1
@@ -263,7 +263,13 @@ int json_parse_uint64(const char *buf, uint64_t *retval)
|
||||
uint64_t val;
|
||||
|
||||
errno = 0;
|
||||
while (*buf == ' ')
|
||||
/* strtoull() skips leading whitespace and then quietly negates a
|
||||
* leading '-', wrapping the result into a huge value. We only skipped
|
||||
* spaces here, so a '-' behind a tab/newline/etc slipped past the check
|
||||
* below. Skip the same whitespace set strtoull() does so the rejection
|
||||
* actually holds. */
|
||||
while (*buf == ' ' || *buf == '\t' || *buf == '\n' || *buf == '\v' || *buf == '\f' ||
|
||||
*buf == '\r')
|
||||
buf++;
|
||||
if (*buf == '-')
|
||||
return 1; /* error: uint cannot be negative */
|
||||
|
||||
Reference in New Issue
Block a user