From 8b1dbe49727bad9bd009306ab8921d06fd91b38a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 2 Oct 2023 13:01:47 +0200 Subject: [PATCH] libfdisk: reset errno before calling read() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- libfdisk/src/utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libfdisk/src/utils.c b/libfdisk/src/utils.c index 38ad233933..6b6167d478 100644 --- a/libfdisk/src/utils.c +++ b/libfdisk/src/utils.c @@ -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) -- 2.47.2