8000 gh-100795: Don't call freeaddrinfo on failure. by gpshead · Pull Request #101252 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-100795: Don't call freeaddrinfo on failure. #101252

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

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Avoid potential unexpected ``freeaddrinfo`` call (double free) in :mod:`socket`
when when a libc ``getaddrinfo()`` implementation leaves garbage in an output
pointer when returning an error. Original patch by Sergey G. Brester.
4 changes: 4 additions & 0 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,7 @@ setipaddr(const char *name, struct sockaddr *addr_ret, size_t addr_ret_size, int
subsequent call to getaddrinfo() does not destroy the
outcome of the first call. */
if (error) {
res = NULL; // no-op, remind us that it is invalid; gh-100795
set_gaierror(error);
return -1;
}
Expand Down Expand Up @@ -1195,6 +1196,7 @@ setipaddr(const char *name, struct sockaddr *addr_ret, size_t addr_ret_size, int
#endif
Py_END_ALLOW_THREADS
if (error) {
res = NULL; // no-op, remind us that it is invalid; gh-100795
set_gaierror(error);
return -1;
}
Expand Down Expand Up @@ -6719,6 +6721,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
error = getaddrinfo(hptr, pptr, &hints, &res0);
Py_END_ALLOW_THREADS
if (error) {
res0 = NULL; // gh-100795
set_gaierror(error);
goto err;
}
Expand Down Expand Up @@ -6815,6 +6818,7 @@ socket_getnameinfo(PyObject *self, PyObject *args)
error = getaddrinfo(hostp, pbuf, &hints, &res);
Py_END_ALLOW_THREADS
if (error) {
res = NULL; // gh-100795
set_gaierror(error);
goto fail;
}
Expand Down
0