summaryrefslogtreecommitdiffstats
path: root/libblkid
diff options
context:
space:
mode:
authorSami Kerola2017-03-05 21:52:23 +0100
committerKarel Zak2017-03-13 14:48:12 +0100
commit57f1539592c43dcf4c33eddcc022b47d3a64d177 (patch)
treecc392fcf7e1bd2d29ea015e2aa73a87e002b6383 /libblkid
parentlibblkid: avoid overflow when initializing array (diff)
downloadkernel-qcow2-util-linux-57f1539592c43dcf4c33eddcc022b47d3a64d177.tar.gz
kernel-qcow2-util-linux-57f1539592c43dcf4c33eddcc022b47d3a64d177.tar.xz
kernel-qcow2-util-linux-57f1539592c43dcf4c33eddcc022b47d3a64d177.zip
libblkid: ensure uninitialized variable is not used [clang]
Following condition can be true if minix file system is corrupt, and versio number is found to be greater than 3. It is fair to say described scenario is unlikely. libblkid/src/superblocks/minix.c:107:13: warning: variable 'zone_size' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] } else if (version == 3) { ^~~~~~~~~~~~ libblkid/src/superblocks/minix.c:121:6: note: uninitialized use occurs here if (zone_size != 0 || ninodes == 0 || ninodes == UINT32_MAX) ^~~~~~~~~ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'libblkid')
-rw-r--r--libblkid/src/superblocks/minix.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libblkid/src/superblocks/minix.c b/libblkid/src/superblocks/minix.c
index b8881e574..c47378d73 100644
--- a/libblkid/src/superblocks/minix.c
+++ b/libblkid/src/superblocks/minix.c
@@ -87,10 +87,9 @@ static int probe_minix(blkid_probe pr,
if (!data)
return errno ? -errno : 1;
version = get_minix_version(data, &swabme);
- if (version < 1)
- return 1;
-
- if (version <= 2) {
+ switch (version) {
+ case 1:
+ case 2: {
struct minix_super_block *sb = (struct minix_super_block *) data;
uint16_t state = minix_swab16(swabme, sb->s_state);
@@ -104,7 +103,9 @@ static int probe_minix(blkid_probe pr,
zmaps = minix_swab16(swabme, sb->s_zmap_blocks);
firstz = minix_swab16(swabme, sb->s_firstdatazone);
zone_size = sb->s_log_zone_size;
- } else if (version == 3) {
+ break;
+ }
+ case 3: {
struct minix3_super_block *sb = (struct minix3_super_block *) data;
zones = minix_swab32(swabme, sb->s_zones);
@@ -113,6 +114,10 @@ static int probe_minix(blkid_probe pr,
zmaps = minix_swab16(swabme, sb->s_zmap_blocks);
firstz = minix_swab16(swabme, sb->s_firstdatazone);
zone_size = sb->s_log_zone_size;
+ break;
+ }
+ default:
+ return 1;
}
/* sanity checks to be sure that the FS is really minix.