[New-bugs-announce] [issue18528] Possible fd leak in socketmodule

Christian Heimes report at bugs.python.org
Mon Jul 22 14:34:56 CEST 2013


New submission from Christian Heimes:

Coverity claims that sock_accept() may leak a fd. I have been starring at the code for a while and I'm still not sure if Coverity is right. The macros make the code paths hard to follow. The attached patch is simple and should not be a performance issue.

http://hg.python.org/cpython/file/01597384531f/Modules/socketmodule.c#l1965

6. open_fn: Returning handle opened by function "accept(int, __SOCKADDR_ARG, socklen_t * restrict)".
7. var_assign: Assigning: "newfd" = handle returned from "accept(s->sock_fd, __SOCKADDR_ARG({ .__sockaddr__ = &addrbuf.sa}), &addrlen)".
CID 983312 (#1 of 1): Resource leak (RESOURCE_LEAK)14. overwrite_var: Overwriting handle "newfd" in "newfd = accept(s->sock_fd, __SOCKADDR_ARG({ .__sockaddr__ = &addrbuf.sa}), &addrlen)" leaks the handle.
1969        newfd = accept(s->sock_fd, SAS2SA(&addrbuf), &addrlen);

----------
components: Extension Modules
files: closesock.patch
keywords: needs review, patch
messages: 193530
nosy: christian.heimes
priority: normal
severity: normal
stage: patch review
status: open
title: Possible fd leak in socketmodule
type: resource usage
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file31004/closesock.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18528>
_______________________________________


More information about the New-bugs-announce mailing list