FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-102281: fix potential nullptr dereference + use of uninitialized memory by maxbachmann · Pull Request #102282 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix potential nullptr dereference and use of uninitialized memory in fileutils. Patch by Max Bachmann.
5 changes: 4 additions & 1 deletion Modules/getpath.c
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
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,10 @@ getpath_realpath(PyObject *Py_UNUSED(self) , PyObject *args)
if (s) {
*s = L'\0';
}
path2 = _Py_normpath(_Py_join_relfile(path, resolved), -1);
path2 = _Py_join_relfile(path, resolved);
if (path2) {
path2 = _Py_normpath(path2, -1);
}
Comment thread
maxbachmann marked this conversation as resolved.
PyMem_RawFree((void *)path);
path = path2;
}
Expand Down
6 changes: 5 additions & 1 deletion Python/fileutils.c
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
Original file line number Diff line number Diff line change
Expand Up @@ -2158,7 +2158,10 @@ _Py_join_relfile(const wchar_t *dirname, const wchar_t *relfile)
}
assert(wcslen(dirname) < MAXPATHLEN);
assert(wcslen(relfile) < MAXPATHLEN - wcslen(dirname));
join_relfile(filename, bufsize, dirname, relfile);
if (join_relfile(filename, bufsize, dirname, relfile) < 0) {
PyMem_RawFree(filename);
return NULL;
}
return filename;
}

Expand Down Expand Up @@ -2196,6 +2199,7 @@ _Py_find_basename(const wchar_t *filename)
wchar_t *
_Py_normpath(wchar_t *path, Py_ssize_t size)
{
assert(path != NULL);
if (!path[0] || size == 0) {
return path;
}
Expand Down

Back | FazBrowse Home | New Git URL