summaryrefslogtreecommitdiff
path: root/usr.sbin/snmpd/snmpe.c
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2008-02-09 13:03:02 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2008-02-09 13:03:02 +0000
commit268034c47daad3c36e58275f26eeddf58cff6c86 (patch)
tree30203ca3adf6c70f2bf8dfeb3b9ddfa6ce7ecc64 /usr.sbin/snmpd/snmpe.c
parent13764048a80cd9e08c1980ade80e29918a8061fa (diff)
fix a memleak in the snmp engine and the ber i/o; free the dynamically
allocated ber write buffer after using it. extend the ber api with a ber_free() function to do the required cleanup. Thanks to Will Backman (bitgeist at yahoo dot com) for testing and for figuring out that there was a memleak.
Diffstat (limited to 'usr.sbin/snmpd/snmpe.c')
-rw-r--r--usr.sbin/snmpd/snmpe.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.sbin/snmpd/snmpe.c b/usr.sbin/snmpd/snmpe.c
index 45f6a24505d..857b3a33fb6 100644
--- a/usr.sbin/snmpd/snmpe.c
+++ b/usr.sbin/snmpd/snmpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: snmpe.c,v 1.15 2008/01/16 21:43:19 reyk Exp $ */
+/* $OpenBSD: snmpe.c,v 1.16 2008/02/09 13:03:01 reyk Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net>
@@ -699,7 +699,7 @@ snmpe_recvmsg(int fd, short sig, void *arg)
{
struct snmp_stats *stats = &env->sc_stats;
struct sockaddr_storage ss;
- u_int8_t buf[READ_BUF_SIZE], *ptr;
+ u_int8_t buf[READ_BUF_SIZE], *ptr = NULL;
socklen_t slen;
ssize_t len;
struct ber ber;
@@ -775,6 +775,7 @@ snmpe_recvmsg(int fd, short sig, void *arg)
stats->snmp_outpkts++;
done:
+ ber_free(&ber);
if (req != NULL)
ber_free_elements(req);
if (resp != NULL)