]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix off by one in SNMP subsystem
authorSebastian Krahmer <krahmer@suse.com>
Mon, 15 Sep 2014 05:03:30 +0000 (23:03 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 15 Sep 2014 05:03:30 +0000 (23:03 -0600)
src/snmp_core.cc

index 1fa2fc6a23f656d41d878f253cd7069bb5024392..4023c4879d87528f0b23f0c9d00ad7ba297b66dc 100644 (file)
@@ -476,8 +476,7 @@ snmpConnectionClose(void)
 void
 snmpHandleUdp(int sock, void *not_used)
 {
-    LOCAL_ARRAY(char, buf, SNMP_REQUEST_SIZE);
-
+    static char buf[SNMP_REQUEST_SIZE];
     struct sockaddr_in from;
     socklen_t from_len;
     snmp_request_t *snmp_rq;
@@ -489,18 +488,17 @@ snmpHandleUdp(int sock, void *not_used)
 
     from_len = sizeof(struct sockaddr_in);
     memset(&from, '\0', from_len);
-    memset(buf, '\0', SNMP_REQUEST_SIZE);
+    memset(buf, '\0', sizeof(buf));
 
     len = comm_udp_recvfrom(sock,
                             buf,
-                            SNMP_REQUEST_SIZE,
+                            sizeof(buf)-1,
                             0,
 
                             (struct sockaddr *) &from,
                             &from_len);
 
     if (len > 0) {
-        buf[len] = '\0';
         debugs(49, 3, "snmpHandleUdp: FD " << sock << ": received " << len << " bytes from " << inet_ntoa(from.sin_addr) << ".");
 
         snmp_rq = (snmp_request_t *)xcalloc(1, sizeof(snmp_request_t));