Commit bb4deaa245c9edd18901992c701518b7013e0bfe

Con Kolivas 2011-07-12T22:36:30

strcat in longpoll thread can write outside of longpoll_block so cat them all in main().

diff --git a/main.c b/main.c
index cb51b7c..04016b7 100644
--- a/main.c
+++ b/main.c
@@ -879,12 +879,6 @@ static void *stage_thread(void *userdata)
 {
 	struct thr_info *mythr = userdata;
 	bool ok = true;
-	unsigned int i;
-
-	for (i = 0; i < 36; i++) {
-		strcat(current_block, "0");
-		strcat(blank, "0");
-	}
 
 	while (ok) {
 		struct work *work = NULL;
@@ -1617,7 +1611,6 @@ static void *longpoll_thread(void *userdata)
 	char *copy_start, *hdr_path, *lp_url = NULL;
 	bool need_slash = false;
 	int failures = 0;
-	unsigned int i;
 
 	hdr_path = tq_pop(mythr->q, NULL);
 	if (!hdr_path)
@@ -1650,9 +1643,6 @@ static void *longpoll_thread(void *userdata)
 		goto out;
 	}
 
-	for (i = 0; i < 36; i++)
-		strcat(longpoll_block, "0");
-
 	while (1) {
 		json_t *val;
 
@@ -1748,6 +1738,13 @@ int main (int argc, char *argv[])
 	if (unlikely(pthread_mutex_init(&curses_lock, NULL)))
 		return 1;
 
+	for (i = 0; i < 36; i++) {
+		strcat(blank, "0");
+		strcat(current_block, "0");
+		strcat(longpoll_block, "0");
+	}
+
+
 #ifdef WIN32
 	opt_n_threads = num_processors = 1;
 #else