1 commit c8fc0c91695b1c7003c7170861274161f9224817
2 Author: Ulrich Drepper <drepper@gmail.com>
3 Date: Tue May 31 08:45:44 2011 -0400
5 Don't free non-malloced memory and fix memory leak
7 diff --git a/nscd/nscd_getserv_r.c b/nscd/nscd_getserv_r.c
8 index de96a57..f9ef056 100644
9 --- a/nscd/nscd_getserv_r.c
10 +++ b/nscd/nscd_getserv_r.c
11 @@ -124,6 +124,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
12 s_name = (char *) (&found->data[0].servdata + 1);
13 serv_resp = found->data[0].servdata;
14 s_proto = s_name + serv_resp.s_name_len;
15 + alloca_aliases_len = 1;
16 aliases_len = (uint32_t *) (s_proto + serv_resp.s_proto_len);
17 aliases_list = ((char *) aliases_len
18 + serv_resp.s_aliases_cnt * sizeof (uint32_t));
19 @@ -154,7 +155,9 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
20 + (serv_resp.s_aliases_cnt
21 * sizeof (uint32_t)));
22 if (alloca_aliases_len)
23 - tmp = __alloca (serv_resp.s_aliases_cnt * sizeof (uint32_t));
24 + tmp = alloca_account (serv_resp.s_aliases_cnt
25 + * sizeof (uint32_t),
29 tmp = malloc (serv_resp.s_aliases_cnt * sizeof (uint32_t));
30 @@ -249,8 +252,9 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
31 + (serv_resp.s_aliases_cnt
32 * sizeof (uint32_t)));
33 if (alloca_aliases_len)
34 - aliases_len = alloca (serv_resp.s_aliases_cnt
35 - * sizeof (uint32_t));
36 + aliases_len = alloca_account (serv_resp.s_aliases_cnt
37 + * sizeof (uint32_t),
41 aliases_len = malloc (serv_resp.s_aliases_cnt
42 @@ -368,7 +372,11 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
48 + if (!alloca_aliases_len)
54 if (!alloca_aliases_len)
55 commit 8c29731192565b9c917d6b97db78dcd302283df8
56 Author: Ulrich Drepper <drepper@gmail.com>
57 Date: Tue May 31 14:23:01 2011 -0400
59 Fix typo in stack guard setup code for old kernels
61 diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
62 index eb7fedc..28fce4f 100644
63 --- a/sysdeps/unix/sysv/linux/dl-osinfo.h
64 +++ b/sysdeps/unix/sysv/linux/dl-osinfo.h
65 @@ -81,7 +81,7 @@ _dl_setup_stack_chk_guard (void *dl_random)
67 ssize_t reslen = read_not_cancel (fd, ret.bytes + 1, filllen);
68 close_not_cancel_no_status (fd);
69 - if (reslen == (ssize_) filllen)
70 + if (reslen == (ssize_t) filllen)
74 ;2011-06-10 Andreas Schwab <schwab@redhat.com>
76 ; * sysdeps/posix/getaddrinfo.c (gaih_inet): Fix logic allocating
79 diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
80 index 1e017b2..469abe2 100644
81 --- a/sysdeps/posix/getaddrinfo.c
82 +++ b/sysdeps/posix/getaddrinfo.c
83 @@ -821,7 +821,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
84 size_t tmpbuflen = 1024;
85 malloc_tmpbuf = !__libc_use_alloca (alloca_used + tmpbuflen);
86 assert (tmpbuf == NULL);
89 tmpbuf = alloca_account (tmpbuflen, alloca_used);
92 commit 3d29045b5e8329d97693eda8d98f1d1e60b99c8f
93 Author: H.J. Lu <hongjiu.lu@intel.com>
94 Date: Fri Jun 3 07:01:25 2011 -0400
96 Assume Intel Core i3/i5/i7 processor if AVX is available
98 diff --git a/sysdeps/x86_64/multiarch/init-arch.c b/sysdeps/x86_64/multiarch/init-arch.c
99 index 34ec2df..809d105 100644
100 --- a/sysdeps/x86_64/multiarch/init-arch.c
101 +++ b/sysdeps/x86_64/multiarch/init-arch.c
102 @@ -74,6 +74,7 @@ __init_cpu_features (void)
104 else if (family == 0x06)
106 + ecx = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx;
107 model += extended_model;
110 @@ -83,6 +84,12 @@ __init_cpu_features (void)
111 __cpu_features.feature[index_Slow_BSF] |= bit_Slow_BSF;
115 + /* Unknown family 0x06 processors. Assuming this is one
116 + of Core i3/i5/i7 processors if AVX is available. */
117 + if ((ecx & bit_AVX) == 0)
123 commit c71ca1f89c6e89d8c4145e4c2fdcce2fc78812bd
124 Author: Andreas Jaeger <aj@suse.de>
125 Date: Tue Jun 14 13:11:39 2011 -0700
127 Quash two memset undeclared warnings.
129 diff --git a/nptl/pthread_rwlock_init.c b/nptl/pthread_rwlock_init.c
130 index c0aa194..9ecd48c 100644
131 --- a/nptl/pthread_rwlock_init.c
132 +++ b/nptl/pthread_rwlock_init.c
134 -/* Copyright (C) 2002, 2007, 2009 Free Software Foundation, Inc.
135 +/* Copyright (C) 2002,2007,2009,2011 Free Software Foundation, Inc.
136 This file is part of the GNU C Library.
137 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
142 #include "pthreadP.h"
144 #include <kernel-features.h>
147 diff --git a/sysdeps/unix/sysv/linux/check_native.c b/sysdeps/unix/sysv/linux/check_native.c
148 index 6e6624a..dedce34 100644
149 --- a/sysdeps/unix/sysv/linux/check_native.c
150 +++ b/sysdeps/unix/sysv/linux/check_native.c
152 /* Determine whether interfaces use native transport. Linux version.
153 - Copyright (C) 2007 Free Software Foundation, Inc.
154 + Copyright (C) 2007,2011 Free Software Foundation, Inc.
155 This file is part of the GNU C Library.
157 The GNU C Library is free software; you can redistribute it and/or
166 commit c5e3c2ae59cc8c5d3ad5e1adfd099c726baad862
167 Author: Ulrich Drepper <drepper@gmail.com>
168 Date: Tue Jun 21 13:06:42 2011 -0400
170 Minor optimization of getaddrinfo after recent patch
172 diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
173 index 469abe2..d68ac83 100644
174 --- a/sysdeps/posix/getaddrinfo.c
175 +++ b/sysdeps/posix/getaddrinfo.c
176 @@ -565,7 +565,6 @@ gaih_inet (const char *name, const struct gaih_service *service,
178 if (req->ai_family == AF_INET)
180 - int family = req->ai_family;
181 size_t tmpbuflen = 512;
182 assert (tmpbuf == NULL);
183 tmpbuf = alloca_account (tmpbuflen, alloca_used);
184 @@ -576,7 +575,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
188 - rc = __gethostbyname2_r (name, family, &th, tmpbuf,
189 + rc = __gethostbyname2_r (name, AF_INET, &th, tmpbuf,
190 tmpbuflen, &h, &herrno);
191 if (rc != ERANGE || herrno != NETDB_INTERNAL)
193 @@ -638,18 +637,9 @@ gaih_inet (const char *name, const struct gaih_service *service,
197 - (*pat)->family = req->ai_family;
198 - if (family == req->ai_family)
199 - memcpy ((*pat)->addr, h->h_addr_list[i],
203 - uint32_t *addr = (uint32_t *) (*pat)->addr;
204 - addr[3] = *(uint32_t *) h->h_addr_list[i];
205 - addr[2] = htonl (0xffff);
209 + (*pat)->family = AF_INET;
210 + memcpy ((*pat)->addr, h->h_addr_list[i],
212 pat = &((*pat)->next);
215 commit c0244a9dedce43a4b950d91451b16a7cf5408476
216 Author: Ulrich Drepper <drepper@gmail.com>
217 Date: Tue Jun 21 17:03:38 2011 -0400
219 Fix IPv6-only lookups through getaddrinfo
221 A recent patch introduced a problem where IPv6 lookups happily returned
224 diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
225 index d68ac83..3a2737e 100644
226 --- a/sysdeps/posix/getaddrinfo.c
227 +++ b/sysdeps/posix/getaddrinfo.c
228 @@ -871,16 +871,44 @@ gaih_inet (const char *name, const struct gaih_service *service,
232 - no_inet6_data = no_data;
234 if (status == NSS_STATUS_SUCCESS)
239 if ((req->ai_flags & AI_CANONNAME) != 0 && canon == NULL)
240 canon = (*pat)->name;
243 - pat = &((*pat)->next);
245 + if ((*pat)->family == AF_INET
246 + && req->ai_family == AF_INET6
247 + && (req->ai_flags & AI_V4MAPPED) != 0)
249 + uint32_t *pataddr = (*pat)->addr;
250 + (*pat)->family = AF_INET6;
251 + pataddr[3] = pataddr[0];
252 + pataddr[2] = htonl (0xffff);
255 + pat = &((*pat)->next);
258 + else if ((*pat)->family == AF_UNSPEC
259 + || (*pat)->family == req->ai_family)
261 + pat = &((*pat)->next);
264 + if (req->ai_family == AF_INET6)
268 + *pat = ((*pat)->next);
272 + no_inet6_data = no_data;
276 commit 6e502e19455c6110dd4487d91b7b7d6d8121f9ba
277 Author: Ulrich Drepper <drepper@gmail.com>
278 Date: Wed Jun 22 08:32:55 2011 -0400
280 Clean up after kernel sigcontext header mess
282 diff --git a/sysdeps/unix/sysv/linux/bits/sigcontext.h b/sysdeps/unix/sysv/linux/bits/sigcontext.h
283 index 67dcf94..0f5b607 100644
284 --- a/sysdeps/unix/sysv/linux/bits/sigcontext.h
285 +++ b/sysdeps/unix/sysv/linux/bits/sigcontext.h
287 -/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
288 +/* Copyright (C) 1996, 1997, 1998, 2011 Free Software Foundation, Inc.
289 This file is part of the GNU C Library.
291 The GNU C Library is free software; you can redistribute it and/or
293 # define sigcontext_struct sigcontext
295 # include <asm/sigcontext.h>
297 +/* The Linux kernel headers redefine NULL wrongly, so cleanup afterwards. */
298 +# define __need_NULL
299 +# include <stddef.h>
301 commit 852eb34d5c56bc75bdd82327fcf310d98655f6b0
302 Author: Ulrich Drepper <drepper@gmail.com>
303 Date: Wed Jun 22 09:50:39 2011 -0400
305 Rate limit expensive _SC_NPROCESSORS_ONLN computation
307 diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
308 index af454b6..a13b6e3 100644
309 --- a/sysdeps/unix/sysv/linux/getsysstats.c
310 +++ b/sysdeps/unix/sysv/linux/getsysstats.c
312 /* Determine various system internal values, Linux version.
313 - Copyright (C) 1996-2003,2006,2007,2009,2010 Free Software Foundation, Inc.
314 + Copyright (C) 1996-2003,2006,2007,2009,2010,2011 Free Software Foundation, Inc.
315 This file is part of the GNU C Library.
316 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
321 #include <not-cancel.h>
322 +#include <kernel-features.h>
324 +#ifndef HAVE_CLOCK_GETTIME_VSYSCALL
325 +# undef INTERNAL_VSYSCALL
326 +# define INTERNAL_VSYSCALL INTERNAL_SYSCALL
327 +# undef INLINE_VSYSCALL
328 +# define INLINE_VSYSCALL INLINE_SYSCALL
330 +# include <bits/libc-vdso.h>
334 /* How we can determine the number of available processors depends on
335 @@ -128,6 +138,22 @@ next_line (int fd, char *const buffer, char **cp, char **re,
339 + static int cached_result;
340 + static time_t timestamp;
342 +#ifdef __ASSUME_POSIX_TIMERS
343 + struct timespec ts;
344 + INTERNAL_SYSCALL_DECL (err);
345 + INTERNAL_VSYSCALL (clock_gettime, err, 2, CLOCK_REALTIME, &ts);
348 + gettimeofday (&ts, NULL);
350 + time_t prev = timestamp;
351 + atomic_read_barrier ();
352 + if (ts.tv_sec == prev)
353 + return cached_result;
355 /* XXX Here will come a test for the new system call. */
357 const size_t buffer_size = __libc_use_alloca (8192) ? 8192 : 512;
358 @@ -169,6 +195,10 @@ __get_nprocs ()
362 + cached_result = result;
363 + atomic_write_barrier ();
364 + timestamp = ts.tv_sec;
368 weak_alias (__get_nprocs, get_nprocs)
369 commit 84e2a551a72c79b020694bb327e33b6d71b09b63
370 Author: Ulrich Drepper <drepper@gmail.com>
371 Date: Wed Jun 22 10:32:07 2011 -0400
373 Use a /sys/devices/system/cpu/online for _SC_NPROCESSORS_ONLN implementation
375 diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
376 index a13b6e3..b74774f 100644
377 --- a/sysdeps/unix/sysv/linux/getsysstats.c
378 +++ b/sysdeps/unix/sysv/linux/getsysstats.c
379 @@ -161,20 +161,65 @@ __get_nprocs ()
380 char *buffer_end = buffer + buffer_size;
381 char *cp = buffer_end;
382 char *re = buffer_end;
386 const int flags = O_RDONLY | O_CLOEXEC;
388 const int flags = O_RDONLY;
390 + int fd = open_not_cancel_2 ("/sys/devices/system/cpu/online", flags);
395 + l = next_line (fd, buffer, &cp, &re, buffer_end);
400 + unsigned long int n = strtoul (l, &endp, 10);
407 + unsigned long int m = n;
411 + m = strtoul (l, &endp, 10);
419 + result += m - n + 1;
422 + while (l < re && isspace (*l))
427 + close_not_cancel_no_status (fd);
437 /* The /proc/stat format is more uniform, use it by default. */
438 - int fd = open_not_cancel_2 ("/proc/stat", flags);
439 + fd = open_not_cancel_2 ("/proc/stat", flags);
445 while ((l = next_line (fd, buffer, &cp, &re, buffer_end)) != NULL)
446 /* The current format of /proc/stat has all the cpu* entries
447 at the front. We assume here that stays this way. */
448 @@ -195,6 +240,7 @@ __get_nprocs ()
453 cached_result = result;
454 atomic_write_barrier ();
455 timestamp = ts.tv_sec;
456 commit e12df166d37522c2ed434c2d70a1b04640d2d7c6
457 Author: Andreas Schwab <schwab@redhat.com>
458 Date: Wed Jun 22 14:35:49 2011 -0400
460 Fix Ipv4&IPv6 lookup in getaddrinfo
462 Problem introduced in the last patch.
464 diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
465 index 3a2737e..14e9270 100644
466 --- a/sysdeps/posix/getaddrinfo.c
467 +++ b/sysdeps/posix/getaddrinfo.c
468 @@ -894,7 +894,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
469 pat = &((*pat)->next);
472 - else if ((*pat)->family == AF_UNSPEC
473 + else if (req->ai_family == AF_UNSPEC
474 || (*pat)->family == req->ai_family)
476 pat = &((*pat)->next);
477 commit fa3fc0fe5f452d0aa7e435d8f32e992958683819
478 Author: Ulrich Drepper <drepper@gmail.com>
479 Date: Wed Jun 22 15:00:54 2011 -0400
481 Avoid __check_pf calls in getaddrinfo unless really needed
483 diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
484 index 14e9270..05c883d 100644
485 --- a/sysdeps/posix/getaddrinfo.c
486 +++ b/sysdeps/posix/getaddrinfo.c
487 @@ -2352,14 +2352,17 @@ getaddrinfo (const char *name, const char *service,
489 bool seen_ipv4 = false;
490 bool seen_ipv6 = false;
491 - /* We might need information about what interfaces are available.
492 - Also determine whether we have IPv4 or IPv6 interfaces or both. We
493 - cannot cache the results since new interfaces could be added at
495 - __check_pf (&seen_ipv4, &seen_ipv6, &in6ai, &in6ailen);
496 + bool check_pf_called = false;
498 if (hints->ai_flags & AI_ADDRCONFIG)
500 + /* We might need information about what interfaces are available.
501 + Also determine whether we have IPv4 or IPv6 interfaces or both. We
502 + cannot cache the results since new interfaces could be added at
504 + __check_pf (&seen_ipv4, &seen_ipv6, &in6ai, &in6ailen);
505 + check_pf_called = true;
507 /* Now make a decision on what we return, if anything. */
508 if (hints->ai_family == PF_UNSPEC && (seen_ipv4 || seen_ipv6))
510 @@ -2441,6 +2444,10 @@ getaddrinfo (const char *name, const char *service,
511 struct addrinfo *last = NULL;
512 char *canonname = NULL;
514 + /* Now we definitely need the interface information. */
515 + if (! check_pf_called)
516 + __check_pf (&seen_ipv4, &seen_ipv6, &in6ai, &in6ailen);
518 /* If we have information about deprecated and temporary addresses
519 sort the array now. */
521 commit 034807a9cbddfa9e7d35df4cdb2ecce569a00851
522 Author: Ulrich Drepper <drepper@gmail.com>
523 Date: Mon Jun 27 13:10:44 2011 -0400
525 Fix handling of RES_USE_INET6 big in nscd
527 This fixes BZ #12350 also for nscd.
529 diff --git a/nscd/aicache.c b/nscd/aicache.c
530 index 3190a13..6c8d83a 100644
533 @@ -534,7 +534,7 @@ next_nip:
537 - _res.options = old_res_options;
538 + _res.options |= old_res_options & RES_USE_INET6;
540 if (dataset != NULL && !alloca_used)
542 commit 89f654c57b3b9a6aee480e25e37f88f06c898901
543 Author: Andreas Schwab <schwab@redhat.com>
544 Date: Thu Jun 30 06:33:32 2011 -0400
546 Make sure RES_USE_INET6 is always restored
548 diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
549 index 05c883d..6d574c5 100644
550 --- a/sysdeps/posix/getaddrinfo.c
551 +++ b/sysdeps/posix/getaddrinfo.c
552 @@ -818,6 +818,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
553 tmpbuf = malloc (tmpbuflen);
556 + _res.options |= old_res_options & RES_USE_INET6;
557 result = -EAI_MEMORY;
558 goto free_and_return;
560 @@ -862,6 +863,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
564 + _res.options |= old_res_options & RES_USE_INET6;
565 result = -EAI_MEMORY;
566 goto free_and_return;
568 @@ -981,6 +983,8 @@ gaih_inet (const char *name, const struct gaih_service *service,
569 canonbuf = malloc (max_fqdn_len);
570 if (canonbuf == NULL)
573 + |= old_res_options & RES_USE_INET6;
574 result = -EAI_MEMORY;
575 goto free_and_return;