0006-IP-MIB-Linux-Fix-a-memory-leak-in-an-error-path.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From 7c073e3a1b736689135fd2ed44ede5b83790bd37 Mon Sep 17 00:00:00 2001
  2. From: Bart Van Assche <bvanassche@acm.org>
  3. Date: Mon, 26 Aug 2019 18:32:08 -0700
  4. Subject: IP-MIB, Linux: Fix a memory leak in an error path
  5. When a Linux system is booted with "ipv6.disable=1" in the kernel command
  6. line, the file "/proc/net/snmp6" is not created. Fix the memory leak in
  7. _systemstats_v6_load_systemstats() that is triggered with IPv6 disabled.
  8. See also https://sourceforge.net/p/net-snmp/bugs/2976/.
  9. Reported-by: Mark E Rusk <marker55@users.sourceforge.net>
  10. ---
  11. agent/mibgroup/ip-mib/data_access/systemstats_linux.c | 4 +++-
  12. 1 file changed, 3 insertions(+), 1 deletion(-)
  13. diff --git a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
  14. index e28ff93..f68d122 100644
  15. --- a/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
  16. +++ b/agent/mibgroup/ip-mib/data_access/systemstats_linux.c
  17. @@ -560,10 +560,12 @@ _systemstats_v6_load_systemstats(netsnmp_container* container, u_int load_flags)
  18. * try to open file. If we can't, that's ok - maybe the module hasn't
  19. * been loaded yet.
  20. */
  21. - if (!(devin = fopen(filename, "r"))) {
  22. + devin = fopen(filename, "r");
  23. + if (!devin) {
  24. DEBUGMSGTL(("access:systemstats",
  25. "Failed to load Systemstats Table (linux1), cannot open %s\n",
  26. filename));
  27. + netsnmp_access_systemstats_entry_free(entry);
  28. return 0;
  29. }
  30. --
  31. 2.7.4