diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2008-03-18 16:57:59 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2008-03-18 16:57:59 +0000 |
commit | 133978336e9ddebf7f8ddc71a0c421bc68c237af (patch) | |
tree | 51372458fb9eae8dd4948bbf6161618217a4e247 /usr.sbin/snmpd/trap.c | |
parent | 009dcf22dae36690d89ab9d9ba7acb09fdf6c7f1 (diff) |
remove ber_add_astring and make it the default behaviour in
ber_add_string, ber_add_nstring, and ber_add_bitstring to allocate and
copy the provided buffer instead of just attaching it to the ber
element. this may add some overhead but fixes and avoids some bugs
with static buffers and simplifies the ber api again.
From Matthew at Dempsky dot org
With input from claudio@
Diffstat (limited to 'usr.sbin/snmpd/trap.c')
-rw-r--r-- | usr.sbin/snmpd/trap.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/usr.sbin/snmpd/trap.c b/usr.sbin/snmpd/trap.c index 8d31b282bb7..e411ac27104 100644 --- a/usr.sbin/snmpd/trap.c +++ b/usr.sbin/snmpd/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.11 2008/02/08 12:36:47 reyk Exp $ */ +/* $OpenBSD: trap.c,v 1.12 2008/03/18 16:57:58 reyk Exp $ */ /* * Copyright (c) 2008 Reyk Floeter <reyk@vantronix.net> @@ -110,17 +110,13 @@ trap_imsg(struct imsgbuf *ibuf, pid_t pid) if ((sm->snmp_len < 1) || (sm->snmp_len >= SNMPD_MAXSTRLEN)) goto imsgdone; - if ((c = - calloc(1, sm->snmp_len)) == NULL) - goto imsgdone; - bcopy(sm + 1, c, sm->snmp_len); + c = (u_int8_t *)(sm + 1); if (sm->snmp_type == SNMP_BITSTRING) a = ber_add_bitstring(a, c, sm->snmp_len); else a = ber_add_nstring(a, c, sm->snmp_len); - a->be_free = 1; break; case SNMP_NULL: a = ber_add_null(a); |