From 467105d0863ad0f03593749812afc9f49f265768 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 10 Nov 2014 17:49:45 +0100 Subject: [PATCH] bfs_tools: fix NULL pointer dereference Happened when the given path did not map to any device (for example '/'). Fixes #11436. --- src/bin/bfs_tools/lib/Disk.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bin/bfs_tools/lib/Disk.cpp b/src/bin/bfs_tools/lib/Disk.cpp index b082938ea6..29d7da08b0 100644 --- a/src/bin/bfs_tools/lib/Disk.cpp +++ b/src/bin/bfs_tools/lib/Disk.cpp @@ -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");