cherry-pick.FILE5_30-42-gf0bcdd07.dont-try-to-read-past-the-end-of-the-properties-found-by-oss-fuzz.patch 842 B

123456789101112131415161718192021222324252627
  1. Subject: Don't try to read past the end of the properties, found by oss-fuzz
  2. Origin: FILE5_30-42-gf0bcdd07
  3. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Sat Apr 8 20:38:46 2017 +0000
  5. --- a/src/cdf.c
  6. +++ b/src/cdf.c
  7. @@ -835,6 +835,10 @@
  8. size_t ofs;
  9. const uint8_t *q;
  10. + if (p >= e) {
  11. + DPRINTF(("Past end %p < %p\n", e, p));
  12. + return NULL;
  13. + }
  14. if (cdf_check_stream_offset(sst, h, p, tail * sizeof(uint32_t),
  15. __LINE__) == -1)
  16. return NULL;
  17. @@ -945,7 +949,7 @@
  18. *count += sh.sh_properties;
  19. p = CAST(const uint8_t *, cdf_offset(sst->sst_tab, offs + sizeof(sh)));
  20. e = CAST(const uint8_t *, cdf_offset(shp, sh.sh_len));
  21. - if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1)
  22. + if (p >= e || cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1)
  23. goto out;
  24. for (i = 0; i < sh.sh_properties; i++) {