diff --git a/NodeManager.cpp b/NodeManager.cpp index 72ec15954d19710a9433b914916ccded0ce721f3..b9b37f9d689b90cb06f55a0ff9bd0957a2cbccc3 100644 --- a/NodeManager.cpp +++ b/NodeManager.cpp @@ -164,12 +164,14 @@ float Timer::getElapsed() { */ Request::Request(const char* string) { - char str[10]; char* ptr; - strcpy(str,string); + // copy to working area + strcpy((char*)&_value, string); // tokenize the string and split function from value - strtok_r(str,",",&ptr); - _function = atoi(str); + strtok_r(_value, ",", &ptr); + // get function code + _function = atoi(_value); + // move user data to working area strcpy(_value,ptr); #if DEBUG == 1 Serial.print(F("REQ F=")); diff --git a/NodeManager.h b/NodeManager.h index 54c6e0bd2b3aaf0c0e68f17ebdc2d016be4e76bf..220edaff1283b07bba4c0dbc3574c7992fbd4f33 100644 --- a/NodeManager.h +++ b/NodeManager.h @@ -492,7 +492,8 @@ class Request { private: NodeManager* _node_manager; int _function; - char* _value; + // Size of buffer to prevent overrun + char _value[MAX_PAYLOAD+1]; }; /***************************************