jsonToPixels robustness

avoid string overflow when constructing filename
This commit is contained in:
Frank
2023-07-13 18:36:11 +02:00
parent 0fb5edc4a2
commit 3295579e05

View File

@@ -605,11 +605,12 @@ void Segment::drawArc(uint16_t x0, uint16_t y0, uint16_t radius, uint32_t color,
//WLEDMM for artifx
bool Segment::jsonToPixels(char * name, uint8_t fileNr) {
char fileName[32];
if (!isActive()) return true; // segment not active, nothing to do
char fileName[32] = { '\0' };
//WLEDMM: als support segment name ledmaps
bool isFile = false;;
bool isFile = false;
// strcpy_P(fileName, PSTR("/mario"));
sprintf(fileName, "/%s%d.json", name, fileNr); //WLEDMM: trick to not include 0 in ledmap.json
snprintf(fileName, sizeof(fileName), "/%s%d.json", name, fileNr); //WLEDMM: trick to not include 0 in ledmap.json
// strcat(fileName, ".json");
isFile = WLED_FS.exists(fileName);