------------------------------------------------------------
revno: 12682
revision-id: squid3@treenet.co.nz-20140915045919-0m34pzj8tm4v349u
parent: squid3@treenet.co.nz-20140827141553-ubgtveigs95lh0n2
author: Sebastian Krahmer <krahmer@suse.com>
committer: Amos Jeffries <squid3@treenet.co.nz>
branch nick: 3.3
timestamp: Sun 2014-09-14 22:59:19 -0600
message:
  Fix off by one in SNMP subsystem
------------------------------------------------------------
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: squid3@treenet.co.nz-20140915045919-0m34pzj8tm4v349u
# target_branch: http://bzr.squid-cache.org/bzr/squid3/3.3
# testament_sha1: 828557ab3f5073781d2570452555b8f1329c6587
# timestamp: 2014-09-15 11:08:57 +0000
# source_branch: http://bzr.squid-cache.org/bzr/squid3/3.3
# base_revision_id: squid3@treenet.co.nz-20140827141553-\
#   ubgtveigs95lh0n2
# 
# Begin patch
=== modified file 'b/src/snmp_core.cc'
--- a/src/snmp_core.cc	2012-10-16 23:40:01 +0000
+++ b/src/snmp_core.cc	2014-09-15 04:59:19 +0000
@@ -362,7 +362,7 @@
 void
 snmpHandleUdp(int sock, void *not_used)
 {
-    LOCAL_ARRAY(char, buf, SNMP_REQUEST_SIZE);
+    static char buf[SNMP_REQUEST_SIZE];
     Ip::Address from;
     SnmpRequest *snmp_rq;
     int len;
@@ -371,16 +371,11 @@
 
     Comm::SetSelect(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 = (SnmpRequest *)xcalloc(1, sizeof(SnmpRequest));

