diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2019-09-30 17:42:16 +0200 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2019-09-30 17:42:16 +0200 |
commit | 52793b733de2ce5176b61d332b31e47ecfb844f0 (patch) | |
tree | 06a7abd2aea866228bb9db458d636b9151f6c822 | |
parent | 4bd0a47b222bd5fbfb820fba74d0a73307bff449 (diff) | |
download | 0xFFFF-52793b733de2ce5176b61d332b31e47ecfb844f0.tar.bz2 |
disk: Check if reading from block device failed
-rw-r--r-- | src/disk.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -270,6 +270,11 @@ int disk_dump_dev(int fd, const char * file) { size = read(fd, global_buf, need); if ( size == 0 ) break; + if ( size < 0 ) { + PRINTF_ERROR("Reading from block device failed"); + close(fd2); + return -1; + } if ( write(fd2, global_buf, size) != size ) { PRINTF_ERROR("Dumping image failed"); close(fd2); |