mirror of
https://github.com/sudomesh/disaster-radio.git
synced 2026-02-20 02:01:18 +01:00
fix buffer overflow when memsetting response datagram fixes #77
This commit is contained in:
@@ -34,7 +34,7 @@ lib_deps =
|
||||
ESP Async WebServer@1.2.3
|
||||
LoRa@0.7.2
|
||||
https://github.com/jgromes/RadioLib#3682c6c9215891e3afb7672f1235fde1c3bd75fd
|
||||
https://github.com/sudomesh/LoRaLayer2#1e2204ebaa7f81b8d06853fedb92ab0ddc9b9414
|
||||
https://github.com/sudomesh/LoRaLayer2#b071e53ceb6d2530fa2de28019165fd7534a378f
|
||||
https://github.com/paidforby/AsyncSDServer#13375c6be978cb34180378ecf4042a3a4a1f5eab
|
||||
ESP8266 and ESP32 OLED driver for SSD1306 displays
|
||||
TinyGPSPlus@1.0.2
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "DisasterClient.h"
|
||||
|
||||
#define DATAGRAM_HEADER 5
|
||||
#define DATAGRAM_MESSAGE 239
|
||||
#define DATAGRAM_MESSAGE 238
|
||||
|
||||
class DisasterClient;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ void Console::printf(const char* format, ...)
|
||||
struct Datagram response;
|
||||
memcpy(response.destination, LOOPBACK, ADDR_LENGTH);
|
||||
response.type = 'i';
|
||||
size_t len = vsprintf((char *)response.message, format, args);
|
||||
size_t len = vsnprintf((char *)response.message, sizeof(response.message), format, args);
|
||||
client->receive(response, len + DATAGRAM_HEADER);
|
||||
va_end(args);
|
||||
}
|
||||
@@ -48,7 +48,7 @@ void Console::processLine(char *message, size_t len)
|
||||
return;
|
||||
}
|
||||
struct Datagram response;
|
||||
memset(response.message, 0, DATAGRAM_MESSAGE);
|
||||
memset(&response, 0, DATAGRAM_MESSAGE);
|
||||
int msgLen;
|
||||
|
||||
// message might not be NULL ended
|
||||
@@ -195,11 +195,12 @@ void Console::printBanner()
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
char *str = (char*)malloc(ADDR_LENGTH*2 + 1);// = {'\0'};
|
||||
// TODO: need to get local address through a datagram
|
||||
//char *str = (char*)malloc(ADDR_LENGTH*2 + 1);// = {'\0'};
|
||||
//hexToChar(str, LL2Class::localAddress(), ADDR_LENGTH);
|
||||
printf("Local address of your node is %s\r\n", str);
|
||||
printf("Local address of your node is __\r\n");
|
||||
printf("Type '/join NICKNAME' to join the chat, or '/help' for more commands.\r\n");
|
||||
free(str);
|
||||
//free(str);
|
||||
}
|
||||
|
||||
void Console::printPrompt()
|
||||
|
||||
Reference in New Issue
Block a user