obsproject / obsproject/obs-studio

Segfault (null pointer) when RTMP output receives error with missing description

Open Beginner friendly
#13,144 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
76.4k
Forks
10.2k
Avg merge
4d 23h
Merged PRs (30d)
12

Description

Operating System Info

Other

Other OS

Gentoo Linux

OBS Studio Version

32.0.4

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/9CZrOtD0zMC5ZBjg

OBS Studio Crash Log URL

No response

Expected Behavior

OBS displays an error message and fails to connect

Current Behavior

OBS segfaults

Steps to Reproduce
  1. Have a misbehaving RTMP server that sends a connect _error without a description field
  2. Connect OBS to it
  3. Observe segfault

Specifically the message that my server sent to OBS, in response to the connect message, was:

  • Message type 20 (AMF0-encoded message)
  • Message body in hex: 0200065f6572726f72003ff0000000000000050000090500076d6573736167650200026869000009
  • This corresponds to: the string "_error"; the transaction ID 1; an empty object; another object containing {"message":"hi"}
Anything else we should know?

At this line OBS gets the description field from the error response and passes it to the PublisherAuth function without checking whether the field was actually present:
https://github.com/obsproject/obs-studio/blob/6340d7a845ee1b7bc9b8801bed0b30f708b34c44/plugins/obs-outputs/librtmp/rtmp.c#L3290

Inside PublisherAuth the description is matched with strstr and if no description field was present, it appears description->av_val is null as it crashes inside strstr:
https://github.com/obsproject/obs-studio/blob/6340d7a845ee1b7bc9b8801bed0b30f708b34c44/plugins/obs-outputs/librtmp/rtmp.c#L2690

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in plugins/obs-outputs/librtmp/rtmp.c at the reported lines around the RTMP error handling and PublisherAuth. Reproduce with the supplied AMF0 response or inspect the linked OBS log, then verify that an error without a description produces OBS's expected connection error rather than a segfault.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.