sdio: fix read buffer overflow
authorRoel Kluin <[email protected]>
Tue, 22 Sep 2009 23:45:09 +0000 (16:45 -0700)
committerLinus Torvalds <[email protected]>
Wed, 23 Sep 2009 14:39:36 +0000 (07:39 -0700)
Avoid buffer underrun when parsing an invalid CISTPL_VERS_1.

Signed-off-by: Roel Kluin <[email protected]>
Cc: David Vrabel <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
drivers/mmc/core/sdio_cis.c

index 963f2937c5e37da83819249826995aa098751f99..6636354b48ceac476c3ecbb7a88054dd4047d8d2 100644 (file)
@@ -40,7 +40,7 @@ static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func,
                        nr_strings++;
        }
 
-       if (buf[i-1] != '\0') {
+       if (nr_strings < 4) {
                printk(KERN_WARNING "SDIO: ignoring broken CISTPL_VERS_1\n");
                return 0;
        }