]> err.no Git - util-linux/commitdiff
blkid: check idinfo[] index
authorKarel Zak <kzak@redhat.com>
Fri, 3 Apr 2009 09:02:17 +0000 (11:02 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 3 Apr 2009 09:02:17 +0000 (11:02 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libs/blkid/src/probe.c

index 0fd3c10191de7aac8ab528d9fa9b9f0dd2de1027..604c7ebab4361cf816b143f64527e15457543b5b 100644 (file)
@@ -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++) {