changeset 14051:f296f8cfe0c6

regex: don't infloop on persistent failing calloc * lib/regexec.c (build_trtable): Return failure indication upon calloc failure. Otherwise, re_search_internal could infloop on OOM. In glibc, this was fixed for version 2.13: http://sourceware.org/bugzilla/show_bug.cgi?id=12348
author Jim Meyering <meyering@redhat.com>
date Tue, 28 Dec 2010 15:12:47 +0100
parents 6566818713fe
children ce397caf9dbb
files ChangeLog lib/regexec.c
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-12-28  Jim Meyering  <meyering@redhat.com>
+
+	regex: don't infloop on persistent failing calloc
+	* lib/regexec.c (build_trtable): Return failure indication upon
+	calloc failure.  Otherwise, re_search_internal could infloop on OOM.
+	In glibc, this was fixed for version 2.13:
+	http://sourceware.org/bugzilla/show_bug.cgi?id=12348
+
 2010-12-28  Bruno Haible  <bruno@clisp.org>
             Paul Eggert <eggert@cs.ucla.edu>
 
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -3402,6 +3402,8 @@
 	{
 	  state->trtable = (re_dfastate_t **)
 	    calloc (sizeof (re_dfastate_t *), SBC_MAX);
+          if (BE (state->trtable == NULL, 0))
+            return false;
 	  return true;
 	}
       return false;