cherry-pick.FILE5_31-21-g55cb70a2.add-another-bounds-check-oss-fuzz-issue-2242.patch 492 B

12345678910111213141516
  1. Subject: Add another bounds check: OSS-FUZZ issue 2242
  2. Origin: FILE5_31-21-g55cb70a2 <https://github.com/file/file/commit/FILE5_31-21-g55cb70a2>
  3. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Mon Jun 19 18:30:25 2017 +0000
  5. --- a/src/softmagic.c
  6. +++ b/src/softmagic.c
  7. @@ -1199,7 +1199,7 @@
  8. const char *end;
  9. size_t lines, linecnt, bytecnt;
  10. - if (s == NULL) {
  11. + if (s == NULL || nbytes < offset) {
  12. ms->search.s_len = 0;
  13. ms->search.s = NULL;
  14. return 0;