Commit d3435e5
fix(connection): prevent IndexError on malformed ChibiOS banner line
_extract_chibios_version_from_banner crashed with IndexError when a
banner line starting with "ChibiOS:" did not contain a space followed
by a version hash (for example a truncated "ChibiOS:" line, or
"ChibiOS:hash" without the expected space separator).
msg.split(" ")[1] unconditionally indexed the second element of the
split, which does not exist when the separator is absent. The
IndexError propagated out of the banner-parsing loop during flight
controller connection setup and aborted the whole connection attempt.
Use split(" ", 1) and guard the length before indexing, falling back
to an empty version string. The surrounding code already handles an
empty os_custom_version correctly (it logs a version mismatch warning
against info.os_custom_version when the two differ).
Add two unit tests covering the malformed banner cases that previously
raised IndexError.
Signed-off-by: Yash Goel <yashvardhan664@gmail.com>1 parent 63582c1 commit d3435e5
2 files changed
Lines changed: 37 additions & 1 deletion
File tree
- ardupilot_methodic_configurator
- tests
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
634 | | - | |
| 634 | + | |
| 635 | + | |
635 | 636 | | |
636 | 637 | | |
637 | 638 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1518 | 1518 | | |
1519 | 1519 | | |
1520 | 1520 | | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
1521 | 1556 | | |
1522 | 1557 | | |
1523 | 1558 | | |
| |||
0 commit comments