[Iftop-users] iftop segfaults on amd64 (proposed patch)

William Robinet william.robinet at conostix.com
Fri, 2 Dec 2005 11:50:21 +0100


On Fri, Dec 02, 2005 at 10:36:46AM +0000, Chris Lightfoot wrote:
> On Fri, Dec 02, 2005 at 11:30:55AM +0100, William Robinet wrote:
> > Hi,
> > 
> > Iftop segfaults on my amd64 machine (Gentoo Linux 2.6.14) when I'm using a
> > .iftoprc file containing the line:
> > dns-resolution: no
> 
> oops. I'm not really sure how that ever worked. Can you
> try this slightly shorter patch?
> 
> diff -u -r1.5 cfgfile.c
> --- cfgfile.c   19 Mar 2004 10:08:47 -0000      1.5
> +++ cfgfile.c   2 Dec 2005 10:32:06 -0000
> @@ -46,7 +46,7 @@
>  
>  int is_cfgdirective_valid(const char *s) {
>      char **t;
> -    for (t = config_directives; t != NULL; ++t)
> +    for (t = config_directives; *t != NULL; ++t)
>          if (strcmp(s, *t) == 0) return 1;
>      return 0;
>  }
> 


It works. Here is the complete patch against iftop-0.16:

--- iftop-0.16/cfgfile.c        2003-11-06 19:22:16.000000000 +0100
+++ iftop-0.16_patched/cfgfile.c        2005-12-02 11:45:40.222745673
+0100
@@ -45,9 +45,9 @@
 extern options_t options ;
 
 int is_cfgdirective_valid(const char *s) {
-    char* t;
-    for (t = config_directives[0]; t != NULL; ++t)
-        if (strcmp(s, t) == 0) return 1;
+    char **t;
+    for (t = config_directives; *t != NULL; ++t)
+        if (strcmp(s, *t) == 0) return 1;
     return 0;
 }

William

-- 
GPG Key ID: 74C7A949