]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: reset errno before calling read()
authorThomas Weißschuh <thomas@t-8ch.de>
Mon, 2 Oct 2023 11:01:47 +0000 (13:01 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Mon, 2 Oct 2023 11:07:43 +0000 (13:07 +0200)
The else branch will be executed on short reads.
For those errno is not reset so a random left-over errno value may be
checked.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
libfdisk/src/utils.c

index 38ad233933af60ee8a3fce6b828cb08cf914110e..6b6167d478681545d5b406d9b4240709508aed4e 100644 (file)
@@ -29,6 +29,7 @@ static int read_from_device(struct fdisk_context *cxt,
                return -errno;
        }
 
+       errno = 0;
        r = read(cxt->dev_fd, buf, size);
        if (r < 0 || (size_t)r != size) {
                if (!errno)