forked from pool/glibc
Accepting request 227699 from home:Andreas_Schwab:Factory
- check-pf-alloca.patch: remove use of alloca while collecting interface addresses OBS-URL: https://build.opensuse.org/request/show/227699 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=345
This commit is contained in:
parent
f99cf3ddb6
commit
26f82ad953
@ -9,95 +9,155 @@ Index: glibc-2.19/sysdeps/unix/sysv/linux/check_pf.c
|
|||||||
===================================================================
|
===================================================================
|
||||||
--- glibc-2.19.orig/sysdeps/unix/sysv/linux/check_pf.c
|
--- glibc-2.19.orig/sysdeps/unix/sysv/linux/check_pf.c
|
||||||
+++ glibc-2.19/sysdeps/unix/sysv/linux/check_pf.c
|
+++ glibc-2.19/sysdeps/unix/sysv/linux/check_pf.c
|
||||||
@@ -139,9 +139,10 @@ make_request (int fd, pid_t pid)
|
@@ -106,6 +106,11 @@ cache_valid_p (void)
|
||||||
|
static struct cached_data *
|
||||||
|
make_request (int fd, pid_t pid)
|
||||||
|
{
|
||||||
|
+ struct cached_data *result = NULL;
|
||||||
|
+
|
||||||
|
+ size_t result_len = 0;
|
||||||
|
+ size_t result_cap = 32;
|
||||||
|
+
|
||||||
|
struct req
|
||||||
|
{
|
||||||
|
struct nlmsghdr nlh;
|
||||||
|
@@ -137,19 +142,9 @@ make_request (int fd, pid_t pid)
|
||||||
|
#else
|
||||||
|
const size_t buf_size = __getpagesize ();
|
||||||
#endif
|
#endif
|
||||||
bool use_malloc = false;
|
- bool use_malloc = false;
|
||||||
char *buf;
|
char *buf;
|
||||||
+ size_t alloca_used = 0;
|
|
||||||
|
|
||||||
if (__libc_use_alloca (buf_size))
|
- if (__libc_use_alloca (buf_size))
|
||||||
- buf = alloca (buf_size);
|
- buf = alloca (buf_size);
|
||||||
+ buf = alloca_account (buf_size, alloca_used);
|
- else
|
||||||
else
|
- {
|
||||||
{
|
- buf = malloc (buf_size);
|
||||||
buf = malloc (buf_size);
|
- if (buf != NULL)
|
||||||
@@ -163,6 +164,7 @@ make_request (int fd, pid_t pid)
|
- use_malloc = true;
|
||||||
{
|
- else
|
||||||
struct in6addrinfo info;
|
- goto out_fail;
|
||||||
struct in6ailist *next;
|
- }
|
||||||
+ bool use_malloc;
|
+ buf = alloca (buf_size);
|
||||||
} *in6ailist = NULL;
|
|
||||||
size_t in6ailistlen = 0;
|
struct iovec iov = { buf, buf_size };
|
||||||
|
|
||||||
|
@@ -159,12 +154,7 @@ make_request (int fd, pid_t pid)
|
||||||
|
goto out_fail;
|
||||||
|
|
||||||
|
bool done = false;
|
||||||
|
- struct in6ailist
|
||||||
|
- {
|
||||||
|
- struct in6addrinfo info;
|
||||||
|
- struct in6ailist *next;
|
||||||
|
- } *in6ailist = NULL;
|
||||||
|
- size_t in6ailistlen = 0;
|
||||||
|
+
|
||||||
bool seen_ipv4 = false;
|
bool seen_ipv4 = false;
|
||||||
@@ -180,10 +182,10 @@ make_request (int fd, pid_t pid)
|
bool seen_ipv6 = false;
|
||||||
|
|
||||||
ssize_t read_len = TEMP_FAILURE_RETRY (__recvmsg (fd, &msg, 0));
|
@@ -239,28 +229,36 @@ make_request (int fd, pid_t pid)
|
||||||
if (read_len < 0)
|
|
||||||
- goto out_fail;
|
|
||||||
+ goto out_fail2;
|
|
||||||
|
|
||||||
if (msg.msg_flags & MSG_TRUNC)
|
|
||||||
- goto out_fail;
|
|
||||||
+ goto out_fail2;
|
|
||||||
|
|
||||||
struct nlmsghdr *nlmh;
|
|
||||||
for (nlmh = (struct nlmsghdr *) buf;
|
|
||||||
@@ -239,7 +241,19 @@ make_request (int fd, pid_t pid)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- struct in6ailist *newp = alloca (sizeof (*newp));
|
- struct in6ailist *newp = alloca (sizeof (*newp));
|
||||||
+ struct in6ailist *newp;
|
- newp->info.flags = (((ifam->ifa_flags
|
||||||
+ if (__libc_use_alloca (alloca_used + sizeof (*newp)))
|
- & (IFA_F_DEPRECATED
|
||||||
|
- | IFA_F_OPTIMISTIC))
|
||||||
|
- ? in6ai_deprecated : 0)
|
||||||
|
- | ((ifam->ifa_flags
|
||||||
|
- & IFA_F_HOMEADDRESS)
|
||||||
|
- ? in6ai_homeaddress : 0));
|
||||||
|
- newp->info.prefixlen = ifam->ifa_prefixlen;
|
||||||
|
- newp->info.index = ifam->ifa_index;
|
||||||
|
+ if (result_len == 0 || result_len == result_cap)
|
||||||
+ {
|
+ {
|
||||||
+ newp = alloca_account (sizeof (*newp), alloca_used);
|
+ result_cap = 2 * result_cap;
|
||||||
+ newp->use_malloc = false;
|
+ result = realloc (result, sizeof (*result)
|
||||||
|
+ + result_cap * sizeof (struct in6addrinfo));
|
||||||
+ }
|
+ }
|
||||||
+ else
|
+
|
||||||
+ {
|
+ if (!result)
|
||||||
+ newp = malloc (sizeof (*newp));
|
+ goto out_fail;
|
||||||
+ if (newp == NULL)
|
+
|
||||||
+ goto out_fail2;
|
+ struct in6addrinfo *info = &result->in6ai[result_len++];
|
||||||
+ newp->use_malloc = true;
|
+
|
||||||
+ }
|
+ info->flags = (((ifam->ifa_flags
|
||||||
newp->info.flags = (((ifam->ifa_flags
|
+ & (IFA_F_DEPRECATED
|
||||||
& (IFA_F_DEPRECATED
|
+ | IFA_F_OPTIMISTIC))
|
||||||
| IFA_F_OPTIMISTIC))
|
+ ? in6ai_deprecated : 0)
|
||||||
@@ -275,7 +289,7 @@ make_request (int fd, pid_t pid)
|
+ | ((ifam->ifa_flags
|
||||||
result = malloc (sizeof (*result)
|
+ & IFA_F_HOMEADDRESS)
|
||||||
+ in6ailistlen * sizeof (struct in6addrinfo));
|
+ ? in6ai_homeaddress : 0));
|
||||||
if (result == NULL)
|
+ info->prefixlen = ifam->ifa_prefixlen;
|
||||||
- goto out_fail;
|
+ info->index = ifam->ifa_index;
|
||||||
+ goto out_fail2;
|
if (ifam->ifa_family == AF_INET)
|
||||||
|
{
|
||||||
|
- newp->info.addr[0] = 0;
|
||||||
|
- newp->info.addr[1] = 0;
|
||||||
|
- newp->info.addr[2] = htonl (0xffff);
|
||||||
|
- newp->info.addr[3] = *(const in_addr_t *) address;
|
||||||
|
+ info->addr[0] = 0;
|
||||||
|
+ info->addr[1] = 0;
|
||||||
|
+ info->addr[2] = htonl (0xffff);
|
||||||
|
+ info->addr[3] = *(const in_addr_t *) address;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
- memcpy (newp->info.addr, address, sizeof (newp->info.addr));
|
||||||
|
- newp->next = in6ailist;
|
||||||
|
- in6ailist = newp;
|
||||||
|
- ++in6ailistlen;
|
||||||
|
+ memcpy (info->addr, address, sizeof (info->addr));
|
||||||
|
}
|
||||||
|
else if (nlmh->nlmsg_type == NLMSG_DONE)
|
||||||
|
/* We found the end, leave the loop. */
|
||||||
|
@@ -269,42 +267,29 @@ make_request (int fd, pid_t pid)
|
||||||
|
}
|
||||||
|
while (! done);
|
||||||
|
|
||||||
|
- struct cached_data *result;
|
||||||
|
- if (seen_ipv6 && in6ailist != NULL)
|
||||||
|
+ if (seen_ipv6 && result != NULL)
|
||||||
|
{
|
||||||
|
- result = malloc (sizeof (*result)
|
||||||
|
- + in6ailistlen * sizeof (struct in6addrinfo));
|
||||||
|
- if (result == NULL)
|
||||||
|
- goto out_fail;
|
||||||
|
-
|
||||||
result->timestamp = get_nl_timestamp ();
|
result->timestamp = get_nl_timestamp ();
|
||||||
result->usecnt = 2;
|
result->usecnt = 2;
|
||||||
@@ -286,7 +300,10 @@ make_request (int fd, pid_t pid)
|
result->seen_ipv4 = seen_ipv4;
|
||||||
do
|
result->seen_ipv6 = true;
|
||||||
{
|
- result->in6ailen = in6ailistlen;
|
||||||
result->in6ai[--in6ailistlen] = in6ailist->info;
|
-
|
||||||
|
- do
|
||||||
|
- {
|
||||||
|
- result->in6ai[--in6ailistlen] = in6ailist->info;
|
||||||
- in6ailist = in6ailist->next;
|
- in6ailist = in6ailist->next;
|
||||||
+ struct in6ailist *next = in6ailist->next;
|
- }
|
||||||
+ if (in6ailist->use_malloc)
|
- while (in6ailist != NULL);
|
||||||
+ free (in6ailist);
|
+ result->in6ailen = result_len;
|
||||||
+ in6ailist = next;
|
|
||||||
}
|
}
|
||||||
while (in6ailist != NULL);
|
else
|
||||||
|
{
|
||||||
|
+ free (result);
|
||||||
|
+
|
||||||
|
atomic_add (&noai6ai_cached.usecnt, 2);
|
||||||
|
noai6ai_cached.seen_ipv4 = seen_ipv4;
|
||||||
|
noai6ai_cached.seen_ipv6 = seen_ipv6;
|
||||||
|
result = &noai6ai_cached;
|
||||||
}
|
}
|
||||||
@@ -302,7 +319,15 @@ make_request (int fd, pid_t pid)
|
|
||||||
free (buf);
|
- if (use_malloc)
|
||||||
|
- free (buf);
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
-out_fail:
|
-out_fail:
|
||||||
+ out_fail2:
|
- if (use_malloc)
|
||||||
+ while (in6ailist != NULL)
|
- free (buf);
|
||||||
+ {
|
|
||||||
+ struct in6ailist *next = in6ailist->next;
|
|
||||||
+ if (in6ailist->use_malloc)
|
|
||||||
+ free (in6ailist);
|
|
||||||
+ in6ailist = next;
|
|
||||||
+ }
|
|
||||||
+ out_fail:
|
+ out_fail:
|
||||||
if (use_malloc)
|
+
|
||||||
free (buf);
|
+ free (result);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Mar 27 08:40:20 UTC 2014 - schwab@suse.de
|
||||||
|
|
||||||
|
- check-pf-alloca.patch: remove use of alloca while collecting interface
|
||||||
|
addresses
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Mar 25 09:26:44 UTC 2014 - schwab@suse.de
|
Tue Mar 25 09:26:44 UTC 2014 - schwab@suse.de
|
||||||
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Mar 27 08:40:20 UTC 2014 - schwab@suse.de
|
||||||
|
|
||||||
|
- check-pf-alloca.patch: remove use of alloca while collecting interface
|
||||||
|
addresses
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Mar 25 09:26:44 UTC 2014 - schwab@suse.de
|
Tue Mar 25 09:26:44 UTC 2014 - schwab@suse.de
|
||||||
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Mar 27 08:40:20 UTC 2014 - schwab@suse.de
|
||||||
|
|
||||||
|
- check-pf-alloca.patch: remove use of alloca while collecting interface
|
||||||
|
addresses
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Mar 25 09:26:44 UTC 2014 - schwab@suse.de
|
Tue Mar 25 09:26:44 UTC 2014 - schwab@suse.de
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user