Skip to content

Commit

Permalink
Fix for homieiot#477
Browse files Browse the repository at this point in the history
  • Loading branch information
timpur committed Mar 18, 2018
1 parent b884730 commit f3cc890
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/Homie/Boot/BootConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,18 @@ void BootConfig::__setCORS() {
}

void BootConfig::__parsePost(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) {
if (!index && total > MAX_POST_SIZE) {
Interface::get().getLogger() << "Request is to large to be processed." << endl;
} else if (!index && total <= MAX_POST_SIZE) {
char* buff = new char[total + 1];
strcpy(buff, (const char*)data);
request->_tempObject = buff;
} else if (total <= MAX_POST_SIZE) {
char* buff = reinterpret_cast<char*>(request->_tempObject);
strcat(buff, (const char*)data);
if (total > MAX_POST_SIZE) {
Interface::get().getLogger() << F("Request is to large to be processed.") << endl;
} else {
if (index == 0) {
request->_tempObject = new char[total + 1];
}
void* buff = request->_tempObject + index;
memcpy(buff, data, len);
if (index + len == total) {
void* buff = request->_tempObject + total;
*(char*)buff = 0;
}
}
}
static const String ConfigJSONError(const String error) {
Expand Down

0 comments on commit f3cc890

Please sign in to comment.