Potential memory safety issues in Rust FFI exports (NULL pointer handling) #895

Closed
opened 2026-01-29 16:56:26 +00:00 by claunia · 1 comment
Owner

Originally created by @THE-Amrit-mahto-05 on GitHub (Jan 5, 2026).

Description

While going through the Rust FFI layer, I noticed a few places where raw pointers coming from C are used without NULL checks. This can lead to undefined behavior if these functions are ever called with invalid inputs.

I’m still learning Rust FFI, so please correct me if I’m wrong, but based on my understanding these look like genuine safety issues.

What I found

ccxr_verify_crc32

  • buf is used without a NULL check
  • len is not checked for negative values before creating a slice

ccxr_levenshtein_dist and ccxr_levenshtein_dist_char

  • Pointer arguments are assumed to be non-NULL

Functions in libccxr_exports/bitstream.rs

  • Multiple exported FFI functions dereference *mut bitstream without checking for NULL (via copy_bitstream_c_to_rust)
Originally created by @THE-Amrit-mahto-05 on GitHub (Jan 5, 2026). ### Description While going through the Rust FFI layer, I noticed a few places where raw pointers coming from C are used without NULL checks. This can lead to undefined behavior if these functions are ever called with invalid inputs. I’m still learning Rust FFI, so please correct me if I’m wrong, but based on my understanding these look like genuine safety issues. ### What I found ccxr_verify_crc32 - buf is used without a NULL check - len is not checked for negative values before creating a slice ccxr_levenshtein_dist and ccxr_levenshtein_dist_char - Pointer arguments are assumed to be non-NULL Functions in libccxr_exports/bitstream.rs - Multiple exported FFI functions dereference *mut bitstream without checking for NULL (via copy_bitstream_c_to_rust)
Author
Owner

@cfsmp3 commented on GitHub (Jan 5, 2026):

Closing, explanation in PR.

@cfsmp3 commented on GitHub (Jan 5, 2026): Closing, explanation in PR.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#895