From: Sebastian Krahmer Date: Mon, 15 Sep 2014 04:59:19 +0000 (-0600) Subject: Fix off by one in SNMP subsystem X-Git-Tag: SQUID_3_3_14~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4eab554c67bb3a985f3b1ea25918d4a5bc73b80;p=thirdparty%2Fsquid.git Fix off by one in SNMP subsystem --- diff --git a/src/snmp_core.cc b/src/snmp_core.cc index 7ac54ddd37..00c1131064 100644 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@ -362,7 +362,7 @@ snmpClosePorts(void) 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 @@ snmpHandleUdp(int sock, void *not_used) 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));