Commit 2b8e647
committed
Fix the EOF retry loop and the drain guards
Findings from the second review round on the EOF and close changes.
- wolfSSH_stream_read() held inputBuffer across the new EOF retry. When
DoChannelClose() retired the head inside DoReceive() and the next head
already had its EOF latched and drained, the override forced WS_EOF
while lastRxId still named the channel that had gone, so the retry
looped forever on freed memory. Both messages that get there are
peer-controlled. Capture the head's id and only loop while it is
unchanged.
- The EOF drain guards read a peek of WS_REKEYING as a drained channel.
wolfSSH_stream_peek() reports it before it looks at the buffer, and
wolfSSH_worker() no longer masks WS_EOF during a rekey, so this is
reachable. Distinguish it in wolfsshd and both echoservers.
- wolfsshd closed the child's stdin without checking that the buffered
channel data had been handed over. The read above it is skipped while
windowFull, so a later read would write to a closed pipe.
- DoChannelClose() reported WS_WANT_WRITE and left lastRxId unset when
the flush was back-pressured, costing the caller the graceful-close
signal for a channel that is already closed and already bundled. The
pending flush belongs to the output buffer, not the channel.
- test_SendEofApi's idempotence check could not fail: DiscardIoSend
flushes everything, so the output buffer length was 0 either way.
Count what reaches the transport instead.
Add coverage for the retry loop and the deferred flush; both fail
without the fix.1 parent bf8c40f commit 2b8e647
6 files changed
Lines changed: 276 additions & 26 deletions
File tree
- apps/wolfsshd
- examples/echoserver
- ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main
- src
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
934 | 934 | | |
935 | 935 | | |
936 | 936 | | |
937 | | - | |
938 | | - | |
939 | | - | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
940 | 946 | | |
941 | 947 | | |
942 | 948 | | |
| |||
1967 | 1973 | | |
1968 | 1974 | | |
1969 | 1975 | | |
1970 | | - | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
1971 | 1982 | | |
| 1983 | + | |
1972 | 1984 | | |
1973 | 1985 | | |
1974 | 1986 | | |
1975 | 1987 | | |
1976 | | - | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
1977 | 1994 | | |
1978 | 1995 | | |
1979 | 1996 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1096 | 1096 | | |
1097 | 1097 | | |
1098 | 1098 | | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
1099 | 1107 | | |
1100 | 1108 | | |
1101 | 1109 | | |
| |||
1438 | 1446 | | |
1439 | 1447 | | |
1440 | 1448 | | |
1441 | | - | |
1442 | | - | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
1443 | 1458 | | |
1444 | 1459 | | |
1445 | 1460 | | |
| |||
1477 | 1492 | | |
1478 | 1493 | | |
1479 | 1494 | | |
1480 | | - | |
| 1495 | + | |
| 1496 | + | |
1481 | 1497 | | |
| 1498 | + | |
1482 | 1499 | | |
1483 | 1500 | | |
1484 | 1501 | | |
| |||
1648 | 1665 | | |
1649 | 1666 | | |
1650 | 1667 | | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
1651 | 1677 | | |
1652 | 1678 | | |
1653 | 1679 | | |
| |||
Lines changed: 29 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1083 | 1083 | | |
1084 | 1084 | | |
1085 | 1085 | | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
1086 | 1094 | | |
1087 | 1095 | | |
1088 | 1096 | | |
| |||
1409 | 1417 | | |
1410 | 1418 | | |
1411 | 1419 | | |
1412 | | - | |
1413 | | - | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
1414 | 1429 | | |
1415 | 1430 | | |
1416 | 1431 | | |
| |||
1435 | 1450 | | |
1436 | 1451 | | |
1437 | 1452 | | |
1438 | | - | |
| 1453 | + | |
| 1454 | + | |
1439 | 1455 | | |
| 1456 | + | |
1440 | 1457 | | |
1441 | 1458 | | |
1442 | 1459 | | |
| |||
1578 | 1595 | | |
1579 | 1596 | | |
1580 | 1597 | | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
1581 | 1607 | | |
1582 | 1608 | | |
1583 | 1609 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11331 | 11331 | | |
11332 | 11332 | | |
11333 | 11333 | | |
11334 | | - | |
11335 | | - | |
11336 | | - | |
11337 | | - | |
11338 | | - | |
| 11334 | + | |
| 11335 | + | |
| 11336 | + | |
| 11337 | + | |
| 11338 | + | |
| 11339 | + | |
| 11340 | + | |
| 11341 | + | |
11339 | 11342 | | |
11340 | 11343 | | |
11341 | 11344 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1230 | 1230 | | |
1231 | 1231 | | |
1232 | 1232 | | |
| 1233 | + | |
1233 | 1234 | | |
1234 | 1235 | | |
1235 | 1236 | | |
1236 | 1237 | | |
1237 | 1238 | | |
1238 | 1239 | | |
1239 | 1240 | | |
| 1241 | + | |
| 1242 | + | |
1240 | 1243 | | |
1241 | 1244 | | |
1242 | 1245 | | |
| |||
1269 | 1272 | | |
1270 | 1273 | | |
1271 | 1274 | | |
1272 | | - | |
| 1275 | + | |
| 1276 | + | |
1273 | 1277 | | |
1274 | 1278 | | |
1275 | 1279 | | |
1276 | 1280 | | |
1277 | | - | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
1278 | 1284 | | |
1279 | 1285 | | |
1280 | 1286 | | |
| |||
0 commit comments