1
0

001-regex-read-overrun.patch 868 B

1234567891011121314151617181920212223242526
  1. commit 583dd860d5b833037175247230a328f0050dbfe9
  2. Author: Paul Eggert <eggert@cs.ucla.edu>
  3. Date: Mon Jan 21 11:08:13 2019 -0800
  4. regex: fix read overrun [BZ #24114]
  5. Problem found by AddressSanitizer, reported by Hongxu Chen in:
  6. https://debbugs.gnu.org/34140
  7. * posix/regexec.c (proceed_next_node):
  8. Do not read past end of input buffer.
  9. --- a/posix/regexec.c
  10. +++ b/posix/regexec.c
  11. @@ -1293,8 +1293,10 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
  12. else if (naccepted)
  13. {
  14. char *buf = (char *) re_string_get_buffer (&mctx->input);
  15. - if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
  16. - naccepted) != 0)
  17. + if (mctx->input.valid_len - *pidx < naccepted
  18. + || (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
  19. + naccepted)
  20. + != 0))
  21. return -1;
  22. }
  23. }