[PATCH] mv: strcat -> strcpy to account for uninitialized memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At one stage, the code assumed erroneously that the memory was initialized 
to zero.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@xxxxxx>
---

	On Tue, 8 Aug 2006, Juergen Ruehle wrote:

	> This might have been fixed already (my tree is a couple of days old),
	> but the strcat fails for me, because the alloced memory is not
	> cleared.
	> 
	> Johannes Schindelin writes:
	>  > +static const char *add_slash(const char *path)
	>  > +{
	>  > +	int len = strlen(path);
	>  > +	if (path[len - 1] != '/') {
	>  > +		char *with_slash = xmalloc(len + 2);
	>  > +		memcpy(with_slash, path, len);
	>  > +		strcat(with_slash + len, "/");

	Oops. That strcat should be a strcpy, obviously.

 builtin-mv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/builtin-mv.c b/builtin-mv.c
index e47942c..5f57870 100644
--- a/builtin-mv.c
+++ b/builtin-mv.c
@@ -48,7 +48,7 @@ static const char *add_slash(const char 
 	if (path[len - 1] != '/') {
 		char *with_slash = xmalloc(len + 2);
 		memcpy(with_slash, path, len);
-		strcat(with_slash + len, "/");
+		strcpy(with_slash + len, "/");
 		return with_slash;
 	}
 	return path;
-- 
1.4.2.rc3.g6b27-dirty

-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]