summaryrefslogtreecommitdiffstats
path: root/shlibs/blkid/src/probe.c
diff options
context:
space:
mode:
authorKarel Zak2009-10-01 22:49:44 +0200
committerKarel Zak2009-10-01 22:49:44 +0200
commitbd635f86e8a3f674ff2ae37dc89e3342cae6d9cc (patch)
tree1e454831ed747daedfb59ca38529b996519f01ec /shlibs/blkid/src/probe.c
parentlibblkid: fix non-magic FAT detection (diff)
downloadkernel-qcow2-util-linux-bd635f86e8a3f674ff2ae37dc89e3342cae6d9cc.tar.gz
kernel-qcow2-util-linux-bd635f86e8a3f674ff2ae37dc89e3342cae6d9cc.tar.xz
kernel-qcow2-util-linux-bd635f86e8a3f674ff2ae37dc89e3342cae6d9cc.zip
libblkid: fix segfault in blkid_do_probe()
This: pr->cur_chain += sizeof(struct blkid_chain); is nonsense of course, there should be a cast to (char *) or so. It seems that the most robust solution is to avoid this game with pointers and use chain->driver-id which is useful as array index. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/probe.c')
-rw-r--r--shlibs/blkid/src/probe.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c
index 25be36ed0..054cc920c 100644
--- a/shlibs/blkid/src/probe.c
+++ b/shlibs/blkid/src/probe.c
@@ -679,10 +679,14 @@ int blkid_do_probe(blkid_probe pr)
if (!pr->cur_chain)
pr->cur_chain = &pr->chains[0];
- else if (pr->cur_chain < &pr->chains[BLKID_NCHAINS - 1])
- pr->cur_chain += sizeof(struct blkid_chain);
- else
- return 1; /* all chains already probed */
+ else {
+ int idx = pr->cur_chain->driver->id + 1;
+
+ if (idx < BLKID_NCHAINS)
+ pr->cur_chain = &pr->chains[idx];
+ else
+ return 1; /* all chains already probed */
+ }
chn = pr->cur_chain;
chn->binary = FALSE; /* for sure... */