From 1d614599a79ac76c6dcbbe6c20254f496afde6f4 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 13 Aug 2013 14:35:35 +1000 Subject: [PATCH] Add room for the null byte at the end of the nonce2 string on stratum share submission and zero the allocated ram. --- cgminer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cgminer.c b/cgminer.c index 9968ff1a..9b1de6d3 100644 --- a/cgminer.c +++ b/cgminer.c @@ -5183,8 +5183,10 @@ static void *stratum_sthread(void *userdata) * the 4 bytes so avoid potential overflow if a pool has set a * large length by allocating the ram ourselves and using the * low level __bin2hex function. */ + work->nonce2_len += 1; /* Null byte */ align_len(&work->nonce2_len); nonce2 = alloca(work->nonce2_len); + memset(nonce2, 0, work->nonce2_len); __bin2hex(nonce2, (const unsigned char *)&work->nonce2, sizeof(uint32_t)); snprintf(s, sizeof(s),