summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2023-08-16 23:19:48 (GMT)
committerGitHub <noreply@github.com>2023-08-16 23:19:48 (GMT)
commitede98958810b76694cf756d305b564cd6adc1a48 (patch)
tree89b00419836960b648ab4104277db32c45e9ad14 /Modules/posixmodule.c
parent2a00cf2db8a19533dc7d71276ce6a77f6a103c65 (diff)
downloadcpython-ede98958810b76694cf756d305b564cd6adc1a48.zip
cpython-ede98958810b76694cf756d305b564cd6adc1a48.tar.gz
cpython-ede98958810b76694cf756d305b564cd6adc1a48.tar.bz2
[3.12] gh-106242: Fix path truncation in os.path.normpath (GH-106816) (#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 <flan313@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 342f393..b9f45c0 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5275,7 +5275,9 @@ os__path_normpath_impl(PyObject *module, PyObject *path)
if (!buffer) {
return NULL;
}
- PyObject *result = PyUnicode_FromWideChar(_Py_normpath(buffer, len), -1);
+ Py_ssize_t norm_len;
+ wchar_t *norm_path = _Py_normpath_and_size(buffer, len, &norm_len);
+ PyObject *result = PyUnicode_FromWideChar(norm_path, norm_len);
PyMem_Free(buffer);
return result;
}