[PR #1851] [MERGED] fix(rust): Handle NULL file pointer in ccxr_demuxer_open for UDP/TCP input #2611

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

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/1851
Author: @cfsmp3
Created: 12/19/2025
Status: Merged
Merged: 12/19/2025
Merged by: @cfsmp3

Base: masterHead: fix/issue-1846-udp-tcp-crash


📝 Commits (1)

  • 6c44100 fix(rust): Handle NULL file pointer in ccxr_demuxer_open for UDP/TCP input

📊 Changes

1 file changed (+9 additions, -4 deletions)

View changed files

📝 src/rust/src/libccxr_exports/demuxer.rs (+9 -4)

📄 Description

Summary

Fixes #1846

When using --udp or --tcp options, ccxr_demuxer_open() was called with a NULL file pointer, causing a crash in CStr::from_ptr().

Root Cause

The Rust FFI function ccxr_demuxer_open assumed the file parameter was always a valid C string pointer:

let c_str = CStr::from_ptr(file);  // Crashes if file is NULL

For network input modes (UDP/TCP), the C code passes NULL since there's no file to open.

Fix

Check if the file pointer is NULL before dereferencing:

let file_str = if !file.is_null() {
    match CStr::from_ptr(file).to_str() {
        Ok(s) => s,
        Err(_) => return -1,
    }
} else {
    ""
};

Testing

Verified both UDP and TCP modes work:

# UDP - confirmed listening with ss
$ timeout 10 ./ccextractor --udp 54321 &
$ ss -ulnp | grep 54321
UNCONN 0 0 0.0.0.0:54321 0.0.0.0:* users:(("ccextractor",pid=99942,fd=4))

# TCP - confirmed listening
$ timeout 10 ./ccextractor --tcp 54322 &
$ ss -tlnp | grep 54322
LISTEN 0 128 *:54322 *:* users:(("ccextractor",pid=98972,fd=4))

Test Plan

  • Build succeeds
  • UDP mode starts and listens on specified port
  • TCP mode starts and listens on specified port
  • No crash on startup

🤖 Generated with Claude Code


🔄 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/1851 **Author:** [@cfsmp3](https://github.com/cfsmp3) **Created:** 12/19/2025 **Status:** ✅ Merged **Merged:** 12/19/2025 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `fix/issue-1846-udp-tcp-crash` --- ### 📝 Commits (1) - [`6c44100`](https://github.com/CCExtractor/ccextractor/commit/6c44100f9735fcb28f85b31f3181ba1116f0ccec) fix(rust): Handle NULL file pointer in ccxr_demuxer_open for UDP/TCP input ### 📊 Changes **1 file changed** (+9 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/rust/src/libccxr_exports/demuxer.rs` (+9 -4) </details> ### 📄 Description ## Summary Fixes #1846 When using `--udp` or `--tcp` options, `ccxr_demuxer_open()` was called with a NULL file pointer, causing a crash in `CStr::from_ptr()`. ### Root Cause The Rust FFI function `ccxr_demuxer_open` assumed the `file` parameter was always a valid C string pointer: ```rust let c_str = CStr::from_ptr(file); // Crashes if file is NULL ``` For network input modes (UDP/TCP), the C code passes NULL since there's no file to open. ### Fix Check if the file pointer is NULL before dereferencing: ```rust let file_str = if !file.is_null() { match CStr::from_ptr(file).to_str() { Ok(s) => s, Err(_) => return -1, } } else { "" }; ``` ## Testing Verified both UDP and TCP modes work: ```bash # UDP - confirmed listening with ss $ timeout 10 ./ccextractor --udp 54321 & $ ss -ulnp | grep 54321 UNCONN 0 0 0.0.0.0:54321 0.0.0.0:* users:(("ccextractor",pid=99942,fd=4)) # TCP - confirmed listening $ timeout 10 ./ccextractor --tcp 54322 & $ ss -tlnp | grep 54322 LISTEN 0 128 *:54322 *:* users:(("ccextractor",pid=98972,fd=4)) ``` ## Test Plan - [x] Build succeeds - [x] UDP mode starts and listens on specified port - [x] TCP mode starts and listens on specified port - [x] No crash on startup 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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:05 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2611