1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-25 20:02:37 +03:00

Merge remote-tracking branch 'remotes/esp8266/master'

This commit is contained in:
Markus Sattler 2015-12-01 17:13:38 +01:00
commit e372457367
2 changed files with 13 additions and 5 deletions

View File

@ -30,10 +30,10 @@ void setup() {
Serial.println("Start"); Serial.println("Start");
}); });
ArduinoOTA.onEnd([]() { ArduinoOTA.onEnd([]() {
Serial.println("End"); Serial.println("\nEnd");
}); });
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\n", (progress / (total / 100))); Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
}); });
ArduinoOTA.onError([](ota_error_t error) { ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error); Serial.printf("Error[%u]: ", error);

View File

@ -87,17 +87,25 @@ bool ESP8266WebServer::authenticate(const char * username, const char * password
authReq.trim(); authReq.trim();
char toencodeLen = strlen(username)+strlen(password)+1; char toencodeLen = strlen(username)+strlen(password)+1;
char *toencode = new char[toencodeLen]; char *toencode = new char[toencodeLen];
if(toencode == NULL) if(toencode == NULL){
authReq = String();
return false; return false;
}
char *encoded = new char[base64_encode_expected_len(toencodeLen)+1]; char *encoded = new char[base64_encode_expected_len(toencodeLen)+1];
if(encoded == NULL) if(encoded == NULL){
authReq = String();
delete[] toencode;
return false; return false;
}
sprintf(toencode, "%s:%s", username, password); sprintf(toencode, "%s:%s", username, password);
if(base64_encode_chars(toencode, toencodeLen, encoded) > 0 && authReq.equals(encoded)){ if(base64_encode_chars(toencode, toencodeLen, encoded) > 0 && authReq.equals(encoded)){
authReq = String(); authReq = String();
delete[] toencode;
delete[] encoded;
return true; return true;
} }
delete[] toencode;
delete[] encoded;
} }
authReq = String(); authReq = String();
} }