From: Karel Zak Date: Fri, 3 Apr 2009 09:02:17 +0000 (+0200) Subject: blkid: check idinfo[] index X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87aab0e19af5964d88ed5945e6489ce90cc4ce60;p=util-linux blkid: check idinfo[] index Signed-off-by: Karel Zak --- diff --git a/libs/blkid/src/probe.c b/libs/blkid/src/probe.c index 0fd3c101..604c7eba 100644 --- a/libs/blkid/src/probe.c +++ b/libs/blkid/src/probe.c @@ -258,6 +258,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd, pr->fd = fd; pr->off = off; pr->size = 0; + pr->idx = 0; if (size) pr->size = size; @@ -284,7 +285,6 @@ int blkid_probe_set_device(blkid_probe pr, int fd, DBG(DEBUG_LOWPROBE, printf("ready for low-probing, offset=%zd, size=%zd\n", pr->off, pr->size)); - pr->idx = 0; return 0; } @@ -453,6 +453,9 @@ int blkid_do_probe(blkid_probe pr) if (pr->idx) i = pr->idx + 1; + if (i < 0 && i >= ARRAY_SIZE(idinfos)) + return -1; + DBG(DEBUG_LOWPROBE, printf("--> starting probing loop\n")); for ( ; i < ARRAY_SIZE(idinfos); i++) {