diff options
author | maximilian attems <max@stro.at> | 2011-08-04 23:16:56 +0200 |
---|---|---|
committer | maximilian attems <max@stro.at> | 2011-08-04 23:22:43 +0200 |
commit | fc4e88562815e3ebe525e57b28934612257ed0c4 (patch) | |
tree | 8045bba03392364e351c1bdb19c6b919c3e6e6a5 | |
parent | e90b19b9558c9a5a054266393b7ef378b133f1aa (diff) | |
download | klibc-fc4e88562815e3ebe525e57b28934612257ed0c4.tar.gz |
[klibc] fstype: fix possible null deref in check_for_modules()
Make check_for_modules() more readable, just allways call
continue on NULL return. That way the possible null dereference
in strlen is no longer possible.
This doesn't yet make it unsuck, but is a small step.
Seen fixed too in blkid there with patch adding ko.gz support.
Cc: Karel Zak <kzak@redhat.com>
Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r-- | usr/kinit/fstype/fstype.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c index 2e26c9afdef80..c5a1432869197 100644 --- a/usr/kinit/fstype/fstype.c +++ b/usr/kinit/fstype/fstype.c @@ -171,13 +171,13 @@ static int check_for_modules(const char *fs_name) return 0; while (fgets(buf, sizeof(buf), f)) { cp = strchr(buf, ':'); - if (cp != NULL) - *cp = 0; - else + if (cp == NULL) continue; + *cp = 0; cp = strrchr(buf, '/'); - if (cp != NULL) - cp++; + if (cp == NULL) + continue; + cp++; i = strlen(cp); if (i > 3) { t = cp + i - 3; |