Nmap Development mailing list archives
Possible memory leaks in libnetutil
From: "Luis MartinGarcia." <luis.mgarc () gmail com>
Date: Tue, 10 Aug 2010 01:01:15 +0200
Hi again, Valgrind also showed possible memory leaks in libnetutil. I haven't look at this in detail but I think there should be a way to avoid the valgrind warnings like: o [libnetutil] Study route_dst(), getinterfaces() and getsysroutes() because they don't seem to be freeing memory they aquire thorugh safe_zalloc(). Currently valgrind reports this: ==12849== 2,944 bytes in 1 blocks are still reachable in loss record 8 of 9 ==12849== at 0x4C277CC: calloc (vg_replace_malloc.c:467) ==12849== by 0x42AEE5: safe_zalloc (nbase_memalloc.c:140) ==12849== by 0x438809: getinterfaces(int*, char*, unsigned long) (netuti ==12849== by 0x438ED2: getsysroutes_proc(_IO_FILE*, int*, char*, unsigne ==12849== by 0x4394A7: getsysroutes(int*, char*, unsigned long) (netutil ==12849== by 0x4398EC: route_dst(sockaddr_storage const*, route_nfo*, ch ==12849== by 0x413939: getNetworkInterfaceName(sockaddr_storage*, char*) ==12849== by 0x40F64A: NpingOps::validateOptions() (NpingOps.cc:2489) ==12849== by 0x40B2B1: main (nping.cc:156) ==12849== ==12849== 3,072 bytes in 1 blocks are still reachable in loss record 9 of 9 ==12849== at 0x4C277CC: calloc (vg_replace_malloc.c:467) ==12849== by 0x42AEE5: safe_zalloc (nbase_memalloc.c:140) ==12849== by 0x438EEF: getsysroutes_proc(_IO_FILE*, int*, char*, unsigne ==12849== by 0x4394A7: getsysroutes(int*, char*, unsigned long) (netutil ==12849== by 0x4398EC: route_dst(sockaddr_storage const*, route_nfo*, ch ==12849== by 0x413939: getNetworkInterfaceName(sockaddr_storage*, char*) ==12849== by 0x40F64A: NpingOps::validateOptions() (NpingOps.cc:2489) ==12849== by 0x40B2B1: main (nping.cc:156) The thing is that getinterfaces() caches the list of interfaces so subsequent calls don't have to use dnet or do ioctl() calls again. I guess getsysroutes() does something similar. However, it may be nice to provide some helpers or modify the functions in some way so we can free() any allocated memory and avoid the warnings. Regards, Luis MartinGarcia. _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://seclists.org/nmap-dev/
Current thread:
- Possible memory leaks in libnetutil Luis MartinGarcia. (Aug 09)
- Re: Possible memory leaks in libnetutil Brandon Enright (Aug 09)
- Re: Possible memory leaks in libnetutil Luis MartinGarcia. (Aug 09)
- Re: Possible memory leaks in libnetutil Fyodor (Aug 10)
- Re: Possible memory leaks in libnetutil Brandon Enright (Aug 09)