From 6007efe3e6772fe6973a2215d295e662ff36f435 Mon Sep 17 00:00:00 2001 From: Nick Lott Date: Wed, 14 Mar 2018 21:03:43 +1300 Subject: [PATCH] Allow update to function over HTTPS due to peek() missing from mbedTLS. Removed redundant check of magic byte from writeStream() * The magic byte is checked in _writeBuffer() before any flash is altered. * The check using peek earlier will at best only save a wasted read of one buffer length of data being read if data is correupted. * As we are already prepared to read an entire buffers worth of data anyway this saving doesn't matter. --- libraries/Update/src/Updater.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/libraries/Update/src/Updater.cpp b/libraries/Update/src/Updater.cpp index d2ea1e9b41a..44a8e50f608 100644 --- a/libraries/Update/src/Updater.cpp +++ b/libraries/Update/src/Updater.cpp @@ -200,18 +200,6 @@ bool UpdateClass::_writeBuffer(){ return true; } -bool UpdateClass::_verifyHeader(uint8_t data) { - if(_command == U_FLASH) { - if(data != ESP_IMAGE_HEADER_MAGIC) { - _abort(UPDATE_ERROR_MAGIC_BYTE); - return false; - } - return true; - } else if(_command == U_SPIFFS) { - return true; - } - return false; -} bool UpdateClass::_verifyEnd() { if(_command == U_FLASH) { @@ -308,10 +296,6 @@ size_t UpdateClass::writeStream(Stream &data) { if(hasError() || !isRunning()) return 0; - if(!_verifyHeader(data.peek())) { - _reset(); - return 0; - } if (_progress_callback) { _progress_callback(0, _size); }