obsproject / obsproject/obs-studio
Segfault (null pointer) when RTMP output receives error with missing description
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
- Have a misbehaving RTMP server that sends a connect _error without a description field
- Connect OBS to it
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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