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

index 18ea9b6fcffef45a5230c32dd7407c889c4eb65a..e16a0d48da3242bbc5856338b949a6066fd2697e 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;