diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2017-07-09 17:26:13 +0200 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2017-07-09 17:26:13 +0200 |
commit | 559fe2a3bde61ccac3619fe2281dd6faaeeebd33 (patch) | |
tree | dd1d45a6c505ce4c4372412831a3b85e9c802b9a | |
parent | ccec7a182f1373fb15051a1c03d28e44c4188cce (diff) | |
download | 0xFFFF-559fe2a3bde61ccac3619fe2281dd6faaeeebd33.tar.bz2 |
disk: After opening blkdev, check that it is really block device
-rw-r--r-- | src/disk.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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 { |