diff options
-rw-r--r-- | usr.sbin/snmpd/ber.3 | 10 | ||||
-rw-r--r-- | usr.sbin/snmpd/ber.c | 9 | ||||
-rw-r--r-- | usr.sbin/snmpd/ber.h | 3 | ||||
-rw-r--r-- | usr.sbin/snmpd/snmpe.c | 5 |
4 files changed, 20 insertions, 7 deletions
diff --git a/usr.sbin/snmpd/ber.3 b/usr.sbin/snmpd/ber.3 index f37ff2af71a..8c4a35c83b0 100644 --- a/usr.sbin/snmpd/ber.3 +++ b/usr.sbin/snmpd/ber.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ber.3,v 1.3 2007/12/05 23:29:19 reyk Exp $ +.\" $OpenBSD: ber.3,v 1.4 2008/02/09 13:03:01 reyk Exp $ .\" .\" Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 5 2007 $ +.Dd $Mdocdate: February 9 2008 $ .Dt BER 3 .Os .Sh NAME @@ -53,6 +53,7 @@ .Nm ber_free_elements , .Nm ber_calc_len , .Nm ber_set_application , +.Nm ber_free .Nd Parse ASN.1 with Basic Encoding Rules. .Sh SYNOPSIS .Fd #include <ber.h> @@ -126,6 +127,8 @@ .Fn "ber_calc_len" "struct ber_element *root" .Ft "void" .Fn "ber_set_application" "struct ber *ber" "unsigned long (*cb)(struct ber_element *)" +.Ft "void" +.Fn "ber_free" "struct ber *ber" .Sh DESCRIPTION The .Nm ber @@ -193,7 +196,8 @@ struct ber_oid { .Fn ber_set_readbuf , .Fn ber_read_elements , .Fn ber_free_elements , -.Fn ber_set_application +.Fn ber_set_application , +.Fn ber_free .Pp .Sh RETURN VALUES diff --git a/usr.sbin/snmpd/ber.c b/usr.sbin/snmpd/ber.c index 53a172aa83a..e146acd47d1 100644 --- a/usr.sbin/snmpd/ber.c +++ b/usr.sbin/snmpd/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.5 2008/01/03 14:44:08 reyk Exp $ */ +/* $OpenBSD: ber.c,v 1.6 2008/02/09 13:03:01 reyk Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> @@ -1131,6 +1131,13 @@ ber_set_application(struct ber *b, unsigned long (*cb)(struct ber_element *)) b->br_application = cb; } +void +ber_free(struct ber *b) +{ + if (b->br_wbuf != NULL) + free (b->br_wbuf); +} + static ssize_t ber_getc(struct ber *b, u_char *c) { diff --git a/usr.sbin/snmpd/ber.h b/usr.sbin/snmpd/ber.h index d4fb8e52775..d20f98bcbf4 100644 --- a/usr.sbin/snmpd/ber.h +++ b/usr.sbin/snmpd/ber.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.h,v 1.3 2008/01/03 14:44:08 reyk Exp $ */ +/* $OpenBSD: ber.h,v 1.4 2008/02/09 13:03:01 reyk Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> @@ -121,4 +121,5 @@ void ber_free_elements(struct ber_element *); size_t ber_calc_len(struct ber_element *); void ber_set_application(struct ber *, unsigned long (*)(struct ber_element *)); +void ber_free(struct ber *); __END_DECLS 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) |