aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2010-12-07 20:31:49 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2010-12-07 20:31:49 -0500
commit755866fee7ea4a6c2871a95fa9081656fb5bef23 (patch)
treec901bc8c33af4f13318bac6df7678b03f172fe34 /src
parentf9d771b678a824c8565c1bb9cd9127b8194b910c (diff)
downloadNetNuke2-755866fee7ea4a6c2871a95fa9081656fb5bef23.tar.gz
Check the return value of fgets
Diffstat (limited to 'src')
-rw-r--r--src/bus.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/bus.c b/src/bus.c
index 2c3f614..e28bda1 100644
--- a/src/bus.c
+++ b/src/bus.c
@@ -80,8 +80,8 @@ int scanbus_sysfs(nndevice_t** device)
}
else
{
- fgets(device[i]->model, sizeof(device[i]->model), fp);
- device[i]->model[strlen(device[i]->model) - 1] = 0;
+ if(fgets(device[i]->model, sizeof(device[i]->model), fp) != NULL)
+ device[i]->model[strlen(device[i]->model) - 1] = 0;
fclose(fp);
}
@@ -95,10 +95,11 @@ int scanbus_sysfs(nndevice_t** device)
}
else
{
- fgets(device[i]->vendor, sizeof(device[i]->model), fp);
- /* Why does sysfs not terminate the string after the last character? Kernel 2.6 bug?
+ /* Why does sysfs not terminate the string after the last character? Kernel 2.6 bug?
Here we are checking for the space character and terminating it manually. */
- device[i]->vendor[strind(device[i]->vendor, ' ')] = 0;
+ if((fgets(device[i]->vendor, sizeof(device[i]->model), fp)) != NULL)
+ device[i]->vendor[strind(device[i]->vendor, ' ')] = 0;
+
fclose(fp);
}