apache / tsfile

Apache TsFile
https://tsfile.apache.org/
Apache License 2.0
104 stars 50 forks source link

Fix code scanning alert no. 11: Multiplication result converted to larger type #287

Closed HTHou closed 2 weeks ago

HTHou commented 2 weeks ago

Fixes https://github.com/apache/tsfile/security/code-scanning/11

To fix the problem, we need to ensure that the multiplication is performed using a larger integer type to prevent overflow. This can be achieved by casting one of the operands to size_t before performing the multiplication. This way, the multiplication will be done using the size_t type, which is typically larger than unsigned int and can hold larger values.

The specific change involves casting items to size_t before multiplying it by size on line 313. This ensures that the multiplication is performed using the size_t type, preventing overflow.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

codecov-commenter commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 63.63%. Comparing base (6c4f911) to head (78d120f).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #287 +/- ## ======================================== Coverage 63.63% 63.63% ======================================== Files 501 501 Lines 31787 31787 Branches 4110 4110 ======================================== Hits 20228 20228 Misses 11082 11082 Partials 477 477 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.