CVE-2014-3478.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. Subject: Buffer overflow in the mconvert function allows remote attackers to cause a denial of service
  2. ID: CVE-2014-3478
  3. Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Wed Jun 4 17:36:34 2014 +0000
  5. Origin:
  6. commit 27a14bc7ba285a0a5ebfdb55e54001aa11932b08
  7. Debian-Author: Holger Levsen <holger@debian.org>
  8. Comment:
  9. made apply cleanly based on [origin]
  10. Reviewed-By: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
  11. Last-Update: 2014-09-07
  12. Correctly compute the truncated pascal string size (Francisco Alonso and
  13. Jan Kaluza at RedHat)
  14. --- a/src/softmagic.c
  15. +++ b/src/softmagic.c
  16. @@ -800,10 +800,18 @@
  17. return 1;
  18. }
  19. case FILE_PSTRING: {
  20. - char *ptr1 = p->s, *ptr2 = ptr1 + file_pstring_length_size(m);
  21. + size_t sz = file_pstring_length_size(m);
  22. + char *ptr1 = p->s, *ptr2 = ptr1 + sz;
  23. size_t len = file_pstring_get_length(m, ptr1);
  24. - if (len >= sizeof(p->s))
  25. - len = sizeof(p->s) - 1;
  26. + if (len >= sizeof(p->s)) {
  27. + /*
  28. + * The size of the pascal string length (sz)
  29. + * is 1, 2, or 4. We need at least 1 byte for NUL
  30. + * termination, but we've already truncated the
  31. + * string by p->s, so we need to deduct sz.
  32. + */
  33. + len = sizeof(p->s) - sz;
  34. + }
  35. while (len--)
  36. *ptr1++ = *ptr2++;
  37. *ptr1 = '\0';