pkg / sftp

SFTP support for the go.crypto/ssh package
BSD 2-Clause "Simplified" License
1.52k stars 380 forks source link

bugfix: int64 math overflows possible on 32-bit architectures #435

Closed puellanivis closed 3 years ago

puellanivis commented 3 years ago

Investigating #433 I tracked it down to a situation where an overflow in 32-bit architectures can result in a calculation of concurrency = 0. With zero concurrency… the wg.Wait() returns immediately and no work is done.

The solution is to check if concurrency is less than one, and if it is, then use max concurrency, as we overflowed an int32, so it should use max concurrency.

puellanivis commented 3 years ago

https://play.golang.org/p/7y0QNA-vLNO

drakkan commented 3 years ago

Thank you