mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Fix potential double close in __check_fd if OOM
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2011-10-30 Ulrich Drepper <drepper@gmail.com>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/check_pf.c (make_request): Don't call
|
||||||
|
close_not_cancel_no_status here.
|
||||||
|
(__check_pf): Reorganize code a bit to not call close twice if OOM.
|
||||||
|
|
||||||
2011-10-29 Ulrich Drepper <drepper@gmail.com>
|
2011-10-29 Ulrich Drepper <drepper@gmail.com>
|
||||||
|
|
||||||
[BZ #13276]
|
[BZ #13276]
|
||||||
|
@ -211,8 +211,6 @@ make_request (int fd, pid_t pid, bool *seen_ipv4, bool *seen_ipv6,
|
|||||||
}
|
}
|
||||||
while (! done);
|
while (! done);
|
||||||
|
|
||||||
close_not_cancel_no_status (fd);
|
|
||||||
|
|
||||||
if (*seen_ipv6 && in6ailist != NULL)
|
if (*seen_ipv6 && in6ailist != NULL)
|
||||||
{
|
{
|
||||||
*in6ai = malloc (in6ailistlen * sizeof (**in6ai));
|
*in6ai = malloc (in6ailistlen * sizeof (**in6ai));
|
||||||
@ -262,22 +260,27 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
|
|||||||
{
|
{
|
||||||
int fd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
int fd = __socket (PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||||
|
|
||||||
struct sockaddr_nl nladdr;
|
if (__builtin_expect (fd >= 0, 1))
|
||||||
memset (&nladdr, '\0', sizeof (nladdr));
|
{
|
||||||
nladdr.nl_family = AF_NETLINK;
|
struct sockaddr_nl nladdr;
|
||||||
|
memset (&nladdr, '\0', sizeof (nladdr));
|
||||||
|
nladdr.nl_family = AF_NETLINK;
|
||||||
|
|
||||||
socklen_t addr_len = sizeof (nladdr);
|
socklen_t addr_len = sizeof (nladdr);
|
||||||
|
|
||||||
if (fd >= 0
|
bool success
|
||||||
&& __bind (fd, (struct sockaddr *) &nladdr, sizeof (nladdr)) == 0
|
= (__bind (fd, (struct sockaddr *) &nladdr, sizeof (nladdr)) == 0
|
||||||
&& __getsockname (fd, (struct sockaddr *) &nladdr, &addr_len) == 0
|
&& __getsockname (fd, (struct sockaddr *) &nladdr,
|
||||||
&& make_request (fd, nladdr.nl_pid, seen_ipv4, seen_ipv6,
|
&addr_len) == 0
|
||||||
in6ai, in6ailen) == 0)
|
&& make_request (fd, nladdr.nl_pid, seen_ipv4, seen_ipv6,
|
||||||
/* It worked. */
|
in6ai, in6ailen) == 0);
|
||||||
return;
|
|
||||||
|
|
||||||
if (fd >= 0)
|
close_not_cancel_no_status (fd);
|
||||||
__close (fd);
|
|
||||||
|
if (success)
|
||||||
|
/* It worked. */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#if __ASSUME_NETLINK_SUPPORT == 0
|
#if __ASSUME_NETLINK_SUPPORT == 0
|
||||||
/* Remember that there is no netlink support. */
|
/* Remember that there is no netlink support. */
|
||||||
|
Reference in New Issue
Block a user