[PATCH] Fix set_work_tree on cygwin

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

 



I don't know why, but for some unknown reason the buffer did not
contain zeros. This broke t1500-rev-parse.sh (the test for
GIT_DIR=../.git git rev-parse --show-prefix).

Signed-off-by: Alex Riesen <raa.lkml@xxxxxxxxx>
---

It could be a memory corruption somewhere, but I really was
unable to find what could that, nor could I reproduce the problem
on a handy linux box.

 setup.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
From e5e7adb7db0d9c00a938f32281774f6a7532b44a Mon Sep 17 00:00:00 2001
From: Alex Riesen <raa.lkml@xxxxxxxxx>
Date: Thu, 2 Aug 2007 16:33:02 +0200
Subject: [PATCH] Fix set_work_tree on cygwin

I don't know why, but for some unknown reason the buffer did not
contain zeros. This broke t1500-rev-parse.sh (the test for
GIT_DIR=../.git git rev-parse --show-prefix).

Signed-off-by: Alex Riesen <raa.lkml@xxxxxxxxx>
---
 setup.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/setup.c b/setup.c
index 3653092..1beba7e 100644
--- a/setup.c
+++ b/setup.c
@@ -209,7 +209,8 @@ const char *set_work_tree(const char *dir)
 	len = strlen(dir);
 	if (len > postfix_len && !strcmp(dir + len - postfix_len,
 				"/" DEFAULT_GIT_DIR_ENVIRONMENT)) {
-			strncpy(dir_buffer, dir, len - postfix_len);
+		strncpy(dir_buffer, dir, len - postfix_len);
+		dir_buffer[len - postfix_len] = '\0';
 
 		/* are we inside the default work tree? */
 		rel = get_relative_cwd(buffer, sizeof(buffer), dir_buffer);
-- 
1.5.3.rc3.145.g4d9cdb


[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]

  Powered by Linux