Hi!

Many thanks for the debugging and the explanation how to reproduce the problem! I'll see that I upload a fixed version soonish, and ask Debian release managers also for inclusion into the next point releases.


Best regards,
  Alexander

Am 2013-05-05 21:24, schrieb Olivier Allard-Jacquin:
Hi,

        according to e3zhbo6k AT arcor.de :

<mail>
Upstream didn't respond nor did they fix it.

The memory leak is in resolver.c introduced by commit "Frédéric
Perrin patch for ipv6 reverse resolution via address structure that
retains IP family.". A struct addr_storage is always allocated in
resolve(). If dns resolution is turned off it will not be freed.

Possible fix?

diff --git a/resolver.c b/resolver.c
index c09de9d..e3b965d 100644
--- a/resolver.c
+++ b/resolver.c
@@ -472,15 +472,15 @@ void resolve(int af, void* addr, char* result, int
buflen) {
     int added = 0;
     struct addr_storage *raddr;

-    raddr = malloc(sizeof *raddr);
-    memset(raddr, 0, sizeof *raddr);
-    raddr->af = af;
-    raddr->len = (af == AF_INET ? sizeof(struct in_addr)
-                  : sizeof(struct in6_addr));
-    memcpy(&raddr->addr, addr, raddr->len);
-
     if(options.dnsresolution == 1) {

+        raddr = malloc(sizeof *raddr);
+        memset(raddr, 0, sizeof *raddr);
+        raddr->af = af;
+        raddr->len = (af == AF_INET ? sizeof(struct in_addr)
+                  : sizeof(struct in6_addr));
+        memcpy(&raddr->addr, addr, raddr->len);
+
         pthread_mutex_lock(&resolver_queue_mutex);

         if(hash_find(ns_hash, raddr, u_hostname.void_pp) ==
HASH_STATUS_OK) {</mail>
</mail>

        I confirm this patch does fix memory leak issue.

        Tested on both i386 and amd64 arch, with sources from
http://packages.debian.org/wheezy/iftop (iftop_1.0~pre2.orig.tar.gz &
iftop_1.0~pre2-3.diff.gz)

<Test procedure>
iftop -n -i lo
ping -f localhost
top
-> memory leak clearly appear after about 2min (~300Mo used)
-> without "-n" parameter, there is no memory leak (iftop process use
about 45Mo)
</Test procedure>

        Best regards,

                                                Olivier


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to