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
The last parameter of _Py_wreadlink(), _Py_wrealpath() and
_Py_wgetcwd() is a length, not a size: number of characters including
the trailing NUL character.
The last parameter of _Py_wreadlink(), _Py_wrealpath() and
_Py_wgetcwd() is a length, not a size: number of characters including
the trailing NUL character.
Enhance also documentation of error conditions.
To me, length is the number of characters not including the trailing NUL character, and size is the number of characters including the trailing NUL character.
To me, length is the number of characters not including the trailing NUL character, and size is the number of characters including the trailing NUL character.
Oh. I tried but I failed to find a clear "definition" of "length" vs "size". Usually for me, on a wchar_t* string, size means the number of bytes: wcslen(str)*sizeof(wchar_t), whereas length means the number of characters excluding trainling NUL: wcslen(str).
In fact, I don't know any exact term for "length including trailing NUL". That's why I added doc to be more explicit about that.
Since this PR, I also modified getpath.c to handle differently buffer length/size. I added functions which take Py_ARRAY_LENGTH(buffer) to decide if an operation will overflow a string or not.
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.
The last parameter of _Py_wreadlink(), _Py_wrealpath() and
_Py_wgetcwd() is a length, not a size: number of characters including
the trailing NUL character.
Enhance also documentation of error conditions.
https://bugs.python.org/issue36333