mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
max_upload was armed once when the upload began and never reduced, so `max_upload - uip_len > 0` was an unsigned expression that only went false when a segment arrived whose length matched the limit exactly. The write pointer climbed from the staging address with nothing to stop it, while flash_write_bytes() carries the address in three bytes and drops whatever does not fit. Subtract each segment as it is taken and compare before subtracting, which is what the comment there described. The limit was only ever armed for firmware uploads; configuration uploads keep the bound their own buffer already imposes.