cherry-pick.FILE5_37-67-g46a8443f.limit-the-number-of-elements-in-a-vector-found-by-oss-fuzz.patch 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. Subject: Limit the number of elements in a vector (found by oss-fuzz)
  2. Origin: FILE5_37-67-g46a8443f <https://github.com/file/file/commit/FILE5_37-67-g46a8443f>
  3. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Mon Aug 26 14:31:39 2019 +0000
  5. --- a/src/cdf.c
  6. +++ b/src/cdf.c
  7. @@ -1013,8 +1013,9 @@
  8. goto out;
  9. }
  10. nelements = CDF_GETUINT32(q, 1);
  11. - if (nelements == 0) {
  12. - DPRINTF(("CDF_VECTOR with nelements == 0\n"));
  13. + if (nelements > CDF_ELEMENT_LIMIT || nelements == 0) {
  14. + DPRINTF(("CDF_VECTOR with nelements == %"
  15. + SIZE_T_FORMAT "u\n", nelements));
  16. goto out;
  17. }
  18. slen = 2;
  19. @@ -1056,8 +1057,6 @@
  20. goto out;
  21. inp += nelem;
  22. }
  23. - DPRINTF(("nelements = %" SIZE_T_FORMAT "u\n",
  24. - nelements));
  25. for (j = 0; j < nelements && i < sh.sh_properties;
  26. j++, i++)
  27. {
  28. --- a/src/cdf.h
  29. +++ b/src/cdf.h
  30. @@ -48,6 +48,7 @@
  31. typedef int32_t cdf_secid_t;
  32. #define CDF_LOOP_LIMIT 10000
  33. +#define CDF_ELEMENT_LIMIT 100000
  34. #define CDF_SECID_NULL 0
  35. #define CDF_SECID_FREE -1