Commit 78810b4
committed
Clamp terminal dimensions to what a winsize can hold
The four pty-req and window-change dimensions were decoded straight into
the WOLFSSH fields and handed to the resize callback unchecked. The
consumers copy them into the unsigned short fields of a struct winsize
for TIOCSWINSZ, so anything above 65535 wraps, and 0x10000 arrives as a
0x0 terminal.
- Add SetTerminalSize() and route both the pty-req and window-change
branches through it, so pty-req stops decoding straight into the
WOLFSSH fields.
- Clamp all four to TERMINAL_DIMENSION_MAX. Others truncate at the
ioctl and accept it, but wolfSSH hands the word32 values to
termResizeCb first, so an unclamped dimension escapes the library
rather than being cut down on the way to the ioctl.
- Take a zero dimension as sent. Others do too, and a zero is how a
peer reports a dimension it has no information about.
- unit.c drives all four dimensions from one table, covering the zero,
single-zero and wrapping cases, in an error code range no other case
in the function claims.
F-8833 recommended ignoring a zero dimension. That is declined above:
Others take zeros as sent, and a zero is how a peer reports a dimension
it has no information about. The finding's symptom, a 0x0 terminal, is
also reached by a route it did not identify, a dimension above 65535
wrapping, and the clamp closes that one.
Issue: F-88331 parent 12a53f5 commit 78810b4
3 files changed
Lines changed: 110 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11383 | 11383 | | |
11384 | 11384 | | |
11385 | 11385 | | |
| 11386 | + | |
| 11387 | + | |
| 11388 | + | |
| 11389 | + | |
| 11390 | + | |
| 11391 | + | |
| 11392 | + | |
| 11393 | + | |
| 11394 | + | |
| 11395 | + | |
| 11396 | + | |
| 11397 | + | |
| 11398 | + | |
| 11399 | + | |
| 11400 | + | |
| 11401 | + | |
| 11402 | + | |
11386 | 11403 | | |
11387 | 11404 | | |
11388 | 11405 | | |
| |||
11470 | 11487 | | |
11471 | 11488 | | |
11472 | 11489 | | |
| 11490 | + | |
11473 | 11491 | | |
11474 | 11492 | | |
11475 | 11493 | | |
11476 | 11494 | | |
11477 | 11495 | | |
11478 | | - | |
| 11496 | + | |
11479 | 11497 | | |
11480 | | - | |
| 11498 | + | |
11481 | 11499 | | |
11482 | | - | |
| 11500 | + | |
11483 | 11501 | | |
11484 | | - | |
| 11502 | + | |
11485 | 11503 | | |
11486 | 11504 | | |
11487 | 11505 | | |
11488 | 11506 | | |
11489 | 11507 | | |
| 11508 | + | |
| 11509 | + | |
11490 | 11510 | | |
11491 | 11511 | | |
11492 | 11512 | | |
| |||
11518 | 11538 | | |
11519 | 11539 | | |
11520 | 11540 | | |
11521 | | - | |
11522 | | - | |
11523 | | - | |
11524 | | - | |
11525 | | - | |
11526 | | - | |
11527 | | - | |
11528 | | - | |
| 11541 | + | |
| 11542 | + | |
| 11543 | + | |
| 11544 | + | |
| 11545 | + | |
| 11546 | + | |
11529 | 11547 | | |
11530 | | - | |
11531 | | - | |
| 11548 | + | |
| 11549 | + | |
| 11550 | + | |
11532 | 11551 | | |
11533 | 11552 | | |
11534 | 11553 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6740 | 6740 | | |
6741 | 6741 | | |
6742 | 6742 | | |
| 6743 | + | |
| 6744 | + | |
| 6745 | + | |
| 6746 | + | |
| 6747 | + | |
| 6748 | + | |
| 6749 | + | |
| 6750 | + | |
| 6751 | + | |
| 6752 | + | |
| 6753 | + | |
| 6754 | + | |
| 6755 | + | |
| 6756 | + | |
| 6757 | + | |
| 6758 | + | |
| 6759 | + | |
| 6760 | + | |
| 6761 | + | |
| 6762 | + | |
| 6763 | + | |
| 6764 | + | |
| 6765 | + | |
| 6766 | + | |
| 6767 | + | |
| 6768 | + | |
| 6769 | + | |
| 6770 | + | |
| 6771 | + | |
| 6772 | + | |
| 6773 | + | |
| 6774 | + | |
| 6775 | + | |
| 6776 | + | |
| 6777 | + | |
| 6778 | + | |
| 6779 | + | |
| 6780 | + | |
| 6781 | + | |
| 6782 | + | |
| 6783 | + | |
| 6784 | + | |
| 6785 | + | |
| 6786 | + | |
| 6787 | + | |
| 6788 | + | |
| 6789 | + | |
| 6790 | + | |
| 6791 | + | |
| 6792 | + | |
| 6793 | + | |
| 6794 | + | |
| 6795 | + | |
| 6796 | + | |
| 6797 | + | |
| 6798 | + | |
| 6799 | + | |
| 6800 | + | |
| 6801 | + | |
| 6802 | + | |
| 6803 | + | |
| 6804 | + | |
| 6805 | + | |
| 6806 | + | |
| 6807 | + | |
| 6808 | + | |
| 6809 | + | |
| 6810 | + | |
| 6811 | + | |
| 6812 | + | |
| 6813 | + | |
| 6814 | + | |
| 6815 | + | |
| 6816 | + | |
| 6817 | + | |
| 6818 | + | |
6743 | 6819 | | |
6744 | 6820 | | |
6745 | 6821 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
| 563 | + | |
563 | 564 | | |
564 | 565 | | |
565 | 566 | | |
| |||
0 commit comments