Author: aurel32 Date: 2015-02-08 14:54:30 +0000 (Sun, 08 Feb 2015) New Revision: 6354
Added: glibc-package/trunk/debian/patches/any/cvs-wscanf.diff Modified: glibc-package/trunk/debian/changelog glibc-package/trunk/debian/patches/series Log: debian/patches/any/cvs-wscanf.diff: new patch from upstream to fix a heap buffer overflow in wscanf (CVE-2015-1472, CVE-2015-1473). Closes: #777197. Modified: glibc-package/trunk/debian/changelog =================================================================== --- glibc-package/trunk/debian/changelog 2015-02-01 10:42:28 UTC (rev 6353) +++ glibc-package/trunk/debian/changelog 2015-02-08 14:54:30 UTC (rev 6354) @@ -1,6 +1,9 @@ glibc (2.19-15) UNRELEASED; urgency=medium - * + [ Aurelien Jarno ] + * debian/patches/any/cvs-wscanf.diff: new patch from upstream to fix a + heap buffer overflow in wscanf (CVE-2015-1472, CVE-2015-1473). Closes: + #777197. -- Aurelien Jarno <[email protected]> Sun, 01 Feb 2015 10:47:39 +0100 Added: glibc-package/trunk/debian/patches/any/cvs-wscanf.diff =================================================================== --- glibc-package/trunk/debian/patches/any/cvs-wscanf.diff (rev 0) +++ glibc-package/trunk/debian/patches/any/cvs-wscanf.diff 2015-02-08 14:54:30 UTC (rev 6354) @@ -0,0 +1,82 @@ +2015-02-05 Paul Pluzhnikov <[email protected]> + + [BZ #16618] + * stdio-common/tst-sscanf.c (main): Test for buffer overflow. + * stdio-common/vfscanf.c (_IO_vfscanf_internal): Compute needed + size in bytes. Store needed elements in wpmax. Use needed size + in bytes for extend_alloca. + +--- a/stdio-common/tst-sscanf.c ++++ b/stdio-common/tst-sscanf.c +@@ -232,5 +232,38 @@ + } + } + ++ /* BZ #16618 ++ The test will segfault during SSCANF if the buffer overflow ++ is not fixed. The size of `s` is such that it forces the use ++ of malloc internally and this triggers the incorrect computation. ++ Thus the value for SIZE is arbitrariy high enough that malloc ++ is used. */ ++ { ++#define SIZE 131072 ++ CHAR *s = malloc ((SIZE + 1) * sizeof (*s)); ++ if (s == NULL) ++ abort (); ++ for (size_t i = 0; i < SIZE; i++) ++ s[i] = L('0'); ++ s[SIZE] = L('\0'); ++ int i = 42; ++ /* Scan multi-digit zero into `i`. */ ++ if (SSCANF (s, L("%d"), &i) != 1) ++ { ++ printf ("FAIL: bug16618: SSCANF did not read one input item.\n"); ++ result = 1; ++ } ++ if (i != 0) ++ { ++ printf ("FAIL: bug16618: Value of `i` was not zero as expected.\n"); ++ result = 1; ++ } ++ free (s); ++ if (result != 1) ++ printf ("PASS: bug16618: Did not crash.\n"); ++#undef SIZE ++ } ++ ++ + return result; + } +--- a/stdio-common/vfscanf.c ++++ b/stdio-common/vfscanf.c +@@ -272,9 +272,10 @@ + if (__builtin_expect (wpsize == wpmax, 0)) \ + { \ + CHAR_T *old = wp; \ +- size_t newsize = (UCHAR_MAX + 1 > 2 * wpmax \ +- ? UCHAR_MAX + 1 : 2 * wpmax); \ +- if (use_malloc || !__libc_use_alloca (newsize)) \ ++ bool fits = __glibc_likely (wpmax <= SIZE_MAX / sizeof (CHAR_T) / 2); \ ++ size_t wpneed = MAX (UCHAR_MAX + 1, 2 * wpmax); \ ++ size_t newsize = fits ? wpneed * sizeof (CHAR_T) : SIZE_MAX; \ ++ if (!__libc_use_alloca (newsize)) \ + { \ + wp = realloc (use_malloc ? wp : NULL, newsize); \ + if (wp == NULL) \ +@@ -286,14 +287,13 @@ + } \ + if (! use_malloc) \ + MEMCPY (wp, old, wpsize); \ +- wpmax = newsize; \ ++ wpmax = wpneed; \ + use_malloc = true; \ + } \ + else \ + { \ + size_t s = wpmax * sizeof (CHAR_T); \ +- wp = (CHAR_T *) extend_alloca (wp, s, \ +- newsize * sizeof (CHAR_T)); \ ++ wp = (CHAR_T *) extend_alloca (wp, s, newsize); \ + wpmax = s / sizeof (CHAR_T); \ + if (old != NULL) \ + MEMCPY (wp, old, wpsize); \ Modified: glibc-package/trunk/debian/patches/series =================================================================== --- glibc-package/trunk/debian/patches/series 2015-02-01 10:42:28 UTC (rev 6353) +++ glibc-package/trunk/debian/patches/series 2015-02-08 14:54:30 UTC (rev 6354) @@ -267,3 +267,4 @@ any/cvs-wordexp.diff any/cvs-getnetbyname.diff any/cvs-vfprintf.diff +any/cvs-wscanf.diff -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected] Archive: https://lists.debian.org/[email protected]

