From: Joshua Rogers Date: Sat, 25 Oct 2025 15:08:41 +0000 (+0000) Subject: pinger: Echo all received bytes on Windows icmp_sock (#2210) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b8af615ec19bd7fcb92312b095802a227aa31633;p=thirdparty%2Fsquid.git pinger: Echo all received bytes on Windows icmp_sock (#2210) Avoids OOB read by strlen(). --- diff --git a/src/icmp/IcmpPinger.cc b/src/icmp/IcmpPinger.cc index 24df9d6469..e5fa30fd5d 100644 --- a/src/icmp/IcmpPinger.cc +++ b/src/icmp/IcmpPinger.cc @@ -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;