Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
06b1d21e
Commit
06b1d21e
authored
Nov 02, 2001
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct getnameinfo refcounting and tuple parsing. Fixes #476648.
parent
6b45b1ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
Lib/test/test_socket.py
Lib/test/test_socket.py
+14
-0
Modules/socketmodule.c
Modules/socketmodule.c
+4
-6
No files found.
Lib/test/test_socket.py
View file @
06b1d21e
...
...
@@ -90,6 +90,20 @@ if hasattr(socket, 'getservbyname'):
except
socket
.
error
:
pass
try
:
# On some versions, this loses a reference
import
sys
orig
=
sys
.
getrefcount
(
__name__
)
socket
.
getnameinfo
(
__name__
,
0
)
except
SystemError
:
if
sys
.
getrefcount
(
__name__
)
<>
orig
:
raise
TestFailed
,
"socket.getnameinfo loses a reference"
try
:
# On some versions, this crashes the interpreter.
socket
.
getnameinfo
((
'x'
,
0
,
0
,
0
),
0
)
except
socket
.
gaierror
:
pass
canfork
=
hasattr
(
os
,
'fork'
)
try
:
...
...
Modules/socketmodule.c
View file @
06b1d21e
...
...
@@ -2537,18 +2537,17 @@ PySocket_getnameinfo(PyObject *self, PyObject *args)
PyObject
*
sa
=
(
PyObject
*
)
NULL
;
int
flags
;
char
*
hostp
;
int
n
,
port
,
flowinfo
,
scope_id
;
int
port
,
flowinfo
,
scope_id
;
char
hbuf
[
NI_MAXHOST
],
pbuf
[
NI_MAXSERV
];
struct
addrinfo
hints
,
*
res
=
NULL
;
int
error
;
PyObject
*
ret
=
(
PyObject
*
)
NULL
;
flags
=
flowinfo
=
scope_id
=
0
;
if
(
PyArg_ParseTuple
(
args
,
"Oi:getnameinfo"
,
&
sa
,
&
flags
)
==
0
)
if
(
!
PyArg_ParseTuple
(
args
,
"Oi:getnameinfo"
,
&
sa
,
&
flags
))
return
NULL
;
if
(
!
PyArg_ParseTuple
(
sa
,
"si|ii"
,
&
hostp
,
&
port
,
&
flowinfo
,
&
scope_id
))
return
NULL
;
n
=
PyArg_ParseTuple
(
sa
,
"si|ii"
,
&
hostp
,
&
port
,
&
flowinfo
,
scope_id
);
if
(
n
==
0
)
goto
fail
;
PyOS_snprintf
(
pbuf
,
sizeof
(
pbuf
),
"%d"
,
port
);
memset
(
&
hints
,
0
,
sizeof
(
hints
));
hints
.
ai_family
=
PF_UNSPEC
;
...
...
@@ -2597,7 +2596,6 @@ PySocket_getnameinfo(PyObject *self, PyObject *args)
fail:
if
(
res
)
freeaddrinfo
(
res
);
Py_XDECREF
(
sa
);
return
ret
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment