summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3ebba02)
raw | patch | inline | side by side (parent: 3ebba02)
author | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Wed, 19 Nov 2014 15:00:54 +0000 (16:00 +0100) | ||
committer | Pierre-Yves Ritschard <pyr@spootnik.org> | |
Wed, 19 Nov 2014 15:47:06 +0000 (16:47 +0100) |
When reading from tables, upon errors the PDUs sent are already
freed by snmp_synch_response since they are right after
snmp_send is called.
This commit syncs collectd's approach with other occurences of
snmp_synch_response calls.
There might be a few corner cases where we leak PDUs, but it
is unclear how to check for those since we would need to
have an indication that snmp_send was never called, which
as far as I can tell is not possible.
The potential for failure in snmp_send is rather low and will
be easily spotted though, since when crafting invalid PDUs
snmp send will constantly fail and since valid configurations
can never leak memory.
This fixes #804
freed by snmp_synch_response since they are right after
snmp_send is called.
This commit syncs collectd's approach with other occurences of
snmp_synch_response calls.
There might be a few corner cases where we leak PDUs, but it
is unclear how to check for those since we would need to
have an indication that snmp_send was never called, which
as far as I can tell is not possible.
The potential for failure in snmp_send is rather low and will
be easily spotted though, since when crafting invalid PDUs
snmp send will constantly fail and since valid configurations
can never leak memory.
This fixes #804
src/snmp.c | patch | blob | history |
diff --git a/src/snmp.c b/src/snmp.c
index 3e6cb9119cb7a8a40a24f330f2398b00e3b1d104..b90e0ffa69269f4ad67df7874423989521d7cb60 100644 (file)
--- a/src/snmp.c
+++ b/src/snmp.c
@@ -1437,8 +1437,9 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
snmp_free_pdu (res);
res = NULL;
- if (req != NULL)
- snmp_free_pdu (req);
+ /*
+ * memory is handled by snmp_synch_response
+ */
req = NULL;
if (status == 0)