From 5fdb35cb7848f4dcf7098dbb9405a18a69f39805 Mon Sep 17 00:00:00 2001 From: gerhard Date: Mon, 8 May 2023 12:25:23 +0000 Subject: [PATCH] Fix a potential mem-leak in usm_decrypt(). Spotted by hshoexer@ ok martijn@ --- usr.sbin/snmpd/usm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr.sbin/snmpd/usm.c b/usr.sbin/snmpd/usm.c index 1ced2fdb432..a3df1ac0f31 100644 --- a/usr.sbin/snmpd/usm.c +++ b/usr.sbin/snmpd/usm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usm.c,v 1.25 2022/12/20 20:01:25 martijn Exp $ */ +/* $OpenBSD: usm.c,v 1.26 2023/05/08 12:25:23 gerhard Exp $ */ /* * Copyright (c) 2012 GeNUA mbH @@ -629,8 +629,10 @@ usm_decrypt(struct snmp_message *msg, struct ber_element *encr) return NULL; scoped_pdu_len = usm_crypt(msg, privstr, (int)privlen, buf, 0); - if (scoped_pdu_len < 0) + if (scoped_pdu_len < 0) { + free(buf); return NULL; + } bzero(&ber, sizeof(ber)); ober_set_application(&ber, smi_application); -- 2.20.1