strcat in longpoll thread can write outside of longpoll_block so cat them all in main().
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
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