summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2009-02-24 15:13:39 -0600
committerTheodore Ts'o <tytso@mit.edu>2009-03-06 02:37:33 -0500
commitf2fe5da31deebc689bb64e71c8e873efc925d312 (patch)
treedb14139e8b3b4136d25f5c2d4a82ba45572521f3 /lib
parent8d8224550c1f5b5c77afbf5acd95f73979276a0a (diff)
downloade2fsprogs-f2fe5da31deebc689bb64e71c8e873efc925d312.tar.gz
e2fsprogs: fix potential null ptr defef in check_for_modules()
The coverity scanner found this one. If a line in modules.dep has a ":" but no "/" then: if ((cp = strchr(buf, ':')) != NULL) *cp = 0; else continue; if ((cp = strrchr(buf, '/')) != NULL) cp++; /* XXX else cp is still null */ i = strlen(cp); ... we will deref a null pointer (cp). This can be demonstrated by putting a line like: foo.ko: into modules.dep. The below change just says that if no "/" is found, treat the whole string as the module name. Addresses-Red-Hat-Bugzilla: #486997 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib')
-rw-r--r--lib/blkid/probe.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
index 17feb9df..91a63131 100644
--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -227,6 +227,8 @@ static int check_for_modules(const char *fs_name)
continue;
if ((cp = strrchr(buf, '/')) != NULL)
cp++;
+ else
+ cp = buf;
i = strlen(cp);
if (i > 3) {
t = cp + i - 3;