All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] cramfs: fix bug for wrong filename comparison
@ 2013-07-04  8:29 Holger Brunck
  2013-07-05 21:23 ` Albert ARIBAUD
  2013-07-08  7:06 ` [U-Boot] [PATCH v2] " Holger Brunck
  0 siblings, 2 replies; 5+ messages in thread
From: Holger Brunck @ 2013-07-04  8:29 UTC (permalink / raw)
  To: u-boot

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.
So compare also the length of the filename we search and the
filename we found in cramfs. This leads to:
=> cramfsload uImage_1
can't find corresponding entry
CRAMFS LOAD ERROR<0> for uImage_1!

which is the behaviour we want.

Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
cc: Wolfgang Denk <wd@denx.de>
---
 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 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'))
-- 
1.8.0.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] cramfs: fix bug for wrong filename comparison
  2013-07-04  8:29 [U-Boot] [PATCH] cramfs: fix bug for wrong filename comparison Holger Brunck
@ 2013-07-05 21:23 ` Albert ARIBAUD
  2013-07-08  6:53   ` Holger Brunck
  2013-07-08  7:06 ` [U-Boot] [PATCH v2] " Holger Brunck
  1 sibling, 1 reply; 5+ messages in thread
From: Albert ARIBAUD @ 2013-07-05 21:23 UTC (permalink / raw)
  To: u-boot

Hi Holger,

On Thu,  4 Jul 2013 10:29:46 +0200, Holger Brunck
<holger.brunck@keymile.com> wrote:

> 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.
> So compare also the length of the filename we search and the
> filename we found in cramfs. This leads to:
> => cramfsload uImage_1
> can't find corresponding entry
> CRAMFS LOAD ERROR<0> for uImage_1!
> 
> which is the behaviour we want.
> Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
> cc: Wolfgang Denk <wd@denx.de>
> ---

Can't the commit message above be summarized as follows?

---8<---
"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.
---8<---

The demonstrative part of the commit message can go here, below the
commit message delimiter '---'.

>  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 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'))


Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] cramfs: fix bug for wrong filename comparison
  2013-07-05 21:23 ` Albert ARIBAUD
@ 2013-07-08  6:53   ` Holger Brunck
  0 siblings, 0 replies; 5+ messages in thread
From: Holger Brunck @ 2013-07-08  6:53 UTC (permalink / raw)
  To: u-boot

On 07/05/2013 11:23 PM, Albert ARIBAUD wrote:
> On Thu,  4 Jul 2013 10:29:46 +0200, Holger Brunck
> <holger.brunck@keymile.com> wrote:
> 
>> 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.
>> So compare also the length of the filename we search and the
>> filename we found in cramfs. This leads to:
>> => cramfsload uImage_1
>> can't find corresponding entry
>> CRAMFS LOAD ERROR<0> for uImage_1!
>>
>> which is the behaviour we want.
>> Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
>> cc: Wolfgang Denk <wd@denx.de>
>> ---
> 
> Can't the commit message above be summarized as follows?
> 
> ---8<---
> "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.
> ---8<---
> 
> The demonstrative part of the commit message can go here, below the
> commit message delimiter '---'.
> 

ok. I'll send a v2.

Regards
Holger

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2] cramfs: fix bug for wrong filename comparison
  2013-07-04  8:29 [U-Boot] [PATCH] cramfs: fix bug for wrong filename comparison Holger Brunck
  2013-07-05 21:23 ` Albert ARIBAUD
@ 2013-07-08  7:06 ` Holger Brunck
  2013-07-16 14:37   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 1 reply; 5+ messages in thread
From: Holger Brunck @ 2013-07-08  7:06 UTC (permalink / raw)
  To: u-boot

"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(-)

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'))
-- 
1.8.0.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [U-Boot, v2] cramfs: fix bug for wrong filename comparison
  2013-07-08  7:06 ` [U-Boot] [PATCH v2] " Holger Brunck
@ 2013-07-16 14:37   ` Tom Rini
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Rini @ 2013-07-16 14:37 UTC (permalink / raw)
  To: u-boot

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!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130716/6538f714/attachment.pgp>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-07-16 14:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-04  8:29 [U-Boot] [PATCH] cramfs: fix bug for wrong filename comparison Holger Brunck
2013-07-05 21:23 ` Albert ARIBAUD
2013-07-08  6:53   ` Holger Brunck
2013-07-08  7:06 ` [U-Boot] [PATCH v2] " Holger Brunck
2013-07-16 14:37   ` [U-Boot] [U-Boot, " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.