Skip to content

libfec fastfec crashes on form types containing / (e.g. SC/10) #10

Description

@asg017

Note

Much of this ticket was composed with Claude

When a filing contains a form type with a / character (e.g. SC/10), libfec fastfec crashes with "No such file or directory (os error 2)". The form type is used directly as a filename (SC/10.csv), which the OS interprets as a path with directory SC/ and file 10.csv. Since the SC/ directory doesn't exist, File::create_new fails.

FastFEC handles this correctly by replacing / with - in filenames (producing SC-10.csv).

Root Cause

fastfec.rs:96:

let f = File::create_new(filing_directory.join(format!("{}.csv", r.row_type)))?;

r.row_type is used unsanitized as a filename component. FEC form types like SC/10, SC/9, SC/10-A contain slashes that are path separators on Unix.

Affected Filing

Filing ID: 1937483 (3KB, F3N filing for LOGAN CUNNINGHAM FOR CONGRESS)

Reproduction

# libfec crashes:
libfec fastfec ~/.cache/libfec/cache/1937483.fec /tmp/out_libfec
# error: No such file or directory (os error 2)

# FastFEC succeeds:
fastfec --no-stdin ~/.cache/libfec/cache/1937483.fec /tmp/out_fastfec
# Done; parsing successful!

Observe the Difference

# libfec creates these files (missing SC/10):
ls /tmp/out_libfec/1937483/
# F3N.csv  SA11AI.csv  SA11D.csv  SA13A.csv  SB17.csv  header.csv

# FastFEC creates these files (includes SC-10):
ls /tmp/out_fastfec/1937483/
# F3N.csv  SA11AI.csv  SA11D.csv  SA13A.csv  SB17.csv  SC-10.csv  header.csv

# Diff the file lists:
diff <(ls /tmp/out_libfec/1937483/) <(ls /tmp/out_fastfec/1937483/)
# > SC-10.csv

Suggested Fix

Sanitize r.row_type before using as a filename, replacing / with - to match FastFEC behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions