FwUpdate binary: the chunk crc covers sid, offset and length too

This commit is contained in:
tth committed 2026-11-13 02:11:00 +01:00
1 parent 227edb9c63
commit a029863d66
2 files changed
+5 -2

No files matched your search

+4 -1
View File
@@ -535,7 +535,10 @@ int FwUpdate::handleBinary(const uint8_t *req, int len, uint8_t *reply, int repl
_w_drop++;
return 0;
}
if (11 + n > len || crc16_update(0xFFFF, &req[11], n) != crc) {
// crc over sid, offset, length AND data: seen on the bench, a fresh header
// with the previous transfer's chunk (data and its crc) behind it
uint16_t want = crc16_update(crc16_update(0xFFFF, &req[2], 7), &req[11], 11 + n <= len ? n : 0);
if (11 + n > len || want != crc) {
// the data got mangled on the way (seen: a fresh header with the previous
// chunk's data behind it) -- drop it, the bitmap asks for it again
_w_bad++;
+1 -1
View File
@@ -39,7 +39,7 @@
// Binary request carrying firmware data (over the mesh, admin only). Upstream
// request types are 0x01..0x07; 0xF0 is far from them on purpose.
// [0xF0]['w'][sid u16][offset u32 LE][len u8][crc16 of data][data] chunk,
// [0xF0]['w'][sid u16][offset u32 LE][len u8][crc16 of sid..len + data][data] chunk,
// no reply; a bad crc is dropped. The
// length is explicit (the node only sees
// the decrypted size padded to 16 B); sid