-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-106242: Fix path truncation in normpath #106816
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with the minor name convention update
Looks like we just need the NEWS entry - click "Details" next to the failed check for info on it (or run Text should be something like ``Fixes :func: |
Misc/NEWS.d/next/Library/2023-08-14-23-11-11.gh-issue-106242.71HMym.rst
Outdated
Show resolved
Hide resolved
…1HMym.rst Co-authored-by: Steve Dower <[email protected]>
Sorry, @finnagin and @zooba, I could not cleanly backport this to |
Sorry, @finnagin and @zooba, I could not cleanly backport this to |
GH-107981 is a backport of this pull request to the 3.12 branch. |
GH-107982 is a backport of this pull request to the 3.11 branch. |
…#107982) Co-authored-by: Finn Womack <[email protected]>
…#107981) * gh-106242: Fix path truncation in os.path.normpath (GH-106816) * gh-106242: Minor fixup to avoid compiler warnings --------- Co-authored-by: Finn Womack <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]>
Following the suggestion from this comment in the original issue this PR adds a new function
_Py_normpathAndSize
which behaves like_Py_normpath
but also takes a pointer which it will use to store the length of the final normalized path. This new function is then used inos__path_normpath_impl
to pass the above mentioned length intoPyUnicode_FromWideChar
instead of -1.Additionally, this adds a test to check that normpath is not truncating paths containing a null character as well as changes
test_addpackage_import_bad_pth_file
intest_site.py
which was using a null character to make a bad path, specifically it was using the string'abc\x00def'
. The problem is that before this change this was being truncated for parts of the test so the string it was actually using in those parts was'abc'
. Upon making the normpath changes it started throwing the errorValueError: embedded null character
so I changed the test to use'abc<>$$**:://def'
instead.