Repository navigation
Description
Location
rust/obs-util/src/config_file.rs:501-523, read_file / parse_file_into:
let data = std::fs::read(path).ok()?;
...
None if always_open => match std::fs::File::create(&path) {
Ok(_) => None,
Err(_) => return CONFIG_FILENOTFOUND,
}The C reference at libobs/util/config-file.c.h:230-254 opens rb, retries w+ only if the open failed, and reports success with an empty config if a subsequent read produces no data.
Class
Data loss / C compatibility regression in the Rust port.
How it is reached
An unprivileged local user opens their existing write-only mode 0200 config with CONFIG_OPEN_ALWAYS. Rust cannot read it, then File::create opens write-only and truncates the existing bytes. The C w+ fallback requires both read and write access, fails, and preserves the file with CONFIG_FILENOTFOUND.
Rust also merges open failures with failures after a successful open. Such read failures must not enter a destructive create fallback. For example, opening a directory for reading succeeds on Linux, while reading it fails; C returns success with an empty config for either open mode and for defaults.
Only the local user's own file permissions and configuration are involved; no credential disclosure or remote input is needed. This is a normal public bug under SECURITY.md.
Duplicate search: open PRs for config; all issues for config-file, config truncate, and config write-only. No matching issue or PR found.
Proposed fix and failing test
Separate opening from reading. Match the C fallback's w+ read/write/create/truncate access, and only use it after the initial open fails. Keep the C behavior of an empty successful parse after a read error.
Add safe-core and C-oracle differential regressions in the existing utilities category harness. On an unprivileged Linux user, create separate configs with known bytes, chmod to 0200, call CONFIG_OPEN_ALWAYS, restore permissions, and assert both return values and byte preservation. Cover read failure after successful open with a directory and both open modes/defaults. Keep existing C tests and public headers unchanged.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
ProtonDev-sys commentedon Oct 23, 2026
Claiming: config-file open/read failure compatibility.
First draft PR expected within this session, about 20 minutes. Existing C tests/public headers and the C++ obs-websocket plugin stay unchanged.
fix(obs-util): separate config open and read failures (obs-rust#1942)
ProtonDev-sys commentedon Oct 23, 2026
Reproduced and fixed in #1944.
RED 8d4118d: 68 passed / 4 failed as unprivileged dev (uid 1000) on DESKTOP-3FLAOFG Ubuntu/WSL. Mode-0200 CONFIG_OPEN_ALWAYS: C returned -1 with all 18 original bytes; Rust returned 0 with zero bytes. Separate successful-open/read-error directory regressions also failed.
GREEN f46617c: full obs-util suite 832/832 plus 2 doctests passed; fmt and clippy (-D warnings) passed. Production change is 19 added / 22 removed lines (net -3). Existing C tests/public headers are unchanged, no intentional C difference, and Tier 2 remains with PR CI because Docker is unavailable locally. Both read-error defaults and open modes are covered.
fix(obs-util): preserve configs when opening fails (obs-rust#1944)