]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: check index before access to array [coverity scan]
authorKarel Zak <kzak@redhat.com>
Thu, 17 Mar 2011 21:58:05 +0000 (22:58 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 17 Mar 2011 21:58:05 +0000 (22:58 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk/fdisksgilabel.c

index 4019eacefb5b7ab5220eb0dc3da0211e386c6824..b5cbadb35c257baaf00ce6dfdf2ef5df1fc5a653 100644 (file)
@@ -43,8 +43,10 @@ static freeblocks freelist[17]; /* 16 partitions can produce 17 vacant slots */
 
 static void
 setfreelist(int i, unsigned int f, unsigned int l) {
-       freelist[i].first = f;
-       freelist[i].last = l;
+       if (i < 17) {
+               freelist[i].first = f;
+               freelist[i].last = l;
+       }
 }
 
 static void