win: Fix an out-of-bounds array access
authorShao Miller <shao.miller@yrdsb.edu.on.ca>
Tue, 30 Aug 2011 00:21:09 +0000 (20:21 -0400)
committerPaulo Alcantara <pcacjr@gmail.com>
Sun, 11 Sep 2011 04:09:59 +0000 (04:09 +0000)
We should not attempt to make a map of more LDLINUX.SYS
sectors than we have.  Simply multiplying a cluster count
times the number of sectors per cluster does not account
for unused sectors in the last used cluster.

Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Signed-off-by: Paulo Alcantara <pcacjr@gmail.com>
win/syslinux.c

index 13f25b6..26e5a27 100644 (file)
@@ -409,7 +409,7 @@ int main(int argc, char *argv[])
            len.QuadPart = ((extent.NextVcn.QuadPart -
                             extent.FirstVcn.QuadPart) *
                            vol_info.SectorsPerCluster);
-           while (len.QuadPart--) {
+           while (len.QuadPart-- && nsectors < ldlinux_sectors) {
                *secp++ = lba.QuadPart++;
                nsectors++;
            }