]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Yahttp router: avoid unsigned underflow in route() 14479/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 17 Jul 2024 09:23:19 +0000 (11:23 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 17 Jul 2024 09:23:19 +0000 (11:23 +0200)
ext/yahttp/yahttp/router.cpp

index 90612ad8ec62d80f0824895d1204ce8e6de0756d..e9f6beecde459b54f6cc9d2cbeb538ab03d7ac24 100644 (file)
@@ -63,8 +63,16 @@ namespace YaHTTP {
             while(k2 < static_cast<int>(req->url.path.size()) && req->url.path[k2] != url[k1+1]) k2++;
             pos2 = k2;
             params[pname] = funcptr::tie(pos1,pos2);
+            if (k2 > 0) {
+              k2--;
+            }
+            else {
+              // If k2 is zero, do not decrement it and then increment at bottom of loop
+              // Only increment k1 and continue loop
+              k1++;
+              continue;
+            }
           }
-          k2--;
         }
         else if (url[k1] != req->url.path[k2]) {
           break;