[PR #1997] fix Prevent command-line panics on malformed user input #2797

Open
opened 2026-01-29 17:23:56 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/1997
Author: @THE-Amrit-mahto-05
Created: 1/8/2026
Status: 🔄 Open

Base: masterHead: fix/parser-cli-panics


📝 Commits (6)

  • d3296f0 fix prevent command line panics on malformed user input
  • 4eb36ce replace fatal! with panic/expect for clap-validated inputs
  • 070d7a1 rustfmt
  • 4fa94ea move CLI validation to clap value_parser and remove panic/fatal in parser.rs
  • 3c49010 cargo fmt i forget fixing that
  • e862697 re run checks

📊 Changes

2 files changed (+294 additions, -208 deletions)

View changed files

📝 src/rust/src/args.rs (+220 -33)
📝 src/rust/src/parser.rs (+74 -175)

📄 Description

In raising this pull request, I confirm the following (please check boxes):

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.
  • I have mentioned this change in the changelog.

My familiarity with the project is as follows (check one):

  • I have never used CCExtractor.
  • I have used CCExtractor just a couple of times.
  • I absolutely love CCExtractor, but have not contributed previously.
  • I am an active contributor to CCExtractor.

Description

fixes multiple panic scenarios in parser.rs caused by malformed or unexpected
command-line arguments.

Issues fixed

  • Prevents buffer overflow when parsing --usercolor
  • Removes unwrap() panics when parsing numeric CLI values
  • Safely handles invalid buffer size arguments
  • Replaces timestamp parsing panics with proper fatal!(MalformedParameter) errors

Impact

  • no longer panics on invalid user input
  • Invalid arguments now produce clear error messages and exit cleanly

Changes made

  • Added bounds checking for fixed-size buffers
  • Replaced unwrap() calls with safe error handling
  • Preserved existing CLI behavior while improving robustness

Verification

  • Manually tested with malformed and invalid CLI arguments
  • Confirmed no Rust panics occur

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/CCExtractor/ccextractor/pull/1997 **Author:** [@THE-Amrit-mahto-05](https://github.com/THE-Amrit-mahto-05) **Created:** 1/8/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix/parser-cli-panics` --- ### 📝 Commits (6) - [`d3296f0`](https://github.com/CCExtractor/ccextractor/commit/d3296f0b898510ed43d914485608d8358973886f) fix prevent command line panics on malformed user input - [`4eb36ce`](https://github.com/CCExtractor/ccextractor/commit/4eb36ce48fd949eba143420d82fc5635b274da67) replace fatal! with panic/expect for clap-validated inputs - [`070d7a1`](https://github.com/CCExtractor/ccextractor/commit/070d7a1f508de44e745b00958fc58df534f2b3a0) rustfmt - [`4fa94ea`](https://github.com/CCExtractor/ccextractor/commit/4fa94eaceb73bf197049dad3180a2f212aa09389) move CLI validation to clap value_parser and remove panic/fatal in parser.rs - [`3c49010`](https://github.com/CCExtractor/ccextractor/commit/3c4901045b7b9939752b1fc54c168032d2e03d19) cargo fmt i forget fixing that - [`e862697`](https://github.com/CCExtractor/ccextractor/commit/e862697c2044c616390274acd14423c9430935ba) re run checks ### 📊 Changes **2 files changed** (+294 additions, -208 deletions) <details> <summary>View changed files</summary> 📝 `src/rust/src/args.rs` (+220 -33) 📝 `src/rust/src/parser.rs` (+74 -175) </details> ### 📄 Description <!-- Please prefix your pull request with one of the following: **[FEATURE]** **[FIX]** **[IMPROVEMENT]**. --> **In raising this pull request, I confirm the following (please check boxes):** - [x] I have read and understood the [contributors guide](https://github.com/CCExtractor/ccextractor/blob/master/.github/CONTRIBUTING.md). - [x] I have checked that another pull request for this purpose does not exist. - [x] I have considered, and confirmed that this submission will be valuable to others. - [x] I accept that this submission may not be used, and the pull request closed at the will of the maintainer. - [x] I give this submission freely, and claim no ownership to its content. - [x] **I have mentioned this change in the [changelog](https://github.com/CCExtractor/ccextractor/blob/master/docs/CHANGES.TXT).** **My familiarity with the project is as follows (check one):** - [ ] I have never used CCExtractor. - [ ] I have used CCExtractor just a couple of times. - [ ] I absolutely love CCExtractor, but have not contributed previously. - [x] I am an active contributor to CCExtractor. --- ### Description fixes multiple panic scenarios in `parser.rs` caused by malformed or unexpected command-line arguments. ### Issues fixed - Prevents buffer overflow when parsing `--usercolor` - Removes `unwrap()` panics when parsing numeric CLI values - Safely handles invalid buffer size arguments - Replaces timestamp parsing panics with proper `fatal!(MalformedParameter)` errors ### Impact - no longer panics on invalid user input - Invalid arguments now produce clear error messages and exit cleanly ### Changes made - Added bounds checking for fixed-size buffers - Replaced `unwrap()` calls with safe error handling - Preserved existing CLI behavior while improving robustness ### Verification - Manually tested with malformed and invalid CLI arguments - Confirmed no Rust panics occur --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 17:23:56 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2797