Commit 5ae79b6
committed
wolfsftp: buffer the SFTP DATA length across partial reads
- STATE_SEND_READ_FTP_DATA trims state->buffer to UINT32_SZ with
wolfSSH_SFTP_buffer_set_size(), reads the data string length into
it with wolfSSH_SFTP_buffer_read(), and decodes it with
wolfSSH_SFTP_buffer_rewind() and wolfSSH_SFTP_buffer_ato32().
- The outSz bound is applied to the decoded length before
wolfSSH_SFTP_buffer_create() allocates for it, and that call's
return is checked.
- ssh->error is set to WS_BUFFER_E when the size or decode helper
fails, to WS_RECV_OVERFLOW_E when the decoded length exceeds
outSz, and to WS_MEMORY_E when the allocation fails.
- The szFlat stack array is removed from
wolfSSH_SFTP_SendReadPacket().
- tests/unit.c gains test_SftpSendReadPacketSplit() and
test_SftpSendReadPacketOverflow(), both registered in
wolfSSH_UnitTest(), with the SftpBuildData() and
SftpClientDriveReadSplit() helpers. The first drives a DATA reply
split at each of the four points across the length prefix; the
second drives one whose string length exceeds the caller's buffer
and checks for WS_RECV_OVERFLOW_E with no retained send read
state.
Issue: F-88281 parent 5336ee5 commit 5ae79b6
2 files changed
Lines changed: 192 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8422 | 8422 | | |
8423 | 8423 | | |
8424 | 8424 | | |
8425 | | - | |
8426 | 8425 | | |
8427 | 8426 | | |
8428 | 8427 | | |
| |||
8557 | 8556 | | |
8558 | 8557 | | |
8559 | 8558 | | |
8560 | | - | |
8561 | | - | |
| 8559 | + | |
| 8560 | + | |
| 8561 | + | |
| 8562 | + | |
| 8563 | + | |
| 8564 | + | |
| 8565 | + | |
| 8566 | + | |
| 8567 | + | |
| 8568 | + | |
8562 | 8569 | | |
8563 | 8570 | | |
8564 | 8571 | | |
8565 | 8572 | | |
8566 | 8573 | | |
8567 | 8574 | | |
8568 | 8575 | | |
8569 | | - | |
8570 | | - | |
8571 | | - | |
| 8576 | + | |
| 8577 | + | |
| 8578 | + | |
| 8579 | + | |
| 8580 | + | |
| 8581 | + | |
| 8582 | + | |
| 8583 | + | |
| 8584 | + | |
| 8585 | + | |
8572 | 8586 | | |
| 8587 | + | |
8573 | 8588 | | |
8574 | 8589 | | |
8575 | 8590 | | |
8576 | 8591 | | |
8577 | 8592 | | |
| 8593 | + | |
| 8594 | + | |
| 8595 | + | |
| 8596 | + | |
| 8597 | + | |
| 8598 | + | |
| 8599 | + | |
8578 | 8600 | | |
8579 | 8601 | | |
8580 | 8602 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16165 | 16165 | | |
16166 | 16166 | | |
16167 | 16167 | | |
| 16168 | + | |
| 16169 | + | |
| 16170 | + | |
| 16171 | + | |
| 16172 | + | |
| 16173 | + | |
| 16174 | + | |
| 16175 | + | |
| 16176 | + | |
| 16177 | + | |
| 16178 | + | |
| 16179 | + | |
| 16180 | + | |
| 16181 | + | |
| 16182 | + | |
| 16183 | + | |
| 16184 | + | |
| 16185 | + | |
| 16186 | + | |
| 16187 | + | |
| 16188 | + | |
| 16189 | + | |
| 16190 | + | |
| 16191 | + | |
| 16192 | + | |
| 16193 | + | |
| 16194 | + | |
| 16195 | + | |
| 16196 | + | |
| 16197 | + | |
| 16198 | + | |
| 16199 | + | |
| 16200 | + | |
| 16201 | + | |
| 16202 | + | |
| 16203 | + | |
| 16204 | + | |
| 16205 | + | |
| 16206 | + | |
| 16207 | + | |
| 16208 | + | |
| 16209 | + | |
| 16210 | + | |
| 16211 | + | |
| 16212 | + | |
| 16213 | + | |
| 16214 | + | |
| 16215 | + | |
| 16216 | + | |
| 16217 | + | |
| 16218 | + | |
| 16219 | + | |
| 16220 | + | |
| 16221 | + | |
| 16222 | + | |
| 16223 | + | |
| 16224 | + | |
| 16225 | + | |
| 16226 | + | |
| 16227 | + | |
| 16228 | + | |
| 16229 | + | |
| 16230 | + | |
| 16231 | + | |
| 16232 | + | |
| 16233 | + | |
| 16234 | + | |
| 16235 | + | |
| 16236 | + | |
| 16237 | + | |
| 16238 | + | |
| 16239 | + | |
| 16240 | + | |
| 16241 | + | |
| 16242 | + | |
| 16243 | + | |
| 16244 | + | |
| 16245 | + | |
| 16246 | + | |
| 16247 | + | |
| 16248 | + | |
| 16249 | + | |
| 16250 | + | |
| 16251 | + | |
| 16252 | + | |
| 16253 | + | |
| 16254 | + | |
| 16255 | + | |
| 16256 | + | |
| 16257 | + | |
| 16258 | + | |
| 16259 | + | |
| 16260 | + | |
| 16261 | + | |
| 16262 | + | |
| 16263 | + | |
| 16264 | + | |
| 16265 | + | |
| 16266 | + | |
| 16267 | + | |
| 16268 | + | |
| 16269 | + | |
| 16270 | + | |
| 16271 | + | |
| 16272 | + | |
| 16273 | + | |
| 16274 | + | |
| 16275 | + | |
| 16276 | + | |
| 16277 | + | |
| 16278 | + | |
| 16279 | + | |
| 16280 | + | |
| 16281 | + | |
| 16282 | + | |
| 16283 | + | |
| 16284 | + | |
| 16285 | + | |
| 16286 | + | |
| 16287 | + | |
| 16288 | + | |
| 16289 | + | |
| 16290 | + | |
| 16291 | + | |
| 16292 | + | |
| 16293 | + | |
| 16294 | + | |
| 16295 | + | |
| 16296 | + | |
| 16297 | + | |
| 16298 | + | |
| 16299 | + | |
| 16300 | + | |
| 16301 | + | |
| 16302 | + | |
| 16303 | + | |
| 16304 | + | |
| 16305 | + | |
| 16306 | + | |
| 16307 | + | |
| 16308 | + | |
| 16309 | + | |
| 16310 | + | |
| 16311 | + | |
| 16312 | + | |
| 16313 | + | |
| 16314 | + | |
| 16315 | + | |
| 16316 | + | |
| 16317 | + | |
| 16318 | + | |
| 16319 | + | |
| 16320 | + | |
| 16321 | + | |
16168 | 16322 | | |
16169 | 16323 | | |
16170 | 16324 | | |
| |||
17318 | 17472 | | |
17319 | 17473 | | |
17320 | 17474 | | |
| 17475 | + | |
| 17476 | + | |
| 17477 | + | |
| 17478 | + | |
| 17479 | + | |
| 17480 | + | |
| 17481 | + | |
| 17482 | + | |
| 17483 | + | |
| 17484 | + | |
17321 | 17485 | | |
17322 | 17486 | | |
17323 | 17487 | | |
| |||
0 commit comments