From: Junio C Hamano Date: Mon, 18 Apr 2005 03:31:40 +0000 (-0700) Subject: [PATCH] (resend) show-diff.c off-by-one fix X-Git-Tag: v0.99~837 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/64982f75109dfc42967773f35301f2dcd30a1a9f?ds=sidebyside [PATCH] (resend) show-diff.c off-by-one fix 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 Signed-off-by: Linus Torvalds --- diff --git a/show-diff.c b/show-diff.c index 8a66e59cf5..36afb3cc91 100644 --- a/show-diff.c +++ b/show-diff.c @@ -27,8 +27,8 @@ static char *sq_expand(char *src) 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;