-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #792 - set errno=EINVAL if parsing the string in json_parse_int…
…64 fails, to match the docs for json_object_get_int.
- Loading branch information
Showing
1 changed file
with
6 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,7 +247,12 @@ int json_parse_int64(const char *buf, int64_t *retval) | |
val = strtoll(buf, &end, 10); | ||
if (end != buf) | ||
*retval = val; | ||
return ((val == 0 && errno != 0) || (end == buf)) ? 1 : 0; | ||
if ((val == 0 && errno != 0) || (end == buf)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
hawicz
Author
Member
|
||
{ | ||
errno = EINVAL; | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
||
int json_parse_uint64(const char *buf, uint64_t *retval) | ||
|
Is the first part of the check correct?
man page on my system says:
So ie would a
val = LONG_MIN
witherrno == ERANGE
wrongly pass the test here? Shouldval==0
be dropped?