]> git.ipfire.org Git - people/pmueller/ipfire-3.x.git/blobdiff - net-tools/patches/007-net-tools-interface_stack.patch
net-tools: Update to 2.0 git-rev e5f1be13.
[people/pmueller/ipfire-3.x.git] / net-tools / patches / 007-net-tools-interface_stack.patch
similarity index 53%
rename from net-tools/patches/net-tools-1.60-interface_stack.patch
rename to net-tools/patches/007-net-tools-interface_stack.patch
index 10bbe6dc3bb1b230056d665b16c5326cb8f63e01..6a93e67418328d3d79440a1f7ce7fc3d25b38eb8 100644 (file)
@@ -1,13 +1,13 @@
-Bugzilla Bug 176714 – *** stack smashing detected ***: /sbin/ifconfig terminated
-
---- a/lib/interface.c-old      2005-12-30 11:08:15.000000000 -0800
-+++ b/lib/interface.c  2005-12-30 11:17:02.000000000 -0800
-@@ -201,10 +201,11 @@
+diff -up net-tools-2.0/include/interface.h.stack net-tools-2.0/include/interface.h
+diff -up net-tools-2.0/lib/interface.c.stack net-tools-2.0/lib/interface.c
+--- net-tools-2.0/lib/interface.c.stack        2014-11-24 14:54:32.293134466 +0100
++++ net-tools-2.0/lib/interface.c      2014-11-24 15:07:58.434764441 +0100
+@@ -214,10 +214,11 @@ out:
      return err;
  }
  
--static char *get_name(char *name, char *p)
-+static char *get_name(char **namep, char *p)
+-static const char *get_name(char *name, const char *p)
++static const char *get_name(char **namep, const char *p)
  {
      while (isspace(*p))
        p++;
@@ -15,33 +15,35 @@ Bugzilla Bug 176714 – *** stack smashing detected ***: /sbin/ifconfig terminat
      while (*p) {
        if (isspace(*p))
            break;
-@@ -305,9 +306,10 @@
+@@ -320,9 +321,10 @@ static int get_dev_fields(const char *bp
+ static int if_readlist_proc(const char *target)
  {
-     static int proc_read; 
      FILE *fh;
 -    char buf[512];
      struct interface *ife;
      int err;
 +    char *line = NULL;
-+    size_t linelen = 0;
++    size_t linelen = 0;  
  
-     if (proc_read) 
-           return 0; 
-@@ -320,8 +322,11 @@
-                       _PATH_PROCNET_DEV, strerror(errno)); 
-               return if_readconf();
-       }       
--    fgets(buf, sizeof buf, fh);       /* eat line */
--    fgets(buf, sizeof buf, fh);
+     fh = fopen(_PATH_PROCNET_DEV, "r");
+     if (!fh) {
+@@ -330,10 +332,11 @@ static int if_readlist_proc(const char *
+                       _PATH_PROCNET_DEV, strerror(errno));
+               return -2;
+       }
+-    if (fgets(buf, sizeof buf, fh))
+-              /* eat line */;
+-    if (fgets(buf, sizeof buf, fh))
+-              /* eat line */;
 +    if (getline(&line, &linelen, fh) == -1 /* eat line */
-+      || getline(&line, &linelen, fh) == -1) {
++      || getline(&line, &linelen, fh) == -1) { /* eat line */
 +              err = -1;
 +              goto out;
-+    }
++      }
  
  #if 0                         /* pretty, but can't cope with missing fields */
      fmt = proc_gen_fmt(_PATH_PROCNET_DEV, 1, fh,
-@@ -346,13 +351,13 @@
+@@ -358,14 +361,14 @@ static int if_readlist_proc(const char *
      if (!fmt)
        return -1;
  #else
@@ -51,15 +53,16 @@ Bugzilla Bug 176714 – *** stack smashing detected ***: /sbin/ifconfig terminat
  
      err = 0;
 -    while (fgets(buf, sizeof buf, fh)) {
--      char *s, name[IFNAMSIZ];
--      s = get_name(name, buf);    
 +    while (getline(&line, &linelen, fh) != -1) {
-+      char *s, *name;
+       const char *s;
+-      char name[IFNAMSIZ];
+-      s = get_name(name, buf);
++      char *name;
 +      s = get_name(&name, line);    
-       ife = add_interface(name);
+       ife = if_cache_add(name);
        get_dev_fields(s, ife);
        ife->statistics_valid = 1;
-@@ -368,6 +373,8 @@
+@@ -380,6 +383,8 @@ static int if_readlist_proc(const char *
  #if 0
      free(fmt);
  #endif
@@ -68,8 +71,8 @@ Bugzilla Bug 176714 – *** stack smashing detected ***: /sbin/ifconfig terminat
      fclose(fh);
      return err;
  }
-@@ -376,8 +383,9 @@
- static int if_readlist_rep(char *target, struct interface *ife)
+@@ -387,24 +392,28 @@ static int if_readlist_proc(const char *
+ static int if_readlist_rep(const char *target, struct interface *ife)
  {
      FILE *fh;
 -    char buf[512];
@@ -79,17 +82,18 @@ Bugzilla Bug 176714 – *** stack smashing detected ***: /sbin/ifconfig terminat
  
      fh = fopen(_PATH_PROCNET_DEV, "r");
      if (!fh) {
-@@ -385,15 +393,18 @@
+               fprintf(stderr, _("Warning: cannot open %s (%s). Limited output.\n"),
                        _PATH_PROCNET_DEV, strerror(errno)); 
                return if_readconf();
-       }       
+-      }       
 -    fgets(buf, sizeof buf, fh);       /* eat line */
 -    fgets(buf, sizeof buf, fh);
++      }
 +    if (getline(&line, &linelen, fh) == -1 /* eat line */
-+      || getline(&line, &linelen, fh) == -1) {
++      || getline(&line, &linelen, fh) == -1) { /* eat line */
 +              err = -1;
 +              goto out;
-+    }
++      }
  
 -    procnetdev_vsn = procnetdev_version(buf);
 +    procnetdev_vsn = procnetdev_version(line);
@@ -104,7 +108,7 @@ Bugzilla Bug 176714 – *** stack smashing detected ***: /sbin/ifconfig terminat
        get_dev_fields(s, ife);
        if (target && !strcmp(target,name))
        {
-@@ -406,6 +417,8 @@
+@@ -417,6 +426,8 @@ static int if_readlist_rep(const char *t
        err = -1;
      }