OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.5 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../libtiff/libtiff-4.0.3-0101-CVE-2012-4447.patch
  5. # Copyright (C) 2013 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From ea1f57c13f083528b6b38350aa00c3c0f44a1c9d Mon Sep 17 00:00:00 2001
  17. From: tgl <tgl>
  18. Date: Mon, 10 Dec 2012 17:27:13 +0000
  19. Subject: [PATCH] Detect integer overflow in addition when computing buffer
  20. size.
  21. original ChangeLog entry:
  22. ----------------------------------------------------------------------------
  23. 2012-12-10 Tom Lane <tgl@sss.pgh.pa.us>
  24. * libtiff/tif_pixarlog.c: Improve previous patch for CVE-2012-4447
  25. (to enlarge tbuf for possible partial stride at end) so that
  26. overflow in the integer addition is detected. Per gripe from
  27. Huzaifa Sidhpurwala.
  28. ----------------------------------------------------------------------------
  29. diff --git a/libtiff/tif_pixarlog.c b/libtiff/tif_pixarlog.c
  30. index 572dc7f..ba554e7 100644
  31. --- a/libtiff/tif_pixarlog.c
  32. +++ b/libtiff/tif_pixarlog.c
  33. @@ -644,6 +644,20 @@ multiply_ms(tmsize_t m1, tmsize_t m2)
  34. return bytes;
  35. }
  36. +static tmsize_t
  37. +add_ms(tmsize_t m1, tmsize_t m2)
  38. +{
  39. + tmsize_t bytes = m1 + m2;
  40. +
  41. + /* if either input is zero, assume overflow already occurred */
  42. + if (m1 == 0 || m2 == 0)
  43. + bytes = 0;
  44. + else if (bytes <= m1 || bytes <= m2)
  45. + bytes = 0;
  46. +
  47. + return bytes;
  48. +}
  49. +
  50. static int
  51. PixarLogFixupTags(TIFF* tif)
  52. {
  53. @@ -671,9 +685,11 @@ PixarLogSetupDecode(TIFF* tif)
  54. td->td_samplesperpixel : 1);
  55. tbuf_size = multiply_ms(multiply_ms(multiply_ms(sp->stride, td->td_imagewidth),
  56. td->td_rowsperstrip), sizeof(uint16));
  57. + /* add one more stride in case input ends mid-stride */
  58. + tbuf_size = add_ms(tbuf_size, sizeof(uint16) * sp->stride);
  59. if (tbuf_size == 0)
  60. return (0); /* TODO: this is an error return without error report through TIFFErrorExt */
  61. - sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size+sizeof(uint16)*sp->stride);
  62. + sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size);
  63. if (sp->tbuf == NULL)
  64. return (0);
  65. if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
  66. --
  67. 1.7.10.2