Skip to content

libobs: A refused registration can call a partly copied free_type_data pointer #2195

Closed

Description

@rdoupe

Bug

HANDLE_ERROR in libobs/obs-module.c.h can call a partly copied function pointer. It runs when obs_register_source_s, obs_register_output_s, obs_register_encoder_s or obs_register_service_s refuses a registration:

memcpy(&err_data, info, sizeof(err_data) < size_var ? sizeof(err_data) : size_var);
if (err_data.type_data && err_data.free_type_data)
	err_data.free_type_data(err_data.type_data);

err_data starts zeroed and receives the first size_var bytes of the caller's struct. If size_var ends partway through free_type_data (or type_data), the pointer holds only some of the caller's bytes, and the code calls it. The move harness in #2194 crashed this way for a service registered with size 137: it jumped to 0x80.

This can only happen when a plugin passes a size that isn't its struct's sizeof(). The bundled plugins and the public obs_register_*() macros always pass sizeof. Upstream has the same code.

Plan

  1. RED: a cmocka test that registers each type with a refused info struct whose size ends inside type_data, inside free_type_data, and just after both. Check that free_type_data is called only when both fields lie wholly within size, and that nothing crashes.
  2. GREEN: in HANDLE_ERROR, read type_data and free_type_data only when offsetof + sizeof <= size, as HAS_VAL already does. Every registration that passes sizeof behaves exactly as before.

Activity

  1. rdoupe commented on Oct 24, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2195.

  2. added
    claimed
    on Oct 24, 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

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions