diff options
author | Fantix King | 2014-01-14 11:13:06 +0800 |
---|---|---|
committer | Fantix King | 2015-11-13 01:19:07 +0800 |
commit | a10f01126bdc721a518b4943a314c52c7737a924 (patch) | |
tree | 1e22033d1dedc806de1b52384da6d1a4af194a5c | |
parent | 6305f83b7acbfff0841c2cd55e7126a4d914258f (diff) | |
download | aur-a10f01126bdc721a518b4943a314c52c7737a924.tar.gz |
2.17_5-1
-rw-r--r-- | .SRCINFO | 33 | ||||
-rw-r--r-- | PKGBUILD | 98 | ||||
-rw-r--r-- | glibc-2.15-fix-res_query-assert.patch | 51 | ||||
-rw-r--r-- | glibc-2.16-detect-fma.patch | 72 | ||||
-rw-r--r-- | glibc-2.16-glob-use-size_t.patch | 52 | ||||
-rw-r--r-- | glibc-2.16-rpcgen-cpp-path.patch | 68 | ||||
-rw-r--r-- | glibc-2.16-strncasecmp-segfault.patch | 65 | ||||
-rw-r--r-- | glibc-2.16-strtod-overflow.patch | 389 | ||||
-rw-r--r-- | glibc-2.16-unlock-mutex.patch | 775 | ||||
-rw-r--r-- | glibc-2.17-getaddrinfo-stack-overflow.patch | 47 | ||||
-rw-r--r-- | glibc-2.17-regexp-matcher-overrun.patch | 137 | ||||
-rw-r--r-- | glibc-2.17-sync-with-linux37.patch | 130 |
12 files changed, 366 insertions, 1551 deletions
@@ -1,34 +1,27 @@ pkgbase = libx32-glibc pkgdesc = GNU C Library for x32 ABI - pkgver = 2.16.0 - pkgrel = 5.1 + pkgver = 2.17_5 + pkgrel = 1 url = http://www.gnu.org/software/libc arch = x86_64 license = GPL license = LGPL makedepends = gcc-multilib-x32>=4.7 + provides = glibc-x32-seed conflicts = glibc-x32-seed options = !strip options = !emptydirs - source = http://ftp.gnu.org/gnu/libc/glibc-2.16.0.tar.xz - source = http://ftp.gnu.org/gnu/libc/glibc-2.16.0.tar.xz.sig - source = glibc-2.15-fix-res_query-assert.patch - source = glibc-2.16-unlock-mutex.patch - source = glibc-2.16-rpcgen-cpp-path.patch - source = glibc-2.16-strncasecmp-segfault.patch - source = glibc-2.16-strtod-overflow.patch - source = glibc-2.16-detect-fma.patch - source = glibc-2.16-glob-use-size_t.patch + source = http://ftp.gnu.org/gnu/libc/glibc-2.17.tar.xz + source = http://ftp.gnu.org/gnu/libc/glibc-2.17.tar.xz.sig + source = glibc-2.17-sync-with-linux37.patch + source = glibc-2.17-getaddrinfo-stack-overflow.patch + source = glibc-2.17-regexp-matcher-overrun.patch source = libx32-glibc.conf - md5sums = 80b181b02ab249524ec92822c0174cf7 - md5sums = 2a1221a15575820751c325ef4d2fbb90 - md5sums = 31f415b41197d85d3bbee3d1eecd06a3 - md5sums = 0afcd8c6020d61684aba63ed5f26bd91 - md5sums = ea6a43915474e8276e9361eed6a01280 - md5sums = f042d37cc8ca3459023431809039bc88 - md5sums = 61d322f7681a85d3293ada5c3ccc2c7e - md5sums = 2426f593bc43f5499c41d21b57ee0e30 - md5sums = a441353901992feda4b15a11a20140a1 + md5sums = 87bf675c8ee523ebda4803e8e1cec638 + md5sums = SKIP + md5sums = fb99380d94598cc76d793deebf630022 + md5sums = 56d5f2c09503a348281a20ae404b7de3 + md5sums = 200acc05961b084ee00dde919e64f82d md5sums = 34a4169d2bdc5a3eb83676a0831aae57 pkgname = libx32-glibc @@ -1,76 +1,47 @@ -# $Id: PKGBUILD 78834 2012-10-25 13:03:04Z heftig $ +# $Id$ +# Maintainer: Fantix King <fantix.king@gmail.com> # Upstream Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> # Contributor: Jan de Groot <jgc@archlinux.org> # Contributor: Allan McRae <allan@archlinux.org> -# Maintainer: Fantix King <fantix.king at gmail.com> # toolchain build order: linux-api-headers->glibc->binutils->gcc->binutils->glibc # NOTE: valgrind requires rebuilt with each major glibc version _pkgbasename=glibc pkgname=libx32-$_pkgbasename -pkgver=2.16.0 -pkgrel=5.1 +pkgver=2.17_5 +pkgrel=1 pkgdesc="GNU C Library for x32 ABI" arch=('x86_64') url="http://www.gnu.org/software/libc" license=('GPL' 'LGPL') makedepends=('gcc-multilib-x32>=4.7') conflicts=('glibc-x32-seed') +provides=('glibc-x32-seed') options=('!strip' '!emptydirs') -source=(http://ftp.gnu.org/gnu/libc/${_pkgbasename}-${pkgver}.tar.xz{,.sig} - glibc-2.15-fix-res_query-assert.patch - glibc-2.16-unlock-mutex.patch - glibc-2.16-rpcgen-cpp-path.patch - glibc-2.16-strncasecmp-segfault.patch - glibc-2.16-strtod-overflow.patch - glibc-2.16-detect-fma.patch - glibc-2.16-glob-use-size_t.patch +source=(http://ftp.gnu.org/gnu/libc/${_pkgbasename}-${pkgver%_*}.tar.xz{,.sig} + glibc-2.17-sync-with-linux37.patch + glibc-2.17-getaddrinfo-stack-overflow.patch + glibc-2.17-regexp-matcher-overrun.patch libx32-glibc.conf) -md5sums=('80b181b02ab249524ec92822c0174cf7' - '2a1221a15575820751c325ef4d2fbb90' - '31f415b41197d85d3bbee3d1eecd06a3' - '0afcd8c6020d61684aba63ed5f26bd91' - 'ea6a43915474e8276e9361eed6a01280' - 'f042d37cc8ca3459023431809039bc88' - '61d322f7681a85d3293ada5c3ccc2c7e' - '2426f593bc43f5499c41d21b57ee0e30' - 'a441353901992feda4b15a11a20140a1' +md5sums=('87bf675c8ee523ebda4803e8e1cec638' + 'SKIP' + 'fb99380d94598cc76d793deebf630022' + '56d5f2c09503a348281a20ae404b7de3' + '200acc05961b084ee00dde919e64f82d' '34a4169d2bdc5a3eb83676a0831aae57') build() { - cd ${srcdir}/${_pkgbasename}-${pkgver} + cd ${srcdir}/${_pkgbasename}-${pkgver%_*} - # fix res_query assertion - # http://sourceware.org/bugzilla/show_bug.cgi?id=13013 - patch -p1 -i ${srcdir}/glibc-2.15-fix-res_query-assert.patch + # combination of upstream commits 318cd0b, b540704 and fc1abbe + patch -p1 -i ${srcdir}/glibc-2.17-sync-with-linux37.patch - # prevent hang by locked mutex - # http://sourceware.org/git/?p=glibc.git;a=patch;h=c30e8edf - patch -p1 -i ${srcdir}/glibc-2.16-unlock-mutex.patch + # CVE-2013-1914 - upstream commit 1cef1b19 + patch -p1 -i ${srcdir}/glibc-2.17-getaddrinfo-stack-overflow.patch - # prevent need for /lib/cpp symlink - # http://sourceware.org/git/?p=glibc.git;a=commit;h=bf9b740a - patch -p1 -i ${srcdir}/glibc-2.16-rpcgen-cpp-path.patch - - # strncasecmp segfault on i686 - # http://sourceware.org/git/?p=glibc.git;a=commit;h=6db8f737 - patch -p1 -i ${srcdir}/glibc-2.16-strncasecmp-segfault.patch - - # strtod integer/buffer overflow - # http://sourceware.org/git/?p=glibc.git;a=commit;h=da1f4319 - patch -p1 -i ${srcdir}/glibc-2.16-strtod-overflow.patch - - # detect FMA supprt - # http://sourceware.org/git/?p=glibc.git;a=commit;h=a5cfcf08 - patch -p1 -i ${srcdir}/glibc-2.16-detect-fma.patch - - # prevent overflow in globc - # http://sourceware.org/git/?p=glibc.git;a=commit;h=6c62f108 - patch -p1 -i ${srcdir}/glibc-2.16-glob-use-size_t.patch - - # ldconfig does not need to look in /usr/lib64 or /usr/libx32 on Arch Linux - sed -i "s#add_system_dir#do_not_add_system_dir#" sysdeps/unix/sysv/linux/x86_64/dl-cache.h + # CVE-2013-0242 - upstream commit a445af0b + patch -p1 -i ${srcdir}/glibc-2.17-regexp-matcher-overrun.patch cd ${srcdir} mkdir glibc-build @@ -79,13 +50,14 @@ build() { #if [[ ${CARCH} = "i686" ]]; then # Hack to fix NPTL issues with Xen, only required on 32bit platforms # TODO: make separate glibc-xen package for i686 - export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs" + #export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs" #fi if [ -x "/opt/gcc-x32-seed/bin/gcc" ]; then echo "Using gcc-x32-seed" - export CC="/opt/gcc-x32-seed/bin/gcc -mx32 -B/opt/gcc-x32-seed/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/" - export CXX="/opt/gcc-x32-seed/bin/cpp -mx32 -B/opt/gcc-x32-seed/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/" + gcc_home=`ls -d /opt/gcc-x32-seed/lib/gcc/x86_64-unknown-linux-gnu/*/` + export CC="/opt/gcc-x32-seed/bin/gcc -mx32 -B"${gcc_home} + export CXX="/opt/gcc-x32-seed/bin/g++ -mx32 -B"${gcc_home} else echo "Using gcc-multilib-x32" export CC="gcc -mx32" @@ -93,13 +65,14 @@ build() { fi echo "slibdir=/usr/libx32" >> configparms - # remove hardening options from CFLAGS for building libraries + # remove hardening options for building libraries CFLAGS=${CFLAGS/-fstack-protector/} - CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/} + CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/} - ${srcdir}/${_pkgbasename}-${pkgver}/configure --prefix=/usr \ + ${srcdir}/${_pkgbasename}-${pkgver%_*}/configure --prefix=/usr \ --libdir=/usr/libx32 --libexecdir=/usr/libx32 \ --with-headers=/usr/include \ + --with-bugurl=https://bugs.archlinux.org/ \ --enable-add-ons=nptl,libidn \ --enable-obsolete-rpc \ --enable-kernel=2.6.32 \ @@ -123,8 +96,15 @@ build() { } check() { + # bug to file - the linker commands need to be reordered + LDFLAGS=${LDFLAGS/--as-needed,/} + cd ${srcdir}/glibc-build - make check + if [ -x "/opt/gcc-x32-seed/bin/gcc" ]; then + make check || true + else + make check + fi } package() { @@ -133,7 +113,7 @@ package() { rm -rf ${pkgdir}/{etc,sbin,usr/{bin,sbin,share},var} - # We need one 32 bit specific header file + # We need one x32 ABI specific header file find ${pkgdir}/usr/include -type f -not -name stubs-x32.h -delete # Do not strip the following files for improved debugging support @@ -144,7 +124,7 @@ package() { # libthread_db-1.0.so cd $pkgdir - strip $STRIP_BINARIES usr/libx32/getconf/* || true + strip $STRIP_BINARIES usr/libx32/getconf/* strip $STRIP_STATIC usr/libx32/*.a diff --git a/glibc-2.15-fix-res_query-assert.patch b/glibc-2.15-fix-res_query-assert.patch deleted file mode 100644 index a894da9c7954..000000000000 --- a/glibc-2.15-fix-res_query-assert.patch +++ /dev/null @@ -1,51 +0,0 @@ ---- a/resolv/res_query.c -+++ a/resolv/res_query.c -@@ -122,6 +122,7 @@ __libc_res_nquery(res_state statp, - int *resplen2) - { - HEADER *hp = (HEADER *) answer; -+ HEADER *hp2; - int n, use_malloc = 0; - u_int oflags = statp->_flags; - -@@ -239,26 +240,25 @@ __libc_res_nquery(res_state statp, - /* __libc_res_nsend might have reallocated the buffer. */ - hp = (HEADER *) *answerp; - -- /* We simplify the following tests by assigning HP to HP2. It -- is easy to verify that this is the same as ignoring all -- tests of HP2. */ -- HEADER *hp2 = answerp2 ? (HEADER *) *answerp2 : hp; -- -- if (n < (int) sizeof (HEADER) && answerp2 != NULL -- && *resplen2 > (int) sizeof (HEADER)) -+ /* We simplify the following tests by assigning HP to HP2 or -+ vice versa. It is easy to verify that this is the same as -+ ignoring all tests of HP or HP2. */ -+ if (answerp2 == NULL || *resplen2 < (int) sizeof (HEADER)) - { -- /* Special case of partial answer. */ -- assert (hp != hp2); -- hp = hp2; -+ hp2 = hp; - } -- else if (answerp2 != NULL && *resplen2 < (int) sizeof (HEADER) -- && n > (int) sizeof (HEADER)) -+ else - { -- /* Special case of partial answer. */ -- assert (hp != hp2); -- hp2 = hp; -+ hp2 = (HEADER *) *answerp2; -+ if (n < (int) sizeof (HEADER)) -+ { -+ hp = hp2; -+ } - } - -+ /* Make sure both hp and hp2 are defined */ -+ assert((hp != NULL) && (hp2 != NULL)); -+ - if ((hp->rcode != NOERROR || ntohs(hp->ancount) == 0) - && (hp2->rcode != NOERROR || ntohs(hp2->ancount) == 0)) { - #ifdef DEBUG diff --git a/glibc-2.16-detect-fma.patch b/glibc-2.16-detect-fma.patch deleted file mode 100644 index daffb976871a..000000000000 --- a/glibc-2.16-detect-fma.patch +++ /dev/null @@ -1,72 +0,0 @@ -diff --git a/sysdeps/x86_64/multiarch/init-arch.c b/sysdeps/x86_64/multiarch/init-arch.c -index fb44dcf..fed5ab8 100644 ---- a/sysdeps/x86_64/multiarch/init-arch.c -+++ b/sysdeps/x86_64/multiarch/init-arch.c -@@ -156,6 +156,9 @@ __init_cpu_features (void) - /* Determine if AVX is usable. */ - if (CPUID_AVX) - __cpu_features.feature[index_AVX_Usable] |= bit_AVX_Usable; -+ /* Determine if FMA is usable. */ -+ if (CPUID_FMA) -+ __cpu_features.feature[index_FMA_Usable] |= bit_FMA_Usable; - /* Determine if FMA4 is usable. */ - if (CPUID_FMA4) - __cpu_features.feature[index_FMA4_Usable] |= bit_FMA4_Usable; -diff --git a/sysdeps/x86_64/multiarch/init-arch.h b/sysdeps/x86_64/multiarch/init-arch.h -index 45e2651..f33f1c8 100644 ---- a/sysdeps/x86_64/multiarch/init-arch.h -+++ b/sysdeps/x86_64/multiarch/init-arch.h -@@ -22,7 +22,8 @@ - #define bit_Fast_Unaligned_Load (1 << 4) - #define bit_Prefer_PMINUB_for_stringop (1 << 5) - #define bit_AVX_Usable (1 << 6) --#define bit_FMA4_Usable (1 << 7) -+#define bit_FMA_Usable (1 << 7) -+#define bit_FMA4_Usable (1 << 8) - - /* CPUID Feature flags. */ - #define bit_SSE2 (1 << 26) -@@ -56,6 +57,7 @@ - # define index_Fast_Unaligned_Load FEATURE_INDEX_1*FEATURE_SIZE - # define index_Prefer_PMINUB_for_stringop FEATURE_INDEX_1*FEATURE_SIZE - # define index_AVX_Usable FEATURE_INDEX_1*FEATURE_SIZE -+# define index_FMA_Usable FEATURE_INDEX_1*FEATURE_SIZE - # define index_FMA4_Usable FEATURE_INDEX_1*FEATURE_SIZE - - #else /* __ASSEMBLER__ */ -@@ -131,6 +133,8 @@ extern const struct cpu_features *__get_cpu_features (void) - HAS_CPUID_FLAG (COMMON_CPUID_INDEX_1, ecx, bit_OSXSAVE) - # define CPUID_AVX \ - HAS_CPUID_FLAG (COMMON_CPUID_INDEX_1, ecx, bit_AVX) -+# define CPUID_FMA \ -+ HAS_CPUID_FLAG (COMMON_CPUID_INDEX_1, ecx, bit_FMA) - # define CPUID_FMA4 \ - HAS_CPUID_FLAG (COMMON_CPUID_INDEX_80000001, ecx, bit_FMA4) - -@@ -140,7 +144,6 @@ extern const struct cpu_features *__get_cpu_features (void) - # define HAS_SSSE3 HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_SSSE3) - # define HAS_SSE4_1 HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_SSE4_1) - # define HAS_SSE4_2 HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_SSE4_2) --# define HAS_FMA HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_FMA) - - # define index_Fast_Rep_String FEATURE_INDEX_1 - # define index_Fast_Copy_Backward FEATURE_INDEX_1 -@@ -148,6 +151,7 @@ extern const struct cpu_features *__get_cpu_features (void) - # define index_Prefer_SSE_for_memop FEATURE_INDEX_1 - # define index_Fast_Unaligned_Load FEATURE_INDEX_1 - # define index_AVX_Usable FEATURE_INDEX_1 -+# define index_FMA_Usable FEATURE_INDEX_1 - # define index_FMA4_Usable FEATURE_INDEX_1 - - # define HAS_ARCH_FEATURE(name) \ -@@ -159,6 +163,7 @@ extern const struct cpu_features *__get_cpu_features (void) - # define HAS_PREFER_SSE_FOR_MEMOP HAS_ARCH_FEATURE (Prefer_SSE_for_memop) - # define HAS_FAST_UNALIGNED_LOAD HAS_ARCH_FEATURE (Fast_Unaligned_Load) - # define HAS_AVX HAS_ARCH_FEATURE (AVX_Usable) -+# define HAS_FMA HAS_ARCH_FEATURE (FMA_Usable) - # define HAS_FMA4 HAS_ARCH_FEATURE (FMA4_Usable) - - #endif /* __ASSEMBLER__ */ --- -1.7.3.4 - diff --git a/glibc-2.16-glob-use-size_t.patch b/glibc-2.16-glob-use-size_t.patch deleted file mode 100644 index 8c5df45be7e1..000000000000 --- a/glibc-2.16-glob-use-size_t.patch +++ /dev/null @@ -1,52 +0,0 @@ -diff --git a/posix/glob.c b/posix/glob.c -index 68ea205..87d4f1b 100644 ---- a/posix/glob.c -+++ b/posix/glob.c -@@ -217,7 +217,7 @@ static int collated_compare (const void *, const void *) __THROW; - static const char * - next_brace_sub (const char *cp, int flags) - { -- unsigned int depth = 0; -+ size_t depth = 0; - while (*cp != '\0') - if ((flags & GLOB_NOESCAPE) == 0 && *cp == '\\') - { -@@ -960,7 +960,7 @@ glob (pattern, flags, errfunc, pglob) - && S_ISDIR (st.st_mode)) - : (__stat64 (dirname, &st64) == 0 && S_ISDIR (st64.st_mode))))) - { -- int newcount = pglob->gl_pathc + pglob->gl_offs; -+ size_t newcount = pglob->gl_pathc + pglob->gl_offs; - char **new_gl_pathv; - - if (newcount > UINTPTR_MAX - (1 + 1) -@@ -1059,7 +1059,7 @@ glob (pattern, flags, errfunc, pglob) - appending the results to PGLOB. */ - for (i = 0; i < dirs.gl_pathc; ++i) - { -- int old_pathc; -+ size_t old_pathc; - - #ifdef SHELL - { -@@ -1114,7 +1114,7 @@ glob (pattern, flags, errfunc, pglob) - /* No matches. */ - if (flags & GLOB_NOCHECK) - { -- int newcount = pglob->gl_pathc + pglob->gl_offs; -+ size_t newcount = pglob->gl_pathc + pglob->gl_offs; - char **new_gl_pathv; - - if (newcount > UINTPTR_MAX - 2 -@@ -1158,7 +1158,7 @@ glob (pattern, flags, errfunc, pglob) - } - else - { -- int old_pathc = pglob->gl_pathc; -+ size_t old_pathc = pglob->gl_pathc; - int orig_flags = flags; - - if (meta & 2) --- -1.7.3.4 - diff --git a/glibc-2.16-rpcgen-cpp-path.patch b/glibc-2.16-rpcgen-cpp-path.patch deleted file mode 100644 index 822b57294b3a..000000000000 --- a/glibc-2.16-rpcgen-cpp-path.patch +++ /dev/null @@ -1,68 +0,0 @@ -diff --git a/sunrpc/rpc_main.c b/sunrpc/rpc_main.c -index 06d951a..2103b10 100644 ---- a/sunrpc/rpc_main.c -+++ b/sunrpc/rpc_main.c -@@ -75,12 +75,9 @@ struct commandline - - static const char *cmdname; - --#define SVR4_CPP "/usr/ccs/lib/cpp" --#define SUNOS_CPP "/lib/cpp" -- - static const char *svcclosetime = "120"; - static int cppDefined; /* explicit path for C preprocessor */ --static const char *CPP = SUNOS_CPP; -+static const char *CPP = "/lib/cpp"; - static const char CPPFLAGS[] = "-C"; - static char *pathbuf; - static int cpp_pid; -@@ -327,23 +324,17 @@ find_cpp (void) - { - struct stat buf; - -- if (stat (CPP, &buf) < 0) -- { /* /lib/cpp or explicit cpp does not exist */ -- if (cppDefined) -- { -- fprintf (stderr, _ ("cannot find C preprocessor: %s \n"), CPP); -- crash (); -- } -- else -- { /* try the other one */ -- CPP = SVR4_CPP; -- if (stat (CPP, &buf) < 0) -- { /* can't find any cpp */ -- fputs (_ ("cannot find any C preprocessor (cpp)\n"), stdout); -- crash (); -- } -- } -+ if (stat (CPP, &buf) == 0) -+ return; -+ -+ if (cppDefined) /* user specified cpp but it does not exist */ -+ { -+ fprintf (stderr, _ ("cannot find C preprocessor: %s\n"), CPP); -+ crash (); - } -+ -+ /* fall back to system CPP */ -+ CPP = "cpp"; - } - - /* -@@ -374,8 +365,13 @@ open_input (const char *infile, const char *define) - close (1); - dup2 (pd[1], 1); - close (pd[0]); -- execv (arglist[0], (char **) arglist); -- perror ("execv"); -+ execvp (arglist[0], (char **) arglist); -+ if (errno == ENOENT) -+ { -+ fprintf (stderr, _ ("cannot find C preprocessor: %s\n"), CPP); -+ exit (1); -+ } -+ perror ("execvp"); - exit (1); - case -1: - perror ("fork"); diff --git a/glibc-2.16-strncasecmp-segfault.patch b/glibc-2.16-strncasecmp-segfault.patch deleted file mode 100644 index ce91bbe82ae1..000000000000 --- a/glibc-2.16-strncasecmp-segfault.patch +++ /dev/null @@ -1,65 +0,0 @@ -diff --git a/string/test-strncasecmp.c b/string/test-strncasecmp.c -index 6c17530..acfe668 100644 ---- a/string/test-strncasecmp.c -+++ b/string/test-strncasecmp.c -@@ -1,5 +1,5 @@ - /* Test and measure strncasecmp functions. -- Copyright (C) 1999, 2002, 2003, 2005, 2010 Free Software Foundation, Inc. -+ Copyright (C) 1999-2012 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Written by Jakub Jelinek <jakub@redhat.com>, 1999. - -@@ -251,9 +251,9 @@ do_random_tests (void) - } - } - -- -+/* Regression test for BZ #12205 */ - static void --check1 (void) -+bz12205 (void) - { - static char cp [4096+16] __attribute__ ((aligned(4096))); - static char gotrel[4096] __attribute__ ((aligned(4096))); -@@ -270,6 +270,15 @@ check1 (void) - check_result (impl, s1, s2, n, exp_result); - } - -+/* Regression test for BZ #14195 */ -+static void -+bz14195 (void) -+{ -+ const char *empty_string = ""; -+ FOR_EACH_IMPL (impl, 0) -+ check_result (impl, empty_string, "", 5, 0); -+} -+ - int - test_main (void) - { -@@ -277,7 +286,8 @@ test_main (void) - - test_init (); - -- check1 (); -+ bz12205 (); -+ bz14195 (); - - printf ("%23s", ""); - FOR_EACH_IMPL (impl, 0) -diff --git a/sysdeps/i386/i686/multiarch/strcmp-ssse3.S b/sysdeps/i386/i686/multiarch/strcmp-ssse3.S -index 5e6321e..9735ad0 100644 ---- a/sysdeps/i386/i686/multiarch/strcmp-ssse3.S -+++ b/sysdeps/i386/i686/multiarch/strcmp-ssse3.S -@@ -2445,7 +2445,7 @@ L(less16bytes_sncmp): - # endif - jne L(neq_sncmp) - test %cl, %cl -- je L(eq) -+ je L(eq_sncmp) - - cmp $1, REM - je L(eq_sncmp) --- -1.7.3.4 - diff --git a/glibc-2.16-strtod-overflow.patch b/glibc-2.16-strtod-overflow.patch deleted file mode 100644 index 526296325dc5..000000000000 --- a/glibc-2.16-strtod-overflow.patch +++ /dev/null @@ -1,389 +0,0 @@ -diff --git a/stdlib/Makefile b/stdlib/Makefile -index f7811c5..79c9acb 100644 ---- a/stdlib/Makefile -+++ b/stdlib/Makefile -@@ -68,7 +68,8 @@ tests := tst-strtol tst-strtod testmb testrand testsort testdiv \ - tst-atof1 tst-atof2 tst-strtod2 tst-strtod3 tst-rand48-2 \ - tst-makecontext tst-strtod4 tst-strtod5 tst-qsort2 \ - tst-makecontext2 tst-strtod6 tst-unsetenv1 \ -- tst-makecontext3 bug-getcontext bug-fmtmsg1 -+ tst-makecontext3 bug-getcontext bug-fmtmsg1 \ -+ tst-strtod-overflow - - include ../Makeconfig - -diff --git a/stdlib/strtod_l.c b/stdlib/strtod_l.c -index 2166a08..a8a7ea8 100644 ---- a/stdlib/strtod_l.c -+++ b/stdlib/strtod_l.c -@@ -60,6 +60,7 @@ extern unsigned long long int ____strtoull_l_internal (const char *, char **, - #include <math.h> - #include <stdlib.h> - #include <string.h> -+#include <stdint.h> - - /* The gmp headers need some configuration frobs. */ - #define HAVE_ALLOCA 1 -@@ -72,7 +73,6 @@ extern unsigned long long int ____strtoull_l_internal (const char *, char **, - #include "longlong.h" - #include "fpioconst.h" - --#define NDEBUG 1 - #include <assert.h> - - -@@ -174,19 +174,19 @@ extern const mp_limb_t _tens_in_limb[MAX_DIG_PER_LIMB + 1]; - /* Return a floating point number of the needed type according to the given - multi-precision number after possible rounding. */ - static FLOAT --round_and_return (mp_limb_t *retval, int exponent, int negative, -+round_and_return (mp_limb_t *retval, intmax_t exponent, int negative, - mp_limb_t round_limb, mp_size_t round_bit, int more_bits) - { - if (exponent < MIN_EXP - 1) - { -- mp_size_t shift = MIN_EXP - 1 - exponent; -- -- if (shift > MANT_DIG) -+ if (exponent < MIN_EXP - 1 - MANT_DIG) - { - __set_errno (ERANGE); - return 0.0; - } - -+ mp_size_t shift = MIN_EXP - 1 - exponent; -+ - more_bits |= (round_limb & ((((mp_limb_t) 1) << round_bit) - 1)) != 0; - if (shift == MANT_DIG) - /* This is a special case to handle the very seldom case where -@@ -233,6 +233,9 @@ round_and_return (mp_limb_t *retval, int exponent, int negative, - __set_errno (ERANGE); - } - -+ if (exponent > MAX_EXP) -+ goto overflow; -+ - if ((round_limb & (((mp_limb_t) 1) << round_bit)) != 0 - && (more_bits || (retval[0] & 1) != 0 - || (round_limb & ((((mp_limb_t) 1) << round_bit) - 1)) != 0)) -@@ -258,6 +261,7 @@ round_and_return (mp_limb_t *retval, int exponent, int negative, - } - - if (exponent > MAX_EXP) -+ overflow: - return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL; - - return MPN2FLOAT (retval, exponent, negative); -@@ -271,7 +275,7 @@ round_and_return (mp_limb_t *retval, int exponent, int negative, - factor for the resulting number (see code) multiply by it. */ - static const STRING_TYPE * - str_to_mpn (const STRING_TYPE *str, int digcnt, mp_limb_t *n, mp_size_t *nsize, -- int *exponent -+ intmax_t *exponent - #ifndef USE_WIDE_CHAR - , const char *decimal, size_t decimal_len, const char *thousands - #endif -@@ -301,6 +305,7 @@ str_to_mpn (const STRING_TYPE *str, int digcnt, mp_limb_t *n, mp_size_t *nsize, - cy += __mpn_add_1 (n, n, *nsize, low); - if (cy != 0) - { -+ assert (*nsize < MPNSIZE); - n[*nsize] = cy; - ++(*nsize); - } -@@ -335,7 +340,7 @@ str_to_mpn (const STRING_TYPE *str, int digcnt, mp_limb_t *n, mp_size_t *nsize, - } - while (--digcnt > 0); - -- if (*exponent > 0 && cnt + *exponent <= MAX_DIG_PER_LIMB) -+ if (*exponent > 0 && *exponent <= MAX_DIG_PER_LIMB - cnt) - { - low *= _tens_in_limb[*exponent]; - start = _tens_in_limb[cnt + *exponent]; -@@ -355,7 +360,10 @@ str_to_mpn (const STRING_TYPE *str, int digcnt, mp_limb_t *n, mp_size_t *nsize, - cy = __mpn_mul_1 (n, n, *nsize, start); - cy += __mpn_add_1 (n, n, *nsize, low); - if (cy != 0) -- n[(*nsize)++] = cy; -+ { -+ assert (*nsize < MPNSIZE); -+ n[(*nsize)++] = cy; -+ } - } - - return str; -@@ -413,7 +421,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) - { - int negative; /* The sign of the number. */ - MPN_VAR (num); /* MP representation of the number. */ -- int exponent; /* Exponent of the number. */ -+ intmax_t exponent; /* Exponent of the number. */ - - /* Numbers starting `0X' or `0x' have to be processed with base 16. */ - int base = 10; -@@ -435,7 +443,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) - /* Points at the character following the integer and fractional digits. */ - const STRING_TYPE *expp; - /* Total number of digit and number of digits in integer part. */ -- int dig_no, int_no, lead_zero; -+ size_t dig_no, int_no, lead_zero; - /* Contains the last character read. */ - CHAR_TYPE c; - -@@ -767,7 +775,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) - are all or any is really a fractional digit will be decided - later. */ - int_no = dig_no; -- lead_zero = int_no == 0 ? -1 : 0; -+ lead_zero = int_no == 0 ? (size_t) -1 : 0; - - /* Read the fractional digits. A special case are the 'american - style' numbers like `16.' i.e. with decimal point but without -@@ -789,12 +797,13 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) - (base == 16 && ({ CHAR_TYPE lo = TOLOWER (c); - lo >= L_('a') && lo <= L_('f'); }))) - { -- if (c != L_('0') && lead_zero == -1) -+ if (c != L_('0') && lead_zero == (size_t) -1) - lead_zero = dig_no - int_no; - ++dig_no; - c = *++cp; - } - } -+ assert (dig_no <= (uintmax_t) INTMAX_MAX); - - /* Remember start of exponent (if any). */ - expp = cp; -@@ -817,24 +826,80 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) - - if (c >= L_('0') && c <= L_('9')) - { -- int exp_limit; -+ intmax_t exp_limit; - - /* Get the exponent limit. */ - if (base == 16) -- exp_limit = (exp_negative ? -- -MIN_EXP + MANT_DIG + 4 * int_no : -- MAX_EXP - 4 * int_no + 4 * lead_zero + 3); -+ { -+ if (exp_negative) -+ { -+ assert (int_no <= (uintmax_t) (INTMAX_MAX -+ + MIN_EXP - MANT_DIG) / 4); -+ exp_limit = -MIN_EXP + MANT_DIG + 4 * (intmax_t) int_no; -+ } -+ else -+ { -+ if (int_no) -+ { -+ assert (lead_zero == 0 -+ && int_no <= (uintmax_t) INTMAX_MAX / 4); -+ exp_limit = MAX_EXP - 4 * (intmax_t) int_no + 3; -+ } -+ else if (lead_zero == (size_t) -1) -+ { -+ /* The number is zero and this limit is -+ arbitrary. */ -+ exp_limit = MAX_EXP + 3; -+ } -+ else -+ { -+ assert (lead_zero -+ <= (uintmax_t) (INTMAX_MAX - MAX_EXP - 3) / 4); -+ exp_limit = (MAX_EXP -+ + 4 * (intmax_t) lead_zero -+ + 3); -+ } -+ } -+ } - else -- exp_limit = (exp_negative ? -- -MIN_10_EXP + MANT_DIG + int_no : -- MAX_10_EXP - int_no + lead_zero + 1); -+ { -+ if (exp_negative) -+ { -+ assert (int_no -+ <= (uintmax_t) (INTMAX_MAX + MIN_10_EXP - MANT_DIG)); -+ exp_limit = -MIN_10_EXP + MANT_DIG + (intmax_t) int_no; -+ } -+ else -+ { -+ if (int_no) -+ { -+ assert (lead_zero == 0 -+ && int_no <= (uintmax_t) INTMAX_MAX); -+ exp_limit = MAX_10_EXP - (intmax_t) int_no + 1; -+ } -+ else if (lead_zero == (size_t) -1) -+ { -+ /* The number is zero and this limit is -+ arbitrary. */ -+ exp_limit = MAX_10_EXP + 1; -+ } -+ else -+ { -+ assert (lead_zero -+ <= (uintmax_t) (INTMAX_MAX - MAX_10_EXP - 1)); -+ exp_limit = MAX_10_EXP + (intmax_t) lead_zero + 1; -+ } -+ } -+ } -+ -+ if (exp_limit < 0) -+ exp_limit = 0; - - do - { -- exponent *= 10; -- exponent += c - L_('0'); -- -- if (__builtin_expect (exponent > exp_limit, 0)) -+ if (__builtin_expect ((exponent > exp_limit / 10 -+ || (exponent == exp_limit / 10 -+ && c - L_('0') > exp_limit % 10)), 0)) - /* The exponent is too large/small to represent a valid - number. */ - { -@@ -843,7 +908,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) - /* We have to take care for special situation: a joker - might have written "0.0e100000" which is in fact - zero. */ -- if (lead_zero == -1) -+ if (lead_zero == (size_t) -1) - result = negative ? -0.0 : 0.0; - else - { -@@ -862,6 +927,9 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) - /* NOTREACHED */ - } - -+ exponent *= 10; -+ exponent += c - L_('0'); -+ - c = *++cp; - } - while (c >= L_('0') && c <= L_('9')); -@@ -930,7 +998,14 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) - } - #endif - startp += lead_zero + decimal_len; -- exponent -= base == 16 ? 4 * lead_zero : lead_zero; -+ assert (lead_zero <= (base == 16 -+ ? (uintmax_t) INTMAX_MAX / 4 -+ : (uintmax_t) INTMAX_MAX)); -+ assert (lead_zero <= (base == 16 -+ ? ((uintmax_t) exponent -+ - (uintmax_t) INTMAX_MIN) / 4 -+ : ((uintmax_t) exponent - (uintmax_t) INTMAX_MIN))); -+ exponent -= base == 16 ? 4 * (intmax_t) lead_zero : (intmax_t) lead_zero; - dig_no -= lead_zero; - } - -@@ -972,7 +1047,10 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) - } - - /* Adjust the exponent for the bits we are shifting in. */ -- exponent += bits - 1 + (int_no - 1) * 4; -+ assert (int_no <= (uintmax_t) (exponent < 0 -+ ? (INTMAX_MAX - bits + 1) / 4 -+ : (INTMAX_MAX - exponent - bits + 1) / 4)); -+ exponent += bits - 1 + ((intmax_t) int_no - 1) * 4; - - while (--dig_no > 0 && idx >= 0) - { -@@ -1024,13 +1102,15 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) - really integer digits or belong to the fractional part; i.e. we normalize - 123e-2 to 1.23. */ - { -- register int incr = (exponent < 0 ? MAX (-int_no, exponent) -- : MIN (dig_no - int_no, exponent)); -+ register intmax_t incr = (exponent < 0 -+ ? MAX (-(intmax_t) int_no, exponent) -+ : MIN ((intmax_t) dig_no - (intmax_t) int_no, -+ exponent)); - int_no += incr; - exponent -= incr; - } - -- if (__builtin_expect (int_no + exponent > MAX_10_EXP + 1, 0)) -+ if (__builtin_expect (exponent > MAX_10_EXP + 1 - (intmax_t) int_no, 0)) - { - __set_errno (ERANGE); - return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL; -@@ -1215,7 +1295,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) - digits we should have enough bits for the result. The remaining - decimal digits give us the information that more bits are following. - This can be used while rounding. (Two added as a safety margin.) */ -- if (dig_no - int_no > (MANT_DIG - bits + 2) / 3 + 2) -+ if ((intmax_t) dig_no > (intmax_t) int_no + (MANT_DIG - bits + 2) / 3 + 2) - { - dig_no = int_no + (MANT_DIG - bits + 2) / 3 + 2; - more_bits = 1; -@@ -1223,7 +1303,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group, loc) - else - more_bits = 0; - -- neg_exp = dig_no - int_no - exponent; -+ neg_exp = (intmax_t) dig_no - (intmax_t) int_no - exponent; - - /* Construct the denominator. */ - densize = 0; -diff --git a/stdlib/tst-strtod-overflow.c b/stdlib/tst-strtod-overflow.c -new file mode 100644 -index 0000000..668d55b ---- /dev/null -+++ b/stdlib/tst-strtod-overflow.c -@@ -0,0 +1,48 @@ -+/* Test for integer/buffer overflow in strtod. -+ Copyright (C) 2012 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 -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ <http://www.gnu.org/licenses/>. */ -+ -+#include <stdio.h> -+#include <stdlib.h> -+#include <string.h> -+ -+#define EXPONENT "e-2147483649" -+#define SIZE 214748364 -+ -+static int -+do_test (void) -+{ -+ char *p = malloc (1 + SIZE + sizeof (EXPONENT)); -+ if (p == NULL) -+ { -+ puts ("malloc failed, cannot test for overflow"); -+ return 0; -+ } -+ p[0] = '1'; -+ memset (p + 1, '0', SIZE); -+ memcpy (p + 1 + SIZE, EXPONENT, sizeof (EXPONENT)); -+ double d = strtod (p, NULL); -+ if (d != 0) -+ { -+ printf ("strtod returned wrong value: %a\n", d); -+ return 1; -+ } -+ return 0; -+} -+ -+#define TEST_FUNCTION do_test () -+#include "../test-skeleton.c" --- -1.7.3.4 - diff --git a/glibc-2.16-unlock-mutex.patch b/glibc-2.16-unlock-mutex.patch deleted file mode 100644 index 0649d36423c0..000000000000 --- a/glibc-2.16-unlock-mutex.patch +++ /dev/null @@ -1,775 +0,0 @@ ---- a/nptl/Makefile -+++ b/nptl/Makefile -@@ -206,7 +206,7 @@ tests = tst-typesizes \ - tst-cond1 tst-cond2 tst-cond3 tst-cond4 tst-cond5 tst-cond6 tst-cond7 \ - tst-cond8 tst-cond9 tst-cond10 tst-cond11 tst-cond12 tst-cond13 \ - tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 tst-cond19 \ -- tst-cond20 tst-cond21 tst-cond22 tst-cond23 \ -+ tst-cond20 tst-cond21 tst-cond22 tst-cond23 tst-cond24 \ - tst-robust1 tst-robust2 tst-robust3 tst-robust4 tst-robust5 \ - tst-robust6 tst-robust7 tst-robust8 tst-robust9 \ - tst-robustpi1 tst-robustpi2 tst-robustpi3 tst-robustpi4 tst-robustpi5 \ -@@ -274,6 +275,7 @@ gen-as-const-headers = pthread-errnos.sym - - LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst - -+LDFLAGS-tst-cond24 = $(no-as-needed) -lrt - - include ../Makeconfig - -diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S -index d14d7de..6761c13 100644 ---- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S -+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S -@@ -212,8 +212,23 @@ __pthread_cond_timedwait: - sete 24(%esp) - je 41f - -- /* Normal and PI futexes dont mix. Use normal futex functions only -- if the kernel does not support the PI futex functions. */ -+ /* When a futex syscall with FUTEX_WAIT_REQUEUE_PI returns -+ successfully, it has already locked the mutex for us and the -+ pi_flag (24(%esp)) is set to denote that fact. However, if another -+ thread changed the futex value before we entered the wait, the -+ syscall may return an EAGAIN and the mutex is not locked. We go -+ ahead with a success anyway since later we look at the pi_flag to -+ decide if we got the mutex or not. The sequence numbers then make -+ sure that only one of the threads actually wake up. We retry using -+ normal FUTEX_WAIT only if the kernel returned ENOSYS, since normal -+ and PI futexes don't mix. -+ -+ Note that we don't check for EAGAIN specifically; we assume that the -+ only other error the futex function could return is EAGAIN (barring -+ the ETIMEOUT of course, for the timeout case in futex) since -+ anything else would mean an error in our function. It is too -+ expensive to do that check for every call (which is quite common in -+ case of a large number of threads), so it has been skipped. */ - cmpl $-ENOSYS, %eax - jne 41f - xorl %ecx, %ecx -@@ -273,9 +288,24 @@ __pthread_cond_timedwait: - jne 9f - - 15: cmpl $-ETIMEDOUT, %esi -- jne 8b -+ je 28f -+ -+ /* We need to go back to futex_wait. If we're using requeue_pi, then -+ release the mutex we had acquired and go back. */ -+ movl 24(%esp), %edx -+ test %edx, %edx -+ jz 8b -+ -+ /* Adjust the mutex values first and then unlock it. The unlock -+ should always succeed or else the kernel did not lock the mutex -+ correctly. */ -+ movl dep_mutex(%ebx), %eax -+ call __pthread_mutex_cond_lock_adjust -+ xorl %edx, %edx -+ call __pthread_mutex_unlock_usercnt -+ jmp 8b - -- addl $1, wakeup_seq(%ebx) -+28: addl $1, wakeup_seq(%ebx) - adcl $0, wakeup_seq+4(%ebx) - addl $1, cond_futex(%ebx) - movl $ETIMEDOUT, %esi -diff --git a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S -index 366de69..0af06ac 100644 ---- a/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S -+++ b/nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S -@@ -136,7 +136,6 @@ __pthread_cond_wait: - cmpl $PI_BIT, %eax - jne 18f - --90: - movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %ecx - movl %ebp, %edx - xorl %esi, %esi -@@ -152,11 +151,22 @@ __pthread_cond_wait: - sete 16(%esp) - je 19f - -- cmpl $-EAGAIN, %eax -- je 91f -- -- /* Normal and PI futexes dont mix. Use normal futex functions only -- if the kernel does not support the PI futex functions. */ -+ /* When a futex syscall with FUTEX_WAIT_REQUEUE_PI returns -+ successfully, it has already locked the mutex for us and the -+ pi_flag (16(%esp)) is set to denote that fact. However, if another -+ thread changed the futex value before we entered the wait, the -+ syscall may return an EAGAIN and the mutex is not locked. We go -+ ahead with a success anyway since later we look at the pi_flag to -+ decide if we got the mutex or not. The sequence numbers then make -+ sure that only one of the threads actually wake up. We retry using -+ normal FUTEX_WAIT only if the kernel returned ENOSYS, since normal -+ and PI futexes don't mix. -+ -+ Note that we don't check for EAGAIN specifically; we assume that the -+ only other error the futex function could return is EAGAIN since -+ anything else would mean an error in our function. It is too -+ expensive to do that check for every call (which is quite common in -+ case of a large number of threads), so it has been skipped. */ - cmpl $-ENOSYS, %eax - jne 19f - xorl %ecx, %ecx -@@ -206,12 +216,12 @@ __pthread_cond_wait: - cmpl 8(%esp), %edx - jne 7f - cmpl 4(%esp), %edi -- je 8b -+ je 22f - - 7: cmpl %ecx, %edx - jne 9f - cmp %eax, %edi -- je 8b -+ je 22f - - 9: addl $1, woken_seq(%ebx) - adcl $0, woken_seq+4(%ebx) -@@ -287,6 +297,22 @@ __pthread_cond_wait: - jmp 20b - - cfi_adjust_cfa_offset(-FRAME_SIZE); -+ -+ /* We need to go back to futex_wait. If we're using requeue_pi, then -+ release the mutex we had acquired and go back. */ -+22: movl 16(%esp), %edx -+ test %edx, %edx -+ jz 8b -+ -+ /* Adjust the mutex values first and then unlock it. The unlock -+ should always succeed or else the kernel did not lock the mutex -+ correctly. */ -+ movl dep_mutex(%ebx), %eax -+ call __pthread_mutex_cond_lock_adjust -+ xorl %edx, %edx -+ call __pthread_mutex_unlock_usercnt -+ jmp 8b -+ - /* Initial locking failed. */ - 1: - #if cond_lock == 0 -@@ -400,77 +426,6 @@ __pthread_cond_wait: - call __lll_unlock_wake - jmp 11b - --91: --.LcleanupSTART2: -- /* FUTEX_WAIT_REQUEUE_PI returned EAGAIN. We need to -- call it again. */ -- -- /* Get internal lock. */ -- movl $1, %edx -- xorl %eax, %eax -- LOCK --#if cond_lock == 0 -- cmpxchgl %edx, (%ebx) --#else -- cmpxchgl %edx, cond_lock(%ebx) --#endif -- jz 92f -- --#if cond_lock == 0 -- movl %ebx, %edx --#else -- leal cond_lock(%ebx), %edx --#endif --#if (LLL_SHARED-LLL_PRIVATE) > 255 -- xorl %ecx, %ecx --#endif -- cmpl $-1, dep_mutex(%ebx) -- setne %cl -- subl $1, %ecx -- andl $(LLL_SHARED-LLL_PRIVATE), %ecx --#if LLL_PRIVATE != 0 -- addl $LLL_PRIVATE, %ecx --#endif -- call __lll_lock_wait -- --92: -- /* Increment the cond_futex value again, so it can be used as a new -- expected value. */ -- addl $1, cond_futex(%ebx) -- movl cond_futex(%ebx), %ebp -- -- /* Unlock. */ -- LOCK --#if cond_lock == 0 -- subl $1, (%ebx) --#else -- subl $1, cond_lock(%ebx) --#endif -- je 93f --#if cond_lock == 0 -- movl %ebx, %eax --#else -- leal cond_lock(%ebx), %eax --#endif --#if (LLL_SHARED-LLL_PRIVATE) > 255 -- xorl %ecx, %ecx --#endif -- cmpl $-1, dep_mutex(%ebx) -- setne %cl -- subl $1, %ecx -- andl $(LLL_SHARED-LLL_PRIVATE), %ecx --#if LLL_PRIVATE != 0 -- addl $LLL_PRIVATE, %ecx --#endif -- call __lll_unlock_wake -- --93: -- /* Set the rest of SYS_futex args for FUTEX_WAIT_REQUEUE_PI. */ -- xorl %ecx, %ecx -- movl dep_mutex(%ebx), %edi -- jmp 90b --.LcleanupEND2: -- - .size __pthread_cond_wait, .-__pthread_cond_wait - versioned_symbol (libpthread, __pthread_cond_wait, pthread_cond_wait, - GLIBC_2_3_2) -@@ -651,10 +606,6 @@ __condvar_w_cleanup: - .long .LcleanupEND-.Lsub_cond_futex - .long __condvar_w_cleanup-.LSTARTCODE - .uleb128 0 -- .long .LcleanupSTART2-.LSTARTCODE -- .long .LcleanupEND2-.LcleanupSTART2 -- .long __condvar_w_cleanup-.LSTARTCODE -- .uleb128 0 - .long .LcallUR-.LSTARTCODE - .long .LENDCODE-.LcallUR - .long 0 -diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S -index a1c8ca8..b669abb 100644 ---- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S -+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S -@@ -103,7 +103,7 @@ __pthread_cond_timedwait: - mov %RSI_LP, dep_mutex(%rdi) - - 22: -- xorl %r15d, %r15d -+ xorb %r15b, %r15b - - #ifndef __ASSUME_FUTEX_CLOCK_REALTIME - # ifdef PIC -@@ -190,18 +190,39 @@ __pthread_cond_timedwait: - movl $SYS_futex, %eax - syscall - -- movl $1, %r15d -+ cmpl $0, %eax -+ sete %r15b -+ - #ifdef __ASSUME_REQUEUE_PI - jmp 62f - #else -- cmpq $-4095, %rax -- jnae 62f -+ je 62f -+ -+ /* When a futex syscall with FUTEX_WAIT_REQUEUE_PI returns -+ successfully, it has already locked the mutex for us and the -+ pi_flag (%r15b) is set to denote that fact. However, if another -+ thread changed the futex value before we entered the wait, the -+ syscall may return an EAGAIN and the mutex is not locked. We go -+ ahead with a success anyway since later we look at the pi_flag to -+ decide if we got the mutex or not. The sequence numbers then make -+ sure that only one of the threads actually wake up. We retry using -+ normal FUTEX_WAIT only if the kernel returned ENOSYS, since normal -+ and PI futexes don't mix. -+ -+ Note that we don't check for EAGAIN specifically; we assume that the -+ only other error the futex function could return is EAGAIN (barring -+ the ETIMEOUT of course, for the timeout case in futex) since -+ anything else would mean an error in our function. It is too -+ expensive to do that check for every call (which is quite common in -+ case of a large number of threads), so it has been skipped. */ -+ cmpl $-ENOSYS, %eax -+ jne 62f - - subq $cond_futex, %rdi - #endif - - 61: movl $(FUTEX_WAIT_BITSET|FUTEX_PRIVATE_FLAG), %esi --60: xorl %r15d, %r15d -+60: xorb %r15b, %r15b - xorl %eax, %eax - /* The following only works like this because we only support - two clocks, represented using a single bit. */ -@@ -248,7 +269,23 @@ __pthread_cond_timedwait: - ja 39f - - 45: cmpq $-ETIMEDOUT, %r14 -- jne 38b -+ je 99f -+ -+ /* We need to go back to futex_wait. If we're using requeue_pi, then -+ release the mutex we had acquired and go back. */ -+ test %r15b, %r15b -+ jz 38b -+ -+ /* Adjust the mutex values first and then unlock it. The unlock -+ should always succeed or else the kernel did not lock the -+ mutex correctly. */ -+ movq %r8, %rdi -+ callq __pthread_mutex_cond_lock_adjust -+ xorl %esi, %esi -+ callq __pthread_mutex_unlock_usercnt -+ /* Reload cond_var. */ -+ movq 8(%rsp), %rdi -+ jmp 38b - - 99: incq wakeup_seq(%rdi) - incl cond_futex(%rdi) -@@ -298,7 +335,7 @@ __pthread_cond_timedwait: - /* If requeue_pi is used the kernel performs the locking of the - mutex. */ - 41: movq 16(%rsp), %rdi -- testl %r15d, %r15d -+ testb %r15b, %r15b - jnz 64f - - callq __pthread_mutex_cond_lock -diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S -index 6194852..ec403cd 100644 ---- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S -+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S -@@ -136,19 +136,36 @@ __pthread_cond_wait: - cmpl $PI_BIT, %eax - jne 61f - --90: - movl $(FUTEX_WAIT_REQUEUE_PI|FUTEX_PRIVATE_FLAG), %esi - movl $SYS_futex, %eax - syscall - -- movl $1, %r8d -- cmpq $-EAGAIN, %rax -- je 91f -+ cmpl $0, %eax -+ sete %r8b -+ - #ifdef __ASSUME_REQUEUE_PI - jmp 62f - #else -- cmpq $-4095, %rax -- jnae 62f -+ je 62f -+ -+ /* When a futex syscall with FUTEX_WAIT_REQUEUE_PI returns -+ successfully, it has already locked the mutex for us and the -+ pi_flag (%r8b) is set to denote that fact. However, if another -+ thread changed the futex value before we entered the wait, the -+ syscall may return an EAGAIN and the mutex is not locked. We go -+ ahead with a success anyway since later we look at the pi_flag to -+ decide if we got the mutex or not. The sequence numbers then make -+ sure that only one of the threads actually wake up. We retry using -+ normal FUTEX_WAIT only if the kernel returned ENOSYS, since normal -+ and PI futexes don't mix. -+ -+ Note that we don't check for EAGAIN specifically; we assume that the -+ only other error the futex function could return is EAGAIN since -+ anything else would mean an error in our function. It is too -+ expensive to do that check for every call (which is quite common in -+ case of a large number of threads), so it has been skipped. */ -+ cmpl $-ENOSYS, %eax -+ jne 62f - - # ifndef __ASSUME_PRIVATE_FUTEX - movl $FUTEX_WAIT, %esi -@@ -161,7 +178,7 @@ __pthread_cond_wait: - #else - orl %fs:PRIVATE_FUTEX, %esi - #endif --60: xorl %r8d, %r8d -+60: xorb %r8b, %r8b - movl $SYS_futex, %eax - syscall - -@@ -191,10 +208,10 @@ __pthread_cond_wait: - jne 16f - - cmpq 24(%rsp), %r9 -- jbe 8b -+ jbe 19f - - cmpq %rax, %r9 -- jna 8b -+ jna 19f - - incq woken_seq(%rdi) - -@@ -236,7 +253,7 @@ __pthread_cond_wait: - /* If requeue_pi is used the kernel performs the locking of the - mutex. */ - 11: movq 16(%rsp), %rdi -- testl %r8d, %r8d -+ testb %r8b, %r8b - jnz 18f - - callq __pthread_mutex_cond_lock -@@ -253,6 +270,23 @@ __pthread_cond_wait: - xorl %eax, %eax - jmp 14b - -+ /* We need to go back to futex_wait. If we're using requeue_pi, then -+ release the mutex we had acquired and go back. */ -+19: testb %r8b, %r8b -+ jz 8b -+ -+ /* Adjust the mutex values first and then unlock it. The unlock -+ should always succeed or else the kernel did not lock the mutex -+ correctly. */ -+ movq 16(%rsp), %rdi -+ callq __pthread_mutex_cond_lock_adjust -+ movq %rdi, %r8 -+ xorl %esi, %esi -+ callq __pthread_mutex_unlock_usercnt -+ /* Reload cond_var. */ -+ movq 8(%rsp), %rdi -+ jmp 8b -+ - /* Initial locking failed. */ - 1: - #if cond_lock != 0 -@@ -331,69 +365,6 @@ __pthread_cond_wait: - 13: movq %r10, %rax - jmp 14b - --91: --.LcleanupSTART2: -- /* FUTEX_WAIT_REQUEUE_PI returned EAGAIN. We need to -- call it again. */ -- movq 8(%rsp), %rdi -- -- /* Get internal lock. */ -- movl $1, %esi -- xorl %eax, %eax -- LOCK --#if cond_lock == 0 -- cmpxchgl %esi, (%rdi) --#else -- cmpxchgl %esi, cond_lock(%rdi) --#endif -- jz 92f -- --#if cond_lock != 0 -- addq $cond_lock, %rdi --#endif -- LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) -- movl $LLL_PRIVATE, %eax -- movl $LLL_SHARED, %esi -- cmovne %eax, %esi -- callq __lll_lock_wait --#if cond_lock != 0 -- subq $cond_lock, %rdi --#endif --92: -- /* Increment the cond_futex value again, so it can be used as a new -- expected value. */ -- incl cond_futex(%rdi) -- movl cond_futex(%rdi), %edx -- -- /* Release internal lock. */ -- LOCK --#if cond_lock == 0 -- decl (%rdi) --#else -- decl cond_lock(%rdi) --#endif -- jz 93f -- --#if cond_lock != 0 -- addq $cond_lock, %rdi --#endif -- LP_OP(cmp) $-1, dep_mutex-cond_lock(%rdi) -- movl $LLL_PRIVATE, %eax -- movl $LLL_SHARED, %esi -- cmovne %eax, %esi -- /* The call preserves %rdx. */ -- callq __lll_unlock_wake --#if cond_lock != 0 -- subq $cond_lock, %rdi --#endif --93: -- /* Set the rest of SYS_futex args for FUTEX_WAIT_REQUEUE_PI. */ -- xorq %r10, %r10 -- mov dep_mutex(%rdi), %R8_LP -- leaq cond_futex(%rdi), %rdi -- jmp 90b --.LcleanupEND2: -- - .size __pthread_cond_wait, .-__pthread_cond_wait - versioned_symbol (libpthread, __pthread_cond_wait, pthread_cond_wait, - GLIBC_2_3_2) -@@ -547,10 +518,6 @@ __condvar_cleanup1: - .uleb128 .LcleanupEND-.LcleanupSTART - .uleb128 __condvar_cleanup1-.LSTARTCODE - .uleb128 0 -- .uleb128 .LcleanupSTART2-.LSTARTCODE -- .uleb128 .LcleanupEND2-.LcleanupSTART2 -- .uleb128 __condvar_cleanup1-.LSTARTCODE -- .uleb128 0 - .uleb128 .LcallUR-.LSTARTCODE - .uleb128 .LENDCODE-.LcallUR - .uleb128 0 -diff --git a/nptl/tst-cond24.c b/nptl/tst-cond24.c -new file mode 100644 -index 0000000..2eb2df1 ---- /dev/null -+++ b/nptl/tst-cond24.c -@@ -0,0 +1,249 @@ -+/* Verify that condition variables synchronized by PI mutexes don't hang. -+ Copyright (C) 2012 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 -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ <http://www.gnu.org/licenses/>. */ -+ -+#include <pthread.h> -+#include <stdio.h> -+#include <stdlib.h> -+#include <string.h> -+#include <errno.h> -+#include <sys/types.h> -+#include <sys/syscall.h> -+#include <unistd.h> -+#include <sys/time.h> -+#include <time.h> -+ -+#define THREADS_NUM 5 -+#define MAXITER 50000 -+ -+static pthread_mutex_t mutex; -+static pthread_mutexattr_t mutex_attr; -+static pthread_cond_t cond; -+static pthread_t threads[THREADS_NUM]; -+static int pending = 0; -+ -+typedef void * (*threadfunc) (void *); -+ -+void * -+thread_fun_timed (void *arg) -+{ -+ int *ret = arg; -+ int rv, i; -+ -+ printf ("Started thread_fun_timed[%d]\n", *ret); -+ -+ for (i = 0; i < MAXITER / THREADS_NUM; i++) -+ { -+ rv = pthread_mutex_lock (&mutex); -+ if (rv) -+ { -+ printf ("pthread_mutex_lock: %s(%d)\n", strerror (rv), rv); -+ *ret = 1; -+ goto out; -+ } -+ -+ while (!pending) -+ { -+ struct timespec ts; -+ clock_gettime(CLOCK_REALTIME, &ts); -+ ts.tv_sec += 20; -+ rv = pthread_cond_timedwait (&cond, &mutex, &ts); -+ -+ /* There should be no timeout either. */ -+ if (rv) -+ { -+ printf ("pthread_cond_wait: %s(%d)\n", strerror (rv), rv); -+ *ret = 1; -+ goto out; -+ } -+ } -+ -+ pending--; -+ -+ rv = pthread_mutex_unlock (&mutex); -+ if (rv) -+ { -+ printf ("pthread_mutex_unlock: %s(%d)\n", strerror (rv), rv); -+ *ret = 1; -+ goto out; -+ } -+ } -+ -+ *ret = 0; -+ -+out: -+ return ret; -+} -+ -+void * -+thread_fun (void *arg) -+{ -+ int *ret = arg; -+ int rv, i; -+ -+ printf ("Started thread_fun[%d]\n", *ret); -+ -+ for (i = 0; i < MAXITER / THREADS_NUM; i++) -+ { -+ rv = pthread_mutex_lock (&mutex); -+ if (rv) -+ { -+ printf ("pthread_mutex_lock: %s(%d)\n", strerror (rv), rv); -+ *ret = 1; -+ goto out; -+ } -+ -+ while (!pending) -+ { -+ rv = pthread_cond_wait (&cond, &mutex); -+ -+ if (rv) -+ { -+ printf ("pthread_cond_wait: %s(%d)\n", strerror (rv), rv); -+ *ret = 1; -+ goto out; -+ } -+ } -+ -+ pending--; -+ -+ rv = pthread_mutex_unlock (&mutex); -+ if (rv) -+ { -+ printf ("pthread_mutex_unlock: %s(%d)\n", strerror (rv), rv); -+ *ret = 1; -+ goto out; -+ } -+ } -+ -+ *ret = 0; -+ -+out: -+ return ret; -+} -+ -+static int -+do_test_wait (threadfunc f) -+{ -+ int i; -+ int rv; -+ int counter = 0; -+ int retval[THREADS_NUM]; -+ -+ puts ("Starting test"); -+ -+ rv = pthread_mutexattr_init (&mutex_attr); -+ if (rv) -+ { -+ printf ("pthread_mutexattr_init: %s(%d)\n", strerror (rv), rv); -+ return 1; -+ } -+ -+ rv = pthread_mutexattr_setprotocol (&mutex_attr, PTHREAD_PRIO_INHERIT); -+ if (rv) -+ { -+ printf ("pthread_mutexattr_setprotocol: %s(%d)\n", strerror (rv), rv); -+ return 1; -+ } -+ -+ rv = pthread_mutex_init (&mutex, &mutex_attr); -+ if (rv) -+ { -+ printf ("pthread_mutex_init: %s(%d)\n", strerror (rv), rv); -+ return 1; -+ } -+ -+ rv = pthread_cond_init (&cond, NULL); -+ if (rv) -+ { -+ printf ("pthread_cond_init: %s(%d)\n", strerror (rv), rv); -+ return 1; -+ } -+ -+ for (i = 0; i < THREADS_NUM; i++) -+ { -+ retval[i] = i; -+ rv = pthread_create (&threads[i], NULL, f, &retval[i]); -+ if (rv) -+ { -+ printf ("pthread_create: %s(%d)\n", strerror (rv), rv); -+ return 1; -+ } -+ } -+ -+ for (; counter < MAXITER; counter++) -+ { -+ rv = pthread_mutex_lock (&mutex); -+ if (rv) -+ { -+ printf ("pthread_mutex_lock: %s(%d)\n", strerror (rv), rv); -+ return 1; -+ } -+ -+ if (!(counter % 100)) -+ printf ("counter: %d\n", counter); -+ pending += 1; -+ -+ rv = pthread_cond_signal (&cond); -+ if (rv) -+ { -+ printf ("pthread_cond_signal: %s(%d)\n", strerror (rv), rv); -+ return 1; -+ } -+ -+ rv = pthread_mutex_unlock (&mutex); -+ if (rv) -+ { -+ printf ("pthread_mutex_unlock: %s(%d)\n", strerror (rv), rv); -+ return 1; -+ } -+ } -+ -+ for (i = 0; i < THREADS_NUM; i++) -+ { -+ void *ret; -+ rv = pthread_join (threads[i], &ret); -+ if (rv) -+ { -+ printf ("pthread_join: %s(%d)\n", strerror (rv), rv); -+ return 1; -+ } -+ if (ret && *(int *)ret) -+ { -+ printf ("Thread %d returned with an error\n", i); -+ return 1; -+ } -+ } -+ -+ return 0; -+} -+ -+static int -+do_test (void) -+{ -+ puts ("Testing pthread_cond_wait"); -+ int ret = do_test_wait (thread_fun); -+ if (ret) -+ return ret; -+ -+ puts ("Testing pthread_cond_timedwait"); -+ return do_test_wait (thread_fun_timed); -+} -+ -+#define TIMEOUT 10 -+#define TEST_FUNCTION do_test () -+#include "../test-skeleton.c" --- -1.7.3.4 - diff --git a/glibc-2.17-getaddrinfo-stack-overflow.patch b/glibc-2.17-getaddrinfo-stack-overflow.patch new file mode 100644 index 000000000000..aa916ac2c2e1 --- /dev/null +++ b/glibc-2.17-getaddrinfo-stack-overflow.patch @@ -0,0 +1,47 @@ +diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c +index d95c2d1..2309281 100644 +--- a/sysdeps/posix/getaddrinfo.c ++++ b/sysdeps/posix/getaddrinfo.c +@@ -2489,11 +2489,27 @@ getaddrinfo (const char *name, const char *service, + __typeof (once) old_once = once; + __libc_once (once, gaiconf_init); + /* Sort results according to RFC 3484. */ +- struct sort_result results[nresults]; +- size_t order[nresults]; ++ struct sort_result *results; ++ size_t *order; + struct addrinfo *q; + struct addrinfo *last = NULL; + char *canonname = NULL; ++ bool malloc_results; ++ ++ malloc_results ++ = !__libc_use_alloca (nresults * (sizeof (*results) + sizeof (size_t))); ++ if (malloc_results) ++ { ++ results = malloc (nresults * (sizeof (*results) + sizeof (size_t))); ++ if (results == NULL) ++ { ++ __free_in6ai (in6ai); ++ return EAI_MEMORY; ++ } ++ } ++ else ++ results = alloca (nresults * (sizeof (*results) + sizeof (size_t))); ++ order = (size_t *) (results + nresults); + + /* Now we definitely need the interface information. */ + if (! check_pf_called) +@@ -2664,6 +2680,9 @@ getaddrinfo (const char *name, const char *service, + + /* Fill in the canonical name into the new first entry. */ + p->ai_canonname = canonname; ++ ++ if (malloc_results) ++ free (results); + } + + __free_in6ai (in6ai); +-- +1.7.1 + diff --git a/glibc-2.17-regexp-matcher-overrun.patch b/glibc-2.17-regexp-matcher-overrun.patch new file mode 100644 index 000000000000..b108f9d425f7 --- /dev/null +++ b/glibc-2.17-regexp-matcher-overrun.patch @@ -0,0 +1,137 @@ +diff --git a/posix/Makefile b/posix/Makefile +index 88d409f..2cacd21 100644 +--- a/posix/Makefile ++++ b/posix/Makefile +@@ -86,7 +86,7 @@ tests := tstgetopt testfnm runtests runptests \ + tst-rfc3484-3 \ + tst-getaddrinfo3 tst-fnmatch2 tst-cpucount tst-cpuset \ + bug-getopt1 bug-getopt2 bug-getopt3 bug-getopt4 \ +- bug-getopt5 tst-getopt_long1 ++ bug-getopt5 tst-getopt_long1 bug-regex34 + xtests := bug-ga2 + ifeq (yes,$(build-shared)) + test-srcs := globtest +@@ -199,5 +199,6 @@ bug-regex26-ENV = LOCPATH=$(common-objpfx)localedata + bug-regex30-ENV = LOCPATH=$(common-objpfx)localedata + bug-regex32-ENV = LOCPATH=$(common-objpfx)localedata + bug-regex33-ENV = LOCPATH=$(common-objpfx)localedata ++bug-regex34-ENV = LOCPATH=$(common-objpfx)localedata + tst-rxspencer-ARGS = --utf8 rxspencer/tests + tst-rxspencer-ENV = LOCPATH=$(common-objpfx)localedata +diff --git a/posix/bug-regex34.c b/posix/bug-regex34.c +new file mode 100644 +index 0000000..bb3b613 +--- /dev/null ++++ b/posix/bug-regex34.c +@@ -0,0 +1,46 @@ ++/* Test re_search with multi-byte characters in UTF-8. ++ Copyright (C) 2013 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 ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ <http://www.gnu.org/licenses/>. */ ++ ++#define _GNU_SOURCE 1 ++#include <stdio.h> ++#include <string.h> ++#include <locale.h> ++#include <regex.h> ++ ++static int ++do_test (void) ++{ ++ struct re_pattern_buffer r; ++ /* áá»á½ááºá¯ááºx */ ++ const char *s = "\xe1\x80\x80\xe1\x80\xbb\xe1\x80\xbd\xe1\x80\x94\xe1\x80\xba\xe1\x80\xaf\xe1\x80\x95\xe1\x80\xbax"; ++ ++ if (setlocale (LC_ALL, "en_US.UTF-8") == NULL) ++ { ++ puts ("setlocale failed"); ++ return 1; ++ } ++ memset (&r, 0, sizeof (r)); ++ ++ re_compile_pattern ("[^x]x", 5, &r); ++ /* This was triggering a buffer overflow. */ ++ re_search (&r, s, strlen (s), 0, strlen (s), 0); ++ return 0; ++} ++ ++#define TEST_FUNCTION do_test () ++#include "../test-skeleton.c" +diff --git a/posix/regexec.c b/posix/regexec.c +index 7f2de85..5ca2bf6 100644 +--- a/posix/regexec.c ++++ b/posix/regexec.c +@@ -197,7 +197,7 @@ static int group_nodes_into_DFAstates (const re_dfa_t *dfa, + static int check_node_accept (const re_match_context_t *mctx, + const re_token_t *node, int idx) + internal_function; +-static reg_errcode_t extend_buffers (re_match_context_t *mctx) ++static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len) + internal_function; + + /* Entry point for POSIX code. */ +@@ -1160,7 +1160,7 @@ check_matching (re_match_context_t *mctx, int fl_longest_match, + || (BE (next_char_idx >= mctx->input.valid_len, 0) + && mctx->input.valid_len < mctx->input.len)) + { +- err = extend_buffers (mctx); ++ err = extend_buffers (mctx, next_char_idx + 1); + if (BE (err != REG_NOERROR, 0)) + { + assert (err == REG_ESPACE); +@@ -1738,7 +1738,7 @@ clean_state_log_if_needed (re_match_context_t *mctx, int next_state_log_idx) + && mctx->input.valid_len < mctx->input.len)) + { + reg_errcode_t err; +- err = extend_buffers (mctx); ++ err = extend_buffers (mctx, next_state_log_idx + 1); + if (BE (err != REG_NOERROR, 0)) + return err; + } +@@ -2792,7 +2792,7 @@ get_subexp (re_match_context_t *mctx, int bkref_node, int bkref_str_idx) + if (bkref_str_off >= mctx->input.len) + break; + +- err = extend_buffers (mctx); ++ err = extend_buffers (mctx, bkref_str_off + 1); + if (BE (err != REG_NOERROR, 0)) + return err; + +@@ -4102,7 +4102,7 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node, + + static reg_errcode_t + internal_function __attribute_warn_unused_result__ +-extend_buffers (re_match_context_t *mctx) ++extend_buffers (re_match_context_t *mctx, int min_len) + { + reg_errcode_t ret; + re_string_t *pstr = &mctx->input; +@@ -4111,8 +4111,10 @@ extend_buffers (re_match_context_t *mctx) + if (BE (INT_MAX / 2 / sizeof (re_dfastate_t *) <= pstr->bufs_len, 0)) + return REG_ESPACE; + +- /* Double the lengthes of the buffers. */ +- ret = re_string_realloc_buffers (pstr, MIN (pstr->len, pstr->bufs_len * 2)); ++ /* Double the lengthes of the buffers, but allocate at least MIN_LEN. */ ++ ret = re_string_realloc_buffers (pstr, ++ MAX (min_len, ++ MIN (pstr->len, pstr->bufs_len * 2))); + if (BE (ret != REG_NOERROR, 0)) + return ret; + +-- +1.7.1 + diff --git a/glibc-2.17-sync-with-linux37.patch b/glibc-2.17-sync-with-linux37.patch new file mode 100644 index 000000000000..24b25c997097 --- /dev/null +++ b/glibc-2.17-sync-with-linux37.patch @@ -0,0 +1,130 @@ +diff --git a/sysdeps/gnu/netinet/tcp.h b/sysdeps/gnu/netinet/tcp.h +index 06e8414..b62a696 100644 +--- a/sysdeps/gnu/netinet/tcp.h ++++ b/sysdeps/gnu/netinet/tcp.h +@@ -37,20 +37,29 @@ + /* + * User-settable options (used with setsockopt). + */ +-#define TCP_NODELAY 1 /* Don't delay send to coalesce packets */ +-#define TCP_MAXSEG 2 /* Set maximum segment size */ +-#define TCP_CORK 3 /* Control sending of partial frames */ +-#define TCP_KEEPIDLE 4 /* Start keeplives after this period */ +-#define TCP_KEEPINTVL 5 /* Interval between keepalives */ +-#define TCP_KEEPCNT 6 /* Number of keepalives before death */ +-#define TCP_SYNCNT 7 /* Number of SYN retransmits */ +-#define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */ +-#define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */ +-#define TCP_WINDOW_CLAMP 10 /* Bound advertised window */ +-#define TCP_INFO 11 /* Information about this connection. */ +-#define TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */ +-#define TCP_CONGESTION 13 /* Congestion control algorithm. */ +-#define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */ ++#define TCP_NODELAY 1 /* Don't delay send to coalesce packets */ ++#define TCP_MAXSEG 2 /* Set maximum segment size */ ++#define TCP_CORK 3 /* Control sending of partial frames */ ++#define TCP_KEEPIDLE 4 /* Start keeplives after this period */ ++#define TCP_KEEPINTVL 5 /* Interval between keepalives */ ++#define TCP_KEEPCNT 6 /* Number of keepalives before death */ ++#define TCP_SYNCNT 7 /* Number of SYN retransmits */ ++#define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */ ++#define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */ ++#define TCP_WINDOW_CLAMP 10 /* Bound advertised window */ ++#define TCP_INFO 11 /* Information about this connection. */ ++#define TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */ ++#define TCP_CONGESTION 13 /* Congestion control algorithm. */ ++#define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */ ++#define TCP_COOKIE_TRANSACTIONS 15 /* TCP Cookie Transactions */ ++#define TCP_THIN_LINEAR_TIMEOUTS 16 /* Use linear timeouts for thin streams*/ ++#define TCP_THIN_DUPACK 17 /* Fast retrans. after 1 dupack */ ++#define TCP_USER_TIMEOUT 18 /* How long for loss retry before timeout */ ++#define TCP_REPAIR 19 /* TCP sock is under repair right now */ ++#define TCP_REPAIR_QUEUE 20 /* Set TCP queue to repair */ ++#define TCP_QUEUE_SEQ 21 /* Set sequence number of repaired queue. */ ++#define TCP_REPAIR_OPTIONS 22 /* Repair TCP connection options */ ++#define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */ + + #ifdef __USE_MISC + # include <sys/types.h> +@@ -173,7 +182,9 @@ enum + # define TCPI_OPT_TIMESTAMPS 1 + # define TCPI_OPT_SACK 2 + # define TCPI_OPT_WSCALE 4 +-# define TCPI_OPT_ECN 8 ++# define TCPI_OPT_ECN 8 /* ECN was negociated at TCP session init */ ++# define TCPI_OPT_ECN_SEEN 16 /* we received at least one packet with ECT */ ++# define TCPI_OPT_SYN_DATA 32 /* SYN-ACK acked data in SYN sent or rcvd */ + + /* Values for tcpi_state. */ + enum tcp_ca_state +@@ -241,6 +252,49 @@ struct tcp_md5sig + u_int8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* Key (binary). */ + }; + ++/* For socket repair options. */ ++struct tcp_repair_opt ++{ ++ u_int32_t opt_code; ++ u_int32_t opt_val; ++}; ++ ++/* Queue to repair, for TCP_REPAIR_QUEUE. */ ++enum ++{ ++ TCP_NO_QUEUE, ++ TCP_RECV_QUEUE, ++ TCP_SEND_QUEUE, ++ TCP_QUEUES_NR, ++}; ++ ++/* For cookie transactions socket options. */ ++#define TCP_COOKIE_MIN 8 /* 64-bits */ ++#define TCP_COOKIE_MAX 16 /* 128-bits */ ++#define TCP_COOKIE_PAIR_SIZE (2*TCP_COOKIE_MAX) ++ ++/* Flags for both getsockopt and setsockopt */ ++#define TCP_COOKIE_IN_ALWAYS (1 << 0) /* Discard SYN without cookie */ ++#define TCP_COOKIE_OUT_NEVER (1 << 1) /* Prohibit outgoing cookies, ++ * supercedes everything. */ ++ ++/* Flags for getsockopt */ ++#define TCP_S_DATA_IN (1 << 2) /* Was data received? */ ++#define TCP_S_DATA_OUT (1 << 3) /* Was data sent? */ ++ ++#define TCP_MSS_DEFAULT 536U /* IPv4 (RFC1122, RFC2581) */ ++#define TCP_MSS_DESIRED 1220U /* IPv6 (tunneled), EDNS0 (RFC3226) */ ++ ++struct tcp_cookie_transactions ++{ ++ u_int16_t tcpct_flags; ++ u_int8_t __tcpct_pad1; ++ u_int8_t tcpct_cookie_desired; ++ u_int16_t tcpct_s_data_desired; ++ u_int16_t tcpct_used; ++ u_int8_t tcpct_value[TCP_MSS_DEFAULT]; ++}; ++ + #endif /* Misc. */ + + #endif /* netinet/tcp.h */ +diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h +index df8f167..eadd7d9 100644 +--- a/sysdeps/unix/sysv/linux/bits/socket.h ++++ b/sysdeps/unix/sysv/linux/bits/socket.h +@@ -1,6 +1,5 @@ + /* System-specific socket constants and types. Linux version. +- Copyright (C) 1991, 1992, 1994-2001, 2004, 2006-2010, 2011, 2012 +- Free Software Foundation, Inc. ++ Copyright (C) 1991-2013 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 +@@ -208,6 +207,8 @@ enum + #define MSG_MORE MSG_MORE + MSG_WAITFORONE = 0x10000, /* Wait for at least one packet to return.*/ + #define MSG_WAITFORONE MSG_WAITFORONE ++ MSG_FASTOPEN = 0x20000000, /* Send data in TCP SYN. */ ++#define MSG_FASTOPEN MSG_FASTOPEN + + MSG_CMSG_CLOEXEC = 0x40000000 /* Set close_on_exit for file + descriptor received through |