Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.2
net-tools
net-tools-1.60-interface_stack.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File net-tools-1.60-interface_stack.patch of Package net-tools
Index: lib/interface.c =================================================================== --- lib/interface.c.orig +++ lib/interface.c @@ -216,10 +216,11 @@ out: return err; } -static char *get_name(char *name, char *p) +static char *get_name(char **namep, char *p) { while (isspace(*p)) p++; + char *name = *namep = p; while (*p) { if (isspace(*p)) break; @@ -320,9 +321,10 @@ static int if_readlist_proc(char *target { static int proc_read; FILE *fh; - char buf[512]; struct interface *ife; int err; + char *line = NULL; + size_t linelen = 0; if (proc_read) { return 0; @@ -337,8 +339,11 @@ static int if_readlist_proc(char *target _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) { + err = -1; + goto out; + } #if 0 /* pretty, but can't cope with missing fields */ fmt = proc_gen_fmt(_PATH_PROCNET_DEV, 1, fh, @@ -363,13 +368,13 @@ static int if_readlist_proc(char *target if (!fmt) return -1; #else - procnetdev_vsn = procnetdev_version(buf); + procnetdev_vsn = procnetdev_version(line); #endif 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; + s = get_name(&name, line); ife = add_interface(name); get_dev_fields(s, ife); ife->statistics_valid = 1; @@ -385,6 +390,8 @@ static int if_readlist_proc(char *target #if 0 free(fmt); #endif + out: + free(line); fclose(fh); return err; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor