Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libobs: Don't corrupt obs_properties in ..._remove_by_name #2257

Merged
merged 1 commit into from
Feb 16, 2020

Conversation

Xaymar
Copy link
Contributor

@Xaymar Xaymar commented Dec 18, 2019

Description

Fixes the corrupted obs_properties structure that happens when the obs_properties_remove_by_name encounters the first or the last element.

Motivation and Context

Stream Effects 0.8.0 makes heavy use of the obs_properties_remove_by_name feature, which breaks when used on the first or last element in the obs_properties_t*. This means that OBS enters an invalid state, and any future attempts to read from the obs_properties_t* object lead to memory corruption, or even a crash.

How Has This Been Tested?

Validated against new Stream Effects code. Stopped crashing.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.

@WizardCM WizardCM added the Bug Fix Non-breaking change which fixes an issue label Dec 18, 2019
@Xaymar Xaymar force-pushed the fix-remove_by_name-corruption branch 2 times, most recently from 7dcadfe to 0e1f79c Compare December 21, 2019 21:15
Xaymar added a commit to Xaymar/obs-StreamFX that referenced this pull request Dec 22, 2019
The current implementation of obs_properties_remove_by_name corrupts the obs_properties_t object whenever it is called on the first or last property in the list. This leads to rapid unscheduled disassembly, and therefore must be fixed in order for this function to be used.

Fixed by upstream PR obsproject/obs-studio#2257.
When obs_properties_remove_by_name is called on any obs_properties_t*,
it corrupts the pointers for first_property and last which end up
pointing at either unallocated memory or randomly into the heap memory.
Neither of these is a good thing, and it usually leads to rapid
unscheduled program behavior, also known as crashing and security
issues.

This fixes the issue by first checking if the pointer stored in
props->last is identical to &cur->next, then checking if we are the
only element (cur is also prev element), and if we are then the pointer
is fixed to point back at props->first_property. Additionally fixes
props->first_property which was never updated either.
@Xaymar Xaymar force-pushed the fix-remove_by_name-corruption branch from 0e1f79c to 77f1b05 Compare December 22, 2019 07:35
@Xaymar
Copy link
Contributor Author

Xaymar commented Dec 25, 2019

For the time being, StreamFX messes around with libOBS memory to prevent OBS Studio from crashing until this is merged. Since I don't know which version tag the next "stable" OBS Studio will have, I don't have it behind a conditional execution check yet.

@jp9000 jp9000 merged commit d13f204 into obsproject:master Feb 16, 2020
@Xaymar Xaymar deleted the fix-remove_by_name-corruption branch February 16, 2020 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Non-breaking change which fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants