diff options
author | Erik Troan <ewt@redhat.com> | 1999-09-24 03:29:36 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 1999-09-24 03:29:36 +0000 |
commit | 2c5e4815099997af291b5d656a605b8d538cf2d4 (patch) | |
tree | 6a656d5a68a89fad1495c3513ad7f5b30ca15a26 /isys/probe.c | |
parent | 5c307dd1c9209f228c87117d60c3345a921c717e (diff) | |
download | anaconda-2c5e4815099997af291b5d656a605b8d538cf2d4.tar.gz anaconda-2c5e4815099997af291b5d656a605b8d538cf2d4.tar.xz anaconda-2c5e4815099997af291b5d656a605b8d538cf2d4.zip |
null terminating buffers is important
Diffstat (limited to 'isys/probe.c')
-rw-r--r-- | isys/probe.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/isys/probe.c b/isys/probe.c index b5d70484c..0e7cb2ad8 100644 --- a/isys/probe.c +++ b/isys/probe.c @@ -60,14 +60,21 @@ int kdFindNetList(struct knownDevices * devices) { char buf[1024]; char * start, * end; struct kddevice newDevice; + int s; if ((fd = open("/proc/net/dev", O_RDONLY)) < 0) { fprintf(stderr, "failed to open /proc/net/dev!\n"); return 1; } - read(fd, buf, sizeof(buf)); + s = read(fd, buf, sizeof(buf)); close(fd); + if (s < 0) { + fprintf(stderr, "error reading /proc/net/dev!\n"); + return 1; + } + + buf[s] = '\0'; /* skip the first two lines */ start = strchr(buf, '\n'); |