mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
ArduinoOTA: don't crash on unrecognized packets (#4086)
* ArduinoOTA: handle end of packet in readStringUntil fixes #3912 * ArduinoOTA: fix buffer overflow in parseInt fixes #3912
This commit is contained in:
parent
82e5186786
commit
d9ef6b5f18
@ -143,10 +143,10 @@ void ArduinoOTAClass::begin() {
|
||||
|
||||
int ArduinoOTAClass::parseInt(){
|
||||
char data[16];
|
||||
uint8_t index = 0;
|
||||
uint8_t index;
|
||||
char value;
|
||||
while(_udp_ota->peek() == ' ') _udp_ota->read();
|
||||
while(true){
|
||||
for(index = 0; index < sizeof(data); ++index){
|
||||
value = _udp_ota->peek();
|
||||
if(value < '0' || value > '9'){
|
||||
data[index++] = '\0';
|
||||
@ -159,13 +159,13 @@ int ArduinoOTAClass::parseInt(){
|
||||
|
||||
String ArduinoOTAClass::readStringUntil(char end){
|
||||
String res = "";
|
||||
char value;
|
||||
int value;
|
||||
while(true){
|
||||
value = _udp_ota->read();
|
||||
if(value == '\0' || value == end){
|
||||
if(value < 0 || value == '\0' || value == end){
|
||||
return res;
|
||||
}
|
||||
res += value;
|
||||
res += static_cast<char>(value);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user