changeset 11407:f9c74bf11ae0

[gaim-migrate @ 13642] sf patch #1252769, from Federico Schwindt Fix crashes due to non terminate strings committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 01 Sep 2005 04:21:29 +0000
parents e1507691f5b3
children 85e0778317a7
files src/util.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/util.c	Thu Sep 01 03:46:18 2005 +0000
+++ b/src/util.c	Thu Sep 01 04:21:29 2005 +0000
@@ -2900,6 +2900,7 @@
 		return;
 	}
 
+	/* Read in data, one byte at a time */
 	if (read(sock, &data, 1) > 0 || errno == EWOULDBLOCK)
 	{
 		if (errno == EWOULDBLOCK)
@@ -2911,7 +2912,8 @@
 
 		gfud->len++;
 
-		if (gfud->len == gfud->data_len + 1)
+		/* If we've filled up our buffer then make it bigger */
+		if (gfud->len == gfud->data_len)
 		{
 			gfud->data_len += (gfud->data_len) / 2;
 
@@ -2919,6 +2921,7 @@
 		}
 
 		gfud->webdata[gfud->len - 1] = data;
+		gfud->webdata[gfud->len] = '\0';
 
 		if (!gfud->startsaving)
 		{