]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
pinger: Echo all received bytes on Windows icmp_sock (#2210)
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Sat, 25 Oct 2025 15:08:41 +0000 (15:08 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 25 Oct 2025 15:10:11 +0000 (15:10 +0000)
Avoids OOB read by strlen().

src/icmp/IcmpPinger.cc

index 24df9d6469ba80daebbe1677a90835e7215890c1..e5fa30fd5d15efbbf2b76604c83006d872c83666 100644 (file)
@@ -51,12 +51,14 @@ IcmpPinger::Open(void)
 
     WSADATA wsaData;
     WSAPROTOCOL_INFO wpi;
-    char buf[sizeof(wpi)];
+    char buf[sizeof(wpi)+1];
     int x;
 
     struct sockaddr_in PS;
     int xerrno;
 
+    static_assert(sizeof(WSAPROTOCOL_INFO) >= sizeof(PS), "PS must fit into wpi-sized buf");
+
     WSAStartup(2, &wsaData);
     atexit(Win32SockCleanup);
 
@@ -114,7 +116,7 @@ IcmpPinger::Open(void)
 
     xwrite(1, "OK\n", 3);
     memset(buf, 0, sizeof(buf));
-    x = xrecv(icmp_sock, buf, sizeof(buf), 0);
+    x = xrecv(icmp_sock, buf, sizeof(buf)-1, 0);
 
     if (x < 3) {
         xerrno = errno;