mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-01 23:05:17 +00:00
Check for unexpected value after checking the name, not before.
This commit is contained in:
@@ -586,7 +586,7 @@ json_stack_push(struct json_stack *stack, struct json_item_list *items,
|
|||||||
unsigned int lineno)
|
unsigned int lineno)
|
||||||
{
|
{
|
||||||
struct json_item *item;
|
struct json_item *item;
|
||||||
debug_decl(iolog_parse_loginfo_json, SUDO_DEBUG_UTIL);
|
debug_decl(json_stack_push, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
/* We limit the stack size rather than expanding it. */
|
/* We limit the stack size rather than expanding it. */
|
||||||
if (stack->depth >= stack->maxdepth) {
|
if (stack->depth >= stack->maxdepth) {
|
||||||
@@ -725,12 +725,12 @@ iolog_parse_json(FILE *fp, const char *filename, struct json_object *root)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
|
if (strncmp(cp, "true", sizeof("true") - 1) != 0)
|
||||||
|
goto parse_error;
|
||||||
if (!expect_value) {
|
if (!expect_value) {
|
||||||
sudo_warnx("%s", U_("unexpected boolean"));
|
sudo_warnx("%s", U_("unexpected boolean"));
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
}
|
}
|
||||||
if (strncmp(cp, "true", sizeof("true") - 1) != 0)
|
|
||||||
goto parse_error;
|
|
||||||
cp += sizeof("true") - 1;
|
cp += sizeof("true") - 1;
|
||||||
if (*cp != ',' && !isspace((unsigned char)*cp) && *cp != '\0')
|
if (*cp != ',' && !isspace((unsigned char)*cp) && *cp != '\0')
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
@@ -740,12 +740,12 @@ iolog_parse_json(FILE *fp, const char *filename, struct json_object *root)
|
|||||||
name = NULL;
|
name = NULL;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
|
if (strncmp(cp, "false", sizeof("false") - 1) != 0)
|
||||||
|
goto parse_error;
|
||||||
if (!expect_value) {
|
if (!expect_value) {
|
||||||
sudo_warnx("%s", U_("unexpected boolean"));
|
sudo_warnx("%s", U_("unexpected boolean"));
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
}
|
}
|
||||||
if (strncmp(cp, "false", sizeof("false") - 1) != 0)
|
|
||||||
goto parse_error;
|
|
||||||
cp += sizeof("false") - 1;
|
cp += sizeof("false") - 1;
|
||||||
if (*cp != ',' && !isspace((unsigned char)*cp) && *cp != '\0')
|
if (*cp != ',' && !isspace((unsigned char)*cp) && *cp != '\0')
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
@@ -755,12 +755,12 @@ iolog_parse_json(FILE *fp, const char *filename, struct json_object *root)
|
|||||||
name = NULL;
|
name = NULL;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
if (!expect_value) {
|
|
||||||
sudo_warnx("%s", U_("unexpected boolean"));
|
|
||||||
goto parse_error;
|
|
||||||
}
|
|
||||||
if (strncmp(cp, "null", sizeof("null") - 1) != 0)
|
if (strncmp(cp, "null", sizeof("null") - 1) != 0)
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
|
if (!expect_value) {
|
||||||
|
sudo_warnx("%s", U_("unexpected null"));
|
||||||
|
goto parse_error;
|
||||||
|
}
|
||||||
cp += sizeof("null") - 1;
|
cp += sizeof("null") - 1;
|
||||||
if (*cp != ',' && !isspace((unsigned char)*cp) && *cp != '\0')
|
if (*cp != ',' && !isspace((unsigned char)*cp) && *cp != '\0')
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
|
Reference in New Issue
Block a user