mtd: Be more strict on the "mtdparts=" prefix check
authorBoris Brezillon <boris.brezillon@bootlin.com>
Sun, 2 Dec 2018 09:54:27 +0000 (10:54 +0100)
committerJagan Teki <jagan@amarulasolutions.com>
Wed, 5 Dec 2018 19:15:36 +0000 (00:45 +0530)
strstr() does not guarantee that the string we're searching for is
placed at the beginning. Use strncmp() instead.

Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command")
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Tested-by: Heiko Schocher <hs@denx.de>
drivers/mtd/mtd_uboot.c

index c4434d70520d1238e8ae5afd39141d537442f742..d551aee20203828889a74833e22e3de80af20d9c 100644 (file)
@@ -215,7 +215,7 @@ int mtd_probe_devices(void)
                return 0;
 
        /* Start the parsing by ignoring the extra 'mtdparts=' prefix, if any */
-       if (strstr(mtdparts, "mtdparts="))
+       if (!strncmp(mtdparts, "mtdparts=", sizeof("mtdparts=") - 1))
                mtdparts += 9;
 
        /* For each MTD device in mtdparts */