bfs_tools: fix NULL pointer dereference

Happened when the given path did not map to any device (for example
'/').

Fixes #11436.
This commit is contained in:
Adrien Destugues
2014-11-10 17:49:45 +01:00
parent 41bfed9f20
commit 467105d086
+5
View File
@@ -114,6 +114,11 @@ Disk::Disk(const char *deviceName, bool rawMode, off_t start, off_t stop)
deviceName = fPath.Path();
}
if (deviceName == NULL) {
fprintf(stderr, "Path is not mapped to any device.\n");
return;
}
if (!rawMode && !strncmp(deviceName, "/dev/", 5)
&& !strcmp(deviceName + strlen(deviceName) - 3, "raw"))
fprintf(stderr, "Raw mode not selected, but raw device specified.\n");