threads / patch / 72

patchFix off-by-one error in show-diff

Subject: [PATCH] Fix off-by-one error in show-diff

## tl;dr

One message between Apr 17, 2005 and Apr 17, 2005. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Junio C Hamano· Apr 17, 2005, 05:56 UTC · lore

The patch to introduce shell safety to show-diff has an off-by-one error. Here is an fix.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 show-diff.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

show-diff.c: 8a24ff62b85a6e23469e3f0e7a20170dfe543ebf --- show-diff.c +++ show-diff.c 2005-04-16 22:53:11.000000000 -0700

Show changes to diff +2 −2
@@ -27,8 +27,8 @@
 	int cnt, c;
 	char *cp;
 
-	/* count single quote characters */ 
-	for (cnt = 0, cp = src; *cp; cnt++, cp++)
+	/* count bytes needed to store the quoted string. */ 
+	for (cnt = 1, cp = src; *cp; cnt++, cp++)
 		if (*cp == '\'')
 			cnt += 3;
 

← back to recent threads