Skip to content

Commit

Permalink
prune_impossible_nodes: Avoid overflow in computing re_malloc buffer …
Browse files Browse the repository at this point in the history
…size
  • Loading branch information
Paul Eggert authored and Ulrich Drepper committed Jan 22, 2010
1 parent daa8454 commit 4cd0286
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
2010-01-22 Jim Meyering <jim@meyering.net>

[BZ #11189]
* posix/regexec.c (prune_impossible_nodes): Avoid overflow
in computing re_malloc buffer size.

[BZ #11188]
* posix/regexec.c (build_trtable): Avoid arithmetic overflow
in size calculation.
Expand Down
5 changes: 5 additions & 0 deletions posix/regexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,11 @@ prune_impossible_nodes (mctx)
#endif
match_last = mctx->match_last;
halt_node = mctx->last_node;

/* Avoid overflow. */
if (BE (SIZE_MAX / sizeof (re_dfastate_t *) <= match_last, 0))
return REG_ESPACE;

sifted_states = re_malloc (re_dfastate_t *, match_last + 1);
if (BE (sifted_states == NULL, 0))
{
Expand Down

0 comments on commit 4cd0286

Please sign in to comment.