summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-03-14 17:32:05 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-03-14 17:32:05 +0000
commitd1bdea5a76903cf0d0984f58ce1d5d291807fa48 (patch)
tree14d8488ff8b75efb89da12b0ba724ecd37768df8
parent5b746b6ec6a273ece0802256da91772d7971c22a (diff)
downloaddrakx-backup-do-not-use-d1bdea5a76903cf0d0984f58ce1d5d291807fa48.tar
drakx-backup-do-not-use-d1bdea5a76903cf0d0984f58ce1d5d291807fa48.tar.gz
drakx-backup-do-not-use-d1bdea5a76903cf0d0984f58ce1d5d291807fa48.tar.bz2
drakx-backup-do-not-use-d1bdea5a76903cf0d0984f58ce1d5d291807fa48.tar.xz
drakx-backup-do-not-use-d1bdea5a76903cf0d0984f58ce1d5d291807fa48.zip
fix myself sux: don't unconditionnally fgets /proc/modules, because fopen
may have failed (the libc, in its great search for speed, probably doesn't care to check if the FILE* given to fgets is valid and opened)
-rw-r--r--mdk-stage1/modules.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c
index 283d6123a..210579c62 100644
--- a/mdk-stage1/modules.c
+++ b/mdk-stage1/modules.c
@@ -201,14 +201,15 @@ int module_already_present(const char * name)
{
FILE * f;
int answ = 0;
- f = fopen("/proc/modules", "rb");
- while (1) {
- char buf[500];
- if (!fgets(buf, sizeof(buf), f)) break;
- if (!strncmp(name, buf, strlen(name)) && buf[strlen(name)] == ' ')
- answ = 1;
- }
- fclose(f);
+ if ((f = fopen("/proc/modules", "rb"))) {
+ while (1) {
+ char buf[500];
+ if (!fgets(buf, sizeof(buf), f)) break;
+ if (!strncmp(name, buf, strlen(name)) && buf[strlen(name)] == ' ')
+ answ = 1;
+ }
+ fclose(f);
+ }
return answ;
}