Skip to content

bug: util: os_generate_formatted_filename uses video info that obs_get_video_info did not fill #1509

Closed

Description

@rdoupe

Found while characterizing #262 slice 5 (test_formatted_filename, the #262 slice 5 move PR). Nobody has reported it upstream; the code is the same in upstream OBS master (libobs/util/platform.c). The port keeps the C behavior, so this is a separate fix.

Location

libobs/util/platform-filename.c.h (was libobs/util/platform.c.h), os_generate_formatted_filename(). It starts with

struct obs_video_info ovi;
obs_get_video_info(&ovi);

and ignores the result. obs_get_video_info() (libobs/obs.c.h) returns false without writing ovi when there is no video (no successful obs_reset_video), so %FPS, %CRES, %ORES and %VF are formatted from uninitialized stack memory. Before obs_startup(), obs_get_video_info() dereferences the NULL obs (obs->video.graphics), so the call crashes even for a format with no video specifier, because the video info is read unconditionally. Its neighbours (obs_get_audio_info and the other getters there) have no !obs check either; that is libobs's usual "start libobs first" precondition, but a string helper in util/ is easy to call without it.

Class

Uninitialized read (wrong file name), and a NULL dereference before obs_startup. The format comes from the user's own settings and the video state from the app itself, so nothing outside OBS can trigger it.

How it is reached

No caller in the tree reaches it: the recording outputs (obs-ffmpeg-mux, mp4-output) and the frontend's GenerateSpecifiedFilename run with video up, and the frontend's log and crash file names use their own formatter. A plugin or a libobs-based tool that names a file with no video set up (an audio-only tool, or before obs_reset_video) gets a garbage name, or a crash if libobs is not started.

Reproduced in the current release

Headless (private Xvfb, private D-Bus, fresh HOME). Two small programs linked against libobs. The first starts libobs without obs_reset_video, fills the stack with 0xAB, then formats %FPS %CRES %ORES %VF. The second calls the function before obs_startup.

Build Case Result
v0.1.0-beta.20261018 AppImage, libobs.so.30 and obs-studio-rust/libobs.so.30 obs_startup, no video, "%FPS %CRES %ORES %VF" obs_get_video_info returns false; name 0.00 2880154539x2880154539 2880154539x2880154539 None.mkv (0xABABABAB)
master + the #262 slice 5 move PR, libobs obs_startup, no video, "%FPS %CRES %ORES %VF" obs_get_video_info returns false; name 1.00 2880154539x2880154539 2880154539x2880154539 None.mkv (0xABABABAB)
master + the #262 slice 5 move PR, libobs and libobs-with-rust before obs_startup, "%CCYY-%MM-%DD" SIGSEGV in obs_get_video_info

test_formatted_filename's video_info_read_test pins the current behavior (the fields are used as the call left them; characterized, not endorsed).

Fix

Zero ovi before the call (struct obs_video_info ovi = {0};), so a missing video formats as 0, 0x0 and None. Optionally add a !obs check to obs_get_video_info(), so the call is also safe before obs_startup; that is a libobs core change and can be its own PR. Change video_info_read_test (and its Tier 1 port) to expect the zeroed fields: a deliberate change to a characterization test, which the PR says. In Rust, obs-util::platform_filename starts from a zeroed obs_video_info the same way. This goes after the port PR lands.

Activity

  1. added a commit that references this issue on Oct 21, 2026
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

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions