]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/blkdev: handle interrupted read call
authorSamanta Navarro <ferivoz@riseup.net>
Fri, 13 Jan 2023 11:50:40 +0000 (11:50 +0000)
committerSamanta Navarro <ferivoz@riseup.net>
Mon, 16 Jan 2023 12:05:21 +0000 (12:05 +0000)
The read call may fail if it is interrupted by a signal. Do not assume
that we have reached the end of the underlying block device because of
this. Use read_all which retries in these cases.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
lib/blkdev.c

index cc1eea3a6281d1af435bef74050fe350be99f0d5..954de454e6d6f0ff79df5003580f0c5292414d7e 100644 (file)
@@ -31,6 +31,7 @@
 # define EBADFD 77             /* File descriptor in bad state */
 #endif
 
+#include "all-io.h"
 #include "blkdev.h"
 #include "c.h"
 #include "linux_version.h"
@@ -43,7 +44,7 @@ blkdev_valid_offset (int fd, off_t offset) {
 
        if (lseek (fd, offset, 0) < 0)
                return 0;
-       if (read (fd, &ch, 1) < 1)
+       if (read_all (fd, &ch, 1) < 1)
                return 0;
        return 1;
 }