Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential int overflow in merge chunks #7603

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

erimatnor
Copy link
Contributor

@erimatnor erimatnor commented Jan 20, 2025

When merging chunks, a relation size calculation could potentially overflow an 32-bit integer value. Use a 64-bit integer for the result to prevent overflow.

Disable-check: force-changelog-file
Disable-check: approval-count

When merging chunks, a relation size calculation could potentially
overflow an 32-bit integer value. Use a 64-bit integer for the result
to prevent overflow.
Copy link
Contributor

@mkindahl mkindahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

if (forkNumber == MAIN_FORKNUM)
return merge_rel_nblocks * BLCKSZ;
return nblocks * BLCKSZ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An option is to just add a cast.

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.29%. Comparing base (59f50f2) to head (7a28021).
Report is 701 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7603      +/-   ##
==========================================
+ Coverage   80.06%   82.29%   +2.23%     
==========================================
  Files         190      238      +48     
  Lines       37181    44140    +6959     
  Branches     9450    11101    +1651     
==========================================
+ Hits        29770    36327    +6557     
- Misses       2997     3430     +433     
+ Partials     4414     4383      -31     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@erimatnor erimatnor marked this pull request as ready for review January 20, 2025 09:29
Copy link

@mkindahl, @antekresic: please review this pull request.

Powered by pull-review

@erimatnor
Copy link
Contributor Author

Pushed this to Coverity and the report looks clean.

@erimatnor erimatnor merged commit 6f2aa30 into timescale:main Jan 20, 2025
66 of 70 checks passed
@erimatnor erimatnor deleted the fix-merge-chunks-coverity-issue branch January 20, 2025 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants