cherry-pick.FILE5_30-18-g4e4e7609.pr-599-out-of-bounds-read-in-cdf-files.patch 949 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. Subject: PR/599: Out of bounds read in cdf files
  2. Origin: FILE5_30-18-g4e4e7609
  3. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Fri Mar 17 19:50:22 2017 +0000
  5. --- a/src/cdf.c
  6. +++ b/src/cdf.c
  7. @@ -982,19 +982,26 @@
  8. for (j = 0; j < nelements && i < sh.sh_properties;
  9. j++, i++)
  10. {
  11. - uint32_t l = CDF_GETUINT32(q, o);
  12. + uint32_t l;
  13. +
  14. + o4 += sizeof(uint32_t);
  15. + if (q + o >= e || q + o4 >= e)
  16. + goto out;
  17. +
  18. + l = CDF_GETUINT32(q, o);
  19. inp[i].pi_str.s_len = l;
  20. - inp[i].pi_str.s_buf = (const char *)
  21. - (const void *)(&q[o4 + sizeof(l)]);
  22. + inp[i].pi_str.s_buf = CAST(const char *,
  23. + CAST(const void *, &q[o4]));
  24. +
  25. DPRINTF(("l = %d, r = %" SIZE_T_FORMAT
  26. "u, s = %s\n", l,
  27. CDF_ROUND(l, sizeof(l)),
  28. inp[i].pi_str.s_buf));
  29. +
  30. if (l & 1)
  31. l++;
  32. +
  33. o += l >> 1;
  34. - if (q + o >= e)
  35. - goto out;
  36. o4 = o * sizeof(uint32_t);
  37. }
  38. i--;