Commit dd9cee1
committed
fix: don't truncate compressed packets that outgrow the output reserve
Compress::compress_into reserves input.len() + 10 bytes and grew that
buffer only on flate2::Status::BufError, which deflate returns when it
cannot make progress at all, not when it filled the buffer after
consuming input - that comes back as Status::Ok. The loop broke there
with output still pending inside zlib. The packet went out short and
the leftover bytes desynced the stream for every later packet.
Incompressible payloads are what outgrow the reserve: deflate has to
store them, so past 32 KiB a packet needs more room than input.len() +
10 leaves it. Peers with compression on lose bulk binary transfers -
git pack data is the easy way to hit it - which OpenSSH reports as
channel 0: get data: incomplete message.
Break out of the loop on the output having room to spare instead, which
is what deflate signals completion with, and grow whenever it comes
back full. compress now delegates to compress_into so the two loops
cannot drift apart again. The regression tests round-trip packets that
outgrow the reserve, including through compress_into at a non-zero
start_len - the shape the packet writer uses, which the existing
compressible under-4096-byte tests don't cover.1 parent dbe2234 commit dd9cee1
1 file changed
Lines changed: 86 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
239 | 310 | | |
240 | 311 | | |
241 | 312 | | |
| |||
249 | 320 | | |
250 | 321 | | |
251 | 322 | | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
| 323 | + | |
| 324 | + | |
276 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
277 | 329 | | |
278 | 330 | | |
279 | 331 | | |
| |||
300 | 352 | | |
301 | 353 | | |
302 | 354 | | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
303 | 363 | | |
304 | | - | |
305 | | - | |
| 364 | + | |
| 365 | + | |
306 | 366 | | |
307 | 367 | | |
308 | 368 | | |
| |||
0 commit comments