Commit ba22647
committed
ext/ftp: fix out-of-bounds read in ftp_get() ASCII CRLF translation
In ASCII mode ftp_get() scans each received block for '\r' and peeks at
the next byte to collapse a CRLF pair to '\n'. When the '\r' is the last
byte of a full FTP_BUFSIZE block, the *(s + 1) lookahead reads one byte
past the data buffer; a server placing '\r' at offset 4095 of a 4096-byte
read triggers it. Bound the lookahead to the received data, matching the
guard ftp_readline() already uses. ftp_nb_continue_read() carries the
trailing '\r' across reads via ftp->lastch and is unaffected.
Closes GH-223281 parent 0c52780 commit ba22647
3 files changed
Lines changed: 33 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
946 | 946 | | |
947 | 947 | | |
948 | 948 | | |
949 | | - | |
| 949 | + | |
950 | 950 | | |
951 | 951 | | |
952 | 952 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
394 | 401 | | |
395 | 402 | | |
396 | 403 | | |
| |||
0 commit comments