From 4bc69757312cad09f0cd9dc0c04f483a76176203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 2 Oct 2023 22:24:21 +0200 Subject: [PATCH] libblkid: reset errno before calling probefuncs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The probers optionally use errno to communicate error details. When a leftover errno is set from libblkid internally this can confuse the probers. Signed-off-by: Thomas Weißschuh Reference:https://github.com/util-linux/util-linux/commit/4bc69757312cad09f0cd9dc0c04f483a76176203 Conflict:NA --- libblkid/src/partitions/partitions.c | 1 + libblkid/src/superblocks/superblocks.c | 1 + libblkid/src/topology/topology.c | 1 + 3 files changed, 3 insertions(+) diff --git a/libblkid/src/partitions/partitions.c b/libblkid/src/partitions/partitions.c index 0e38cf4..38ec8df 100644 --- a/libblkid/src/partitions/partitions.c +++ b/libblkid/src/partitions/partitions.c @@ -555,6 +555,7 @@ static int idinfo_probe(blkid_probe pr, const struct blkid_idinfo *id, if (id->probefunc) { DBG(LOWPROBE, ul_debug( "%s: ---> call probefunc()", id->name)); + errno = 0; rc = id->probefunc(pr, mag); if (rc < 0) { /* reset after error */ diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c index f213655..09ac45e 100644 --- a/libblkid/src/superblocks/superblocks.c +++ b/libblkid/src/superblocks/superblocks.c @@ -410,6 +410,7 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn) /* final check by probing function */ if (id->probefunc) { DBG(LOWPROBE, ul_debug("\tcall probefunc()")); + errno = 0; rc = id->probefunc(pr, mag); if (rc != BLKID_PROBE_OK) { blkid_probe_chain_reset_values(pr, chn); diff --git a/libblkid/src/topology/topology.c b/libblkid/src/topology/topology.c index 53007d1..e8b9ba8 100644 --- a/libblkid/src/topology/topology.c +++ b/libblkid/src/topology/topology.c @@ -180,6 +180,7 @@ static int topology_probe(blkid_probe pr, struct blkid_chain *chn) if (id->probefunc) { DBG(LOWPROBE, ul_debug("%s: call probefunc()", id->name)); + errno = 0; if (id->probefunc(pr, NULL) != 0) continue; } -- 2.33.0