Code

[PATCH] (resend) show-diff.c off-by-one fix
authorJunio C Hamano <junkio@cox.net>
Mon, 18 Apr 2005 03:31:40 +0000 (20:31 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 18 Apr 2005 03:31:40 +0000 (20:31 -0700)
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>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
show-diff.c

index 8a66e59cf5f6e05dd5944e479f95a2a12a6ccf95..36afb3cc91305c35d2d811be61b308c14fb1a63d 100644 (file)
@@ -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;