From 028e437c6da50340f95b83978a25748e427012ae Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 28 Dec 2010 15:12:47 +0100 Subject: [PATCH] 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 --- ChangeLog | 8 ++++++++ lib/regexec.c | 2 ++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0d175a2f6..0a17782b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-12-28 Jim Meyering + + 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 Paul Eggert diff --git a/lib/regexec.c b/lib/regexec.c index 9388ac12b..ee702bc6f 100644 --- a/lib/regexec.c +++ b/lib/regexec.c @@ -3402,6 +3402,8 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) { state->trtable = (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); + if (BE (state->trtable == NULL, 0)) + return false; return true; } return false; -- 2.11.0