]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - pkgs/net-tools/patches/net-tools-1.60-interface_stack.patch
Change file layout of the makefiles.
[people/ms/ipfire-3.x.git] / pkgs / net-tools / patches / net-tools-1.60-interface_stack.patch
1 Bugzilla Bug 176714 – *** stack smashing detected ***: /sbin/ifconfig terminated
2
3 --- a/lib/interface.c-old 2005-12-30 11:08:15.000000000 -0800
4 +++ b/lib/interface.c 2005-12-30 11:17:02.000000000 -0800
5 @@ -201,10 +201,11 @@
6 return err;
7 }
8
9 -static char *get_name(char *name, char *p)
10 +static char *get_name(char **namep, char *p)
11 {
12 while (isspace(*p))
13 p++;
14 + char *name = *namep = p;
15 while (*p) {
16 if (isspace(*p))
17 break;
18 @@ -305,9 +306,10 @@
19 {
20 static int proc_read;
21 FILE *fh;
22 - char buf[512];
23 struct interface *ife;
24 int err;
25 + char *line = NULL;
26 + size_t linelen = 0;
27
28 if (proc_read)
29 return 0;
30 @@ -320,8 +322,11 @@
31 _PATH_PROCNET_DEV, strerror(errno));
32 return if_readconf();
33 }
34 - fgets(buf, sizeof buf, fh); /* eat line */
35 - fgets(buf, sizeof buf, fh);
36 + if (getline(&line, &linelen, fh) == -1 /* eat line */
37 + || getline(&line, &linelen, fh) == -1) {
38 + err = -1;
39 + goto out;
40 + }
41
42 #if 0 /* pretty, but can't cope with missing fields */
43 fmt = proc_gen_fmt(_PATH_PROCNET_DEV, 1, fh,
44 @@ -346,13 +351,13 @@
45 if (!fmt)
46 return -1;
47 #else
48 - procnetdev_vsn = procnetdev_version(buf);
49 + procnetdev_vsn = procnetdev_version(line);
50 #endif
51
52 err = 0;
53 - while (fgets(buf, sizeof buf, fh)) {
54 - char *s, name[IFNAMSIZ];
55 - s = get_name(name, buf);
56 + while (getline(&line, &linelen, fh) != -1) {
57 + char *s, *name;
58 + s = get_name(&name, line);
59 ife = add_interface(name);
60 get_dev_fields(s, ife);
61 ife->statistics_valid = 1;
62 @@ -368,6 +373,8 @@
63 #if 0
64 free(fmt);
65 #endif
66 + out:
67 + free(line);
68 fclose(fh);
69 return err;
70 }
71 @@ -376,8 +383,9 @@
72 static int if_readlist_rep(char *target, struct interface *ife)
73 {
74 FILE *fh;
75 - char buf[512];
76 int err;
77 + char *line = NULL;
78 + size_t linelen = 0;
79
80 fh = fopen(_PATH_PROCNET_DEV, "r");
81 if (!fh) {
82 @@ -385,15 +393,18 @@
83 _PATH_PROCNET_DEV, strerror(errno));
84 return if_readconf();
85 }
86 - fgets(buf, sizeof buf, fh); /* eat line */
87 - fgets(buf, sizeof buf, fh);
88 + if (getline(&line, &linelen, fh) == -1 /* eat line */
89 + || getline(&line, &linelen, fh) == -1) {
90 + err = -1;
91 + goto out;
92 + }
93
94 - procnetdev_vsn = procnetdev_version(buf);
95 + procnetdev_vsn = procnetdev_version(line);
96
97 err = 0;
98 - while (fgets(buf, sizeof buf, fh)) {
99 - char *s, name[IFNAMSIZ];
100 - s = get_name(name, buf);
101 + while (getline(&line, &linelen, fh) != -1) {
102 + char *s, *name;
103 + s = get_name(&name, line);
104 get_dev_fields(s, ife);
105 if (target && !strcmp(target,name))
106 {
107 @@ -406,6 +417,8 @@
108 err = -1;
109 }
110
111 + out:
112 + free(line);
113 fclose(fh);
114 return err;
115 }