Skip to content

Commit c0f8fdd

Browse files
authored
Merge pull request #619 from mcnewton/jsonbuffer
don't process JSON past the end of the buffer
2 parents 95beda0 + e5d5c5e commit c0f8fdd

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

src/config.esp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bool ICACHE_FLASH_ATTR loadConfiguration(Config &config)
1212
std::unique_ptr<char[]> buf(new char[size]);
1313
configFile.readBytes(buf.get(), size);
1414
DynamicJsonDocument json(2048);
15-
auto error = deserializeJson(json, buf.get());
15+
auto error = deserializeJson(json, buf.get(), size);
1616
if (error)
1717
{
1818
#ifdef DEBUG

src/mqtt.esp

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ void getUserList()
372372
std::unique_ptr<char[]> buf(new char[size]);
373373
f.readBytes(buf.get(), size);
374374
DynamicJsonDocument json(512);
375-
auto error = deserializeJson(json, buf.get());
375+
auto error = deserializeJson(json, buf.get(), size);
376376
if (!error)
377377
{
378378
mqttPublishEvent(&json);

src/rfid.esp

+3-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void wiegandRead()
7070
f.readBytes(buf.get(), size);
7171
f.close();
7272
DynamicJsonDocument json(512);
73-
auto error = deserializeJson(json, buf.get());
73+
auto error = deserializeJson(json, buf.get(), size);
7474
if (error)
7575
{
7676
processingState = notValid;
@@ -299,7 +299,8 @@ void rfidProcess()
299299
f.readBytes(buf.get(), size);
300300
f.close();
301301
DynamicJsonDocument json(512);
302-
auto error = deserializeJson(json, buf.get());
302+
auto error = deserializeJson(json, buf.get(), size);
303+
303304
if (error)
304305
{
305306
processingState = notValid;

src/wsResponses.esp

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void ICACHE_FLASH_ATTR sendUserList(int page, AsyncWebSocketClient *client)
2121
std::unique_ptr<char[]> buf(new char[size]);
2222
f.readBytes(buf.get(), size);
2323
DynamicJsonDocument json(512);
24-
auto error = deserializeJson(json, buf.get());
24+
auto error = deserializeJson(json, buf.get(), size);
2525
if (!error)
2626
{
2727
String username = json["user"];
@@ -199,4 +199,4 @@ void ICACHE_FLASH_ATTR sendTime(AsyncWebSocketClient *client)
199199
ws.textAll(buffer);
200200
}
201201
}
202-
}
202+
}

0 commit comments

Comments
 (0)