mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-07-24 15:27:41 +08:00
The serial port autodetect computed an offset relative to a ">" prompt without verifying that there were enough preceding bytes in the read buffer. When the prompt landed near the start of the buffer the size_t offset arithmetic underflowed and the subsequent copy read before the buffer. Replace the buffer_offset heuristic with a direct check that the prompt sits at least four bytes into the read buffer before computing the port name offset, and use signed pointer arithmetic on the address difference so the underflow is no longer reachable. Refs: GHSA-v78g-fxg8-gv3j Signed-off-by: Ramon Roche <mrpollo@gmail.com>