threads / patch / 13224

patcharchive.c: format_subst - fixed bogus argument to memchr

Subject: [PATCH] archive.c: format_subst - fixed bogus argument to memchr

## tl;dr

3 messages between Apr 23, 2008 and Apr 23, 2008. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Ariel Badichi· Apr 23, 2008, 00:24 UTC · lore
Also removed a superfluous test.
Signed-off-by: Ariel Badichi <abadichi@bezeqint.net>
---
 archive.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Show changes to archive.c +2 −2
diff --git a/archive.c b/archive.c
index fb159fe..7a32c19 100644
--- a/archive.c
+++ b/archive.c
@@ -16,9 +16,9 @@ static void format_subst(const struct commit *commit,
 		const char *b, *c;
 
 		b = memmem(src, len, "$Format:", 8);
-		if (!b || src + len < b + 9)
+		if (!b)
 			break;
-		c = memchr(b + 8, '$', len - 8);
+		c = memchr(b + 8, '$', (src + len) - b - 8);
 		if (!c)
 			break;
 
-- 
1.5.5.1.57.g5909c
René Scharfe· Apr 23, 2008, 15:54 UTC · re: Ariel Badichi · lore

Re: [PATCH] archive.c: format_subst - fixed bogus argument to memchr

Ariel Badichi schrieb:
Show 18 quoted lines
> Also removed a superfluous test.
> 
> Signed-off-by: Ariel Badichi <abadichi@bezeqint.net>
> ---
>  archive.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/archive.c b/archive.c
> index fb159fe..7a32c19 100644
> --- a/archive.c
> +++ b/archive.c
> @@ -16,9 +16,9 @@ static void format_subst(const struct commit *commit,
>  		const char *b, *c;
>  
>  		b = memmem(src, len, "$Format:", 8);
> -		if (!b || src + len < b + 9)
> +		if (!b)
>  			break;
OK.
> -		c = memchr(b + 8, '$', len - 8);
> +		c = memchr(b + 8, '$', (src + len) - b - 8);
>  		if (!c)
>  			break;

Ouch. Perhaps rearranging it to "len - (b - src) - 8" would make it a little easier to read? Anyway, thanks and:

Acked-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>

← back to recent threads