8000 Updater - fixed signature verification for compressed binaries by bakadave · Pull Request #9109 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Updater - fixed signature verification for compressed binaries #9109

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 5 commits into from
Mar 27, 2024
Merged
Changes from 1 commit
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
Next Next commit
fixed signature verification for compressed binaries
  • Loading branch information
bakadave authored Mar 25, 2024
commit 40d0d03eca6f4cafef2527768614e682faa28d20
20 changes: 18 additions & 2 deletions cores/esp8266/Updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,24 @@ bool UpdaterClass::end(bool evenIfRemaining){
_hash->begin();
for (uint32_t offset = 0; offset < binSize; offset += sizeof(buff)) {
auto len = std::min(sizeof(buff), binSize - offset);
ESP.flashRead(_startAddress + offset, reinterpret_cast<uint32_t *>(&buff[0]), len);
_hash->add(buff, len);

if (len % 4 == 0) {
ESP.flashRead(_startAddress + offset, reinterpret_cast<uint32_t *>(&buff[0]), len);
_hash->add(buff, len);
}
else {
// Calculate padding needed to make len 4-byte aligned
uint32_t padLen = (len + 3) & ~3; // Rounds up to nearest multiple of 4

// Temporary buffer to satisfy 4-byte alignment requirement
uint8_t tempBuff[padLen] = {0};

// Read into the temporary buffer
ESP.flashRead(_startAddress + offset, reinterpret_cast<uint32_t *>(&tempBuff[0]), padLen); // Note: ESP.flashRead size parameter might be in 4-byte words, not bytes

// Process only the relevant portion of the temp buffer
_hash->add(tempBuff, len); // Ensure only len bytes are processed, not including the padded bytes
}
}
_hash->end();

Expand Down
0