Skip to contentSkip to conversation

Fix fsload loads wrong file.

PATCH New ito at mlb.co.jp 1 participant 1 message Apr 4, 2006 Cramfs filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix fsload loads wrong file.

Hello

Command 'fsload' loads wrong file.
Example

 # ls /
 ...<snip>...
 -rw-r--r--   764267 uImage
 -rw-r--r--   764267 uImage2
 # fsload uImage2
   will load uImage.

Please consider to merge.
Patch is attched.
--------
Hiroshi Ito
Media Lab. Inc.,
URL http://www.mlb.co.jp ( Sorry, Japanese only. ) TEL +81-3-5294-7255 FAX +81-3-5294-7256 -------------- next part --------------

fs/cramfs/cramfs.c +3 -1
index 48e7f63..ab5b889 100644
@@ -97,6 +97,7 @@ static unsigned long cramfs_resolve (uns
 				     char *filename)
 {
 	unsigned long inodeoffset = 0, nextoffset;
+	int fnamelen=filename?strlen(filename):0;
 
 	while (inodeoffset < size) {
 		struct cramfs_inode *inode;
@@ -125,7 +126,8 @@ static unsigned long cramfs_resolve (uns
 			namelen--;
 		}
 
-		if (!strncmp (filename, name, namelen)) {
+		if (namelen == fnamelen &&
+			!strncmp (filename, name, namelen)) {
 			char *p = strtok (NULL, "/");
 
 			if (raw && (p == NULL || *p == '\0'))