Skip to content

Potential crash when using unicode characters in filename #11211

Open

Description

@Penwy

Operating System Info

Ubuntu 22.04

Other OS

No response

OBS Studio Version

30.2.2

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/SZyGPxeg4afmKJdo

OBS Studio Crash Log URL

No response

Expected Behavior

Obs should not crash on start recording, no matter what the user decided to put in the filename formatting.

Current Behavior

os_generate_formatted_filename crops the generated filename to 255 bytes, before returning it. However, unicode characters can be more than one byte, as such, this cropping can turn the last character of the filename into an invalid character if the cropping happens in its middle.
This then causes a crash when said filename is attempted to be used.

Steps to Reproduce

  1. Change filename formatting to %CCYY-%MM-%DD %hh-%mm-%ss foo​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​bar (there's 100 zero-width spaces between the foo and the bar, so, copy-paste)
  2. Press "Start Recording"
  3. Notice crash
    ...
    N.B.: the error doesn't appear in the log itself :
terminate called after throwing an instance of 'nlohmann::detail::type_error'
  what():  [json.exception.type_error.316] incomplete UTF-8 string; last byte: 0xE2
Aborted (core dumped)

Anything else we should know?

Honestly, the impact of this is probably rather minimal, it only surfaced because Call of Duty are weirdos and put something like 70 zero-width spaces in their window title for no reason whatsoever.

Activity

  1. Penwy commented on Aug 28, 2024

    @Penwy
    ContributorAuthor

    Slightly related, and possibly worthy to include in a fix : said 255 bytes crop happens after applying the extension, and as such will often create an extension-less file, which crashes the muxer.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions