1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-01 10:06:57 +03:00

regexec.c: avoid overflow in realloc buffer length computation

This commit is contained in:
Paul Eggert
2010-01-22 12:41:12 -08:00
committed by Ulrich Drepper
parent 74bc9f14db
commit aef699dce1
2 changed files with 8 additions and 0 deletions

View File

@ -4104,6 +4104,10 @@ extend_buffers (re_match_context_t *mctx)
reg_errcode_t ret;
re_string_t *pstr = &mctx->input;
/* Avoid overflow. */
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, pstr->bufs_len * 2);
if (BE (ret != REG_NOERROR, 0))