summaryrefslogtreecommitdiffstats
path: root/libblkid/src/verify.c
diff options
context:
space:
mode:
authorKarel Zak2019-07-31 16:18:27 +0200
committerKarel Zak2019-07-31 16:31:10 +0200
commitc4d6d1c54dcd0eff701236d396d88b1fc6251768 (patch)
treef69ae05887909c69fedb2fa847e5ef221e886374 /libblkid/src/verify.c
parentMerge branch '2019wk29' of https://github.com/kerolasa/util-linux (diff)
downloadkernel-qcow2-util-linux-c4d6d1c54dcd0eff701236d396d88b1fc6251768.tar.gz
kernel-qcow2-util-linux-c4d6d1c54dcd0eff701236d396d88b1fc6251768.tar.xz
kernel-qcow2-util-linux-c4d6d1c54dcd0eff701236d396d88b1fc6251768.zip
libblkid: fix file descriptor leak in blkid_verify()
The function blkid_verify() uses private device file descriptor and uses blkid_probe_set_device() to assign the descriptor to low-level probing code. Unfortunately, close() in this case is not enough as the prober can internally open whole-disk device too. The library API has been extended so blkid_probe_set_device() deallocates and close previously used prober for whole-disk. This new functionality is used in blkid_verify() now. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1734545 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid/src/verify.c')
-rw-r--r--libblkid/src/verify.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libblkid/src/verify.c b/libblkid/src/verify.c
index dbc10f254..a78c9f8f2 100644
--- a/libblkid/src/verify.c
+++ b/libblkid/src/verify.c
@@ -184,9 +184,11 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
dev->bid_name, (long long)st.st_rdev, dev->bid_type));
}
- blkid_reset_probe(cache->probe);
+ /* reset prober */
blkid_probe_reset_superblocks_filter(cache->probe);
+ blkid_probe_set_device(cache->probe, -1, 0, 0);
close(fd);
+
return dev;
}