diff options
author | Martijn van Duren <martijn@cvs.openbsd.org> | 2019-10-08 10:00:43 +0000 |
---|---|---|
committer | Martijn van Duren <martijn@cvs.openbsd.org> | 2019-10-08 10:00:43 +0000 |
commit | 698c86fa2e2f7d64d971d292efe53264c4ebdbd3 (patch) | |
tree | 963d3f38c8f7e7fb6a35c078be00db55a3f1caab /usr.bin/snmp | |
parent | 961d7dec836b001f711b2d25f074f2891ed4ef20 (diff) |
Free the "e" element in ber_printf_elements if it fails, since there's no
chance that it's part of the new ber structure.
Feedback and OK claudio@
Diffstat (limited to 'usr.bin/snmp')
-rw-r--r-- | usr.bin/snmp/snmp.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/snmp/snmp.c b/usr.bin/snmp/snmp.c index 8129bff0aac..1fd11a2658a 100644 --- a/usr.bin/snmp/snmp.c +++ b/usr.bin/snmp/snmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmp.c,v 1.7 2019/10/03 11:02:26 martijn Exp $ */ +/* $OpenBSD: snmp.c,v 1.8 2019/10/08 10:00:42 martijn Exp $ */ /* * Copyright (c) 2019 Martijn van Duren <martijn@openbsd.org> @@ -259,6 +259,7 @@ snmp_set(struct snmp_agent *agent, struct ber_element *vblist) if (ber_printf_elements(pdu, "tddd{e", BER_CLASS_CONTEXT, SNMP_C_SETREQ, arc4random() & 0x7fffffff, 0, 0, vblist) == NULL) { ber_free_elements(pdu); + ber_free_elements(vblist); return NULL; } @@ -428,8 +429,10 @@ snmp_package(struct snmp_agent *agent, struct ber_element *pdu, size_t *len) if (ber_printf_elements(message, "d{idxd}xe", agent->version, msgid, UDP_MAXPACKET, &(agent->v3->level), (size_t) 1, agent->v3->sec->model, securityparams, - securitysize, scopedpdu) == NULL) + securitysize, scopedpdu) == NULL) { + ber_free_elements(scopedpdu); goto fail; + } if (ber_scanf_elements(message, "{SSe", &secparams) == -1) goto fail; ber_set_writecallback(secparams, snmp_v3_secparamsoffset, |