Repository navigation
[FIX] Widen numerical sequence parsing to u64 to prevent overflow panic - #2403
Open
muntasir-396 wants to merge 1 commit into
Open
muntasir-396 wants to merge 1 commit into
muntasir-396 wants to merge 1 commit into
Conversation
When an input filename specifies numerical sequence expansion with a '+'
suffix (e.g. capture_20261019120000+.ts), add_file_sequence() extracted
the numeric segment and parsed it using num.parse::<i32>().unwrap().
If the numeric segment exceeded i32::MAX (common in timestamp-based
filenames), the parser panicked with ParseIntError { kind: PosOverflow }.
This commit:
- Parses the numeric sequence segment as u64 instead of i32.
- Handles parse failures gracefully by falling back to appending the
file to the queue without panicking.
- Uses checked_add(1) to avoid potential overflow when generating the
next sequence candidate.
- Adds unit tests verifying that large numbers (> i32::MAX), values
exceeding u64::MAX, and filenames without digits do not panic, and
verifies sequence expansion with real files.
Fixes CCExtractor#2402.
muntasir-396
force-pushed
the
fix/file-sequence-overflow-panic
branch
from
October 19, 2026 15:06
60a71d8 to
b8de24c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2402.
When an input filename specifies numerical sequence expansion with a
+suffix (e.g.capture_20261019120000+.ts),add_file_sequence()insrc/rust/src/parser.rspreviously parsed the sequence number usingnum.parse::<i32>().unwrap().If the numeric segment exceeds
i32::MAX(2,147,483,647), common in timestamp-based filenames (e.g.YYYYMMDDHHMMSS), the parser panicked withParseIntError { kind: PosOverflow }.Changes
u64: Parse the numeric portion asu64instead ofi32..unwrap()withlet Ok(mut i) = num.parse::<u64>() else { ... }, falling back gracefully to appending the literal filename if parsing fails or overflowsu64::MAX.checked_add(1)when generating subsequent sequence filenames to avoid arithmetic overflow.i32::MAX), values exceedingu64::MAX, and suffixes without digits do not panic, and verifying sequential expansion of existing files.