From 0fd939e714f1df31223897de6bc6528e0a393623 Mon Sep 17 00:00:00 2001 From: Kano Date: Mon, 23 Sep 2013 09:01:00 +1000 Subject: [PATCH] klondike - fix chipstats api stats buffer overrun with 16 chips --- driver-klondike.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/driver-klondike.c b/driver-klondike.c index b11c21d6..1be043a5 100644 --- a/driver-klondike.c +++ b/driver-klondike.c @@ -584,18 +584,24 @@ static struct api_data *klondike_api_stats(struct cgpu_info *klncgpu) root = api_add_int(root, buf, (int *)(&iFan), true); if (klninfo->devinfo[dev].chipstats != NULL) { - char data[128]; + char data[2048]; + char one[32]; int n; + sprintf(buf, "Nonces / Chip %d", dev); - for (n = 0; n < klninfo->status[dev].chipcount; n++) - sprintf(data+n*8, "%07d ", klninfo->devinfo[dev].chipstats[n]); - data[127] = 0; + data[0] = '\0'; + for (n = 0; n < klninfo->status[dev].chipcount; n++) { + snprintf(one, sizeof(one), "%07d ", klninfo->devinfo[dev].chipstats[n]); + strcat(data, one); + } root = api_add_string(root, buf, data, true); sprintf(buf, "Errors / Chip %d", dev); - for (n = 0; n < klninfo->status[dev].chipcount; n++) - sprintf(data+n*8, "%07d ", klninfo->devinfo[dev].chipstats[n + klninfo->status[dev].chipcount]); - data[127] = 0; + data[0] = '\0'; + for (n = 0; n < klninfo->status[dev].chipcount; n++) { + snprintf(one, sizeof(one), "%07d ", klninfo->devinfo[dev].chipstats[n + klninfo->status[dev].chipcount]); + strcat(data, one); + } root = api_add_string(root, buf, data, true); } }