Commit ed46f774 authored by Lorenzo's avatar Lorenzo Committed by user2684
Browse files

Correct Request Class memory allocation (#214)

parent ca8879fe
...@@ -164,12 +164,14 @@ float Timer::getElapsed() { ...@@ -164,12 +164,14 @@ float Timer::getElapsed() {
*/ */
Request::Request(const char* string) { Request::Request(const char* string) {
char str[10];
char* ptr; char* ptr;
strcpy(str,string); // copy to working area
strcpy((char*)&_value, string);
// tokenize the string and split function from value // tokenize the string and split function from value
strtok_r(str,",",&ptr); strtok_r(_value, ",", &ptr);
_function = atoi(str); // get function code
_function = atoi(_value);
// move user data to working area
strcpy(_value,ptr); strcpy(_value,ptr);
#if DEBUG == 1 #if DEBUG == 1
Serial.print(F("REQ F=")); Serial.print(F("REQ F="));
......
...@@ -492,7 +492,8 @@ class Request { ...@@ -492,7 +492,8 @@ class Request {
private: private:
NodeManager* _node_manager; NodeManager* _node_manager;
int _function; int _function;
char* _value; // Size of buffer to prevent overrun
char _value[MAX_PAYLOAD+1];
}; };
/*************************************** /***************************************
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment