Skip to content

ArduinoOTA: don't crash on unrecognized packets #4086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions libraries/ArduinoOTA/ArduinoOTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
}
Expand Down