From f1a5ad691239a8840ee8c8da003d6cdbe80d0444 Mon Sep 17 00:00:00 2001 From: =?utf8?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=utf8 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 --- 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 6a11c50698..e096cf8f72 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); blkid_probe_prune_buffers(pr); if (rc < 0) { diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c index e89af1b629..f64b19aef1 100644 --- a/libblkid/src/superblocks/superblocks.c +++ b/libblkid/src/superblocks/superblocks.c @@ -417,6 +417,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); blkid_probe_prune_buffers(pr); if (rc != BLKID_PROBE_OK) { diff --git a/libblkid/src/topology/topology.c b/libblkid/src/topology/topology.c index 1fe7c63943..f19a4f2be5 100644 --- a/libblkid/src/topology/topology.c +++ b/libblkid/src/topology/topology.c @@ -183,6 +183,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; rc = id->probefunc(pr, NULL); blkid_probe_prune_buffers(pr); if (rc != 0) -- 2.47.2