mtd: Be more strict on the "mtdparts=" prefix check

strstr() does not guarantee that the string we're searching for is
placed at the beginning. Use strncmp() instead.

Fixes: 5db66b3aee ("cmd: mtd: add 'mtd' command")
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Tested-by: Heiko Schocher <hs@denx.de>
This commit is contained in:
Boris Brezillon 2018-12-02 10:54:27 +01:00 committed by Jagan Teki
parent 96b06434e5
commit 429e048e41

View 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 */