login
Header Space

 
 

[PATCH] Fix off-by-one error: don't read the byte before a malloc'd buffer.

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: git list <git@...>
Date: Saturday, December 8, 2007 - 11:48 am

* config.c (store_write_pair): Don't read value[-1].

Signed-off-by: Jim Meyering <meyering@redhat.com>
---
 config.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/config.c b/config.c
index ed96213..6031b38 100644
--- a/config.c
+++ b/config.c
@@ -652,7 +652,7 @@ static int store_write_pair(int fd, const char* key, const char* value)
 	for (i = 0; value[i]; i++)
 		if (value[i] == ';' || value[i] == '#')
 			quote = 1;
-	if (value[i-1] == ' ')
+	if (i && value[i-1] == ' ')
 		quote = 1;

 	if (write_in_full(fd, "\t", 1) != 1 ||
--
1.5.3.7.1116.gae2a9
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Fix off-by-one error: don't read the byte before a m..., Jim Meyering, (Sat Dec 8, 11:48 am)
speck-geostationary