Preserve multipart OTA MD5 after Update initialization
Arduino-ESP32 2.0.17 UpdateClass::begin() clears _target_md5 before initializing the digest builder (Updater.cpp:123-126). The installed pinned framework package is 3.20017.241212+sha.dcc1105b. Setting the multipart digest before begin therefore skipped the final comparison in end(), which only compares a nonempty _target_md5 (Updater.cpp:303-308). Set the supplied MD5 after Update.begin succeeds. If the digest is rejected, abort the begun update, release upload admission, and return HTTP 400 before assigning an owner or extending its receive timeout. Model the pinned begin-clears-digest behavior in the host fixture using independent digest vectors. Verify malformed and mismatched digests, actual byte corruption, disconnect cleanup, and later valid admission. Negative controls restore the original ordering and remove abort/busy cleanup. Validation: python3 -B test/test_async_web_lifecycle.py -v passed 4/4, including C++ ASan/UBSan execution and negative controls. No PlatformIO or hardware validation was run in this worktree.
This commit is contained in:
1 parent
9db118db4b
commit
2aef03aa8f
3 files changed
+127
-23
No files matched your search
@@ -100,16 +100,6 @@ void AsyncElegantOtaClass::begin(AsyncWebServer *server, const char* username, c
|
||||
return request->send(400, "text/plain", "MD5 parameter missing");
|
||||
}
|
||||
|
||||
if(!Update.setMD5(request->getParam("MD5", true)->value().c_str())) {
|
||||
ota_upload_busy.store(false);
|
||||
return request->send(400, "text/plain", "MD5 parameter invalid");
|
||||
}
|
||||
|
||||
// The HTTP listener defaults to a three-second receive timeout.
|
||||
// A valid OTA body can pause longer on a weak WiFi link; retain a
|
||||
// bounded timeout on this admitted upload without changing peers.
|
||||
request->client()->setRxTimeout(30);
|
||||
|
||||
#if defined(ESP8266)
|
||||
int cmd = (filename == "filesystem") ? U_FS : U_FLASH;
|
||||
Update.runAsync(true);
|
||||
@@ -123,6 +113,19 @@ void AsyncElegantOtaClass::begin(AsyncWebServer *server, const char* username, c
|
||||
ota_upload_busy.store(false);
|
||||
return request->send(400, "text/plain", "OTA could not begin");
|
||||
}
|
||||
// Arduino Update.begin() clears the expected digest. Set it only
|
||||
// after begin succeeds so end() actually verifies the uploaded body.
|
||||
if(!Update.setMD5(request->getParam("MD5", true)->value().c_str())) {
|
||||
Update.abort();
|
||||
ota_upload_busy.store(false);
|
||||
return request->send(400, "text/plain", "MD5 parameter invalid");
|
||||
}
|
||||
|
||||
// The HTTP listener defaults to a three-second receive timeout.
|
||||
// A valid OTA body can pause longer on a weak WiFi link; retain a
|
||||
// bounded timeout on this admitted upload without changing peers.
|
||||
request->client()->setRxTimeout(30);
|
||||
|
||||
// AsyncWebServer frees this per-request allocation on disconnect.
|
||||
// hasError() alone also reports success for a POST with no upload.
|
||||
request->_tempObject = calloc(1, sizeof(bool));
|
||||
|
||||
Reference in new issue
Block a user