cherry-pick.FILE5_30-43-g19ccebaf.dont-copy-the-string-past-its-length-oss-fuzz.patch 1.0 KB

123456789101112131415161718192021222324252627
  1. Subject: Don't copy the string past its length (oss-fuzz)
  2. Origin: FILE5_30-43-g19ccebaf
  3. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Sat Apr 8 20:58:03 2017 +0000
  5. --- a/src/readcdf.c
  6. +++ b/src/readcdf.c
  7. @@ -152,7 +152,7 @@
  8. struct timespec ts;
  9. char buf[64];
  10. const char *str = NULL;
  11. - const char *s;
  12. + const char *s, *e;
  13. int len;
  14. if (!NOTMIME(ms) && root_storage)
  15. @@ -199,7 +199,9 @@
  16. if (info[i].pi_type == CDF_LENGTH32_WSTRING)
  17. k++;
  18. s = info[i].pi_str.s_buf;
  19. - for (j = 0; j < sizeof(vbuf) && len--; s += k) {
  20. + e = info[i].pi_str.s_buf + len;
  21. + for (j = 0; s < e && j < sizeof(vbuf)
  22. + && len--; s += k) {
  23. if (*s == '\0')
  24. break;
  25. if (isprint((unsigned char)*s))