read_config_file: ignore driver line without driver name
authorYann Droneaud <ydroneaud@opteya.com>
Tue, 31 May 2011 18:20:39 +0000 (11:20 -0700)
committerRoland Dreier <roland@purestorage.com>
Tue, 31 May 2011 18:20:39 +0000 (11:20 -0700)
If there's no driver name, strsep() will set config to NULL and later
processing of the driver name will segfault.

Spotted with zzuf.

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
src/init.c

index 4f0130e..06e550d 100644 (file)
@@ -257,7 +257,7 @@ static void read_config_file(const char *path)
 
                field = strsep(&config, "\n\t ");
 
-               if (strcmp(field, "driver") == 0) {
+               if (strcmp(field, "driver") == 0 && config != NULL) {
                        struct ibv_driver_name *driver_name;
 
                        config += strspn(config, "\t ");