summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2017-07-09 17:26:13 +0200
committerPali Rohár <pali.rohar@gmail.com>2017-07-09 17:26:13 +0200
commit559fe2a3bde61ccac3619fe2281dd6faaeeebd33 (patch)
treedd1d45a6c505ce4c4372412831a3b85e9c802b9a
parentccec7a182f1373fb15051a1c03d28e44c4188cce (diff)
download0xFFFF-559fe2a3bde61ccac3619fe2281dd6faaeeebd33.tar.bz2
disk: After opening blkdev, check that it is really block device
-rw-r--r--src/disk.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/disk.c b/src/disk.c
index b0d4499..c8d218c 100644
--- a/src/disk.c
+++ b/src/disk.c
@@ -173,6 +173,10 @@ int disk_open_dev(int maj, int min, int partition, int readonly) {
if ( fd < 0 ) {
errno = old_errno;
ERROR_INFO("Cannot open block device %s", blkdev);
+ } else if ( fstat(fd, &st) != 0 || ! S_ISBLK(st.st_mode) ) {
+ ERROR("Block device %s is not block device\n", blkdev);
+ close(fd);
+ return -1;
}
} else {