CloudNetService / CloudNet

A modern application that can dynamically and easily deliver Minecraft oriented software
https://cloudnetservice.eu
Apache License 2.0
382 stars 120 forks source link

fix: integer overflow when handling chunked packets #1299

Closed 0utplay closed 8 months ago

0utplay commented 1 year ago

Motivation

While testing an issue described in #1297 it was discovered that sending a large file (around 4Gb in this case) would result in an IOException due to the fact that the random access file does not allow a negative seeking index and the overflow of the int caused the value to become negative.

Modification

Casted the calculation of the seeking index to a long to prevent overflow issues.

Result

Chucked packed sending works with large files.

github-actions[bot] commented 1 year ago

Test Results

  47 files  ±0    47 suites  ±0   1m 17s :stopwatch: +4s 394 tests ±0  394 :heavy_check_mark: ±0  0 :zzz: ±0  0 :x: ±0  724 runs  ±0  724 :heavy_check_mark: ±0  0 :zzz: ±0  0 :x: ±0 

Results for commit 252bc9c9. ± Comparison against base commit 4ad48b5e.