From: Thomas Weißschuh Date: Mon, 2 Oct 2023 20:24:21 +0000 (+0200) Subject: libblkid: reset errno before calling probefuncs X-Git-Tag: v2.39.3~38 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=edc723cd3341ff3d3e660051525dca40a2af6b3b;p=thirdparty%2Futil-linux.git libblkid: reset errno before calling probefuncs 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 Signed-off-by: Karel Zak --- diff --git a/libblkid/src/partitions/partitions.c b/libblkid/src/partitions/partitions.c index 1c344fd303..8ebf480f55 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 fb03927078..96bc0ef896 100644 --- a/libblkid/src/superblocks/superblocks.c +++ b/libblkid/src/superblocks/superblocks.c @@ -421,6 +421,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 cd1f4c25f7..67df3e3389 100644 --- a/libblkid/src/topology/topology.c +++ b/libblkid/src/topology/topology.c @@ -182,6 +182,8 @@ 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; }