Message ID | 1373267209-4668-1-git-send-email-holger.brunck@keymile.com |
---|---|
State | Accepted |
Delegated to: | Tom Rini |
Headers | show |
On Mon, Jul 08, 2013 at 09:06:49AM +0200, Holger Brunck wrote: > "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 <holger.brunck@keymile.com> > cc: Wolfgang Denk <wd@denx.de> > cc: Albert ARIBAUD <albert.u.boot@aribaud.net> Applied to u-boot/master, thanks!
diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c index 910955d..e578a1e 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'))
"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 <holger.brunck@keymile.com> cc: Wolfgang Denk <wd@denx.de> cc: Albert ARIBAUD <albert.u.boot@aribaud.net> --- If we have the following entry in cramfs: => cramfsls -rw-r--r-- 1922689 uImage cramfsload would also succeed if we try to do: => cramfsload uImage_1 CRAMFS load complete: 1922689 bytes loaded to 0x100000 The old code succeeds if the begin of the filename we search matches with a filename stored in cramfs. But the searched file may have additional characters and is therfore not the file we are looking for. fs/cramfs/cramfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)