[prev in list] [next in list] [prev in thread] [next in thread] 

List:       squid-dev
Subject:    SNMP related memory leaks
From:       Radu Greab <radu () netsoft ! ro>
Date:       2001-05-31 18:30:52
Message-ID: 15126.36316.114503.795891 () ix ! netsoft ! ro
[Download RAW message or body]


Hello,

The patch below fixes another set of memory leaks:
- in snmpDecodePacket() the Community created in snmp_parse() was not
freed. Everyone querying squid through SNMP is affected.
- in snmpConstructResponse() the outbuf was not freed in all cases. It
seems more logical to me to move the xfree() call inside
snmpHandleUp(), just three lines down the xmalloc() call.


Thank you,
Radu Greab


Index: snmp_core.c
===================================================================
RCS file: /squid/squid/src/snmp_core.c,v
retrieving revision 1.45.2.2
diff -u -r1.45.2.2 snmp_core.c
--- snmp_core.c	2001/05/27 23:52:21	1.45.2.2
+++ snmp_core.c	2001/05/31 18:20:21
@@ -482,6 +482,7 @@
 	snmp_rq->outbuf = xmalloc(snmp_rq->outlen = SNMP_REQUEST_SIZE);
 	xmemcpy(&snmp_rq->from, &from, sizeof(struct sockaddr_in));
 	snmpDecodePacket(snmp_rq);
+	xfree(rq->outbuf);
 	xfree(snmp_rq);
     } else {
 	debug(49, 1) ("snmpHandleUdp: FD %d recvfrom: %s\n", sock, xstrerror());
@@ -523,6 +524,8 @@
 	    inet_ntoa(rq->from.sin_addr));
 	snmp_free_pdu(PDU);
     }
+    if (Community)
+	xfree(Community);
 }
 
 /*
@@ -545,7 +548,6 @@
 	ret = snmp_build(&Session, RespPDU, rq->outbuf, &rq->outlen);
 	sendto(rq->sock, rq->outbuf, rq->outlen, 0, (struct sockaddr *) &rq->from, sizeof(rq->from));
 	snmp_free_pdu(RespPDU);
-	xfree(rq->outbuf);
     }
 }
 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic