From 87aab0e19af5964d88ed5945e6489ce90cc4ce60 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 3 Apr 2009 11:02:17 +0200 Subject: [PATCH] blkid: check idinfo[] index Signed-off-by: Karel Zak --- libs/blkid/src/probe.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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++) { -- 2.39.5