libobs: Ensure buffer size for utf-16 converted filepaths - #13749
Open
Dankirk wants to merge 2 commits into
Open
libobs: Ensure buffer size for utf-16 converted filepaths#13749Dankirk wants to merge 2 commits into
Dankirk wants to merge 2 commits into
Conversation
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
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Changed many A api calls to W variants to support longer paths. (255 utf-16 codepoints vs 255 bytes)
Minor bugfixes
Fix overflow in
os_stat()when used with long filename (incorrectly usedsizeof()instead_countof())Fix off-by-one length limit check in
nvafx-loadandnvvfx-loadsdk pathMotivation 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
Checklist: