builtin-mv: fix use of uninitialized memory.
Juergen Ruehle noticed that add_slash() tries to strcat() into uninitialized memory and fails. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Aug 8, 2006 at 12:21 UTC
329a304714255f6e5528b4311d29f9d83c85d201
1 file changed
+2
-1
builtin-mv.c
+2
-1
@@ -48,7 +48,8 @@ static const char *add_slash(const char *path)
48
if (path[len - 1] != '/') {
49
char *with_slash = xmalloc(len + 2);
50
memcpy(with_slash, path, len);
51
- strcat(with_slash + len, "/");
51
+ with_slash[len++] = '/';
52
+ with_slash[len] = 0;
53
return with_slash;
54
}
55
return path;