From 443a62e40b56ee796bfc8b76811bfe4ff566edf3 Mon Sep 17 00:00:00 2001 From: reyk Date: Sun, 20 Apr 2014 10:46:20 +0000 Subject: [PATCH] Partially revert the previous: snmp_agentx_ping() didn't leak the pdu because it is added to a list on the handle and eventually released later with the handle itself. This confuses leak detection tools like clang, so at least add a comment that it is not a leak. ok blambert@ --- usr.sbin/relayd/agentx.c | 14 +++++++------- usr.sbin/snmpd/agentx.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/usr.sbin/relayd/agentx.c b/usr.sbin/relayd/agentx.c index 369861436cf..e11cc612329 100644 --- a/usr.sbin/relayd/agentx.c +++ b/usr.sbin/relayd/agentx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agentx.c,v 1.3 2014/04/20 09:29:22 reyk Exp $ */ +/* $OpenBSD: agentx.c,v 1.4 2014/04/20 10:46:20 reyk Exp $ */ /* * Copyright (c) 2013,2014 Bret Stephen Lambert * @@ -889,14 +889,14 @@ snmp_agentx_ping(struct agentx_handle *h) if ((pdu = snmp_agentx_ping_pdu()) == NULL) return (-1); - if ((pdu = snmp_agentx_request(h, pdu)) == NULL || - snmp_agentx_response(h, pdu) == -1) { - error = -1; - goto fail; - } + /* Attaches the pdu to the handle; will be released later */ + if ((pdu = snmp_agentx_request(h, pdu)) == NULL) + return (-1); - fail: + if (snmp_agentx_response(h, pdu) == -1) + error = -1; snmp_agentx_pdu_free(pdu); + return (error); } diff --git a/usr.sbin/snmpd/agentx.c b/usr.sbin/snmpd/agentx.c index 369861436cf..e11cc612329 100644 --- a/usr.sbin/snmpd/agentx.c +++ b/usr.sbin/snmpd/agentx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agentx.c,v 1.3 2014/04/20 09:29:22 reyk Exp $ */ +/* $OpenBSD: agentx.c,v 1.4 2014/04/20 10:46:20 reyk Exp $ */ /* * Copyright (c) 2013,2014 Bret Stephen Lambert * @@ -889,14 +889,14 @@ snmp_agentx_ping(struct agentx_handle *h) if ((pdu = snmp_agentx_ping_pdu()) == NULL) return (-1); - if ((pdu = snmp_agentx_request(h, pdu)) == NULL || - snmp_agentx_response(h, pdu) == -1) { - error = -1; - goto fail; - } + /* Attaches the pdu to the handle; will be released later */ + if ((pdu = snmp_agentx_request(h, pdu)) == NULL) + return (-1); - fail: + if (snmp_agentx_response(h, pdu) == -1) + error = -1; snmp_agentx_pdu_free(pdu); + return (error); } -- 2.20.1