qt.patch 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. Index: configure
  2. --- configure.orig 2004-06-14 11:18:55 +0200
  3. +++ configure 2004-08-11 16:13:39 +0200
  4. @@ -1782,21 +1782,6 @@
  5. CFG_FREETYPE=yes
  6. fi
  7. fi
  8. - # add freetype2 include path
  9. - if [ "$CFG_FREETYPE" = "yes" ] && [ -f $outpath/config.tests/x11/xft.inc ];then
  10. - QMAKE_VARS="$QMAKE_VARS \"INCLUDEPATH+=`cat $outpath/config.tests/x11/xft.inc`\""
  11. - fi
  12. - rm -f $outpath/config.tests/x11/xft.inc
  13. - # add Xft specific libraries
  14. - if [ "$CFG_FREETYPE" = "yes" ] && [ -f $outpath/config.tests/x11/xft.lib ]; then
  15. - QMAKE_VARS="$QMAKE_VARS \"QMAKE_LIBS_X11=`cat $outpath/config.tests/x11/xft.lib` \$\$QMAKE_LIBS_X11\""
  16. - fi
  17. - rm -f $outpath/config.tests/x11/xft.lib
  18. - # add Xft specific config options
  19. - if [ "$CFG_FREETYPE" = "yes" ] && [ -f $outpath/config.tests/x11/xft.cfg ]; then
  20. - QMAKE_CONFIG="$QMAKE_CONFIG `cat $outpath/config.tests/x11/xft.cfg`"
  21. - fi
  22. - rm -f $outpath/config.tests/x11/xft.cfg
  23. # auto-detect Session Management support
  24. if [ "$CFG_SM" = "auto" ]; then
  25. if $x11tests/sm.test $XQMAKESPEC $OPT_VERBOSE $L_FLAGS $I_FLAGS; then
  26. @@ -2926,6 +2911,21 @@
  27. if [ "$CFG_XKB" = "yes" ]; then
  28. QMAKE_CONFIG="$QMAKE_CONFIG xkb"
  29. fi
  30. + # add freetype2 include path
  31. + if [ "$CFG_FREETYPE" = "yes" ] && [ -f $outpath/config.tests/x11/xft.inc ];then
  32. + QMAKE_VARS="$QMAKE_VARS \"INCLUDEPATH+=`cat $outpath/config.tests/x11/xft.inc`\""
  33. + fi
  34. + rm -f $outpath/config.tests/x11/xft.inc
  35. + # add Xft specific libraries
  36. + if [ "$CFG_FREETYPE" = "yes" ] && [ -f $outpath/config.tests/x11/xft.lib ]; then
  37. + QMAKE_VARS="$QMAKE_VARS \"QMAKE_LIBS_X11=`cat $outpath/config.tests/x11/xft.lib` \$\$QMAKE_LIBS_X11\""
  38. + fi
  39. + rm -f $outpath/config.tests/x11/xft.lib
  40. + # add Xft specific config options
  41. + if [ "$CFG_FREETYPE" = "yes" ] && [ -f $outpath/config.tests/x11/xft.cfg ]; then
  42. + QMAKE_CONFIG="$QMAKE_CONFIG `cat $outpath/config.tests/x11/xft.cfg`"
  43. + fi
  44. + rm -f $outpath/config.tests/x11/xft.cfg
  45. elif [ "$PLATFORM_MAC" = "yes" ]; then
  46. if [ "$CFG_TABLET" = "yes" ]; then
  47. QMAKE_CONFIG="$QMAKE_CONFIG tablet"
  48. Index: config.test/x11/xfreetype.test
  49. --- config.tests/x11/xfreetype.test.orig 2003-12-08 10:04:06 +0100
  50. +++ config.tests/x11/xfreetype.test 2004-08-11 16:14:43 +0200
  51. @@ -56,7 +56,7 @@
  52. XFT=no
  53. [ "$VERBOSE" = "yes" ] && echo " Could not find Xft lib anywhere in $LIBDIRS"
  54. fi
  55. -LIBXFT="-l$F -lfreetype"
  56. +LIBXFT="-l$F -lfontconfig -lexpat -lfreetype"
  57. # check for X11/Xft/Xft.h
  58. XFT_H=
  59. @@ -90,7 +90,7 @@
  60. [ "$VERBOSE" = "yes" ] && echo " Found Xft version $XFT_MAJOR.$XFT_MINOR.$XFT_REVISION"
  61. if [ "$XFT_MAJOR" = "2" ]; then
  62. XFT2=yes
  63. - LIBXFT="$LIBXFT -lfontconfig"
  64. + LIBXFT="$LIBXFT"
  65. fi
  66. fi
  67. Index: src/3rdparty/libpng/pngconf.h
  68. --- src/3rdparty/libpng/pngconf.h.orig 2003-05-27 17:19:23 +0200
  69. +++ src/3rdparty/libpng/pngconf.h 2004-08-11 16:18:06 +0200
  70. @@ -251,10 +251,6 @@
  71. # define PNG_SAVE_BSD_SOURCE
  72. # undef _BSD_SOURCE
  73. # endif
  74. -# ifdef _SETJMP_H
  75. - __png.h__ already includes setjmp.h;
  76. - __dont__ include it again.;
  77. -# endif
  78. # endif /* __linux__ */
  79. /* include setjmp.h for error handling */
  80. Index: src/3rdparty/libpng/pngerror.c
  81. --- src/3rdparty/libpng/pngerror.c.orig 2003-05-27 17:19:23 +0200
  82. +++ src/3rdparty/libpng/pngerror.c 2004-08-11 16:19:27 +0200
  83. @@ -135,10 +135,13 @@
  84. buffer[iout] = 0;
  85. else
  86. {
  87. + png_size_t len;
  88. + if ((len = png_strlen(error_message)) > 63)
  89. + len = 63;
  90. buffer[iout++] = ':';
  91. buffer[iout++] = ' ';
  92. - png_memcpy(buffer+iout, error_message, 64);
  93. - buffer[iout+63] = 0;
  94. + png_memcpy(buffer+iout, error_message, len);
  95. + buffer[iout+len] = 0;
  96. }
  97. }
  98. Index: src/3rdparty/libpng/pngrtran.c
  99. --- src/3rdparty/libpng/pngrtran.c.orig 2003-05-27 17:19:23 +0200
  100. +++ src/3rdparty/libpng/pngrtran.c 2004-08-11 16:26:04 +0200
  101. @@ -1889,8 +1889,8 @@
  102. /* This changes the data from GG to GGXX */
  103. if (flags & PNG_FLAG_FILLER_AFTER)
  104. {
  105. - png_bytep sp = row + (png_size_t)row_width;
  106. - png_bytep dp = sp + (png_size_t)row_width;
  107. + png_bytep sp = row + (png_size_t)row_width * 2;
  108. + png_bytep dp = sp + (png_size_t)row_width * 2;
  109. for (i = 1; i < row_width; i++)
  110. {
  111. *(--dp) = hi_filler;
  112. @@ -1907,8 +1907,8 @@
  113. /* This changes the data from GG to XXGG */
  114. else
  115. {
  116. - png_bytep sp = row + (png_size_t)row_width;
  117. - png_bytep dp = sp + (png_size_t)row_width;
  118. + png_bytep sp = row + (png_size_t)row_width * 2;
  119. + png_bytep dp = sp + (png_size_t)row_width * 2;
  120. for (i = 0; i < row_width; i++)
  121. {
  122. *(--dp) = *(--sp);
  123. @@ -1965,8 +1965,8 @@
  124. /* This changes the data from RRGGBB to RRGGBBXX */
  125. if (flags & PNG_FLAG_FILLER_AFTER)
  126. {
  127. - png_bytep sp = row + (png_size_t)row_width * 3;
  128. - png_bytep dp = sp + (png_size_t)row_width;
  129. + png_bytep sp = row + (png_size_t)row_width * 6;
  130. + png_bytep dp = sp + (png_size_t)row_width * 2;
  131. for (i = 1; i < row_width; i++)
  132. {
  133. *(--dp) = hi_filler;
  134. @@ -1987,8 +1987,8 @@
  135. /* This changes the data from RRGGBB to XXRRGGBB */
  136. else
  137. {
  138. - png_bytep sp = row + (png_size_t)row_width * 3;
  139. - png_bytep dp = sp + (png_size_t)row_width;
  140. + png_bytep sp = row + (png_size_t)row_width * 6;
  141. + png_bytep dp = sp + (png_size_t)row_width * 2;
  142. for (i = 0; i < row_width; i++)
  143. {
  144. *(--dp) = *(--sp);
  145. http://www.graphicsmagick.org/libpng/beta/patches/INFO.txt
  146. > [Problems discovered and fixed by] Chris Evans
  147. >
  148. > 1) Remotely exploitable stack-based buffer overrun in png_handle_tRNS (pngrutil.c)
  149. > 2) Dangerous code in png_handle_sBIT (pngrutil.c)
  150. CAN-2004-0597
  151. > 3) Possible NULL-pointer crash in png_handle_iCCP (pngrutil.c)
  152. > this flaw is duplicated in multiple other locations.
  153. CAN-2004-0598
  154. > 4) Theoretical integer overflow in allocation in png_handle_sPLT (pngrutil.c)
  155. > 5) Integer overflow in png_read_png (pngread.c)
  156. > 6) Integer overflows during progressive reading.
  157. > 7) Other flaws. [integer overflows]
  158. CAN-2004-0599
  159. http://www.graphicsmagick.org/libpng/beta/patches/libpng-patch03-trns-chunk-overflow.txt
  160. Use to patch libpng-1.0.9 through 1.2.5
  161. This fixes the most dangerous of the newly reported vulnerabilities
  162. Index: src/3rdparty/libpng/pngrutil.c
  163. --- src/3rdparty/libpng/pngrutil.c.orig 2004-08-11 16:29:37 +0200
  164. +++ src/3rdparty/libpng/pngrutil.c 2004-08-11 16:30:11 +0200
  165. @@ -1241,7 +1241,8 @@
  166. /* Should be an error, but we can cope with it */
  167. png_warning(png_ptr, "Missing PLTE before tRNS");
  168. }
  169. - if (length > (png_uint_32)png_ptr->num_palette)
  170. + if (length > (png_uint_32)png_ptr->num_palette ||
  171. + length > PNG_MAX_PALETTE_LENGTH)
  172. {
  173. png_warning(png_ptr, "Incorrect tRNS chunk length");
  174. png_crc_finish(png_ptr, length);
  175. http://www.graphicsmagick.org/libpng/beta/patches/libpng-patch04-get-uint-31.txt
  176. Use to patch libpng-1.0.6 through 1.2.5
  177. This patch defines PNG_UINT_31_MAX, PNG_UINT_32_MAX, PNG_SIZE_MAX,
  178. and png_get_uint_31(), which are needed by patches 05-08.
  179. Index: src/3rdparty/libpng/png.h
  180. --- src/3rdparty/libpng/png.h.orig 2003-05-27 17:19:23 +0200
  181. +++ src/3rdparty/libpng/png.h 2004-08-11 16:31:06 +0200
  182. @@ -833,7 +833,11 @@
  183. typedef png_info FAR * FAR * png_infopp;
  184. /* Maximum positive integer used in PNG is (2^31)-1 */
  185. -#define PNG_MAX_UINT ((png_uint_32)0x7fffffffL)
  186. +#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
  187. +#define PNG_UINT_32_MAX (~((png_uint_32)0))
  188. +#define PNG_SIZE_MAX (~((png_size_t)0))
  189. +/* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */
  190. +#define PNG_MAX_UINT PNG_UINT_31_MAX
  191. /* These describe the color_type field in png_info. */
  192. /* color type masks */
  193. @@ -2655,6 +2659,8 @@
  194. PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf));
  195. PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf));
  196. #endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */
  197. +PNG_EXTERN png_uint_32 png_get_uint_31 PNGARG((png_structp png_ptr,
  198. + png_bytep buf));
  199. /* Initialize png_ptr struct for reading, and allocate any other memory.
  200. * (old interface - DEPRECATED - use png_create_read_struct instead).
  201. Index: src/3rdparty/libpng/pngrutil.c
  202. --- src/3rdparty/libpng/pngrutil.c.orig 2004-08-11 16:29:37 +0200
  203. +++ src/3rdparty/libpng/pngrutil.c 2004-08-11 16:32:11 +0200
  204. @@ -38,6 +38,14 @@
  205. # endif
  206. #endif
  207. +png_uint_32 /* PRIVATE */
  208. +png_get_uint_31(png_structp png_ptr, png_bytep buf)
  209. +{
  210. + png_uint_32 i = png_get_uint_32(buf);
  211. + if (i > PNG_UINT_31_MAX)
  212. + png_error(png_ptr, "PNG unsigned integer out of range.\n");
  213. + return (i);
  214. +}
  215. #ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
  216. /* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
  217. png_uint_32 /* PRIVATE */
  218. http://www.graphicsmagick.org/libpng/beta/patches/libpng-patch05-pngpread-chunklength.txt
  219. Use to patch libpng-1.0.0 through 1.2.5
  220. Requires one of libpng-patch04*
  221. Index: src/3rdparty/libpng/pngpread.c
  222. --- src/3rdparty/libpng/pngpread.c.orig 2003-05-27 17:19:23 +0200
  223. +++ src/3rdparty/libpng/pngpread.c 2004-08-11 16:34:45 +0200
  224. @@ -208,7 +208,7 @@
  225. }
  226. png_push_fill_buffer(png_ptr, chunk_length, 4);
  227. - png_ptr->push_length = png_get_uint_32(chunk_length);
  228. + png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length);
  229. png_reset_crc(png_ptr);
  230. png_crc_read(png_ptr, png_ptr->chunk_name, 4);
  231. png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
  232. @@ -591,6 +591,11 @@
  233. png_size_t new_max;
  234. png_bytep old_buffer;
  235. + if (png_ptr->save_buffer_size > PNG_SIZE_MAX -
  236. + (png_ptr->current_buffer_size + 256))
  237. + {
  238. + png_error(png_ptr, "Potential overflow of save_buffer");
  239. + }
  240. new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
  241. old_buffer = png_ptr->save_buffer;
  242. png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr,
  243. @@ -637,8 +642,7 @@
  244. }
  245. png_push_fill_buffer(png_ptr, chunk_length, 4);
  246. - png_ptr->push_length = png_get_uint_32(chunk_length);
  247. -
  248. + png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length);
  249. png_reset_crc(png_ptr);
  250. png_crc_read(png_ptr, png_ptr->chunk_name, 4);
  251. png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
  252. http://www.graphicsmagick.org/libpng/beta/patches/libpng-patch06-pngread-chunklength.txt
  253. Use to patch libpng-1.0.13 through 1.0.15 and 1.2.2 through 1.2.5.
  254. Requires libpng-patch04-*
  255. Index: src/3rdparty/libpng/pngpread.c
  256. --- src/3rdparty/libpng/pngread.c.orig 2003-05-27 17:19:23 +0200
  257. +++ src/3rdparty/libpng/pngread.c 2004-08-11 16:36:04 +0200
  258. @@ -384,7 +384,7 @@
  259. png_uint_32 length;
  260. png_read_data(png_ptr, chunk_length, 4);
  261. - length = png_get_uint_32(chunk_length);
  262. + length = png_get_uint_31(png_ptr,chunk_length);
  263. png_reset_crc(png_ptr);
  264. png_crc_read(png_ptr, png_ptr->chunk_name, 4);
  265. @@ -392,9 +392,6 @@
  266. png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name,
  267. length);
  268. - if (length > PNG_MAX_UINT)
  269. - png_error(png_ptr, "Invalid chunk length.");
  270. -
  271. /* This should be a binary subdivision search or a hash for
  272. * matching the chunk name rather than a linear search.
  273. */
  274. @@ -673,10 +670,7 @@
  275. png_crc_finish(png_ptr, 0);
  276. png_read_data(png_ptr, chunk_length, 4);
  277. - png_ptr->idat_size = png_get_uint_32(chunk_length);
  278. -
  279. - if (png_ptr->idat_size > PNG_MAX_UINT)
  280. - png_error(png_ptr, "Invalid chunk length.");
  281. + png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length);
  282. png_reset_crc(png_ptr);
  283. png_crc_read(png_ptr, png_ptr->chunk_name, 4);
  284. @@ -946,16 +940,13 @@
  285. #endif /* PNG_GLOBAL_ARRAYS */
  286. png_read_data(png_ptr, chunk_length, 4);
  287. - length = png_get_uint_32(chunk_length);
  288. + length = png_get_uint_31(png_ptr,chunk_length);
  289. png_reset_crc(png_ptr);
  290. png_crc_read(png_ptr, png_ptr->chunk_name, 4);
  291. png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name);
  292. - if (length > PNG_MAX_UINT)
  293. - png_error(png_ptr, "Invalid chunk length.");
  294. -
  295. if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4))
  296. png_handle_IHDR(png_ptr, info_ptr, length);
  297. else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4))
  298. http://www.graphicsmagick.org/libpng/beta/patches/libpng-patch07-png-read-png-overflow.txt
  299. Use to patch libpng-1.0.6 through 1.2.5. Libpng-1.0.5 and earlier didn't implement png_read_png().
  300. Requires libpng-patch04-*
  301. Index: src/3rdparty/libpng/pngread.c
  302. --- src/3rdparty/libpng/pngread.c.orig 2004-08-11 16:36:04 +0200
  303. +++ src/3rdparty/libpng/pngread.c 2004-08-11 16:37:39 +0200
  304. @@ -1290,6 +1290,9 @@
  305. */
  306. png_read_info(png_ptr, info_ptr);
  307. + if (info_ptr->height > PNG_UINT_32_MAX/sizeof(png_bytep))
  308. + png_error(png_ptr,"Image is too high to process with png_read_png()");
  309. +
  310. /* -------------- image transformations start here ------------------- */
  311. #if defined(PNG_READ_16_TO_8_SUPPORTED)
  312. http://www.graphicsmagick.org/libpng/beta/patches/libpng-patch08-splt-buffer-overflow.txt
  313. Use to patch libpng-1.0.6 through 1.2.5. Libpng-1.0.5 and earlier didn't implement png_read_png().
  314. Requires libpng-patch04-*
  315. The "sPLT chunk too long" check from Matthias Clasen (RedHat libpng package maintainer)
  316. Index: src/3rdparty/libpng/pngrutil.c
  317. --- src/3rdparty/libpng/pngrutil.c.orig 2004-08-05 15:27:41 +0200
  318. +++ src/3rdparty/libpng/pngrutil.c 2004-08-11 16:38:53 +0200
  319. @@ -1154,8 +1162,18 @@
  320. }
  321. new_palette.nentries = data_length / entry_size;
  322. - new_palette.entries = (png_sPLT_entryp)png_malloc(
  323. + if (new_palette.nentries > PNG_SIZE_MAX / sizeof(png_sPLT_entry))
  324. + {
  325. + png_warning(png_ptr, "sPLT chunk too long");
  326. + return;
  327. + }
  328. + new_palette.entries = (png_sPLT_entryp)png_malloc_warn(
  329. png_ptr, new_palette.nentries * sizeof(png_sPLT_entry));
  330. + if (new_palette.entries == NULL)
  331. + {
  332. + png_warning(png_ptr, "sPLT chunk requires too much memory");
  333. + return;
  334. + }
  335. #ifndef PNG_NO_POINTER_INDEXING
  336. for (i = 0; i < new_palette.nentries; i++)
  337. http://www.graphicsmagick.org/libpng/beta/patches/libpng-patch09-null-iccp-profile.txt
  338. Use to patch libpng-1.0.9 through 1.2.5. Does not work with libpng-1.0.6-1.0.8.
  339. Libpng-1.0.5 and earlier didn't implement iCCP chunk reading.
  340. Index: src/3rdparty/libpng/pngrutil.c
  341. --- src/3rdparty/libpng/pngrutil.c.orig 2004-08-05 15:27:41 +0200
  342. +++ src/3rdparty/libpng/pngrutil.c 2004-08-11 16:40:46 +0200
  343. @@ -977,8 +985,7 @@
  344. png_bytep pC;
  345. png_charp profile;
  346. png_uint_32 skip = 0;
  347. - png_uint_32 profile_size = 0;
  348. - png_uint_32 profile_length = 0;
  349. + png_uint_32 profile_size, profile_length;
  350. png_size_t slength, prefix_length, data_length;
  351. png_debug(1, "in png_handle_iCCP\n");
  352. http://www.graphicsmagick.org/libpng/beta/patches/libpng-patch10-find-duplicate-chunk.txt
  353. Use to patch libpng-1.0.6 through 1.2.5 Does not work with libpng-1.0.5 and earlier.
  354. No security problem. The bugs are similar to the one fixed in patch
  355. 03, but the only effect is that libpng will fail to detect misplaced
  356. harmless duplicate chunks.
  357. Index: src/3rdparty/libpng/pngrutil.c
  358. --- src/3rdparty/libpng/pngrutil.c.orig 2004-08-11 16:40:46 +0200
  359. +++ src/3rdparty/libpng/pngrutil.c 2004-08-11 16:42:31 +0200
  360. @@ -587,7 +587,7 @@
  361. /* Should be an error, but we can cope with it */
  362. png_warning(png_ptr, "Out of place gAMA chunk");
  363. - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
  364. + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
  365. #if defined(PNG_READ_sRGB_SUPPORTED)
  366. && !(info_ptr->valid & PNG_INFO_sRGB)
  367. #endif
  368. @@ -668,7 +668,7 @@
  369. /* Should be an error, but we can cope with it */
  370. png_warning(png_ptr, "Out of place sBIT chunk");
  371. }
  372. - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT))
  373. + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT))
  374. {
  375. png_warning(png_ptr, "Duplicate sBIT chunk");
  376. png_crc_finish(png_ptr, length);
  377. @@ -737,7 +737,7 @@
  378. /* Should be an error, but we can cope with it */
  379. png_warning(png_ptr, "Missing PLTE before cHRM");
  380. - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)
  381. + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)
  382. #if defined(PNG_READ_sRGB_SUPPORTED)
  383. && !(info_ptr->valid & PNG_INFO_sRGB)
  384. #endif
  385. @@ -899,7 +899,7 @@
  386. /* Should be an error, but we can cope with it */
  387. png_warning(png_ptr, "Out of place sRGB chunk");
  388. - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))
  389. + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))
  390. {
  391. png_warning(png_ptr, "Duplicate sRGB chunk");
  392. png_crc_finish(png_ptr, length);
  393. @@ -1002,7 +1002,7 @@
  394. /* Should be an error, but we can cope with it */
  395. png_warning(png_ptr, "Out of place iCCP chunk");
  396. - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP))
  397. + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP))
  398. {
  399. png_warning(png_ptr, "Duplicate iCCP chunk");
  400. png_crc_finish(png_ptr, length);
  401. This patch from Chris Evans avoids a host of security problems related
  402. to buffer overflows that might occur when processing very large images.
  403. It causes the reader to reject any images claiming to have more rows or
  404. columns the png format supports.
  405. Index: src/3rdparty/libpng/png.h
  406. --- src/3rdparty/libpng/png.h.orig 2004-08-11 16:31:06 +0200
  407. +++ src/3rdparty/libpng/png.h 2004-08-11 16:44:14 +0200
  408. @@ -839,6 +839,9 @@
  409. /* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */
  410. #define PNG_MAX_UINT PNG_UINT_31_MAX
  411. +/* Constraints on width, height, (2 ^ 24) - 1*/
  412. +#define PNG_MAX_DIMENSION 16777215
  413. +
  414. /* These describe the color_type field in png_info. */
  415. /* color type masks */
  416. #define PNG_COLOR_MASK_PALETTE 1
  417. Index: src/3rdparty/libpng/pngrutil.c
  418. --- src/3rdparty/libpng/pngrutil.c.orig 2004-08-11 16:42:31 +0200
  419. +++ src/3rdparty/libpng/pngrutil.c 2004-08-11 16:45:38 +0200
  420. @@ -355,7 +355,11 @@
  421. png_crc_finish(png_ptr, 0);
  422. width = png_get_uint_32(buf);
  423. + if (width > PNG_MAX_DIMENSION)
  424. + png_error(png_ptr, "Width is too large");
  425. height = png_get_uint_32(buf + 4);
  426. + if (height > PNG_MAX_DIMENSION)
  427. + png_error(png_ptr, "Height is too large");
  428. bit_depth = buf[8];
  429. color_type = buf[9];
  430. compression_type = buf[10];
  431. @@ -680,7 +684,7 @@
  432. else
  433. truelen = (png_size_t)png_ptr->channels;
  434. - if (length != truelen)
  435. + if (length != truelen || length > 4)
  436. {
  437. png_warning(png_ptr, "Incorrect sBIT chunk length");
  438. png_crc_finish(png_ptr, length);
  439. @@ -1415,7 +1419,7 @@
  440. void /* PRIVATE */
  441. png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
  442. {
  443. - int num, i;
  444. + unsigned int num, i;
  445. png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH];
  446. png_debug(1, "in png_handle_hIST\n");
  447. @@ -1441,8 +1445,8 @@
  448. return;
  449. }
  450. - num = (int)length / 2 ;
  451. - if (num != png_ptr->num_palette)
  452. + num = length / 2 ;
  453. + if (num != png_ptr->num_palette || num > PNG_MAX_PALETTE_LENGTH)
  454. {
  455. png_warning(png_ptr, "Incorrect hIST chunk length");
  456. png_crc_finish(png_ptr, length);
  457. @@ -2883,6 +2887,9 @@
  458. png_read_data(png_ptr, chunk_length, 4);
  459. png_ptr->idat_size = png_get_uint_32(chunk_length);
  460. + if (png_ptr->idat_size > PNG_MAX_UINT)
  461. + png_error(png_ptr, "Invalid chunk length.");
  462. +
  463. png_reset_crc(png_ptr);
  464. png_crc_read(png_ptr, png_ptr->chunk_name, 4);
  465. if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))