From 71197fe61ff9e55e4cbfb50cce6a9026e15ddb23 Mon Sep 17 00:00:00 2001 From: "Ryan S. Arnold" Date: Sat, 3 Apr 2010 19:20:29 -0700 Subject: [PATCH 01/57] Remove incorrect paring of /proc/stat etc. (cherry picked from commit 3ed8e241229e370cca96650ed727f09838c51d67) --- ChangeLog | 6 ++++++ sysdeps/unix/sysv/linux/getsysstats.c | 14 +------------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 17dbb62036..def693e279 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-03-25 Ryan S. Arnold + + * sysdeps/unix/sysv/linux/getsysstats.c (next_line): Remove + redundant and incorrect else block which overwrites current line + with the partial next line. + 2010-01-14 Ulrich Drepper [BZ #11127] diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c index 97e20d249b..af454b650d 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/sysdeps/unix/sysv/linux/getsysstats.c @@ -1,5 +1,5 @@ /* Determine various system internal values, Linux version. - Copyright (C) 1996-2003, 2006, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 1996-2003,2006,2007,2009,2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -117,18 +117,6 @@ next_line (int fd, char *const buffer, char **cp, char **re, if (nl == NULL) nl = *re - 1; } - else if (nl + 5 >= *re) - { - memmove (buffer, nl, *re - nl); - *re = buffer + (*re - nl); - nl = *cp = buffer; - - ssize_t n = read_not_cancel (fd, *re, buffer_end - *re); - if (n < 0) - return NULL; - - *re += n; - } *cp = nl + 1; assert (*cp <= *re); From ec10a41982e257e9829c54eb0092dd9fac91a149 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 6 Feb 2010 02:13:56 -0800 Subject: [PATCH 02/57] memchr overshoots on ia64 (cherry picked from commit 70b7d00fc782759f1257001202cc30cb29bae28f) --- ChangeLog | 6 ++++++ sysdeps/ia64/memchr.S | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index def693e279..3158003125 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-02-05 H.J. Lu + + [BZ #11230] + * sysdeps/ia64/memchr.S: Don't read beyond the last byte + during recovery. + 2010-03-25 Ryan S. Arnold * sysdeps/unix/sysv/linux/getsysstats.c (next_line): Remove diff --git a/sysdeps/ia64/memchr.S b/sysdeps/ia64/memchr.S index cdd71ca5a5..56d8056839 100644 --- a/sysdeps/ia64/memchr.S +++ b/sysdeps/ia64/memchr.S @@ -47,7 +47,7 @@ #define saved_lc r16 #define chr r17 #define len r18 -#define pos0 r20 +#define last r20 #define val r21 #define tmp r24 #define chrx8 r25 @@ -67,6 +67,7 @@ ENTRY(__memchr) mov saved_pr = pr // save the predicates .body mov ret0 = str + add last = str, in2 // last byte and tmp = 7, str // tmp = str % 8 cmp.ne p7, p0 = r0, r0 // clear p7 extr.u chr = in1, 0, 8 // chr = (unsigned char) in1 @@ -143,7 +144,10 @@ ENTRY(__memchr) ld8 tmp = [ret0];; // load the first unchecked 8byte xor aux[1] = tmp, chrx8;; czx1.r poschr[1] = aux[1];; - cmp.ne p7, p0 = 8, poschr[1] + cmp.ne p7, p0 = 8, poschr[1];; +(p7) add ret0 = addr[MEMLAT+2], poschr[1];; +(p7) cmp.geu p6, p7 = ret0, last // don't go over the last byte +(p6) br.cond.spnt .notfound;; (p7) br.cond.spnt .foundit;; adds ret0 = 8, ret0 // load the next unchecked 8byte br.sptk .l4;; From 8c55b16c2f2c1fcbfe83916b598ed8c42a70350d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 14 Jan 2010 17:03:42 -0800 Subject: [PATCH 03/57] Make unistd.h pre-c((-safe. (cherry picked from commit 0b689682ad2705f57177f12158479036fcbf9563) --- ChangeLog | 4 ++++ bits/confname.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3158003125..155a9a1e9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-14 Ulrich Drepper + + * bits/confname.h: Make pre-C99-safe. + 2010-02-05 H.J. Lu [BZ #11230] diff --git a/bits/confname.h b/bits/confname.h index 757ed4f3ca..085c385b31 100644 --- a/bits/confname.h +++ b/bits/confname.h @@ -527,7 +527,7 @@ enum _SC_THREAD_ROBUST_PRIO_INHERIT, #define _SC_THREAD_ROBUST_PRIO_INHERIT _SC_THREAD_ROBUST_PRIO_INHERIT - _SC_THREAD_ROBUST_PRIO_PROTECT, + _SC_THREAD_ROBUST_PRIO_PROTECT #define _SC_THREAD_ROBUST_PRIO_PROTECT _SC_THREAD_ROBUST_PRIO_PROTECT }; From e73ad37f1571c67eaa0ea503ae91412f1d7abc6d Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 18 Jan 2010 07:23:23 -0800 Subject: [PATCH 04/57] Ignore negative dynamic entry types. (cherry picked from commit 7a033a828df19b4f3bfd7e4d66102f63d1167f08) --- ChangeLog | 5 +++++ elf/dynamic-link.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 155a9a1e9c..6f616515ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-01-18 Andreas Schwab + + * elf/dynamic-link.h (elf_get_dynamic_info): Ignore negative + dynamic entry types. + 2010-01-14 Ulrich Drepper * bits/confname.h: Make pre-C99-safe. diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h index c34cbcd43b..dff06556a7 100644 --- a/elf/dynamic-link.h +++ b/elf/dynamic-link.h @@ -113,7 +113,7 @@ elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp) while (dyn->d_tag != DT_NULL) { - if (dyn->d_tag < DT_NUM) + if ((Elf32_Word) dyn->d_tag < DT_NUM) info[dyn->d_tag] = dyn; else if (dyn->d_tag >= DT_LOPROC && dyn->d_tag < DT_LOPROC + DT_THISPROCNUM) From 72fe1ad1520b87137b11c315533594a4e350adea Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 18 Jan 2010 07:24:09 -0800 Subject: [PATCH 05/57] Use correct type when casting d_tag. (cherry picked from commit db07e962b6ea963dbb345439f6ab9b0cf74d87c5) --- ChangeLog | 3 +++ elf/dynamic-link.h | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f616515ba..a45e8ee069 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2010-01-18 Andreas Schwab + * elf/dynamic-link.h (elf_get_dynamic_info): Use correct type when + casting d_tag. + * elf/dynamic-link.h (elf_get_dynamic_info): Ignore negative dynamic entry types. diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h index dff06556a7..6d7e14282f 100644 --- a/elf/dynamic-link.h +++ b/elf/dynamic-link.h @@ -103,6 +103,11 @@ elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp) { ElfW(Dyn) *dyn = l->l_ld; ElfW(Dyn) **info; +#if __ELF_NATIVE_CLASS == 32 + typedef Elf32_Word d_tag_utype; +#elif __ELF_NATIVE_CLASS == 64 + typedef Elf64_Xword d_tag_utype; +#endif #ifndef RTLD_BOOTSTRAP if (dyn == NULL) @@ -113,20 +118,20 @@ elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp) while (dyn->d_tag != DT_NULL) { - if ((Elf32_Word) dyn->d_tag < DT_NUM) + if ((d_tag_utype) dyn->d_tag < DT_NUM) info[dyn->d_tag] = dyn; else if (dyn->d_tag >= DT_LOPROC && dyn->d_tag < DT_LOPROC + DT_THISPROCNUM) info[dyn->d_tag - DT_LOPROC + DT_NUM] = dyn; - else if ((Elf32_Word) DT_VERSIONTAGIDX (dyn->d_tag) < DT_VERSIONTAGNUM) + else if ((d_tag_utype) DT_VERSIONTAGIDX (dyn->d_tag) < DT_VERSIONTAGNUM) info[VERSYMIDX (dyn->d_tag)] = dyn; - else if ((Elf32_Word) DT_EXTRATAGIDX (dyn->d_tag) < DT_EXTRANUM) + else if ((d_tag_utype) DT_EXTRATAGIDX (dyn->d_tag) < DT_EXTRANUM) info[DT_EXTRATAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM] = dyn; - else if ((Elf32_Word) DT_VALTAGIDX (dyn->d_tag) < DT_VALNUM) + else if ((d_tag_utype) DT_VALTAGIDX (dyn->d_tag) < DT_VALNUM) info[DT_VALTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM + DT_EXTRANUM] = dyn; - else if ((Elf32_Word) DT_ADDRTAGIDX (dyn->d_tag) < DT_ADDRNUM) + else if ((d_tag_utype) DT_ADDRTAGIDX (dyn->d_tag) < DT_ADDRNUM) info[DT_ADDRTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM] = dyn; ++dyn; From b0e8ad9e4b224d9b45def4efbc66618361f18448 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 19 Jan 2010 12:04:34 -0800 Subject: [PATCH 06/57] Remove unnecessary returns. (cherry picked from commit a7bbf3d742b181bdad41e830f6ef72e632e9fc89) --- ChangeLog | 5 +++++ misc/bits/syslog.h | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a45e8ee069..ba93d2f6a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-01-19 Ulrich Drepper + + [BZ #11194] + * misc/bits/syslog.h (syslog, vsyslog): Remove unnecessary return. + 2010-01-18 Andreas Schwab * elf/dynamic-link.h (elf_get_dynamic_info): Use correct type when diff --git a/misc/bits/syslog.h b/misc/bits/syslog.h index 853b30c84a..5d64d7acb8 100644 --- a/misc/bits/syslog.h +++ b/misc/bits/syslog.h @@ -1,5 +1,5 @@ /* Checking macros for syslog functions. - Copyright (C) 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -29,7 +29,7 @@ extern void __syslog_chk (int __pri, int __flag, __const char *__fmt, ...) __extern_always_inline void syslog (int __pri, __const char *__fmt, ...) { - return __syslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); + __syslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); } #elif !defined __cplusplus # define syslog(pri, ...) \ @@ -45,6 +45,6 @@ extern void __vsyslog_chk (int __pri, int __flag, __const char *__fmt, __extern_always_inline void vsyslog (int __pri, __const char *__fmt, __gnuc_va_list __ap) { - return __vsyslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); + __vsyslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); } #endif From b95387484e410a20334919b250f1614be468e41c Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Wed, 20 Jan 2010 07:59:30 -0800 Subject: [PATCH 07/57] Fix ____longjmp_chk for s390/s390x. (cherry picked from commit e3b7670be21d6992e3ca9ee1ad3a5d08eb3a24c9) --- ChangeLog | 7 +++++++ sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c | 2 +- sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba93d2f6a5..44deae5d19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-01-20 Andreas Schwab + + * sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c + (CHECK_SP): Fix check for alternate stack. + * sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c + (CHECK_SP): Likewise. + 2010-01-19 Ulrich Drepper [BZ #11194] diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c b/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c index b28e587498..f2c1518572 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c +++ b/sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c @@ -46,7 +46,7 @@ { \ if ((oss.ss_flags & SS_ONSTACK) == 0 \ || ((uintptr_t) (oss.ss_sp + oss.ss_size) - new_sp \ - >= oss.ss_size)) \ + < oss.ss_size)) \ __fortify_fail ("longjmp causes uninitialized stack frame");\ } \ } \ diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c b/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c index dcf58fb50b..261be250dc 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c +++ b/sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c @@ -46,7 +46,7 @@ { \ if ((oss.ss_flags & SS_ONSTACK) == 0 \ || ((uintptr_t) (oss.ss_sp + oss.ss_size) - new_sp \ - >= oss.ss_size)) \ + < oss.ss_size)) \ __fortify_fail ("longjmp causes uninitialized stack frame");\ } \ } \ From 5238213a22c9e64eff78e1eda1763c6c4bf52bcd Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 22 Jan 2010 09:33:01 -0800 Subject: [PATCH 08/57] regex: avoid internal re_realloc overflow (cherry picked from commit 54dd0ab31fe2b2168ba1a6180a0c05941fb54b3c) --- ChangeLog | 5 +++++ posix/regex_internal.c | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 44deae5d19..7bd7e8b44a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-01-22 Jim Meyering + + * posix/regex_internal.c (re_string_realloc_buffers): + Detect and handle internal overflow. Patch by Paul Eggert + 2010-01-20 Andreas Schwab * sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c diff --git a/posix/regex_internal.c b/posix/regex_internal.c index c9da2b961c..fec3123054 100644 --- a/posix/regex_internal.c +++ b/posix/regex_internal.c @@ -133,7 +133,14 @@ re_string_realloc_buffers (re_string_t *pstr, int new_buf_len) #ifdef RE_ENABLE_I18N if (pstr->mb_cur_max > 1) { - wint_t *new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len); + wint_t *new_wcs; + + /* Avoid overflow in realloc. */ + const size_t max_object_size = MAX (sizeof (wint_t), sizeof (int)); + if (BE (SIZE_MAX / max_object_size < new_buf_len, 0)) + return REG_ESPACE; + + new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len); if (BE (new_wcs == NULL, 0)) return REG_ESPACE; pstr->wcs = new_wcs; From ea8e535ed1178b121e3ad5a5b2ebfd24a3bcf27b Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 22 Jan 2010 09:48:35 -0800 Subject: [PATCH 09/57] Extend overflow detection in re_dfa_add_node. (cherry picked from commit 22364644882b6cf426ed13be5b6480c3a9210eb1) --- ChangeLog | 5 +++++ posix/regex_internal.c | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7bd7e8b44a..4f777321f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2010-01-22 Jim Meyering + [BZ #11184] + * posix/regex_internal.c (re_dfa_add_node): Extend the overflow + detection test. Patch by Paul Eggert. + + [BZ #11183] * posix/regex_internal.c (re_string_realloc_buffers): Detect and handle internal overflow. Patch by Paul Eggert diff --git a/posix/regex_internal.c b/posix/regex_internal.c index fec3123054..09cffcf0d7 100644 --- a/posix/regex_internal.c +++ b/posix/regex_internal.c @@ -1411,8 +1411,11 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token) re_node_set *new_edests, *new_eclosures; re_token_t *new_nodes; - /* Avoid overflows. */ - if (BE (new_nodes_alloc < dfa->nodes_alloc, 0)) + /* Avoid overflows in realloc. */ + const size_t max_object_size = MAX (sizeof (re_token_t), + MAX (sizeof (re_node_set), + sizeof (int))); + if (BE (SIZE_MAX / max_object_size < new_nodes_alloc, 0)) return -1; new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc); From 721d1acb10d336ad53dfefff8a515e3c1f2e3791 Mon Sep 17 00:00:00 2001 From: Joe Landers Date: Fri, 22 Jan 2010 12:44:58 -0800 Subject: [PATCH 10/57] _nl_load_locale() incorrectly handles mmap() failures (cherry picked from commit 8b2f25c23374fe79645499b8095f0d2f6eb24f71) --- ChangeLog | 5 +++++ locale/loadlocale.c | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4f777321f1..a9e21bfd0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-01-22 Ulrich Drepper + + * locale/loadlocale.c (_nl_load_locale): Fix recognition of genuine + mmap resource problem. Patch by Joe Landers . + 2010-01-22 Jim Meyering [BZ #11184] diff --git a/locale/loadlocale.c b/locale/loadlocale.c index 467dff157a..b91941eae9 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -224,6 +224,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) PROT_READ, MAP_FILE|MAP_COPY, fd, 0); if (__builtin_expect (filedata == MAP_FAILED, 0)) { + filedata = NULL; if (__builtin_expect (errno, ENOSYS) == ENOSYS) { #endif /* _POSIX_MAPPED_FILES */ From 2ce2bf1a9845ad1e0c5c3fa0bdd3601d95a78c45 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 22 Jan 2010 12:45:43 -0800 Subject: [PATCH 11/57] Add BZ number. (cherry picked from commit 8549abcb9ca4d7857cc457aaa17c2073522804f4) --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index a9e21bfd0a..cea6315b6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2010-01-22 Ulrich Drepper + [BZ #11200] * locale/loadlocale.c (_nl_load_locale): Fix recognition of genuine mmap resource problem. Patch by Joe Landers . From 4aa960e79da30982273b3e572e488c1de635cf53 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 25 Jan 2010 07:17:47 -0800 Subject: [PATCH 12/57] Fix error checking in iconv. (cherry picked from commit 7a518360023592882a7335b843ce1a5ea322dec5) --- ChangeLog | 4 ++++ iconv/iconv_prog.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index cea6315b6c..47f2e529d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-25 Andreas Schwab + + * iconv/iconv_prog.c (write_output): Fix check for open failure. + 2010-01-22 Ulrich Drepper [BZ #11200] diff --git a/iconv/iconv_prog.c b/iconv/iconv_prog.c index a1ca05f153..3bcb9b464e 100644 --- a/iconv/iconv_prog.c +++ b/iconv/iconv_prog.c @@ -442,7 +442,7 @@ write_output (const char *outbuf, const char *outptr, FILE **output, if (output_file != NULL && strcmp (output_file, "-") != 0) { *output = fopen (output_file, "w"); - if (output == NULL) + if (*output == NULL) error (EXIT_FAILURE, errno, _("cannot open output file")); } else From 272eb2b141c22d03c1c68050b4ad97b2a0adfc69 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 25 Jan 2010 12:01:42 -0800 Subject: [PATCH 13/57] Don't map U00DF to U1E9E in toupper table. (cherry picked from commit 1112095740b82eeaea36d2567ea98c6745ef1d13) --- localedata/ChangeLog | 4 ++++ localedata/locales/i18n | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/localedata/ChangeLog b/localedata/ChangeLog index 88284268a9..e2f26deecd 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,3 +1,7 @@ +2010-01-25 Andreas Schwab + + * locales/i18n: Don't map U00DF to U1E9E in toupper table. + 2009-11-24 Ulrich Drepper * locales/hsb_DE: Define week, first_weekday, and first_workday. diff --git a/localedata/locales/i18n b/localedata/locales/i18n index 8afbb717fa..4f8b9e1591 100644 --- a/localedata/locales/i18n +++ b/localedata/locales/i18n @@ -928,8 +928,7 @@ toupper / (,);(,);(,);(,);/ (,);(,);(,);(,);/ (,);(,);(,);(,);/ - (,);(,);(,);(,);/ - (,);/ + (,);(,);(,);(,);/ (,);(,);(,);(,);/ (,);(,);(,);(,);/ (,);(,);(,);(,);/ From b204d65517276f8cdaf3a83349d0f1f553da68a2 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 3 Feb 2010 06:23:31 -0800 Subject: [PATCH 14/57] Fix endless loop with invalid /etc/shells file. (cherry picked from commit caa6e77293d85e31dfde371b78862e9330a1478e) --- ChangeLog | 6 ++++++ misc/getusershell.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 47f2e529d5..b9f7357132 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-02-03 Ulrich Drepper + + [BZ #11242] + * misc/getusershell.c (initshells): Allocate one more byte in input + buffer so that fgets doesn't loop undefinitely. + 2010-01-25 Andreas Schwab * iconv/iconv_prog.c (write_output): Fix check for open failure. diff --git a/misc/getusershell.c b/misc/getusershell.c index 636da322f9..0e4f79619f 100644 --- a/misc/getusershell.c +++ b/misc/getusershell.c @@ -116,7 +116,8 @@ initshells() } if (statb.st_size > ~(size_t)0 / sizeof (char *) * 3) goto init_okshells; - if ((strings = malloc(statb.st_size + 2)) == NULL) + flen = statb.st_size + 3; + if ((strings = malloc(flen)) == NULL) goto init_okshells; shells = malloc(statb.st_size / 3 * sizeof (char *)); if (shells == NULL) { @@ -126,7 +127,6 @@ initshells() } sp = shells; cp = strings; - flen = statb.st_size + 2; while (fgets_unlocked(cp, flen - (cp - strings), fp) != NULL) { while (*cp != '#' && *cp != '/' && *cp != '\0') cp++; From c648b3046e619146357f706a1d0ccced601e039f Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 9 Feb 2010 22:54:36 -0800 Subject: [PATCH 15/57] Fix i386 __mpn_lshift unwind info (cherry picked from commit 1d7223f31af8c35053e7a6fbac3070bcaa7bf87d) --- ChangeLog | 4 ++++ sysdeps/i386/lshift.S | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b9f7357132..a63f1b9036 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-02-09 Ulrich Drepper + + * sysdeps/i386/lshift.S: Fix unwind information. + 2010-02-03 Ulrich Drepper [BZ #11242] diff --git a/sysdeps/i386/lshift.S b/sysdeps/i386/lshift.S index 536d9878eb..398cf038c7 100644 --- a/sysdeps/i386/lshift.S +++ b/sysdeps/i386/lshift.S @@ -1,5 +1,5 @@ /* i80386 __mpn_lshift -- - Copyright (C) 1992, 1994, 1997-2000, 2005 Free Software Foundation, Inc. + Copyright (C) 1992,1994,1997-2000,2005,2010 Free Software Foundation, Inc. This file is part of the GNU MP Library. The GNU MP Library is free software; you can redistribute it and/or modify @@ -55,6 +55,7 @@ ENTRY (BP_SYM (__mpn_lshift)) movl (%esi,%edx,4),%ebx /* read most significant limb */ cfi_rel_offset (ebx, 0) + cfi_remember_state xorl %eax,%eax shldl %cl,%ebx,%eax /* compute carry limb */ decl %edx @@ -95,6 +96,7 @@ L(1): movl (%esi,%edx,4),%eax LEAVE ret + cfi_restore_state L(end): shll %cl,%ebx /* compute least significant limb */ movl %ebx,(%edi) /* store it */ From 69ad8afe74aa5a0aa727553e010ad0dded7721dd Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 10 Feb 2010 20:31:48 -0800 Subject: [PATCH 16/57] Fix file descriotor leak in nftw with FTW_CHDIR (cherry picked from commit 247fdf2e2b798378d8aeaac1ee6f4ba0a49f31f3) --- ChangeLog | 6 ++++++ io/ftw.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a63f1b9036..6a0f4c0a70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-02-10 Ulrich Drepper + + [BZ #11271] + * io/ftw.c (ftw_startup): Close descriptor for initial directory + after changing back to it. + 2010-02-09 Ulrich Drepper * sysdeps/i386/lshift.S: Fix unwind information. diff --git a/io/ftw.c b/io/ftw.c index 9cc09077ed..bb7dba8ca8 100644 --- a/io/ftw.c +++ b/io/ftw.c @@ -1,5 +1,5 @@ /* File tree walker functions. - Copyright (C) 1996-2004, 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1996-2004, 2006-2008, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -790,6 +790,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors, { int save_err = errno; __fchdir (cwdfd); + close_not_cancel_no_status (cwdfd); __set_errno (save_err); } else if (cwd != NULL) From f514e0b22795750f91eea596d5cba1845680dbe0 Mon Sep 17 00:00:00 2001 From: Andreas Krebbel Date: Thu, 11 Feb 2010 07:22:58 -0800 Subject: [PATCH 17/57] S/390: Disable two UTF conversion instructions (cherry picked from commit a3dc465852c38ffb4f329ca8b5b477a3c314c1ef) --- ChangeLog | 7 +++++++ sysdeps/s390/s390-64/utf16-utf32-z9.c | 11 ++++++++++- sysdeps/s390/s390-64/utf8-utf16-z9.c | 9 ++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6a0f4c0a70..0fa8446ecd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-02-11 Andreas Krebbel + + * sysdeps/s390/s390-64/utf8-utf16-z9.c: Disable hardware + instructions cu21 and cu24. Add well-formedness checking + parameter and adjust the software implementation. + * sysdeps/s390/s390-64/utf16-utf32-z9.c: Likewise. + 2010-02-10 Ulrich Drepper [BZ #11271] diff --git a/sysdeps/s390/s390-64/utf16-utf32-z9.c b/sysdeps/s390/s390-64/utf16-utf32-z9.c index 868dea68ca..14daf2118f 100644 --- a/sysdeps/s390/s390-64/utf16-utf32-z9.c +++ b/sysdeps/s390/s390-64/utf16-utf32-z9.c @@ -203,7 +203,10 @@ gconv_end (struct __gconv_step *data) swapping). */ #define BODY \ { \ - if (GLRO (dl_hwcap) & HWCAP_S390_ETF3EH) \ + /* The hardware instruction currently fails to report an error for \ + isolated low surrogates so we have to disable the instruction \ + until this gets resolved. */ \ + if (0) /* (GLRO (dl_hwcap) & HWCAP_S390_ETF3EH) */ \ { \ HARDWARE_CONVERT ("cu24 %0, %1, 1"); \ if (inptr != inend) \ @@ -229,6 +232,12 @@ gconv_end (struct __gconv_step *data) } \ else \ { \ + /* An isolated low-surrogate was found. This has to be \ + considered ill-formed. */ \ + if (__builtin_expect (u1 >= 0xdc00, 0)) \ + { \ + STANDARD_FROM_LOOP_ERR_HANDLER (2); \ + } \ /* It's a surrogate character. At least the first word says \ it is. */ \ if (__builtin_expect (inptr + 4 > inend, 0)) \ diff --git a/sysdeps/s390/s390-64/utf8-utf16-z9.c b/sysdeps/s390/s390-64/utf8-utf16-z9.c index 531d3ebd4b..5f73f3c59e 100644 --- a/sysdeps/s390/s390-64/utf8-utf16-z9.c +++ b/sysdeps/s390/s390-64/utf8-utf16-z9.c @@ -345,9 +345,12 @@ gconv_end (struct __gconv_step *data) Operation. */ #define BODY \ { \ - if (GLRO (dl_hwcap) & HWCAP_S390_ETF3EH) \ + /* The hardware instruction currently fails to report an error for \ + isolated low surrogates so we have to disable the instruction \ + until this gets resolved. */ \ + if (0) /* (GLRO (dl_hwcap) & HWCAP_S390_ETF3EH) */ \ { \ - HARDWARE_CONVERT ("cu21 %0, %1"); \ + HARDWARE_CONVERT ("cu21 %0, %1, 1"); \ if (inptr != inend) \ { \ /* Check if the third byte is \ @@ -388,7 +391,7 @@ gconv_end (struct __gconv_step *data) \ outptr += 2; \ } \ - else if (c >= 0x0800 && c <= 0xd7ff) \ + else if ((c >= 0x0800 && c <= 0xd7ff) || c > 0xdfff) \ { \ /* Three byte UTF-8 char. */ \ \ From a4b67d9bcd17d19386fada0c26f2dbbf0f192d9f Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 28 May 2008 11:37:21 +0200 Subject: [PATCH 18/57] manual: fix doubled-words and typos * manual/charset.texi (Selecting the Conversion): Likewise. * manual/errno.texi (Error Messages): Likewise. * manual/getopt.texi (Getopt Long Options): Likewise. * manual/memory.texi (Resizing the Data Segment): Likewise. * manual/message.texi (GUI program problems): Likewise. * manual/resource.texi (CPU Affinity): Likewise. * manual/stdio.texi (Streams and Threads): Likewise. * manual/time.texi (High Accuracy Clock): Likewise. (cherry picked from commit bbf70ae9ce646540576f2b0cbc66b90da1511b0b) --- ChangeLog | 11 +++++++++++ manual/charset.texi | 2 +- manual/errno.texi | 2 +- manual/getopt.texi | 2 +- manual/memory.texi | 2 +- manual/message.texi | 2 +- manual/resource.texi | 2 +- manual/stdio.texi | 2 +- manual/time.texi | 2 +- 9 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0fa8446ecd..c86bd63a27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2010-02-22 Jim Meyering + + * manual/errno.texi (Error Messages): Fix doubled-words and typos. + * manual/charset.texi (Selecting the Conversion): Likewise. + * manual/getopt.texi (Getopt Long Options): Likewise. + * manual/memory.texi (Resizing the Data Segment): Likewise. + * manual/message.texi (GUI program problems): Likewise. + * manual/resource.texi (CPU Affinity): Likewise. + * manual/stdio.texi (Streams and Threads): Likewise. + * manual/time.texi (High Accuracy Clock): Likewise. + 2010-02-11 Andreas Krebbel * sysdeps/s390/s390-64/utf8-utf16-z9.c: Disable hardware diff --git a/manual/charset.texi b/manual/charset.texi index 79854e50bf..a49798c7c2 100644 --- a/manual/charset.texi +++ b/manual/charset.texi @@ -393,7 +393,7 @@ We already said above that the currently selected locale for the by the functions we are about to describe. Each locale uses its own character set (given as an argument to @code{localedef}) and this is the one assumed as the external multibyte encoding. The wide character -character set always is UCS-4, at least on GNU systems. +set always is UCS-4, at least on GNU systems. A characteristic of each multibyte character set is the maximum number of bytes that can be necessary to represent one character. This diff --git a/manual/errno.texi b/manual/errno.texi index fcba26750e..253e7b0f49 100644 --- a/manual/errno.texi +++ b/manual/errno.texi @@ -1419,7 +1419,7 @@ available on all systems implementing @w{ISO C}. But often the text @code{perror} generates is not what is wanted and there is no way to extend or change what @code{perror} does. The GNU coding standard, for instance, requires error messages to be preceded by the program name and -programs which read some input files should should provide information +programs which read some input files should provide information about the input file name and the line number in case an error is encountered while reading the file. For these occasions there are two functions available which are widely used throughout the GNU project. diff --git a/manual/getopt.texi b/manual/getopt.texi index 8c9bd20d6d..77045157ef 100644 --- a/manual/getopt.texi +++ b/manual/getopt.texi @@ -269,7 +269,7 @@ When @code{getopt_long} has no more options to handle, it returns @var{argv} of the next remaining argument. @end deftypefun -Since long option names were used before before the @code{getopt_long} +Since long option names were used before the @code{getopt_long} options was invented there are program interfaces which require programs to recognize options like @w{@samp{-option value}} instead of @w{@samp{--option value}}. To enable these programs to use the GNU diff --git a/manual/memory.texi b/manual/memory.texi index 43afc7bf95..59ea1ee342 100644 --- a/manual/memory.texi +++ b/manual/memory.texi @@ -2379,7 +2379,7 @@ exceed the process' data storage limit. @c The Brk system call in Linux (as opposed to the GNU C Library function) @c is considerably different. It always returns the new end of the data @c segment, whether it succeeds or fails. The GNU C library Brk determines -@c it's a failure if and only if if the system call returns an address less +@c it's a failure if and only if the system call returns an address less @c than the address requested. @end deftypefun diff --git a/manual/message.texi b/manual/message.texi index e772b2de1f..e44545a311 100644 --- a/manual/message.texi +++ b/manual/message.texi @@ -1466,7 +1466,7 @@ have this problem. But there is a very simple and powerful method to handle these kind of problems with the @code{gettext} functions. @noindent -As as example consider the following fictional situation. A GUI program +As an example consider the following fictional situation. A GUI program has a menu bar with the following entries: @smallexample diff --git a/manual/resource.texi b/manual/resource.texi index 4a814c9e4a..05495722f9 100644 --- a/manual/resource.texi +++ b/manual/resource.texi @@ -1288,7 +1288,7 @@ protected from concurrent accesses from different processors. The POSIX standard up to this date is of not much help to solve this problem. The Linux kernel provides a set of interfaces to allow specifying @emph{affinity sets} for a process. The scheduler will -schedule the thread or process on on CPUs specified by the affinity +schedule the thread or process on CPUs specified by the affinity masks. The interfaces which the GNU C library define follow to some extend the Linux kernel interface. diff --git a/manual/stdio.texi b/manual/stdio.texi index 6748513549..9fb209a473 100644 --- a/manual/stdio.texi +++ b/manual/stdio.texi @@ -574,7 +574,7 @@ operation itself is avoided. More importantly, functions like introduction of threads) were implemented as macros which are very fast if the buffer is not empty. With the addition of locking requirements these functions are no longer implemented as macros since they would -would expand to too much code. +expand to too much code. But these macros are still available with the same functionality under the new names @code{putc_unlocked} and @code{getc_unlocked}. This possibly huge difference of speed also suggests the use of the @code{_unlocked} diff --git a/manual/time.texi b/manual/time.texi index 393bccd99f..f1f4254e90 100644 --- a/manual/time.texi +++ b/manual/time.texi @@ -972,7 +972,7 @@ This counter represents the number of calibration errors (caused by large offsets or jitter). @item long int stbcnt -This counter denotes the number of of calibrations where the stability +This counter denotes the number of calibrations where the stability exceeded the threshold. @end table @end deftp From 2da4488386833b4787fc3e364a304bf2201b0aca Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 4 Jun 2008 11:46:50 +0200 Subject: [PATCH 19/57] manual: adjust grammar * manual/charset.texi: Adjust grammar. (cherry picked from commit 82acaacb9c7689c479c3426743ae66d0ad466a1d) --- ChangeLog | 2 ++ manual/charset.texi | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index c86bd63a27..6071e5626d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2010-02-22 Jim Meyering + * manual/charset.texi: Adjust grammar. + * manual/errno.texi (Error Messages): Fix doubled-words and typos. * manual/charset.texi (Selecting the Conversion): Likewise. * manual/getopt.texi (Getopt Long Options): Likewise. diff --git a/manual/charset.texi b/manual/charset.texi index a49798c7c2..808469b8c1 100644 --- a/manual/charset.texi +++ b/manual/charset.texi @@ -393,7 +393,7 @@ We already said above that the currently selected locale for the by the functions we are about to describe. Each locale uses its own character set (given as an argument to @code{localedef}) and this is the one assumed as the external multibyte encoding. The wide character -set always is UCS-4, at least on GNU systems. +set is always UCS-4, at least on GNU systems. A characteristic of each multibyte character set is the maximum number of bytes that can be necessary to represent one character. This @@ -577,8 +577,8 @@ The @code{btowc} function was introduced in @w{Amendment 1} to @w{ISO C90} and is declared in @file{wchar.h}. @end deftypefun -Despite the limitation that the single byte value always is interpreted -in the initial state this function is actually useful most of the time. +Despite the limitation that the single byte value is always interpreted +in the initial state, this function is actually useful most of the time. Most characters are either entirely single-byte character sets or they are extension to ASCII. But then it is possible to write code like this (not that this specific example is very useful): @@ -607,10 +607,10 @@ that there is no guarantee that one can perform this kind of arithmetic on the character of the character set used for @code{wchar_t} representation. In other situations the bytes are not constant at compile time and so the compiler cannot do the work. In situations like -this it is necessary @code{btowc}. +this, using @code{btowc} is required. @noindent -There also is a function for the conversion in the other direction. +There is also a function for the conversion in the other direction. @comment wchar.h @comment ISO From 3c0fb4080d496b788c4e579f130794574eb35e0b Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 29 Oct 2008 11:05:39 +0100 Subject: [PATCH 20/57] manual: fix typo: s/are/is/ * manual/math.texi (BSD Random): Fix a typo: s/are/is/ (cherry picked from commit e2f4aa547a997922d960876671fb35ea101295f8) --- ChangeLog | 2 ++ manual/math.texi | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6071e5626d..6f4dfaa8cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2010-02-22 Jim Meyering + * manual/math.texi (BSD Random): Fix a typo: s/are/is/ + * manual/charset.texi: Adjust grammar. * manual/errno.texi (Error Messages): Fix doubled-words and typos. diff --git a/manual/math.texi b/manual/math.texi index 50e087c487..95e3378c9e 100644 --- a/manual/math.texi +++ b/manual/math.texi @@ -1421,7 +1421,7 @@ pseudo-random number generator. The GNU C library contains four additional functions which contain the state as an explicit parameter and therefore make it possible to handle -thread-local PRNGs. Beside this there are no difference. In fact, the +thread-local PRNGs. Beside this there is no difference. In fact, the four functions already discussed are implemented internally using the following interfaces. From fae1e90fa13beb6b84454626df2933ecc0b30c66 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 24 Feb 2010 15:44:29 -0800 Subject: [PATCH 21/57] Fix assertion in palloc and pvalloc as well. (cherry picked from commit 8c0b5f148eccd0a4d9714e72f50f13c586af59ec) --- ChangeLog | 6 ++++++ malloc/malloc.c | 16 +++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f4dfaa8cc..e66e0c1ffa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-02-24 Ulrich Drepper + + [BZ #5553] + * malloc/malloc.c (public_vALLOc): Set ar_ptr when trying main_arena. + (public_pVALLOc): Likewise. + 2010-02-22 Jim Meyering * manual/math.texi (BSD Random): Fix a typo: s/are/is/ diff --git a/malloc/malloc.c b/malloc/malloc.c index ea10d17f85..f7226769f8 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -1,5 +1,5 @@ /* Malloc implementation for multiple threads without lock contention. - Copyright (C) 1996-2006, 2007, 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 1996-2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Wolfram Gloger and Doug Lea , 2001. @@ -3933,9 +3933,10 @@ public_vALLOc(size_t bytes) if(!p) { /* Maybe the failure is due to running out of mmapped areas. */ if(ar_ptr != &main_arena) { - (void)mutex_lock(&main_arena.mutex); - p = _int_memalign(&main_arena, pagesz, bytes); - (void)mutex_unlock(&main_arena.mutex); + ar_ptr = &main_arena; + (void)mutex_lock(&ar_ptr->mutex); + p = _int_memalign(&ar_ptr-> pagesz, bytes); + (void)mutex_unlock(&ar_ptr->mutex); } else { #if USE_ARENAS /* ... or sbrk() has failed and there is still a chance to mmap() */ @@ -3978,9 +3979,10 @@ public_pVALLOc(size_t bytes) if(!p) { /* Maybe the failure is due to running out of mmapped areas. */ if(ar_ptr != &main_arena) { - (void)mutex_lock(&main_arena.mutex); - p = _int_memalign(&main_arena, pagesz, rounded_bytes); - (void)mutex_unlock(&main_arena.mutex); + ar_ptr = &main_arena; + (void)mutex_lock(&ar_ptr->mutex); + p = _int_memalign(&ar_ptr-> pagesz, rounded_bytes); + (void)mutex_unlock(&ar_ptr->mutex); } else { #if USE_ARENAS /* ... or sbrk() has failed and there is still a chance to mmap() */ From a82e74eb468e899f7ebe4204eefa04a967002f77 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 24 Feb 2010 16:07:57 -0800 Subject: [PATCH 22/57] Fix reporting of I/O errors in *dprintf functions. (cherry picked from commit 7ca890b88e6ab7624afb1742a9fffb37ad5b3fc3) --- ChangeLog | 5 +++++ libio/iovdprintf.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e66e0c1ffa..674587a0b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,13 @@ 2010-02-24 Ulrich Drepper + [BZ #11319] + * libio/iovdprintf.c (_IO_vdprintf): Explicitly flush stream before + undoing the stream because _IO_FINISH doesn't report failures. + [BZ #5553] * malloc/malloc.c (public_vALLOc): Set ar_ptr when trying main_arena. (public_pVALLOc): Likewise. + Patch by Petr Baudis. 2010-02-22 Jim Meyering diff --git a/libio/iovdprintf.c b/libio/iovdprintf.c index edab849a44..5284ff8938 100644 --- a/libio/iovdprintf.c +++ b/libio/iovdprintf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1997-2000, 2001, 2002, 2003, 2006 +/* Copyright (C) 1995, 1997-2000, 2001, 2002, 2003, 2006, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -60,6 +60,9 @@ _IO_vdprintf (d, format, arg) done = INTUSE(_IO_vfprintf) (&tmpfil.file, format, arg); + if (done != EOF && _IO_do_flush (&tmpfil.file) == EOF) + done = EOF; + _IO_FINISH (&tmpfil.file); return done; From 7dab764e6058b7383d76f0ba2b63ae3afbafd4ba Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Thu, 4 Mar 2010 19:33:41 -0800 Subject: [PATCH 23/57] Fix R_X86_64_PC32 overflow detection (cherry picked from commit e39acb1f165c467e99509146c95f69c7444521e3) --- ChangeLog | 5 +++++ sysdeps/x86_64/dl-machine.h | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 674587a0b2..eece5e957b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-03-02 Richard Guenther + + * sysdeps/x86_64/dl-machine.h (elf_machine_rela): R_X86_64_PC32 + is sign-extending. + 2010-02-24 Ulrich Drepper [BZ #11319] diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index 61a0556d5e..f615e9591f 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -1,5 +1,5 @@ /* Machine-dependent ELF dynamic relocation inline functions. x86-64 version. - Copyright (C) 2001-2005, 2006, 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2001-2006, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger . @@ -419,7 +419,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc, case R_X86_64_PC32: value += reloc->r_addend - (Elf64_Addr) reloc_addr; *(unsigned int *) reloc_addr = value; - if (__builtin_expect (value != (unsigned int) value, 0)) + if (__builtin_expect (value != (int) value, 0)) { fmt = "\ %s: Symbol `%s' causes overflow in R_X86_64_PC32 relocation\n"; From 877103176f621c64bdd847e2db49205de7e32e61 Mon Sep 17 00:00:00 2001 From: Paul Pluzhnikov Date: Wed, 17 Mar 2010 09:01:34 -0700 Subject: [PATCH 24/57] Fix missing dependency of localedata tests on gconv-modules (cherry picked from commit 234333153e5b29fec2c0b383249db6f245a877e9) --- localedata/ChangeLog | 4 ++++ localedata/Makefile | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/localedata/ChangeLog b/localedata/ChangeLog index e2f26deecd..4cb9e616aa 100644 --- a/localedata/ChangeLog +++ b/localedata/ChangeLog @@ -1,3 +1,7 @@ +2010-02-16 Paul Pluzhnikov + + * Makefile: Add missing gconv-modules dependency. + 2010-01-25 Andreas Schwab * locales/i18n: Don't map U00DF to U1E9E in toupper table. diff --git a/localedata/Makefile b/localedata/Makefile index d364001551..8f356ec861 100644 --- a/localedata/Makefile +++ b/localedata/Makefile @@ -107,6 +107,8 @@ install-others := $(addprefix $(inst_i18ndir)/, \ $(addsuffix .gz, $(charmaps)) \ $(locales)) +tests: $(objdir)/iconvdata/gconv-modules + include ../Rules # Install the charmap files in gzipped format. @@ -298,3 +300,6 @@ tst-leaks-ENV = MALLOC_TRACE=$(objpfx)tst-leaks.mtrace \ LOCPATH=$(common-objpfx)localedata $(objpfx)mtrace-tst-leaks: $(objpfx)tst-leaks.out $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks.mtrace > $@ + +$(objdir)/iconvdata/gconv-modules: + $(MAKE) -C ../iconvdata subdir=iconvdata $@ From f273badc6b317d8d0ba9ba52e873c98a7e72a4e7 Mon Sep 17 00:00:00 2001 From: Jonathan Geisler Date: Wed, 24 Mar 2010 16:02:15 -0700 Subject: [PATCH 25/57] calls to cuserid() can result in buffer overruns and/or overflows (cherry picked from commit fd8ccb0427569ffdfbb70c8828029122f3459160) --- ChangeLog | 7 +++++++ sysdeps/posix/cuserid.c | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index eece5e957b..3198695b54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-03-24 Ulrich Drepper + + [BZ #11397] + * sysdeps/posix/cuserid.c (cuserid): Make sure the returned string + is NUL terminated. + Patch by Jonathan Geisler . + 2010-03-02 Richard Guenther * sysdeps/x86_64/dl-machine.h (elf_machine_rela): R_X86_64_PC32 diff --git a/sysdeps/posix/cuserid.c b/sysdeps/posix/cuserid.c index 11c827a686..f30c20e3f8 100644 --- a/sysdeps/posix/cuserid.c +++ b/sysdeps/posix/cuserid.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1996, 1998, 1999, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1996, 1998, 1999, 2001, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -44,5 +44,6 @@ cuserid (s) if (s == NULL) s = name; - return strncpy (s, pwptr->pw_name, L_cuserid); + s[L_userid - 1] = '\0'; + return strncpy (s, pwptr->pw_name, L_cuserid - 1); } From 8469d71f1ffc0c910f69b9097fafdcf6594e108f Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Thu, 25 Mar 2010 11:35:05 +0100 Subject: [PATCH 26/57] Fix typo in cuserid (cherry picked from commit 34b514dff6acf8f1cac0afefd24049e025fd62ea) --- ChangeLog | 4 ++++ sysdeps/posix/cuserid.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3198695b54..92ec78d8c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-03-25 Andreas Schwab + + * sysdeps/posix/cuserid.c: Fix typo. + 2010-03-24 Ulrich Drepper [BZ #11397] diff --git a/sysdeps/posix/cuserid.c b/sysdeps/posix/cuserid.c index f30c20e3f8..a74ff84368 100644 --- a/sysdeps/posix/cuserid.c +++ b/sysdeps/posix/cuserid.c @@ -44,6 +44,6 @@ cuserid (s) if (s == NULL) s = name; - s[L_userid - 1] = '\0'; + s[L_cuserid - 1] = '\0'; return strncpy (s, pwptr->pw_name, L_cuserid - 1); } From 9914417d124400a5b4104a9d8ef8d46d1d464c6e Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Fri, 26 Mar 2010 05:35:50 -0700 Subject: [PATCH 27/57] Fix spurious UNAVAIL status is getaddrinfo (cherry picked from commit c3dfadb87e16f0fab6f4d5242bcecf06c02976c7) --- ChangeLog | 5 +++++ sysdeps/posix/getaddrinfo.c | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 92ec78d8c6..be91db9ff0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-03-25 Andreas Schwab + + * sysdeps/posix/getaddrinfo.c (gaih_inet): Reset no_data before + each action. + 2010-03-25 Andreas Schwab * sysdeps/posix/cuserid.c: Fix typo. diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 62c38f69be..8b7e38fdea 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -702,6 +702,7 @@ gaih_inet (const char *name, const struct gaih_service *service, while (!no_more) { + no_data = 0; nss_gethostbyname4_r fct4 = __nss_lookup_function (nip, "gethostbyname4_r"); if (fct4 != NULL) From 64a532ff2c8cc914b1850a10ce7ca2a945c21098 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 3 Apr 2010 09:43:10 -0700 Subject: [PATCH 28/57] Fix set_max_fast in malloc. (cherry picked from commit 991eda1ec17665ea0da247f8eabc6993d020ed8e) --- ChangeLog | 4 ++++ malloc/malloc.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index be91db9ff0..b135268610 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-04-03 Ulrich Drepper + + * malloc/malloc.c (set_max_fast): Fix computation of the value. + 2010-03-25 Andreas Schwab * sysdeps/posix/getaddrinfo.c (gaih_inet): Reset no_data before diff --git a/malloc/malloc.c b/malloc/malloc.c index f7226769f8..cdd24a02a0 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -2351,7 +2351,8 @@ typedef struct malloc_chunk* mfastbinptr; */ #define set_max_fast(s) \ - global_max_fast = ((s) == 0)? SMALLBIN_WIDTH: request2size(s) + global_max_fast = (((s) == 0) \ + ? SMALLBIN_WIDTH: ((s + SIZE_SZ) & ~MALLOC_ALIGN_MASK)) #define get_max_fast() global_max_fast From 888fec4045838c19406cbe942bd8541e9cc9db77 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 3 Apr 2010 13:45:02 -0700 Subject: [PATCH 29/57] Missing memory barrier in DES initialization. (cherry picked from commit 647450cfb089a60f1dc3de7d68874cd21f475ec7) --- ChangeLog | 8 ++++ crypt/crypt_util.c | 97 +++++++++++++++++++++++----------------------- 2 files changed, 57 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index b135268610..42c1a07a68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-04-03 Ulrich Drepper + + [BZ #11449] + * crypt/crypt_util.c (__init_des_r): Add memory barrier before setting + small_tables_initialized. + + * malloc/malloc.c (set_max_fast): Fix computation of the value. + 2010-04-03 Ulrich Drepper * malloc/malloc.c (set_max_fast): Fix computation of the value. diff --git a/crypt/crypt_util.c b/crypt/crypt_util.c index 0db5be7b0f..a556389111 100644 --- a/crypt/crypt_util.c +++ b/crypt/crypt_util.c @@ -1,7 +1,7 @@ /* * UFC-crypt: ultra fast crypt(3) implementation * - * Copyright (C) 1991, 92, 93, 96, 97, 98, 2000 Free Software Foundation, Inc. + * Copyright (C) 1991-1993,1996-1998,2000,2010 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -114,53 +114,53 @@ static const int perm32[32] = { * The sboxes */ static const int sbox[8][4][16]= { - { { 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7 }, - { 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8 }, - { 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0 }, - { 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13 } - }, - - { { 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10 }, - { 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5 }, - { 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15 }, - { 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9 } - }, - - { { 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8 }, - { 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1 }, - { 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7 }, - { 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12 } - }, - - { { 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15 }, - { 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9 }, - { 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4 }, - { 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14 } - }, - - { { 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9 }, - { 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6 }, - { 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14 }, - { 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3 } - }, - - { { 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11 }, - { 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8 }, - { 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6 }, - { 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13 } - }, - - { { 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1 }, - { 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6 }, - { 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2 }, - { 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12 } - }, - - { { 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7 }, - { 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2 }, - { 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8 }, - { 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 } - } + { { 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7 }, + { 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8 }, + { 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0 }, + { 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13 } + }, + + { { 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10 }, + { 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5 }, + { 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15 }, + { 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9 } + }, + + { { 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8 }, + { 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1 }, + { 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7 }, + { 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12 } + }, + + { { 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15 }, + { 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9 }, + { 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4 }, + { 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14 } + }, + + { { 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9 }, + { 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6 }, + { 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14 }, + { 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3 } + }, + + { { 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11 }, + { 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8 }, + { 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6 }, + { 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13 } + }, + + { { 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1 }, + { 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6 }, + { 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2 }, + { 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12 } + }, + + { { 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7 }, + { 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2 }, + { 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8 }, + { 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 } + } }; /* @@ -468,6 +468,7 @@ __init_des_r(__data) efp[comes_from_word][word_value][o_long] |= mask2; } } + atomic_write_barrier (); small_tables_initialized = 1; #ifdef __GNU_LIBRARY__ small_tables_done: From 02c9c5d2be470a498e707e0a7815ab9833b73a28 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 3 Apr 2010 17:56:51 -0700 Subject: [PATCH 30/57] Document problem with NATs in getaddrinfo. (cherry picked from commit ed0874085976531bda8a05540b0816e8bf711b71) --- ChangeLog | 8 ++++---- posix/gai.conf | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42c1a07a68..7a6417ed72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,15 +1,15 @@ 2010-04-03 Ulrich Drepper + [BZ #11438] + * posix/gai.conf: Document problems with IPv4 site-local addresses and + NATs. + [BZ #11449] * crypt/crypt_util.c (__init_des_r): Add memory barrier before setting small_tables_initialized. * malloc/malloc.c (set_max_fast): Fix computation of the value. -2010-04-03 Ulrich Drepper - - * malloc/malloc.c (set_max_fast): Fix computation of the value. - 2010-03-25 Andreas Schwab * sysdeps/posix/getaddrinfo.c (gaih_inet): Reset no_data before diff --git a/posix/gai.conf b/posix/gai.conf index 3dba1a905d..195287e1c8 100644 --- a/posix/gai.conf +++ b/posix/gai.conf @@ -66,3 +66,12 @@ #scopev4 ::ffff:172.16.0.0/108 5 #scopev4 ::ffff:192.168.0.0/112 5 #scopev4 ::ffff:0.0.0.0/96 14 +# +# For sites which use site-local IPv4 addresses behind NAT there is +# the problem that even if IPv4 addresses are preferred they do not +# have the same scope and are therefore not sorted first. To change +# this use only these rules: +# +#scopev4 ::ffff:169.254.0.0/112 2 +#scopev4 ::ffff:127.0.0.0/104 2 +#scopev4 ::ffff:0.0.0.0/96 14 From 6c4a23bc8d85165623b6331fab43cef8d18671db Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 3 Apr 2010 20:36:59 -0700 Subject: [PATCH 31/57] Fix changes to interface list during getifaddrs calls. (cherry picked from commit b8b14c4cc38883032b8ebae50c9a8b3efd256483) --- ChangeLog | 10 ++++++ sysdeps/unix/sysv/linux/ifaddrs.c | 55 ++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a6417ed72..300ec4ecc9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-04-03 Ulrich Drepper + + [BZ #11387] + * sysdeps/unix/sysv/linux/ifaddrs.c (map_newlin): Don't abort on + unknown interface, return -1. + (getifaddrs_internal): Rename from getifaddrs. Handle errors in + map_newlink be returning -EAGAIN. + (getifaddrs): If -EAGAIN is returned from getifaddrs_internal try + again. + 2010-04-03 Ulrich Drepper [BZ #11438] diff --git a/sysdeps/unix/sysv/linux/ifaddrs.c b/sysdeps/unix/sysv/linux/ifaddrs.c index 149bd1c3ba..84f223ddbd 100644 --- a/sysdeps/unix/sysv/linux/ifaddrs.c +++ b/sysdeps/unix/sysv/linux/ifaddrs.c @@ -1,5 +1,5 @@ /* getifaddrs -- get names and addresses of all network interfaces - Copyright (C) 2003-2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2003-2008, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -315,17 +315,19 @@ map_newlink (int index, struct ifaddrs_storage *ifas, int *map, int max) else if (map[i] == index) return i; } - /* This should never be reached. If this will be reached, we have - a very big problem. */ - abort (); + + /* This means interfaces changed inbetween the reading of the + RTM_GETLINK and RTM_GETADDR information. We have to repeat + everything. */ + return -1; } /* Create a linked list of `struct ifaddrs' structures, one for each network interface on the host machine. If successful, store the list in *IFAP and return 0. On errors, return -1 and set `errno'. */ -int -getifaddrs (struct ifaddrs **ifap) +static int +getifaddrs_internal (struct ifaddrs **ifap) { struct netlink_handle nh = { 0, 0, 0, NULL, NULL }; struct netlink_res *nlp; @@ -481,6 +483,13 @@ getifaddrs (struct ifaddrs **ifap) kernel. */ ifa_index = map_newlink (ifim->ifi_index - 1, ifas, map_newlink_data, newlink); + if (__builtin_expect (ifa_index == -1, 0)) + { + try_again: + result = -EAGAIN; + free (ifas); + goto exit_free; + } ifas[ifa_index].ifa.ifa_flags = ifim->ifi_flags; while (RTA_OK (rta, rtasize)) @@ -565,9 +574,11 @@ getifaddrs (struct ifaddrs **ifap) that we have holes in the interface part of the list, but we always have already the interface for this address. */ ifa_index = newlink + newaddr_idx; - ifas[ifa_index].ifa.ifa_flags - = ifas[map_newlink (ifam->ifa_index - 1, ifas, - map_newlink_data, newlink)].ifa.ifa_flags; + int idx = map_newlink (ifam->ifa_index - 1, ifas, + map_newlink_data, newlink); + if (__builtin_expect (idx == -1, 0)) + goto try_again; + ifas[ifa_index].ifa.ifa_flags = ifas[idx].ifa.ifa_flags; if (ifa_index > 0) ifas[ifa_index - 1].ifa.ifa_next = &ifas[ifa_index].ifa; ++newaddr_idx; @@ -747,9 +758,13 @@ getifaddrs (struct ifaddrs **ifap) /* If we didn't get the interface name with the address, use the name from the interface entry. */ if (ifas[ifa_index].ifa.ifa_name == NULL) - ifas[ifa_index].ifa.ifa_name - = ifas[map_newlink (ifam->ifa_index - 1, ifas, - map_newlink_data, newlink)].ifa.ifa_name; + { + int idx = map_newlink (ifam->ifa_index - 1, ifas, + map_newlink_data, newlink); + if (__builtin_expect (idx == -1, 0)) + goto try_again; + ifas[ifa_index].ifa.ifa_name = ifas[idx].ifa.ifa_name; + } /* Calculate the netmask. */ if (ifas[ifa_index].ifa.ifa_addr @@ -826,6 +841,22 @@ getifaddrs (struct ifaddrs **ifap) return result; } + + +/* Create a linked list of `struct ifaddrs' structures, one for each + network interface on the host machine. If successful, store the + list in *IFAP and return 0. On errors, return -1 and set `errno'. */ +int +getifaddrs (struct ifaddrs **ifap) +{ + int res; + + do + res = getifaddrs_internal (ifap); + while (res == -EAGAIN); + + return res; +} libc_hidden_def (getifaddrs) From ea614f680d5ede741bb2511364d190bceb9073b2 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 3 Apr 2010 23:10:16 -0700 Subject: [PATCH 32/57] Add missing include. (cherry picked from commit 3fedf0feb75457f7098a0119ca4203ff449546b6) --- crypt/crypt_util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/crypt/crypt_util.c b/crypt/crypt_util.c index a556389111..7999a30672 100644 --- a/crypt/crypt_util.c +++ b/crypt/crypt_util.c @@ -27,6 +27,7 @@ #ifdef DEBUG #include #endif +#include #include #ifndef STATIC From 043ea9e79d25398e8e0025b48444257e9e48029c Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 3 Apr 2010 23:51:40 -0700 Subject: [PATCH 33/57] Handle unnecessary padding in getdents64. The getdents64 syscall adds on 32-but platforms padding which isn't needed and not included in the userlevel data structure definition. We have to avoid copying those padding bytes in the readdir64_r function. (cherry picked from commit 1a81139728494810f65aaa0d0c538ff8c2783dd5) --- ChangeLog | 6 ++++++ sysdeps/unix/readdir_r.c | 14 ++++++++++++-- sysdeps/unix/sysv/linux/i386/readdir64_r.c | 3 ++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 300ec4ecc9..5c3a1cd65c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2010-04-03 Ulrich Drepper + [BZ #11333] + * sysdeps/unix/readdir_r.c (__READDIR_R): Add support for platforms + which include unnecessary padding in d_reclen. + * sysdeps/unix/sysv/linux/i386/readdir64_r.c: Select work-around for + unnecessary padding. + [BZ #11387] * sysdeps/unix/sysv/linux/ifaddrs.c (map_newlin): Don't abort on unknown interface, return -1. diff --git a/sysdeps/unix/readdir_r.c b/sysdeps/unix/readdir_r.c index f84709e737..93727912c1 100644 --- a/sysdeps/unix/readdir_r.c +++ b/sysdeps/unix/readdir_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2000,02 +/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2000,02,10 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -113,7 +113,17 @@ __READDIR_R (DIR *dirp, DIRENT_TYPE *entry, DIRENT_TYPE **result) while (dp->d_ino == 0); if (dp != NULL) - *result = memcpy (entry, dp, reclen); + { +#ifdef GETDENTS_64BIT_ALIGNED + /* The d_reclen value might include padding which is not part of + the DIRENT_TYPE data structure. */ + reclen = MIN (reclen, sizeof (DIRENT_TYPE)); +#endif + *result = memcpy (entry, dp, reclen); +#ifdef GETDENTS_64BIT_ALIGNED + entry->d_reclen = reclen; +#endif + } else *result = NULL; diff --git a/sysdeps/unix/sysv/linux/i386/readdir64_r.c b/sysdeps/unix/sysv/linux/i386/readdir64_r.c index c6da57b75e..f96f16a6f2 100644 --- a/sysdeps/unix/sysv/linux/i386/readdir64_r.c +++ b/sysdeps/unix/sysv/linux/i386/readdir64_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2004 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2004, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -19,6 +19,7 @@ #define __READDIR_R __readdir64_r #define __GETDENTS __getdents64 #define DIRENT_TYPE struct dirent64 +#define GETDENTS_64BIT_ALIGNED 1 #include From 159aeed982dc4c36de78027d262be8370e2f35a0 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 4 Apr 2010 00:25:46 -0700 Subject: [PATCH 34/57] Fix concurrent handling of __cpu_features. (cherry picked from commit 22f4f44b6727887957aa1d4039eba290b064da63) --- ChangeLog | 12 ++++++++++ sysdeps/x86_64/multiarch/init-arch.c | 33 ++++++++++++++++++---------- sysdeps/x86_64/multiarch/init-arch.h | 4 ++-- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c3a1cd65c..75bd6b87b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-04-04 H.J. Lu + Ulrich Drepper + + [BZ #11292] + * sysdeps/x86_64/multiarch/init-arch.c (__init_cpu_features): Allow + concurrent initialization and use of __cpu_features. + +2010-04-04 Ulrich Drepper + + * sysdeps/x86_64/multiarch/init-arch.h (cpu_features): Add tag to + the enum. + 2010-04-03 Ulrich Drepper [BZ #11333] diff --git a/sysdeps/x86_64/multiarch/init-arch.c b/sysdeps/x86_64/multiarch/init-arch.c index 7823aceb9b..0fe2f86b4f 100644 --- a/sysdeps/x86_64/multiarch/init-arch.c +++ b/sysdeps/x86_64/multiarch/init-arch.c @@ -1,6 +1,6 @@ /* Initialize CPU feature data. This file is part of the GNU C Library. - Copyright (C) 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. Contributed by Ulrich Drepper . The GNU C Library is free software; you can redistribute it and/or @@ -18,6 +18,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include #include #include "init-arch.h" @@ -26,7 +27,7 @@ struct cpu_features __cpu_features attribute_hidden; static void -get_common_indeces (void) +get_common_indeces (unsigned int *family, unsigned int *model) { __cpuid (1, __cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax, __cpu_features.cpuid[COMMON_CPUID_INDEX_1].ebx, @@ -34,8 +35,8 @@ get_common_indeces (void) __cpu_features.cpuid[COMMON_CPUID_INDEX_1].edx); unsigned int eax = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax; - __cpu_features.family = (eax >> 8) & 0x0f; - __cpu_features.model = (eax >> 4) & 0x0f; + *family = (eax >> 8) & 0x0f; + *model = (eax >> 4) & 0x0f; } @@ -45,36 +46,44 @@ __init_cpu_features (void) unsigned int ebx; unsigned int ecx; unsigned int edx; + unsigned int family = 0; + unsigned int model = 0; + enum cpu_features_kind kind; __cpuid (0, __cpu_features.max_cpuid, ebx, ecx, edx); /* This spells out "GenuineIntel". */ if (ebx == 0x756e6547 && ecx == 0x6c65746e && edx == 0x49656e69) { - __cpu_features.kind = arch_kind_intel; + kind = arch_kind_intel; - get_common_indeces (); + get_common_indeces (&family, &model); unsigned int eax = __cpu_features.cpuid[COMMON_CPUID_INDEX_1].eax; unsigned int extended_family = (eax >> 20) & 0xff; unsigned int extended_model = (eax >> 12) & 0xf0; if (__cpu_features.family == 0x0f) { - __cpu_features.family += extended_family; - __cpu_features.model += extended_model; + family += extended_family; + model += extended_model; } else if (__cpu_features.family == 0x06) - __cpu_features.model += extended_model; + model += extended_model; } /* This spells out "AuthenticAMD". */ else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65) { - __cpu_features.kind = arch_kind_amd; + kind = arch_kind_amd; - get_common_indeces (); + get_common_indeces (&family, &model); } else - __cpu_features.kind = arch_kind_other; + kind = arch_kind_other; + + __cpu_features.family = family; + __cpu_features.model = model; + atomic_write_barrier (); + __cpu_features.kind = kind; } #undef __get_cpu_features diff --git a/sysdeps/x86_64/multiarch/init-arch.h b/sysdeps/x86_64/multiarch/init-arch.h index 9b12831a6e..f6320693bf 100644 --- a/sysdeps/x86_64/multiarch/init-arch.h +++ b/sysdeps/x86_64/multiarch/init-arch.h @@ -1,5 +1,5 @@ /* This file is part of the GNU C Library. - Copyright (C) 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -27,7 +27,7 @@ enum extern struct cpu_features { - enum + enum cpu_features_kind { arch_kind_unknown = 0, arch_kind_intel, From 16c1804e696304140e54108ddd2889cf7b54b768 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 4 Apr 2010 01:02:09 -0700 Subject: [PATCH 35/57] Fix retrieving of kernel header version. (cherry picked from commit 9e37946dba22b53c5108eef777e867f93c894502) --- ChangeLog | 6 ++++++ csu/Makefile | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75bd6b87b7..4ccc115930 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-04-04 Ulrich Drepper + + [BZ #11287] + * csu/Makefile ($(objpfx)version-info.h): Handle newer kernel headers + which don't define UTS_RELEASE. + 2010-04-04 H.J. Lu Ulrich Drepper diff --git a/csu/Makefile b/csu/Makefile index 0e2ae07cf7..69e07c71cf 100644 --- a/csu/Makefile +++ b/csu/Makefile @@ -1,5 +1,5 @@ # Makefile for csu code for GNU C library. -# Copyright (C) 1995-2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 1995-2004, 2005, 2006, 2010 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -209,8 +209,19 @@ $(objpfx)version-info.h: $(common-objpfx)config.make $(all-Banner-files) linux*) version=`(printf '%s\n%s\n' \ '#include ' \ UTS_RELEASE \ - | $(CC) $(CPPFLAGS) -E -P - -DNOT_IN_libc=1 | \ + | $(CC) $(CPPFLAGS) -O -E -P - -DNOT_IN_libc=1 | \ sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\ + if [ -z "$$version" ]; then \ + version=`(printf '%s\n%s\n' \ + '#include ' \ + LINUX_VERSION_CODE \ + | $(CC) $(CPPFLAGS) -O -E -P - -DNOT_IN_libc=1 \ + | sed -n -e '/^[123456789].*/p' \ + | awk '{v=$$1; \ + printf("%d.%d.%d\n", \ + v/65535, v/256%256, v%256)}') \ + 2>/dev/null`; \ + fi; \ if [ -z "$$version" ]; then \ if [ -r /proc/version ]; then \ version=`sed 's/.*Linux version \([^ ]*\) .*/>>\1< Date: Sun, 4 Apr 2010 10:04:55 -0700 Subject: [PATCH 36/57] Fix option aliasing in argp. (cherry picked from commit 8c6de69d00c6be60657ca0d763dda803172c6aab) --- ChangeLog | 6 ++++++ argp/argp-parse.c | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4ccc115930..db3d121085 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-02-05 Sergey Poznyakoff + + [BZ #11254] + * argp/argp-parse.c (convert_options): Fix improper use of `|' + between character values. + 2010-04-04 Ulrich Drepper [BZ #11287] diff --git a/argp/argp-parse.c b/argp/argp-parse.c index 4718ced81d..604fcf0f3a 100644 --- a/argp/argp-parse.c +++ b/argp/argp-parse.c @@ -1,5 +1,5 @@ /* Hierarchial argument parsing, layered over getopt - Copyright (C) 1995-2000, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1995-2000, 2002, 2003, 2004, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . @@ -99,7 +99,7 @@ static volatile int _argp_hang; static const struct argp_option argp_default_options[] = { - {"help", '?', 0, 0, N_("Give this help list"), -1}, + {"help", '?', 0, 0, N_("Give this help list"), -1}, {"usage", OPT_USAGE, 0, 0, N_("Give a short usage message")}, {"program-name",OPT_PROGNAME,"NAME", OPTION_HIDDEN, N_("Set the program name")}, {"HANG", OPT_HANG, "SECS", OPTION_ARG_OPTIONAL | OPTION_HIDDEN, @@ -164,7 +164,7 @@ static const struct argp argp_default_argp = static const struct argp_option argp_version_options[] = { - {"version", 'V', 0, 0, N_("Print program version"), -1}, + {"version", 'V', 0, 0, N_("Print program version"), -1}, {0, 0} }; @@ -364,7 +364,7 @@ convert_options (const struct argp *argp, values (the sign of the lower bits is preserved however)... */ cvt->long_end->val = - ((opt->key | real->key) & USER_MASK) + ((opt->key ? opt->key : real->key) & USER_MASK) + (((group - cvt->parser->groups) + 1) << USER_BITS); /* Keep the LONG_OPTS list terminated. */ @@ -385,7 +385,7 @@ convert_options (const struct argp *argp, if (children) /* Assign GROUP's CHILD_INPUTS field some space from - CVT->child_inputs_end.*/ + CVT->child_inputs_end.*/ { unsigned num_children = 0; while (children[num_children].argp) @@ -823,7 +823,7 @@ parser_parse_next (struct parser *parser, int *arg_ebadkey) parser->try_getopt = 0; if (parser->state.next > 1 && strcmp (parser->state.argv[parser->state.next - 1], QUOTE) - == 0) + == 0) /* Not only is this the end of the options, but it's a `quoted' region, which may have args that *look* like options, so we definitely shouldn't try to use getopt past From 14b56bb1170bdfc4b3f6435017eab676c19b19bd Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 4 Apr 2010 11:28:36 -0700 Subject: [PATCH 37/57] Add test case for last argp bug. (cherry picked from commit 7ebaec64a0171a54dbe9aedd95497b130458060e) --- ChangeLog | 5 +++++ argp/Makefile | 5 +++-- argp/bug-argp2.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 argp/bug-argp2.c diff --git a/ChangeLog b/ChangeLog index db3d121085..8f3aef4323 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-04-04 Ulrich Drepper + + * argp/Makefile: Add rules to build and run bug-argp2. + * argp/bug-argp2.c: New file. + 2010-02-05 Sergey Poznyakoff [BZ #11254] diff --git a/argp/Makefile b/argp/Makefile index b8c9fca0fb..caa95dbb9f 100644 --- a/argp/Makefile +++ b/argp/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1997, 2002, 2003, 2006, 2007 Free Software Foundation, Inc. +# Copyright (C) 1997,2002,2003,2006,2007,2010 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -26,12 +26,13 @@ distribute = argp-fmtstream.h argp-namefrob.h routines = $(addprefix argp-, ba fmtstream fs-xinl help parse pv \ pvh xinl eexst) -tests = argp-test tst-argp1 bug-argp1 tst-argp2 +tests = argp-test tst-argp1 bug-argp1 tst-argp2 bug-argp2 CFLAGS-argp-help.c = $(uses-callbacks) -fexceptions CFLAGS-argp-parse.c = $(uses-callbacks) CFLAGS-argp-fmtstream.c = -fexceptions bug-argp1-ARGS = -- --help +bug-argp2-ARGS = -- -d 111 --dstaddr 222 -p 333 --peer 444 include ../Rules diff --git a/argp/bug-argp2.c b/argp/bug-argp2.c new file mode 100644 index 0000000000..133e5cf6e8 --- /dev/null +++ b/argp/bug-argp2.c @@ -0,0 +1,55 @@ +#include +#include +#include + +static struct argp_option argp_options[] = { + { "dstaddr", 'd', "ADDR", 0, + "set destination (peer) address to ADDR" }, + { "peer", 'p', "ADDR", OPTION_ALIAS }, + { NULL } +}; + +static error_t parse_opt (int key, char *arg, struct argp_state *state); + +static struct argp argp = +{ + argp_options, parse_opt +}; + +static int cnt; + +static int +do_test (int argc, char *argv[]) +{ + int remaining; + argp_parse (&argp, argc, argv, 0, &remaining, NULL); + return cnt != 4; +} + +static error_t +parse_opt (int key, char *arg, struct argp_state *state) +{ + switch (key) + { + case 'd': + case 'p': + printf ("got '%c' with argument '%s'\n", key, arg); + ++cnt; + break; + case 0: + case ARGP_KEY_END: + case ARGP_KEY_NO_ARGS: + case ARGP_KEY_INIT: + case ARGP_KEY_SUCCESS: + case ARGP_KEY_FINI: + // Ignore. + return ARGP_ERR_UNKNOWN; + default: + printf ("invalid key '%x'\n", key); + exit (1); + } + return 0; +} + +#define TEST_FUNCTION do_test (argc, argv) +#include "../test-skeleton.c" From 1845ca23091e5ff22e8620d5d72eccd9e2775324 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 4 Apr 2010 22:01:52 -0700 Subject: [PATCH 38/57] Declare iruserok and iruserok_af. (cherry picked from commit 2cd9670885d32eed6f4de12ddbeb2a9d049f198e) --- ChangeLog | 3 +++ resolv/netdb.h | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8f3aef4323..44659bbf19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2010-04-04 Ulrich Drepper + [BZ #11070] + * resolv/netdb.h: Declare iruserok and iruserok_af. + * argp/Makefile: Add rules to build and run bug-argp2. * argp/bug-argp2.c: New file. diff --git a/resolv/netdb.h b/resolv/netdb.h index dc1f7cec61..06e9a9a6e8 100644 --- a/resolv/netdb.h +++ b/resolv/netdb.h @@ -516,6 +516,30 @@ extern int ruserok_af (__const char *__rhost, int __suser, __const char *__remuser, __const char *__locuser, sa_family_t __af); +/* Check whether user REMUSER on system indicated by IPv4 address + RADDR is allowed to login as LOCUSER. Non-IPv4 (e.g., IPv6) are + not supported. If SUSER is not zero the user tries to become + superuser. Return 0 if it is possible. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int iruserok (uint32_t __raddr, int __suser, + __const char *__remuser, __const char *__locuser); + +/* This is the equivalent function where the pfamiliy if the address + pointed to by RADDR is determined by the value of AF. It therefore + can be used for IPv6 + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int iruserok_af (__const void *__raddr, int __suser, + __const char *__remuser, __const char *__locuser, + sa_family_t __af); + /* Try to allocate reserved port, returning a descriptor for a socket opened at this port or -1 if unsuccessful. The search for an available port will start at ALPORT and continues with lower numbers. From ed5e4f5aac1d6a4c75d78548255a47881cdfb911 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 4 Apr 2010 22:48:55 -0700 Subject: [PATCH 39/57] Fix printing error messages in getopt. (cherry picked from commit 247fdc8ee68cf49cd808becce56b2e923b4f776b) --- ChangeLog | 4 ++++ posix/getopt.c | 25 +++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44659bbf19..2941812648 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-04-04 Ulrich Drepper + [BZ #11043] + * posix/getopt.c (_getopt_internal_r): Fix arguments printed in error + messages. + [BZ #11070] * resolv/netdb.h: Declare iruserok and iruserok_af. diff --git a/posix/getopt.c b/posix/getopt.c index a7f0b54857..88acff0e2f 100644 --- a/posix/getopt.c +++ b/posix/getopt.c @@ -2,7 +2,8 @@ NOTE: getopt is part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! - Copyright (C) 1987-1996,1998-2004,2008,2009 Free Software Foundation, Inc. + Copyright (C) 1987-1996,1998-2004,2008,2009,2010 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -679,8 +680,8 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, char *buf; if (__asprintf (&buf, _("\ -%s: option '%s' requires an argument\n"), - argv[0], argv[d->optind - 1]) >= 0) +%s: option '--%s' requires an argument\n"), + argv[0], pfound->name) >= 0) { _IO_flockfile (stderr); @@ -697,8 +698,8 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, } #else fprintf (stderr, - _("%s: option '%s' requires an argument\n"), - argv[0], argv[d->optind - 1]); + _("%s: option '--%s' requires an argument\n"), + argv[0], pfound->name); #endif } d->__nextchar += strlen (d->__nextchar); @@ -922,7 +923,7 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, char *buf; if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"), - argv[0], argv[d->optind]) >= 0) + argv[0], d->optarg) >= 0) { _IO_flockfile (stderr); @@ -938,7 +939,7 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, } #else fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"), - argv[0], argv[d->optind]); + argv[0], d->optarg); #endif } d->__nextchar += strlen (d->__nextchar); @@ -1001,8 +1002,8 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, char *buf; if (__asprintf (&buf, _("\ -%s: option '%s' requires an argument\n"), - argv[0], argv[d->optind - 1]) >= 0) +%s: option '-W %s' requires an argument\n"), + argv[0], pfound->name) >= 0) { _IO_flockfile (stderr); @@ -1018,9 +1019,9 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, free (buf); } #else - fprintf (stderr, - _("%s: option '%s' requires an argument\n"), - argv[0], argv[d->optind - 1]); + fprintf (stderr, _("\ +%s: option '-W %s' requires an argument\n"), + argv[0], pfound->name); #endif } d->__nextchar += strlen (d->__nextchar); From fbca690a79f9b0232acc0e1d8504d62243bcdbb0 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 5 Apr 2010 11:26:43 -0700 Subject: [PATCH 40/57] Fix aux cache handling in ldconfig with chroot. (cherry picked from commit 4bc2bcba67e870778fb9397f29435ee1b66bebf3) --- ChangeLog | 6 ++++++ elf/ldconfig.c | 21 ++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2941812648..26c4e2f245 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-04-05 Ulrich Drepper + + [BZ #11149] + * elf/ldconfig.c (main): Respect chroot setting when looking for + the aux cache. + 2010-04-04 Ulrich Drepper [BZ #11043] diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 78a0f0c2a8..76075278c0 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -1305,11 +1305,9 @@ main (int argc, char **argv) p ? (*p = '\0', cache_file) : "/"); if (canon == NULL) - { - error (EXIT_FAILURE, errno, - _("Can't open cache file directory %s\n"), - p ? cache_file : "/"); - } + error (EXIT_FAILURE, errno, + _("Can't open cache file directory %s\n"), + p ? cache_file : "/"); if (p) ++p; @@ -1346,8 +1344,17 @@ main (int argc, char **argv) add_system_dir (LIBDIR); } + char *aux_cache_file = _PATH_LDCONFIG_AUX_CACHE; + if (opt_chroot) + { + aux_cache_file = chroot_canon (opt_chroot, aux_cache_file); + if (aux_cache_file == NULL) + error (EXIT_FAILURE, errno, _("Can't open cache file %s\n"), + _PATH_LDCONFIG_AUX_CACHE); + } + if (! opt_ignore_aux_cache) - load_aux_cache (_PATH_LDCONFIG_AUX_CACHE); + load_aux_cache (aux_cache_file); else init_aux_cache (); @@ -1356,7 +1363,7 @@ main (int argc, char **argv) if (opt_build_cache) { save_cache (cache_file); - save_aux_cache (_PATH_LDCONFIG_AUX_CACHE); + save_aux_cache (aux_cache_file); } return 0; From 52ade99fe57673eccffbcd71dea61692c424930d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 5 Apr 2010 12:21:20 -0700 Subject: [PATCH 41/57] Handle DNS timeouts in old-style lookkup code. (cherry picked from commit 4535680d03d15dc9ce19d97b9d242a10941d5016) --- ChangeLog | 4 ++++ resolv/nss_dns/dns-host.c | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 26c4e2f245..6df5c047f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-04-05 Ulrich Drepper + [BZ #11010] + * resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname3_r): Handle + timeouts from servers. + [BZ #11149] * elf/ldconfig.c (main): Respect chroot setting when looking for the aux cache. diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index 818a40a898..e0c4978c3b 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2004, 2007, 2008, 2009 Free Software Foundation, Inc. +/* Copyright (C) 1996-2004, 2007-2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Extended from original form by Ulrich Drepper , 1996. @@ -198,21 +198,27 @@ _nss_dns_gethostbyname3_r (const char *name, int af, struct hostent *result, 1024, &host_buffer.ptr, NULL, NULL, NULL); if (n < 0) { - if (errno == ESRCH) + switch (errno) { + case ESRCH: status = NSS_STATUS_TRYAGAIN; h_errno = TRY_AGAIN; + break; + case ECONNREFUSED: + case ETIMEDOUT: + status = NSS_STATUS_UNAVAIL; + break; + default: + status = NSS_STATUS_NOTFOUND; + break; } - else - status = (errno == ECONNREFUSED - ? NSS_STATUS_UNAVAIL : NSS_STATUS_NOTFOUND); *h_errnop = h_errno; if (h_errno == TRY_AGAIN) *errnop = EAGAIN; else __set_errno (olderr); - /* If we are looking for a IPv6 address and mapping is enabled + /* If we are looking for an IPv6 address and mapping is enabled by having the RES_USE_INET6 bit in _res.options set, we try another lookup. */ if (af == AF_INET6 && (_res.options & RES_USE_INET6)) From 443a33d8042f4084d4d1f40a5b973a19bcae9a23 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 7 Apr 2010 17:16:27 -0700 Subject: [PATCH 42/57] Fix -W with optional parameters in getopt. According to the getopt documentation, if "W;" is part of optstring, then '-W foo' should behave like '--foo'. But if "foo" uses an optional_argument, this is not the case, since optarg is not NULL when using -W. (cherry picked from commit aa7f642769abcfbce658aeaaffdc9fb4790cd905) --- ChangeLog | 6 ++++++ posix/getopt.c | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6df5c047f7..9e247e87df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-12-02 Eric Blake + + [BZ #11041] + * posix/getopt.c (_getopt_internal_r): Handle '-Wfoo' identically + to '--foo', with optional argument or non-ambiguous prefix. + 2010-04-05 Ulrich Drepper [BZ #11010] diff --git a/posix/getopt.c b/posix/getopt.c index 88acff0e2f..01c1071ecb 100644 --- a/posix/getopt.c +++ b/posix/getopt.c @@ -911,7 +911,10 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, pfound = p; indfound = option_index; } - else + else if (long_only + || pfound->has_arg != p->has_arg + || pfound->flag != p->flag + || pfound->val != p->val) /* Second or later nonexact match found. */ ambig = 1; } @@ -1028,6 +1031,8 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, return optstring[0] == ':' ? ':' : '?'; } } + else + d->optarg = NULL; d->__nextchar += strlen (d->__nextchar); if (longind != NULL) *longind = option_index; From d75c76e1d74d3c6fe508738abd442aae0365d690 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 7 Apr 2010 17:28:36 -0700 Subject: [PATCH 43/57] getopt mistakenly allows '-;' as short option (cherry picked from commit cf0b68196c837ad591f0e7fc0f8e8a0f690b847c) --- ChangeLog | 8 +++++++- posix/getopt.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e247e87df..1497e859b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -2009-12-02 Eric Blake +2009-12-01 Eric Blake + + [BZ #11040] + * posix/getopt.c (_getopt_internal_r): Reject '-;' as short + option, since it conflicts with "W;" optstring extension. + +2009-12-02 Eric Blake [BZ #11041] * posix/getopt.c (_getopt_internal_r): Handle '-Wfoo' identically diff --git a/posix/getopt.c b/posix/getopt.c index 01c1071ecb..b778047cd9 100644 --- a/posix/getopt.c +++ b/posix/getopt.c @@ -789,7 +789,7 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, if (*d->__nextchar == '\0') ++d->optind; - if (temp == NULL || c == ':') + if (temp == NULL || c == ':' || c == ';') { if (print_errors) { From 6b6e2d505cf6e9246872e7f98e338b52922c7b33 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 7 Apr 2010 17:56:20 -0700 Subject: [PATCH 44/57] getopt mishandles optstring of "+:" (cherry picked from commit 66b93be793af309fb78d54199aed2306650079d0) --- ChangeLog | 4 ++++ posix/getopt.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1497e859b5..e2a23b7b50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-12-01 Eric Blake + [BZ #11039] + * posix/getopt.c (_getopt_internal_r): Skip optional - or + before + checking lead byte of optstring for :. + [BZ #11040] * posix/getopt.c (_getopt_internal_r): Reject '-;' as short option, since it conflicts with "W;" optstring extension. diff --git a/posix/getopt.c b/posix/getopt.c index b778047cd9..2746364fc7 100644 --- a/posix/getopt.c +++ b/posix/getopt.c @@ -395,8 +395,6 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, int long_only, struct _getopt_data *d, int posixly_correct) { int print_errors = d->opterr; - if (optstring[0] == ':') - print_errors = 0; if (argc < 1) return -1; @@ -411,6 +409,10 @@ _getopt_internal_r (int argc, char *const *argv, const char *optstring, posixly_correct); d->__initialized = 1; } + else if (optstring[0] == '-' || optstring[0] == '+') + optstring++; + if (optstring[0] == ':') + print_errors = 0; /* Test whether ARGV[optind] points to a non-option argument. Either it does not have option syntax, or there is an environment flag From 1aa9c16a2a1b297b31793b99cc3d5d67e720edb2 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Thu, 8 Apr 2010 15:44:55 -0700 Subject: [PATCH 45/57] Fix fallocate error return on i386. (cherry picked from commit de240a05b3638879af2f9ab663c56ad8b26b1ad3) --- ChangeLog | 5 +++++ sysdeps/unix/sysv/linux/i386/fallocate.c | 8 +++++++- sysdeps/unix/sysv/linux/i386/fallocate64.c | 8 +++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e2a23b7b50..1339765a80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-04-07 Andreas Schwab + + * sysdeps/unix/sysv/linux/i386/fallocate.c: Set errno on error. + * sysdeps/unix/sysv/linux/i386/fallocate64.c: Likewise. + 2009-12-01 Eric Blake [BZ #11039] diff --git a/sysdeps/unix/sysv/linux/i386/fallocate.c b/sysdeps/unix/sysv/linux/i386/fallocate.c index 14e788386c..1434a833f9 100644 --- a/sysdeps/unix/sysv/linux/i386/fallocate.c +++ b/sysdeps/unix/sysv/linux/i386/fallocate.c @@ -30,7 +30,13 @@ int fallocate (int fd, int mode, __off_t offset, __off_t len) { #ifdef __NR_fallocate - return __call_fallocate (fd, mode, offset, len); + int err = __call_fallocate (fd, mode, offset, len); + if (__builtin_expect (err, 0)) + { + __set_errno (err); + err = -1; + } + return err; #else __set_errno (ENOSYS); return -1; diff --git a/sysdeps/unix/sysv/linux/i386/fallocate64.c b/sysdeps/unix/sysv/linux/i386/fallocate64.c index 85f315c9b6..063bab06e9 100644 --- a/sysdeps/unix/sysv/linux/i386/fallocate64.c +++ b/sysdeps/unix/sysv/linux/i386/fallocate64.c @@ -30,7 +30,13 @@ int fallocate64 (int fd, int mode, __off64_t offset, __off64_t len) { #ifdef __NR_fallocate - return __call_fallocate (fd, mode, offset, len); + int err = __call_fallocate (fd, mode, offset, len); + if (__builtin_expect (err, 0)) + { + __set_errno (err); + err = -1; + } + return err; #else __set_errno (ENOSYS); return -1; From 39879d17a46e063c674ecf5532cb8c1f49fc7277 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 9 Apr 2010 21:38:20 -0700 Subject: [PATCH 46/57] Fix crash on reloading of gai data in nscd. (cherry picked from commit ea42a20caed5b343ff20a0d4622ae6c17b77161b) --- ChangeLog | 8 ++++++++ nscd/aicache.c | 10 ++++++---- resolv/nss_dns/dns-host.c | 16 ++-------------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1339765a80..18e059866e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-04-09 Ulrich Drepper + + * nscd/aicache.c (addhstaiX): Correct passing memory to address + list to gethostbyname4_r functions. + + * resolv/nss_dns/dns-host.c (gaih_getanswer_slice): Optimize + copying of h_name. + 2010-04-07 Andreas Schwab * sysdeps/unix/sysv/linux/i386/fallocate.c: Set errno on error. diff --git a/nscd/aicache.c b/nscd/aicache.c index 992357d2fe..3cb2208035 100644 --- a/nscd/aicache.c +++ b/nscd/aicache.c @@ -1,5 +1,5 @@ /* Cache handling for host lookup. - Copyright (C) 2004-2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2004-2008, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2004. @@ -111,7 +111,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, int old_res_options = _res.options; _res.options &= ~RES_USE_INET6; - size_t tmpbuf6len = 512; + size_t tmpbuf6len = 1024; char *tmpbuf6 = alloca (tmpbuf6len); size_t tmpbuf4len = 0; char *tmpbuf4 = NULL; @@ -133,9 +133,11 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, "gethostbyname4_r"); if (fct4 != NULL) { - struct gaih_addrtuple *at = NULL; + struct gaih_addrtuple atmem; + struct gaih_addrtuple *at; while (1) { + at = &atmem; rc6 = 0; herrno = 0; status[1] = DL_CALL_FCT (fct4, (key, &at, tmpbuf6, tmpbuf6len, @@ -153,7 +155,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req, goto next_nip; /* We found the data. Count the addresses and the size. */ - for (const struct gaih_addrtuple *at2 = at; at2 != NULL; + for (const struct gaih_addrtuple *at2 = at = &atmem; at2 != NULL; at2 = at2->next) { ++naddrs; diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index e0c4978c3b..8592183f62 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -1050,7 +1050,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, ++had_error; continue; } - if (*firstp) + if (*firstp && canon == NULL) { h_name = buffer; buffer += h_namelen; @@ -1166,19 +1166,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, if (ttl != 0 && ttlp != NULL) *ttlp = ttl; - if (canon != NULL) - { - (*pat)->name = canon; - - /* Reclaim buffer space. */ - if (h_name + h_namelen == buffer) - { - buffer = h_name; - buflen += h_namelen; - } - } - else - (*pat)->name = h_name; + (*pat)->name = canon ?: h_name; *firstp = 0; } From 59d5bd49df96b85c0e61ee21c74f0c7d91c34304 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Wed, 14 Apr 2010 22:16:06 -0700 Subject: [PATCH 47/57] Don't crash in trace mode when dependencies are missing (cherry picked from commit 18a26b301b6ab0d68474fbfffb0d17adf69e8824) --- ChangeLog | 5 +++++ elf/dl-version.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 18e059866e..c26934ae3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-04-14 Andreas Schwab + + * elf/dl-version.c (_dl_check_map_versions): Avoid index overflow + when dependencies are missing. + 2010-04-09 Ulrich Drepper * nscd/aicache.c (addhstaiX): Correct passing memory to address diff --git a/elf/dl-version.c b/elf/dl-version.c index 9e881162a6..c59a6c3cd3 100644 --- a/elf/dl-version.c +++ b/elf/dl-version.c @@ -322,10 +322,14 @@ _dl_check_map_versions (struct link_map *map, int verbose, int trace_mode) while (1) { ElfW(Half) ndx = aux->vna_other & 0x7fff; - map->l_versions[ndx].hash = aux->vna_hash; - map->l_versions[ndx].hidden = aux->vna_other & 0x8000; - map->l_versions[ndx].name = &strtab[aux->vna_name]; - map->l_versions[ndx].filename = &strtab[ent->vn_file]; + /* In trace mode, dependencies may be missing. */ + if (__builtin_expect (ndx < map->l_nversions, 1)) + { + map->l_versions[ndx].hash = aux->vna_hash; + map->l_versions[ndx].hidden = aux->vna_other & 0x8000; + map->l_versions[ndx].name = &strtab[aux->vna_name]; + map->l_versions[ndx].filename = &strtab[ent->vn_file]; + } if (aux->vna_next == 0) /* No more symbols. */ From 49c6fd1ff2a550ad407054a2821d654c41e22679 Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Mon, 26 Apr 2010 09:59:30 -0700 Subject: [PATCH 48/57] Hurd: Fix file_name_lookup_at error case return value. (cherry picked from commit 67481400c51229de3efa2eb3dddc8429b6f9e9f4) --- ChangeLog | 4 ++++ hurd/lookup-at.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c26934ae3b..33f2cb00a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-04-24 Emilio Pozuelo Monfort + + * hurd/lookup-at.c (__file_name_lookup_at): Fix error return value. + 2010-04-14 Andreas Schwab * elf/dl-version.c (_dl_check_map_versions): Avoid index overflow diff --git a/hurd/lookup-at.c b/hurd/lookup-at.c index a2d50cb192..7f55527d8b 100644 --- a/hurd/lookup-at.c +++ b/hurd/lookup-at.c @@ -1,5 +1,5 @@ /* Lookup helper function for Hurd implementation of *at functions. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006,2010 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -33,7 +33,7 @@ __file_name_lookup_at (int fd, int at_flags, flags |= (at_flags & AT_SYMLINK_NOFOLLOW) ? O_NOLINK : 0; at_flags &= ~AT_SYMLINK_NOFOLLOW; if (at_flags != 0) - return __hurd_fail (EINVAL); + return (__hurd_fail (EINVAL), MACH_PORT_NULL); if (fd == AT_FDCWD || file_name[0] == '/') return __file_name_lookup (file_name, flags, mode); From ca27df35b7e821a800c9302bc06b7923e1ff59fd Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 26 Apr 2010 10:07:15 -0700 Subject: [PATCH 49/57] BZ #11537: Hurd: Fix ttyname_r error return value. (cherry picked from commit 6cffee3611f324326ae46bb02d2baeb62c0db6a4) --- ChangeLog | 6 ++++++ sysdeps/mach/hurd/ttyname_r.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33f2cb00a9..1500f3e683 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-04-25 Bruno Haible + + [BZ #11537] + * sysdeps/mach/hurd/ttyname_r.c (__ttyname_r): Upon failure, return + errno, not -1. + 2010-04-24 Emilio Pozuelo Monfort * hurd/lookup-at.c (__file_name_lookup_at): Fix error return value. diff --git a/sysdeps/mach/hurd/ttyname_r.c b/sysdeps/mach/hurd/ttyname_r.c index 7313b9afcb..8896252246 100644 --- a/sysdeps/mach/hurd/ttyname_r.c +++ b/sysdeps/mach/hurd/ttyname_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994, 95, 96, 98 Free Software Foundation, Inc. +/* Copyright (C) 1994,1995,1996,1998,2010 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -34,13 +34,13 @@ __ttyname_r (int fd, char *buf, size_t buflen) nodename[0] = '\0'; if (err = HURD_DPORT_USE (fd, __term_get_nodename (port, nodename))) - return __hurd_dfail (fd, err), -1; + return __hurd_dfail (fd, err), errno; len = strlen (nodename) + 1; if (len > buflen) { errno = EINVAL; - return -1; + return errno; } memcpy (buf, nodename, len); From 15290d70863d800087aa629f035ad4bcb7f1f69b Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 28 Apr 2010 15:00:14 -0700 Subject: [PATCH 50/57] BZ #11538: Fix ttyname_r callers not to expect errno was set. (cherry picked from commit 8c0677fe5d91b7269364ca08fa08ed09e4c2d8c9) --- ChangeLog | 5 +++++ sysdeps/unix/bsd/ptsname.c | 11 ++++++++--- sysdeps/unix/getlogin.c | 9 +++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1500f3e683..3d9f1b5f94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2010-04-25 Bruno Haible + [BZ #11538] + * sysdeps/unix/bsd/ptsname.c (__ptsname_r): Use __ttyname_r's return + value instead of errno. + * sysdeps/unix/getlogin.c (getlogin): Likewise. + [BZ #11537] * sysdeps/mach/hurd/ttyname_r.c (__ttyname_r): Upon failure, return errno, not -1. diff --git a/sysdeps/unix/bsd/ptsname.c b/sysdeps/unix/bsd/ptsname.c index fd446a4b66..6063201b0f 100644 --- a/sysdeps/unix/bsd/ptsname.c +++ b/sysdeps/unix/bsd/ptsname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998,2002 Free Software Foundation, Inc. +/* Copyright (C) 1998,2002,2010 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -44,6 +44,7 @@ int __ptsname_r (int fd, char *buf, size_t buflen) { int save_errno = errno; + int err; struct stat st; if (buf == NULL) @@ -62,8 +63,12 @@ __ptsname_r (int fd, char *buf, size_t buflen) return ERANGE; } - if (__ttyname_r (fd, buf, buflen) != 0) - return errno; + err = __ttyname_r (fd, buf, buflen); + if (err != 0) + { + __set_errno (err); + return errno; + } buf[sizeof (_PATH_DEV) - 1] = 't'; diff --git a/sysdeps/unix/getlogin.c b/sysdeps/unix/getlogin.c index 4752685f86..7345af0886 100644 --- a/sysdeps/unix/getlogin.c +++ b/sysdeps/unix/getlogin.c @@ -33,6 +33,7 @@ getlogin (void) { char tty_pathname[2 + 2 * NAME_MAX]; char *real_tty_path = tty_pathname; + int err; char *result = NULL; static char name[UT_NAMESIZE + 1]; struct utmp *ut, line, buffer; @@ -46,8 +47,12 @@ getlogin (void) thing to do. Note that ttyname(open("/dev/tty")) on those systems returns /dev/tty, so that is not a possible solution for getlogin(). */ - if (__ttyname_r (0, real_tty_path, sizeof (tty_pathname)) != 0) - return NULL; + err = __ttyname_r (0, real_tty_path, sizeof (tty_pathname)); + if (err != 0) + { + __set_errno (err); + return NULL; + } real_tty_path += 5; /* Remove "/dev/". */ From 850121f39d8b0bcf1e5bb2bddd4b50aae708b661 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 2 May 2010 12:12:55 -0700 Subject: [PATCH 51/57] Fix handling if newline in addmntent. (cherry picked from commit ab00f4eac8f4932211259ff87be83144f5211540) --- ChangeLog | 6 ++++++ misc/mntent_r.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3d9f1b5f94..eb9a577918 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-05-02 Ulrich Drepper + + * misc/mntent_r.c (encode_name): The slow loop handles newlines so we + should recognize them as an abort condition. + Patch by Jan Lieskovsky . + 2010-04-25 Bruno Haible [BZ #11538] diff --git a/misc/mntent_r.c b/misc/mntent_r.c index 829750b395..9598528324 100644 --- a/misc/mntent_r.c +++ b/misc/mntent_r.c @@ -1,5 +1,5 @@ /* Utilities for reading/writing fstab, mtab, etc. - Copyright (C) 1995-2000, 2001, 2002, 2003, 2006 + Copyright (C) 1995-2000, 2001, 2002, 2003, 2006, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -194,7 +194,7 @@ weak_alias (__getmntent_r, getmntent_r) const char *rp = name; \ \ while (*rp != '\0') \ - if (*rp == ' ' || *rp == '\t' || *rp == '\\') \ + if (*rp == ' ' || *rp == '\t' || *rp == '\n' || *rp == '\\') \ break; \ else \ ++rp; \ @@ -202,7 +202,7 @@ weak_alias (__getmntent_r, getmntent_r) if (*rp != '\0') \ { \ /* In the worst case the length of the string can increase to \ - founr times the current length. */ \ + four times the current length. */ \ char *wp; \ \ rp = name; \ From 8ef4dbaf6d8faa91ff42a5d7b8b2c29f1c22bed0 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 3 May 2010 10:40:30 -0700 Subject: [PATCH 52/57] One more bug in ldconfig -r handling. (cherry picked from commit 49bd556d43f55d0bb6d76d57e846af85f0c986c9) --- ChangeLog | 5 +++++ elf/ldconfig.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index eb9a577918..48f9aa9339 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-05-03 Ulrich Drepper + + * elf/ldconfig.c (parse_conf_include): Don't fall back to + directories named in config file outside the chroot. + 2010-05-02 Ulrich Drepper * misc/mntent_r.c (encode_name): The slow loop handles newlines so we diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 76075278c0..0d07a6075a 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -1174,7 +1174,9 @@ parse_conf_include (const char *config_file, unsigned int lineno, if (do_chroot && opt_chroot) { char *canon = chroot_canon (opt_chroot, pattern); - result = glob64 (canon ?: pattern, 0, NULL, &gl); + if (canon == NULL) + return; + result = glob64 (canon, 0, NULL, &gl); free (canon); } else From c4e15a30bd196e2201f4d183fc1bdec4f562be10 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 3 May 2010 13:33:13 -0700 Subject: [PATCH 53/57] Simplify OOM handling in ldconfig. (cherry picked from commit f2976023940a8ef3bbe0c7e593897e1b612370f1) --- ChangeLog | 2 ++ elf/chroot_canon.c | 10 +++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 48f9aa9339..99638b6ee9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2010-05-03 Ulrich Drepper + * elf/chroot_canon.c (chroot_canon): Use xmalloc and xrealloc. + * elf/ldconfig.c (parse_conf_include): Don't fall back to directories named in config file outside the chroot. diff --git a/elf/chroot_canon.c b/elf/chroot_canon.c index 3c16a43ebb..54a6a4cc96 100644 --- a/elf/chroot_canon.c +++ b/elf/chroot_canon.c @@ -1,5 +1,5 @@ /* Return the canonical absolute name of a given file inside chroot. - Copyright (C) 1996,1997,1998,1999,2000,2001,2004,2005 + Copyright (C) 1996,1997,1998,1999,2000,2001,2004,2005,2010 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -58,9 +58,7 @@ chroot_canon (const char *chroot, const char *name) return NULL; } - rpath = malloc (chroot_len + PATH_MAX); - if (rpath == NULL) - return NULL; + rpath = xmalloc (chroot_len + PATH_MAX); rpath_limit = rpath + chroot_len + PATH_MAX; @@ -109,9 +107,7 @@ chroot_canon (const char *chroot, const char *name) new_size += end - start + 1; else new_size += PATH_MAX; - new_rpath = (char *) realloc (rpath, new_size); - if (new_rpath == NULL) - goto error; + new_rpath = (char *) xrealloc (rpath, new_size); rpath = new_rpath; rpath_limit = rpath + new_size; From 50a66cf51789d82e515951a9d378bfacc0289df7 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 3 May 2010 14:04:52 -0700 Subject: [PATCH 54/57] Fix ldconfig to handle symlinks in chroot correctly. (cherry picked from commit 7dee26605bf8627f0673f81635c38c8a565dd2b7) --- ChangeLog | 3 +++ elf/ldconfig.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 99638b6ee9..373742c428 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2010-05-03 Ulrich Drepper + [BZ #11149] + * elf/ldconfig.c (search_dir): Fix handling of symlinks in chroot. + * elf/chroot_canon.c (chroot_canon): Use xmalloc and xrealloc. * elf/ldconfig.c (parse_conf_include): Don't fall back to diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 0d07a6075a..da77d80de6 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -773,7 +773,18 @@ search_dir (const struct dir_entry *entry) { /* In case of symlink, we check if the symlink refers to a directory. */ - if (__builtin_expect (stat64 (real_file_name, &stat_buf), 0)) + char *target_name = real_file_name; + if (opt_chroot) + { + target_name = chroot_canon (opt_chroot, file_name); + if (target_name == NULL) + { + if (strstr (file_name, ".so") == NULL) + error (0, 0, _("Input file %s not found.\n"), file_name); + continue; + } + } + if (__builtin_expect (stat64 (target_name, &stat_buf), 0)) { if (opt_verbose) error (0, errno, _("Cannot stat %s"), file_name); From b9b562e8bc985e9dd7f1cc0ef8aeb32e448e9cfa Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Wed, 5 May 2010 09:59:25 -0700 Subject: [PATCH 55/57] Fix lookup of collation sequence value during regexp matching (cherry picked from commit d84acf388ed8b3f162dda0512139095bfc268beb) --- ChangeLog | 5 +++++ posix/regexec.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 373742c428..921df9b31a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-05-04 Andreas Schwab + + * posix/regexec.c (find_collation_sequence_value): Fix skipping + the wide char sequence of the collating element. + 2010-05-03 Ulrich Drepper [BZ #11149] diff --git a/posix/regexec.c b/posix/regexec.c index 7bf0c08a78..8481b618da 100644 --- a/posix/regexec.c +++ b/posix/regexec.c @@ -3998,7 +3998,7 @@ find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len) /* Skip the collation sequence value. */ idx += sizeof (uint32_t); /* Skip the wide char sequence of the collating element. */ - idx = idx + sizeof (uint32_t) * (extra[idx] + 1); + idx = idx + sizeof (uint32_t) * (*(int32_t *) (extra + idx) + 1); /* If we found the entry, return the sequence value. */ if (found) return *(uint32_t *) (extra + idx); From 32901cc363778c71ed4ddf896c054e7450f654c1 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 7 May 2010 16:23:03 -0700 Subject: [PATCH 56/57] Fix a const warning in ldconfig. (cherry picked from commit 3f7dcb2b0f9f2e771f2fd0139f032198c2d01ba9) --- ChangeLog | 4 ++++ elf/ldconfig.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 921df9b31a..5e6a6b20f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-05-07 Roland McGrath + + * elf/ldconfig.c (main): Add a const. + 2010-05-04 Andreas Schwab * posix/regexec.c (find_collation_sequence_value): Fix skipping diff --git a/elf/ldconfig.c b/elf/ldconfig.c index da77d80de6..6e71b098d4 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -1357,7 +1357,7 @@ main (int argc, char **argv) add_system_dir (LIBDIR); } - char *aux_cache_file = _PATH_LDCONFIG_AUX_CACHE; + const char *aux_cache_file = _PATH_LDCONFIG_AUX_CACHE; if (opt_chroot) { aux_cache_file = chroot_canon (opt_chroot, aux_cache_file); From 6d270188ef3fe10125b8723ed69ebdc9e90e914e Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 24 Feb 2010 19:47:09 -0800 Subject: [PATCH 57/57] Fix typos I added in malloc.c (cherry picked from commit 9d2569846c520933546353856aafea86a80d9638) --- malloc/malloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index cdd24a02a0..b1d43c6447 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3936,7 +3936,7 @@ public_vALLOc(size_t bytes) if(ar_ptr != &main_arena) { ar_ptr = &main_arena; (void)mutex_lock(&ar_ptr->mutex); - p = _int_memalign(&ar_ptr-> pagesz, bytes); + p = _int_memalign(ar_ptr, pagesz, bytes); (void)mutex_unlock(&ar_ptr->mutex); } else { #if USE_ARENAS @@ -3982,7 +3982,7 @@ public_pVALLOc(size_t bytes) if(ar_ptr != &main_arena) { ar_ptr = &main_arena; (void)mutex_lock(&ar_ptr->mutex); - p = _int_memalign(&ar_ptr-> pagesz, rounded_bytes); + p = _int_memalign(ar_ptr, pagesz, rounded_bytes); (void)mutex_unlock(&ar_ptr->mutex); } else { #if USE_ARENAS