FwUpdate binary: explicit chunk length (the node sees the payload padded to 16 B)
This commit is contained in:
1 parent
4813340a69
commit
d1e893f692
2 files changed
+8
-4
No files matched your search
@@ -516,10 +516,12 @@ const char *FwUpdate::writeAt(uint32_t off, const uint8_t *buf, int len) {
|
||||
}
|
||||
|
||||
int FwUpdate::handleBinary(const uint8_t *req, int len, uint8_t *reply, int reply_max) {
|
||||
if (len >= 6 && req[1] == 'w') {
|
||||
if (len >= 7 && req[1] == 'w') {
|
||||
// the payload arrives padded to the AES block: trust the length byte, not len
|
||||
uint32_t off;
|
||||
memcpy(&off, &req[2], 4);
|
||||
writeAt(off, &req[6], len - 6); // errors show in the next 'm'
|
||||
int n = req[6];
|
||||
if (7 + n <= len) writeAt(off, &req[7], n); // errors show in the next 'm'
|
||||
return 0;
|
||||
}
|
||||
if (len >= 2 && req[1] == 'm' && reply_max >= 5) {
|
||||
|
||||
Reference in new issue
Block a user