[PATCH] fetch--tool: fix uninitialized buffer when reading from stdin

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

 



Signed-off-by: Johannes Schindelin <Johannes.Schindelin@xxxxxx>
---
 builtin-fetch--tool.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index 48de08d..e5bb560 100644
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
@@ -14,6 +14,10 @@ static char *get_stdin(void)
 		data = xrealloc(data, offset + CHUNK_SIZE);
 		read = xread(0, data + offset, CHUNK_SIZE);
 	}
+	if (read > 0 && data[read - 1] == '\n')
+		data[read - 1] = '\0';
+	else
+		data[read] = '\0';
 	return data;
 }
 
-- 
1.5.0.1.2424.g39563

-
To unsubscribe from this list: 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]