From 457dd025a2899dd486e594ce3dc4afaa4ea09998 Mon Sep 17 00:00:00 2001 From: Holger Brunck Date: Mon, 8 Jul 2013 09:06:49 +0200 Subject: [PATCH] cramfs: fix bug for wrong filename comparison "cramfsload uImage_1" succeeds even though the actual file is named "uImage". Fix file name comparison when one name is the prefix of the other. Signed-off-by: Holger Brunck cc: Wolfgang Denk cc: Albert ARIBAUD --- fs/cramfs/cramfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c index 910955dfc8..e578a1e8bc 100644 --- a/fs/cramfs/cramfs.c +++ b/fs/cramfs/cramfs.c @@ -126,7 +126,8 @@ static unsigned long cramfs_resolve (unsigned long begin, unsigned long offset, namelen--; } - if (!strncmp (filename, name, namelen)) { + if (!strncmp(filename, name, namelen) && + (namelen == strlen(filename))) { char *p = strtok (NULL, "/"); if (raw && (p == NULL || *p == '\0')) -- 2.39.5