From a883b83069b9d0251e920e5a98718e0f5b1fb2ff Mon Sep 17 00:00:00 2001 From: Dale Higgs Date: Thu, 14 Feb 2019 18:07:46 -0600 Subject: [PATCH] Fix pointer corruption for multi LED commands Fixes #332 by null-terminating the hex char arrays. --- Arduino/McLighting/request_handlers.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Arduino/McLighting/request_handlers.h b/Arduino/McLighting/request_handlers.h index 7c62099..769bf26 100644 --- a/Arduino/McLighting/request_handlers.h +++ b/Arduino/McLighting/request_handlers.h @@ -148,6 +148,9 @@ void handleSetSingleLED(uint8_t * mypayload, uint8_t firstChar = 0) { strncpy (redhex, (const char *) &mypayload[2 + firstChar], 2 ); strncpy (greenhex, (const char *) &mypayload[4 + firstChar], 2 ); strncpy (bluehex, (const char *) &mypayload[6 + firstChar], 2 ); + redhex[2] = 0x00; + greenhex[2] = 0x00; + bluehex[2] = 0x00; ledstates[led].red = strtol(redhex, NULL, 16); ledstates[led].green = strtol(greenhex, NULL, 16); ledstates[led].blue = strtol(bluehex, NULL, 16);