From: Eric Sandeen Date: Tue, 24 Feb 2009 21:13:39 +0000 (-0600) Subject: e2fsprogs: fix potential null ptr defef in check_for_modules() X-Git-Tag: v1.41.5~53 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=f2fe5da31deebc689bb64e71c8e873efc925d312;p=tools%2Fe2fsprogs.git 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 Signed-off-by: "Theodore Ts'o" --- diff --git a/e2fsck/util.c b/e2fsck/util.c index 6fbe5fc..6be1923 100644 --- a/e2fsck/util.c +++ b/e2fsck/util.c @@ -663,6 +663,8 @@ 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; diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index 17feb9d..91a6313 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;