]> 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:01:15 +0000 (23:01 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 15 Sep 2014 05:01:15 +0000 (23:01 -0600)
src/snmp_core.cc

index b491342073d46140c8f6e76c2471800bd7d59d64..e081d55cfee1816214990ede930d3872381d0751 100644 (file)
@@ -418,7 +418,7 @@ snmpConnectionClose(void)
 void
 snmpHandleUdp(int sock, void *not_used)
 {
-    LOCAL_ARRAY(char, buf, SNMP_REQUEST_SIZE);
+    static char buf[SNMP_REQUEST_SIZE];
     IpAddress from;
     snmp_request_t *snmp_rq;
     int len;
@@ -427,16 +427,11 @@ snmpHandleUdp(int sock, void *not_used)
 
     commSetSelect(sock, COMM_SELECT_READ, snmpHandleUdp, NULL, 0);
 
-    memset(buf, '\0', SNMP_REQUEST_SIZE);
+    memset(buf, '\0', sizeof(buf));
 
-    len = comm_udp_recvfrom(sock,
-                            buf,
-                            SNMP_REQUEST_SIZE,
-                            0,
-                            from);
+    len = comm_udp_recvfrom(sock, buf, sizeof(buf)-1, 0, from);
 
     if (len > 0) {
-        buf[len] = '\0';
         debugs(49, 3, "snmpHandleUdp: FD " << sock << ": received " << len << " bytes from " << from << ".");
 
         snmp_rq = (snmp_request_t *)xcalloc(1, sizeof(snmp_request_t));