r5822 - in glibc-package/branches/glibc-branch-wheezy/debian: . patches patches/any
Author: aurel32
Date: 2013-11-29 21:49:15 +0000 (Fri, 29 Nov 2013)
New Revision: 5822
Added:
glibc-package/branches/glibc-branch-wheezy/debian/patches/any/cvs-CVE-2013-0242.diff
Modified:
glibc-package/branches/glibc-branch-wheezy/debian/changelog
glibc-package/branches/glibc-branch-wheezy/debian/patches/series
Log:
* patches/any/CVE-2013-0242.diff: Backport buffer overrun in regexp matcher
addressing CVE-2013-0242 (Closes: #699399).
Modified: glibc-package/branches/glibc-branch-wheezy/debian/changelog
===================================================================
--- glibc-package/branches/glibc-branch-wheezy/debian/changelog 2013-11-29 21:37:04 UTC (rev 5821)
+++ glibc-package/branches/glibc-branch-wheezy/debian/changelog 2013-11-29 21:49:15 UTC (rev 5822)
@@ -4,6 +4,8 @@
regressions to ease the pain of ongoing stable/security maintenance.
* patches/any/cvs-CVE-2012-44xx.diff: backport overflow fixes in strcoll
addressing CVE-2012-4412 and CVE-2012-4424 (Closes: #687530, #689423).
+ * patches/any/CVE-2013-0242.diff: Backport buffer overrun in regexp matcher
+ addressing CVE-2013-0242 (Closes: #699399).
-- Aurelien Jarno <aurel32@debian.org> Fri, 29 Nov 2013 21:59:21 +0100
Added: glibc-package/branches/glibc-branch-wheezy/debian/patches/any/cvs-CVE-2013-0242.diff
===================================================================
--- glibc-package/branches/glibc-branch-wheezy/debian/patches/any/cvs-CVE-2013-0242.diff (rev 0)
+++ glibc-package/branches/glibc-branch-wheezy/debian/patches/any/cvs-CVE-2013-0242.diff 2013-11-29 21:49:15 UTC (rev 5822)
@@ -0,0 +1,139 @@
+2013-02-12 Andreas Schwab <schwab@suse.de>
+
+ [BZ #15078]
+ * posix/regexec.c (extend_buffers): Add parameter min_len.
+ (check_matching): Pass minimum needed length.
+ (clean_state_log_if_needed): Likewise.
+ (get_subexp): Likewise.
+ * posix/Makefile (tests): Add bug-regex34.
+ (bug-regex34-ENV): Define.
+ * posix/bug-regex34.c: New file.
+
+--- a/posix/bug-regex34.c
++++ 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"
+--- a/posix/Makefile
++++ b/posix/Makefile
+@@ -105,7 +105,7 @@
+ tst-execvp3 tst-execvp4 \
+ tst-fnmatch2 tst-cpucount tst-cpuset \
+ bug-getopt1 bug-getopt2 bug-getopt3 bug-getopt4 \
+- bug-getopt5
++ bug-getopt5 bug-regex34
+ tests-$(OPTION_EGLIBC_LOCALE_CODE) \
+ += tst-fnmatch tst-regexloc bug-regex1 bug-regex5 \
+ bug-regex23 bug-regex25
+@@ -240,6 +240,7 @@
+ bug-regex25-ENV = LOCPATH=$(common-objpfx)localedata
+ bug-regex26-ENV = LOCPATH=$(common-objpfx)localedata
+ bug-regex30-ENV = LOCPATH=$(common-objpfx)localedata
++bug-regex34-ENV = LOCPATH=$(common-objpfx)localedata
+ tst-rxspencer-ARGS = rxspencer/tests
+ ifeq (y,$(OPTION_EGLIBC_LOCALE_CODE))
+ tst-rxspencer-ARGS += --utf8
+--- a/posix/regexec.c
++++ b/posix/regexec.c
+@@ -200,7 +200,7 @@
+ 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. */
+@@ -1147,7 +1147,7 @@
+ || (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);
+@@ -1725,7 +1725,7 @@
+ && 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;
+ }
+@@ -2779,7 +2779,7 @@
+ 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;
+
+@@ -4097,7 +4097,7 @@
+
+ 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;
+@@ -4106,8 +4106,10 @@
+ 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;
+
Modified: glibc-package/branches/glibc-branch-wheezy/debian/patches/series
===================================================================
--- glibc-package/branches/glibc-branch-wheezy/debian/patches/series 2013-11-29 21:37:04 UTC (rev 5821)
+++ glibc-package/branches/glibc-branch-wheezy/debian/patches/series 2013-11-29 21:49:15 UTC (rev 5822)
@@ -375,3 +375,4 @@
any/cvs-arch-lowlevellock.diff
any/local-tst-eintr1-eagain.diff
any/cvs-CVE-2012-44xx.diff
+any/cvs-CVE-2013-0242.diff
Reply to: