]> git.kaiwu.me - njs.git/commitdiff
QueryString: avoiding arithmetic ops with NULL in parse().
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 11 Jan 2024 23:13:43 +0000 (15:13 -0800)
committerDmitry Volyntsev <xeioex@nginx.com>
Thu, 11 Jan 2024 23:13:43 +0000 (15:13 -0800)
Found by UndefinedBehaviorSanitizer.

external/njs_query_string_module.c

index c927d8e464a98453ba0c1cc13ac767e14f53bf90..f97fb223898145622d34c3100154bada8a25f169 100644 (file)
@@ -491,7 +491,7 @@ njs_query_string_parser(njs_vm_t *vm, u_char *query, u_char *end,
 
     key = query;
 
-    do {
+    while (key < end) {
         if (count++ == max_keys) {
             break;
         }
@@ -519,8 +519,7 @@ njs_query_string_parser(njs_vm_t *vm, u_char *query, u_char *end,
     next:
 
         key = part + sep->length;
-
-    } while (key < end);
+    }
 
     return NJS_OK;
 }