obs-studio icon indicating copy to clipboard operation
obs-studio copied to clipboard

libobs: Fix buffer overrun in os_wcs_to_utf8()

Open derrod opened this issue 1 year ago • 0 comments

Description

Fixes a buffer overrun in os_wcs_to_utf8()

Motivation and Context

If the output buffer size is exactly the same as the length of the converted string, out_len would point to the first element past the end of the buffer, thus writing the terminating NULL character out of bounds.

To fix that, only pass in the size of the buffer minus terminating NULL into wchar_to_utf8().

How Has This Been Tested?

Locally.

Types of changes

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

Checklist:

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

derrod avatar Jun 12 '24 21:06 derrod