summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2019-05-23 15:45:22 (GMT)
committerGitHub <noreply@github.com>2019-05-23 15:45:22 (GMT)
commitb82e17e626f7b1cd98aada0b1ebb65cb9f8fb184 (patch)
tree5370a2a075707cb0b37ce135cad6ffe23da424c4 /Modules
parente788057a9188ff37e232729815dfda2529079420 (diff)
downloadcpython-b82e17e626f7b1cd98aada0b1ebb65cb9f8fb184.zip
cpython-b82e17e626f7b1cd98aada0b1ebb65cb9f8fb184.tar.gz
cpython-b82e17e626f7b1cd98aada0b1ebb65cb9f8fb184.tar.bz2
bpo-36842: Implement PEP 578 (GH-12613)
Adds sys.audit, sys.addaudithook, io.open_code, and associated C APIs.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c16
-rw-r--r--Modules/_ctypes/callproc.c7
-rw-r--r--Modules/_io/_iomodule.c20
-rw-r--r--Modules/_io/clinic/_iomodule.c.h44
-rw-r--r--Modules/_io/fileio.c4
-rw-r--r--Modules/_pickle.c5
-rw-r--r--Modules/_winapi.c47
-rw-r--r--Modules/arraymodule.c5
-rw-r--r--Modules/mmapmodule.c10
-rw-r--r--Modules/posixmodule.c22
-rw-r--r--Modules/socketmodule.c80
11 files changed, 257 insertions, 3 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 7b51153..f4eb536 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -2920,6 +2920,10 @@ PyCData_AtAddress(PyObject *type, void *buf)
CDataObject *pd;
StgDictObject *dict;
+ if (PySys_Audit("ctypes.cdata", "n", (Py_ssize_t)buf) < 0) {
+ return NULL;
+ }
+
assert(PyType_Check(type));
dict = PyType_stgdict(type);
if (!dict) {
@@ -3455,6 +3459,18 @@ PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
+#ifdef MS_WIN32
+ if (PySys_Audit("ctypes.dlsym",
+ ((uintptr_t)name & ~0xFFFF) ? "Os" : "On",
+ dll, name) < 0) {
+ return NULL;
+ }
+#else
+ if (PySys_Audit("ctypes.dlsym", "Os", dll, name) < 0) {
+ return NULL;
+ }
+#endif
+
obj = PyObject_GetAttrString(dll, "_handle");
if (!obj) {
Py_DECREF(ftuple);
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index a8ba84b..8682d54 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -1277,6 +1277,10 @@ static PyObject *load_library(PyObject *self, PyObject *args)
if (!name)
return NULL;
+ if (PySys_Audit("ctypes.dlopen", "O", nameobj) < 0) {
+ return NULL;
+ }
+
Py_BEGIN_ALLOW_THREADS
/* bpo-36085: Limit DLL search directories to avoid pre-loading
* attacks and enable use of the AddDllDirectory function.
@@ -1382,6 +1386,9 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args)
name_str = NULL;
name2 = NULL;
}
+ if (PySys_Audit("ctypes.dlopen", "s", name_str) < 0) {
+ return NULL;
+ }
handle = ctypes_dlopen(name_str, mode);
Py_XDECREF(name2);
if (!handle) {
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index 590d6ce..ba8f001 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -503,6 +503,25 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode,
Py_XDECREF(modeobj);
return NULL;
}
+
+/*[clinic input]
+_io.open_code
+
+ path : unicode
+
+Opens the provided file with the intent to import the contents.
+
+This may perform extra validation beyond open(), but is otherwise interchangeable
+with calling open(path, 'rb').
+
+[clinic start generated code]*/
+
+static PyObject *
+_io_open_code_impl(PyObject *module, PyObject *path)
+/*[clinic end generated code: output=2fe4ecbd6f3d6844 input=f5c18e23f4b2ed9f]*/
+{
+ return PyFile_OpenCodeObject(path);
+}
/*
* Private helpers for the io module.
@@ -630,6 +649,7 @@ iomodule_free(PyObject *mod) {
static PyMethodDef module_methods[] = {
_IO_OPEN_METHODDEF
+ _IO_OPEN_CODE_METHODDEF
{NULL, NULL}
};
diff --git a/Modules/_io/clinic/_iomodule.c.h b/Modules/_io/clinic/_iomodule.c.h
index 990c81c..00ad616 100644
--- a/Modules/_io/clinic/_iomodule.c.h
+++ b/Modules/_io/clinic/_iomodule.c.h
@@ -281,4 +281,46 @@ skip_optional_pos:
exit:
return return_value;
}
-/*[clinic end generated code: output=19fc9b69a5166f63 input=a9049054013a1b77]*/
+
+PyDoc_STRVAR(_io_open_code__doc__,
+"open_code($module, /, path)\n"
+"--\n"
+"\n"
+"Opens the provided file with the intent to import the contents.\n"
+"\n"
+"This may perform extra validation beyond open(), but is otherwise interchangeable\n"
+"with calling open(path, \'rb\').");
+
+#define _IO_OPEN_CODE_METHODDEF \
+ {"open_code", (PyCFunction)(void(*)(void))_io_open_code, METH_FASTCALL|METH_KEYWORDS, _io_open_code__doc__},
+
+static PyObject *
+_io_open_code_impl(PyObject *module, PyObject *path);
+
+static PyObject *
+_io_open_code(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"path", NULL};
+ static _PyArg_Parser _parser = {NULL, _keywords, "open_code", 0};
+ PyObject *argsbuf[1];
+ PyObject *path;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("open_code", 1, "str", args[0]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[0]) == -1) {
+ goto exit;
+ }
+ path = args[0];
+ return_value = _io_open_code_impl(module, path);
+
+exit:
+ return return_value;
+}
+/*[clinic end generated code: output=d479285078750d68 input=a9049054013a1b77]*/
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index c502c43..52a6f49 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -358,6 +358,10 @@ _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
flags |= O_CLOEXEC;
#endif
+ if (PySys_Audit("open", "Osi", nameobj, mode, flags) < 0) {
+ goto error;
+ }
+
if (fd >= 0) {
self->fd = fd;
self->closefd = closefd;
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 87f3cf7..24a5d22 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -6659,6 +6659,11 @@ _pickle_Unpickler_find_class_impl(UnpicklerObject *self,
PyObject *global;
PyObject *module;
+ if (PySys_Audit("pickle.find_class", "OO",
+ module_name, global_name) < 0) {
+ return NULL;
+ }
+
/* Try to map the old names used in Python 2.x to the new ones used in
Python 3.x. We do this only with old pickle protocols and when the
user has not disabled the feature. */
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index 8873519..1317fc9 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -461,6 +461,12 @@ _winapi_CreateFile_impl(PyObject *module, LPCTSTR file_name,
{
HANDLE handle;
+ if (PySys_Audit("_winapi.CreateFile", "uIIII",
+ file_name, desired_access, share_mode,
+ creation_disposition, flags_and_attributes) < 0) {
+ return INVALID_HANDLE_VALUE;
+ }
+
Py_BEGIN_ALLOW_THREADS
handle = CreateFile(file_name, desired_access,
share_mode, security_attributes,
@@ -542,6 +548,10 @@ _winapi_CreateJunction_impl(PyObject *module, LPWSTR src_path,
if (wcsncmp(src_path, L"\\??\\", prefix_len) == 0)
return PyErr_SetFromWindowsErr(ERROR_INVALID_PARAMETER);
+ if (PySys_Audit("_winapi.CreateJunction", "uu", src_path, dst_path) < 0) {
+ return NULL;
+ }
+
/* Adjust privileges to allow rewriting directory entry as a
junction point. */
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))
@@ -670,6 +680,11 @@ _winapi_CreateNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD open_mode,
{
HANDLE handle;
+ if (PySys_Audit("_winapi.CreateNamedPipe", "uII",
+ name, open_mode, pipe_mode) < 0) {
+ return INVALID_HANDLE_VALUE;
+ }
+
Py_BEGIN_ALLOW_THREADS
handle = CreateNamedPipe(name, open_mode, pipe_mode,
max_instances, out_buffer_size,
@@ -704,6 +719,10 @@ _winapi_CreatePipe_impl(PyObject *module, PyObject *pipe_attrs, DWORD size)
HANDLE write_pipe;
BOOL result;
+ if (PySys_Audit("_winapi.CreatePipe", NULL) < 0) {
+ return NULL;
+ }
+
Py_BEGIN_ALLOW_THREADS
result = CreatePipe(&read_pipe, &write_pipe, NULL, size);
Py_END_ALLOW_THREADS
@@ -1055,6 +1074,11 @@ _winapi_CreateProcess_impl(PyObject *module,
wchar_t *command_line_copy = NULL;
AttributeList attribute_list = {0};
+ if (PySys_Audit("_winapi.CreateProcess", "uuu", application_name,
+ command_line, current_directory) < 0) {
+ return NULL;
+ }
+
ZeroMemory(&si, sizeof(si));
si.StartupInfo.cb = sizeof(si);
@@ -1270,8 +1294,10 @@ _winapi_GetModuleFileName_impl(PyObject *module, HMODULE module_handle)
BOOL result;
WCHAR filename[MAX_PATH];
+ Py_BEGIN_ALLOW_THREADS
result = GetModuleFileNameW(module_handle, filename, MAX_PATH);
filename[MAX_PATH-1] = '\0';
+ Py_END_ALLOW_THREADS
if (! result)
return PyErr_SetFromWindowsErr(GetLastError());
@@ -1402,9 +1428,16 @@ _winapi_OpenProcess_impl(PyObject *module, DWORD desired_access,
{
HANDLE handle;
+ if (PySys_Audit("_winapi.OpenProcess", "II",
+ process_id, desired_access) < 0) {
+ return INVALID_HANDLE_VALUE;
+ }
+
+ Py_BEGIN_ALLOW_THREADS
handle = OpenProcess(desired_access, inherit_handle, process_id);
+ Py_END_ALLOW_THREADS
if (handle == NULL) {
- PyErr_SetFromWindowsErr(0);
+ PyErr_SetFromWindowsErr(GetLastError());
handle = INVALID_HANDLE_VALUE;
}
@@ -1539,6 +1572,7 @@ _winapi_SetNamedPipeHandleState_impl(PyObject *module, HANDLE named_pipe,
PyObject *oArgs[3] = {mode, max_collection_count, collect_data_timeout};
DWORD dwArgs[3], *pArgs[3] = {NULL, NULL, NULL};
int i;
+ BOOL b;
for (i = 0 ; i < 3 ; i++) {
if (oArgs[i] != Py_None) {
@@ -1549,7 +1583,11 @@ _winapi_SetNamedPipeHandleState_impl(PyObject *module, HANDLE named_pipe,
}
}
- if (!SetNamedPipeHandleState(named_pipe, pArgs[0], pArgs[1], pArgs[2]))
+ Py_BEGIN_ALLOW_THREADS
+ b = SetNamedPipeHandleState(named_pipe, pArgs[0], pArgs[1], pArgs[2]);
+ Py_END_ALLOW_THREADS
+
+ if (!b)
return PyErr_SetFromWindowsErr(0);
Py_RETURN_NONE;
@@ -1573,6 +1611,11 @@ _winapi_TerminateProcess_impl(PyObject *module, HANDLE handle,
{
BOOL result;
+ if (PySys_Audit("_winapi.TerminateProcess", "nI",
+ (Py_ssize_t)handle, exit_code) < 0) {
+ return NULL;
+ }
+
result = TerminateProcess(handle, exit_code);
if (! result)
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 523afb9..423cac9 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -2635,6 +2635,11 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (!PyArg_ParseTuple(args, "C|O:array", &c, &initial))
return NULL;
+ if (PySys_Audit("array.__new__", "CO",
+ c, initial ? initial : Py_None) < 0) {
+ return NULL;
+ }
+
if (initial && c != 'u') {
if (PyUnicode_Check(initial)) {
PyErr_Format(PyExc_TypeError, "cannot use a str to initialize "
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 917c636..fdd60bb 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -1110,6 +1110,11 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
"mmap invalid access parameter.");
}
+ if (PySys_Audit("mmap.__new__", "ini" _Py_PARSE_OFF_T,
+ fileno, map_size, access, offset) < 0) {
+ return NULL;
+ }
+
#ifdef __APPLE__
/* Issue #11277: fsync(2) is not enough on OS X - a special, OS X specific
fcntl(2) is necessary to force DISKSYNC and get around mmap(2) bug */
@@ -1240,6 +1245,11 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
return NULL;
}
+ if (PySys_Audit("mmap.__new__", "iniL",
+ fileno, map_size, access, offset) < 0) {
+ return NULL;
+ }
+
switch((access_mode)access) {
case ACCESS_READ:
flProtect = PAGE_READONLY;
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 9f15866..8ebe3a0 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -4264,6 +4264,11 @@ os_system_impl(PyObject *module, const Py_UNICODE *command)
/*[clinic end generated code: output=5b7c3599c068ca42 input=303f5ce97df606b0]*/
{
long result;
+
+ if (PySys_Audit("system", "(u)", command) < 0) {
+ return -1;
+ }
+
Py_BEGIN_ALLOW_THREADS
_Py_BEGIN_SUPPRESS_IPH
result = _wsystem(command);
@@ -4286,6 +4291,11 @@ os_system_impl(PyObject *module, PyObject *command)
{
long result;
const char *bytes = PyBytes_AsString(command);
+
+ if (PySys_Audit("system", "(O)", command) < 0) {
+ return -1;
+ }
+
Py_BEGIN_ALLOW_THREADS
result = system(bytes);
Py_END_ALLOW_THREADS
@@ -8279,6 +8289,10 @@ os_open_impl(PyObject *module, path_t *path, int flags, int mode, int dir_fd)
flags |= O_CLOEXEC;
#endif
+ if (PySys_Audit("open", "OOi", path->object, Py_None, flags) < 0) {
+ return -1;
+ }
+
_Py_BEGIN_SUPPRESS_IPH
do {
Py_BEGIN_ALLOW_THREADS
@@ -9598,6 +9612,10 @@ os_ftruncate_impl(PyObject *module, int fd, Py_off_t length)
int result;
int async_err = 0;
+ if (PySys_Audit("os.truncate", "in", fd, length) < 0) {
+ return NULL;
+ }
+
do {
Py_BEGIN_ALLOW_THREADS
_Py_BEGIN_SUPPRESS_IPH
@@ -9641,6 +9659,10 @@ os_truncate_impl(PyObject *module, path_t *path, Py_off_t length)
if (path->fd != -1)
return os_ftruncate_impl(module, path->fd, length);
+ if (PySys_Audit("os.truncate", "On", path->object, length) < 0) {
+ return NULL;
+ }
+
Py_BEGIN_ALLOW_THREADS
_Py_BEGIN_SUPPRESS_IPH
#ifdef MS_WINDOWS
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index c024542..74cdc0f 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -3053,6 +3053,11 @@ sock_bind(PySocketSockObject *s, PyObject *addro)
if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen, "bind")) {
return NULL;
}
+
+ if (PySys_Audit("socket.bind", "OO", s, addro) < 0) {
+ return NULL;
+ }
+
Py_BEGIN_ALLOW_THREADS
res = bind(s->sock_fd, SAS2SA(&addrbuf), addrlen);
Py_END_ALLOW_THREADS
@@ -3219,6 +3224,10 @@ sock_connect(PySocketSockObject *s, PyObject *addro)
return NULL;
}
+ if (PySys_Audit("socket.connect", "OO", s, addro) < 0) {
+ return NULL;
+ }
+
res = internal_connect(s, SAS2SA(&addrbuf), addrlen, 1);
if (res < 0)
return NULL;
@@ -3246,6 +3255,10 @@ sock_connect_ex(PySocketSockObject *s, PyObject *addro)
return NULL;
}
+ if (PySys_Audit("socket.connect", "OO", s, addro) < 0) {
+ return NULL;
+ }
+
res = internal_connect(s, SAS2SA(&addrbuf), addrlen, 0);
if (res < 0)
return NULL;
@@ -4248,6 +4261,10 @@ sock_sendto(PySocketSockObject *s, PyObject *args)
return NULL;
}
+ if (PySys_Audit("socket.sendto", "OO", s, addro) < 0) {
+ return NULL;
+ }
+
ctx.buf = pbuf.buf;
ctx.len = pbuf.len;
ctx.flags = flags;
@@ -4379,8 +4396,15 @@ sock_sendmsg(PySocketSockObject *s, PyObject *args)
{
goto finally;
}
+ if (PySys_Audit("socket.sendmsg", "OO", s, addr_arg) < 0) {
+ return NULL;
+ }
msg.msg_name = &addrbuf;
msg.msg_namelen = addrlen;
+ } else {
+ if (PySys_Audit("socket.sendmsg", "OO", s, Py_None) < 0) {
+ return NULL;
+ }
}
/* Fill in an iovec for each message part, and save the Py_buffer
@@ -5030,6 +5054,17 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)
&family, &type, &proto, &fdobj))
return -1;
+#ifdef MS_WINDOWS
+ /* In this case, we don't use the family, type and proto args */
+ if (fdobj != NULL && fdobj != Py_None)
+#endif
+ {
+ if (PySys_Audit("socket.__new__", "Oiii",
+ s, family, type, proto) < 0) {
+ return -1;
+ }
+ }
+
if (fdobj != NULL && fdobj != Py_None) {
#ifdef MS_WINDOWS
/* recreate a socket that was duplicated */
@@ -5042,6 +5077,12 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)
return -1;
}
memcpy(&info, PyBytes_AS_STRING(fdobj), sizeof(info));
+
+ if (PySys_Audit("socket()", "iii", info.iAddressFamily,
+ info.iSocketType, info.iProtocol) < 0) {
+ return -1;
+ }
+
Py_BEGIN_ALLOW_THREADS
fd = WSASocketW(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
FROM_PROTOCOL_INFO, &info, 0, WSA_FLAG_OVERLAPPED);
@@ -5284,6 +5325,10 @@ static PyTypeObject sock_type = {
static PyObject *
socket_gethostname(PyObject *self, PyObject *unused)
{
+ if (PySys_Audit("socket.gethostname", NULL) < 0) {
+ return NULL;
+ }
+
#ifdef MS_WINDOWS
/* Don't use winsock's gethostname, as this returns the ANSI
version of the hostname, whereas we need a Unicode string.
@@ -5362,6 +5407,11 @@ extern int sethostname(const char *, size_t);
return NULL;
flag = 1;
}
+
+ if (PySys_Audit("socket.sethostname", "(O)", hnobj) < 0) {
+ return NULL;
+ }
+
res = PyObject_GetBuffer(hnobj, &buf, PyBUF_SIMPLE);
if (!res) {
res = sethostname(buf.buf, buf.len);
@@ -5387,6 +5437,9 @@ socket_gethostbyname(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "et:gethostbyname", "idna", &name))
return NULL;
+ if (PySys_Audit("socket.gethostbyname", "O", args) < 0) {
+ goto finally;
+ }
if (setipaddr(name, (struct sockaddr *)&addrbuf, sizeof(addrbuf), AF_INET) < 0)
goto finally;
ret = make_ipv4_addr(&addrbuf);
@@ -5571,6 +5624,9 @@ socket_gethostbyname_ex(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "et:gethostbyname_ex", "idna", &name))
return NULL;
+ if (PySys_Audit("socket.gethostbyname", "O", args) < 0) {
+ goto finally;
+ }
if (setipaddr(name, SAS2SA(&addr), sizeof(addr), AF_INET) < 0)
goto finally;
Py_BEGIN_ALLOW_THREADS
@@ -5649,6 +5705,9 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "et:gethostbyaddr", "idna", &ip_num))
return NULL;
+ if (PySys_Audit("socket.gethostbyaddr", "O", args) < 0) {
+ goto finally;
+ }
af = AF_UNSPEC;
if (setipaddr(ip_num, sa, sizeof(addr), af) < 0)
goto finally;
@@ -5720,6 +5779,11 @@ socket_getservbyname(PyObject *self, PyObject *args)
struct servent *sp;
if (!PyArg_ParseTuple(args, "s|s:getservbyname", &name, &proto))
return NULL;
+
+ if (PySys_Audit("socket.getservbyname", "ss", name, proto) < 0) {
+ return NULL;
+ }
+
Py_BEGIN_ALLOW_THREADS
sp = getservbyname(name, proto);
Py_END_ALLOW_THREADS
@@ -5757,6 +5821,11 @@ socket_getservbyport(PyObject *self, PyObject *args)
"getservbyport: port must be 0-65535.");
return NULL;
}
+
+ if (PySys_Audit("socket.getservbyport", "is", port, proto) < 0) {
+ return NULL;
+ }
+
Py_BEGIN_ALLOW_THREADS
sp = getservbyport(htons((short)port), proto);
Py_END_ALLOW_THREADS
@@ -6392,6 +6461,12 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
pptr = "00";
}
#endif
+
+ if (PySys_Audit("socket.getaddrinfo", "OOiii",
+ hobj, pobj, family, socktype, protocol) < 0) {
+ return NULL;
+ }
+
memset(&hints, 0, sizeof(hints));
hints.ai_family = family;
hints.ai_socktype = socktype;
@@ -6483,6 +6558,11 @@ socket_getnameinfo(PyObject *self, PyObject *args)
"getnameinfo(): flowinfo must be 0-1048575.");
return NULL;
}
+
+ if (PySys_Audit("socket.getnameinfo", "(O)", sa) < 0) {
+ return NULL;
+ }
+
PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port);
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;