Skip to contentSkip to conversation

archive.c: format_subst - fixed bogus argument to memchr

PATCH In review Ariel Badichi 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 archive.c: format_subst - fixed bogus argument to memchr

Also removed a superfluous test.

---
 archive.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
archive.c +2 -2
index fb159fe..7a32c19 100644
@@ -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;
 
Signature · 1 line
1.5.5.1.57.g5909c
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Ariel Badichi

Also removed a superfluous test.

---
 archive.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
archive.c +0 -0
index fb159fe..7a32c19 100644

archive.c static void format_subst(const struct commit *commit, · line 20

Quoted 6 lines
archive.c +1 -1
@@ -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.

archive.c static void format_subst(const struct commit *commit, · line 23

Quoted 4 lines
archive.c +1 -1
-		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: