]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
JSON: More explicit check for depth in arrays/objects
authorJouni Malinen <j@w1.fi>
Sun, 9 Feb 2025 16:17:39 +0000 (18:17 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 9 Feb 2025 17:08:30 +0000 (19:08 +0200)
Invalid state here was detected based on the parent token being in
JSON_STARTED state, but to be clearer for static analyzers, also check
explicitly that depth is not 0.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/utils/json.c

index dd12f1b6ed3e8b178172c8d658ed5413433c2cf0..5523f284d0ffa3b3422f034783dc199e66b1d859 100644 (file)
@@ -269,7 +269,8 @@ struct json_token * json_parse(const char *data, size_t data_len)
                case ']': /* end array */
                case '}': /* end object */
                        if (!curr_token || !curr_token->parent ||
-                           curr_token->parent->state != JSON_STARTED) {
+                           curr_token->parent->state != JSON_STARTED ||
+                           depth == 0) {
                                wpa_printf(MSG_DEBUG,
                                           "JSON: Invalid state for end array/object");
                                goto fail;