Skip to content

src/hash_index: avoid division by zero for small images in hash_file - #2032

Open
zayeem06 wants to merge 1 commit into
rauc:masterfrom
zayeem06:hash-index-progress-divzero
Open

zayeem06 wants to merge 1 commit into
rauc:masterfrom
zayeem06:hash-index-progress-divzero

Conversation

@zayeem06

Copy link
Copy Markdown
Contributor

hash_file() derives the progress-reporting interval as count / (R_HASH_INDEX_GEN_PROGRESS_SPAN - 1) and uses it as a modulo divisor once per chunk, so building the index for an image with fewer than nine 4k chunks while a progress step is active divides by zero (SIGFPE on x86, and the undefined behaviour is flagged by the UBSan job). This computes the interval once before the loop and clamps it to at least one chunk, the same zero guard r_copy_stream_with_progress() already has. The added hash_index test builds an index for a single-chunk image with progress enabled, which reviewers can run to confirm it no longer traps.

@codecov

codecov Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.92%. Comparing base (1a412fe) to head (0905b64).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2032      +/-   ##
==========================================
- Coverage   84.93%   84.92%   -0.01%     
==========================================
  Files          77       77              
  Lines       23431    23456      +25     
==========================================
+ Hits        19902    19921      +19     
- Misses       3529     3535       +6     
Flag Coverage Δ
service=false 79.55% <100.00%> (+0.02%) ⬆️
service=true 84.91% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zayeem06

zayeem06 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

any update?

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.

1 participant