1 Bugzilla Bug 176714 – *** stack smashing detected ***: /sbin/ifconfig terminated
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
9 -static char *get_name(char *name, char *p)
10 +static char *get_name(char **namep, char *p)
14 + char *name = *namep = p;
23 struct interface *ife;
31 _PATH_PROCNET_DEV, strerror(errno));
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) {
42 #if 0 /* pretty, but can't cope with missing fields */
43 fmt = proc_gen_fmt(_PATH_PROCNET_DEV, 1, fh,
48 - procnetdev_vsn = procnetdev_version(buf);
49 + procnetdev_vsn = procnetdev_version(line);
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) {
58 + s = get_name(&name, line);
59 ife = add_interface(name);
60 get_dev_fields(s, ife);
61 ife->statistics_valid = 1;
72 static int if_readlist_rep(char *target, struct interface *ife)
80 fh = fopen(_PATH_PROCNET_DEV, "r");
83 _PATH_PROCNET_DEV, strerror(errno));
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) {
94 - procnetdev_vsn = procnetdev_version(buf);
95 + procnetdev_vsn = procnetdev_version(line);
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) {
103 + s = get_name(&name, line);
104 get_dev_fields(s, ife);
105 if (target && !strcmp(target,name))