Skip to content

libobs: Ensure buffer size for utf-16 converted filepaths - #13749

Open
Dankirk wants to merge 2 commits into
obsproject:masterfrom
Dankirk:path-limits
Open

libobs: Ensure buffer size for utf-16 converted filepaths#13749
Dankirk wants to merge 2 commits into
obsproject:masterfrom
Dankirk:path-limits

Conversation

@Dankirk

@Dankirk Dankirk commented Aug 3, 2026

Copy link
Copy Markdown

Description

File paths from Windows W apis get stored internally in UTF-8, but there are many cases the internal buffer is too small to contain a valid path from W api. For example char file[MAX_PATH] (260) is too small. In other cases 512 bytes is assumed long enough, but many OSs/filesystems support paths longer than that.

This update:

  • Prefers dynamic heap allocation for file paths over static stack size, because their max size varies widely by filesystem/OS

    • Stack allocation is still used when it might be a performance issue, such as scanning directories
    • Defines constants for static allocation of utf-8 paths (Not intended as actual filesystem/OS limits)
  • Changed many A api calls to W variants to support longer paths. (255 utf-16 codepoints vs 255 bytes)

    • This also ensures encoding is correct, since A api will return active code page encoded strings, which are not utf-8 by default.
  • Minor bugfixes

    • Fix overflow in os_stat() when used with long filename (incorrectly used sizeof() instead _countof())

    • Fix off-by-one length limit check in nvafx-load and nvvfx-load sdk path

Motivation and Context

This is mainly findings while working on other things with encodings, but is also somewhat related to recent change about using absolute paths for DLLs, which could trigger one of these length checks.

How Has This Been Tested?

Tried happy paths using a scene with all source types active and restarting the app.
Could use more testing with loading resources from maximum length paths.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Tweak (non-breaking change to improve existing functionality)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Dankirk added 2 commits August 4, 2026 00:15
Filepaths from Windows W apis get stored internally in UTF-8, but there are many cases the internal buffer is too small to contain a valid path from W api.

Define constants for storing utf-8 paths, but prefer dynamic allocation.

Changed some A api calls to W variants to support longer paths.

Fix overflow in os_stat() when used with long filename.

Fix off-by-one length check in nvvfx-load sdk path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant