mirror of
https://github.com/json-c/json-c.git
synced 2026-03-29 09:59:06 +08:00
Issue #407: fix incorrect casts in calls to ctype functions (isdigit and isspace) so we don't crash when asserts are enabled on certain platforms and characters > 128 are parsed.
This commit is contained in:
@@ -44,7 +44,7 @@ static int is_valid_index(struct json_object *jo, const char *path, int32_t *idx
|
||||
/* this code-path optimizes a bit, for when we reference the 0-9 index range in a JSON array
|
||||
and because leading zeros not allowed */
|
||||
if (len == 1) {
|
||||
if (isdigit((int)path[0])) {
|
||||
if (isdigit((unsigned char)path[0])) {
|
||||
*idx = (path[0] - '0');
|
||||
goto check_oob;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ static int is_valid_index(struct json_object *jo, const char *path, int32_t *idx
|
||||
}
|
||||
/* RFC states base-10 decimals */
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!isdigit((int)path[i])) {
|
||||
if (!isdigit((unsigned char)path[i])) {
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user