Skip to contentSkip to conversation

fix cramfs resolve in case of two files, which start with same chars

PATCH New Peter Feuerer 2 participants 2 messages Jul 28, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix cramfs resolve in case of two files, which start with same chars

Hi,

when having two (or more) files in cramfs which start with same name, cramfs_resolve didn't check the filename length and thus returned potentially the wrong file.

kind regards,
--peter;

---
diff -ur u-boot-2011.06_original/fs/cramfs/cramfs.c u-boot-2011.06/fs/cramfs/cramfs.c
--- u-boot-2011.06_original/fs/cramfs/cramfs.c 2011-07-28 09:48:10.000000000 +0200
+++ u-boot-2011.06/fs/cramfs/cramfs.c 2011-07-28 09:51:54.000000000 +0200
@@ -126,7 +126,8 @@

                         namelen--;
                 }

- if (!strncmp (filename, name, namelen)) {
+ if (namelen == strlen (filename) &&

+                               !strncmp (filename, name, namelen)) {
                         char *p = strtok (NULL, "/");

                         if (raw && (p == NULL || *p == '\0'))
#1 lore raw

PATCH 1/1 fix cramfs resolve in case of two files, which start with same chars

Dear Peter Feuerer,

Quoted 8 lines · In message <[email protected]> you wrote:

Hi,

when having two (or more) files in cramfs which start with same name, cramfs_resolve didn't check the filename length and thus returned potentially the wrong file.

kind regards,
--peter;

Please move greetings out of the commit message.

Quoted 9 lines

---
diff -ur u-boot-2011.06_original/fs/cramfs/cramfs.c u-boot-2011.06/fs/cramfs/cramfs.c
--- u-boot-2011.06_original/fs/cramfs/cramfs.c 2011-07-28 09:48:10.000000000 +0200
+++ u-boot-2011.06/fs/cramfs/cramfs.c 2011-07-28 09:51:54.000000000 +0200

Review line 130

Quoted 6 lines
(quoted diff) +2 -1
@@ -126,7 +126,8 @@
                         namelen--;
                 }
 
-               if (!strncmp (filename, name, namelen)) {
+               if (namelen == strlen (filename) &&
+                               !strncmp (filename, name, namelen)) {

Please fix all the errors and warnings reported by checkpatch, and resubmit. Consider using "git format-patch" and "git send-email".

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It is surely a great calamity for  a  human  being  to  have  no  ob-
sessions.                                                - Robert Bly