]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix off-by-one in helper args count assertion (#2212)
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Thu, 11 Sep 2025 13:27:27 +0000 (13:27 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 11 Sep 2025 13:27:32 +0000 (13:27 +0000)
The `nargs` value should now be pointing past both the
`HELPER_MAX_ARGS` and the additional terminator. i.e. outside
the valid array space. This is okay because it is an absolute
counter (1-based) not an offset (0-based) despite how it is
used to fill the array.

src/helper.cc

index 0cead6f48b792a7430705447bdab43b7038a7976..58a4a2f022e38e163e6cd97f7ea7563e1792dcf5 100644 (file)
@@ -238,7 +238,7 @@ Helper::Client::openSessions()
     args[nargs] = nullptr;
     ++nargs;
 
-    assert(nargs <= HELPER_MAX_ARGS);
+    assert(nargs <= HELPER_MAX_ARGS + 1);
 
     int successfullyStarted = 0;
 
@@ -372,7 +372,7 @@ statefulhelper::openSessions()
     args[nargs] = nullptr;
     ++nargs;
 
-    assert(nargs <= HELPER_MAX_ARGS);
+    assert(nargs <= HELPER_MAX_ARGS + 1);
 
     int successfullyStarted = 0;