mirror of the now-defunct rocklinux.org
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.

216 lines
7.1 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/rene/xzgv/xzgv-0.8-integer-overflow-fix.patch
  9. # ROCK Linux is Copyright (C) 1998 - 2005 Clifford Wolf
  10. #
  11. # This patch file is dual-licensed. It is available under the license the
  12. # patched project is licensed under, as long as it is an OpenSource license
  13. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  14. # of the GNU General Public License as published by the Free Software
  15. # Foundation; either version 2 of the License, or (at your option) any later
  16. # version.
  17. #
  18. # --- ROCK-COPYRIGHT-NOTE-END ---
  19. diff -urN xzgv-0.8/ChangeLog xzgv/ChangeLog
  20. --- xzgv-0.8/ChangeLog Tue Sep 16 15:08:42 2003
  21. +++ xzgv/ChangeLog Wed Dec 15 03:30:46 2004
  22. @@ -1,3 +1,13 @@
  23. +2004-11-03 Russell Marks <russell.marks@ntlworld.com>
  24. +
  25. + * Added width/height limits to all native picture readers. This is
  26. + a crude (albeit effective) fix for heap overflow bugs - there may
  27. + yet be more subtle problems, but I can't really fix them until I
  28. + know they're there. :-) Thanks to Luke Macken for letting me know
  29. + about the heap overflow problems (in zgv). I suppose I should also
  30. + thank "infamous41md" for publishing the original advisory/exploit
  31. + (again for zgv), even if he didn't bother emailing me or anything.
  32. +
  33. 2003-09-16 Russell Marks <russell.marks@ntlworld.com>
  34. * Version 0.8.
  35. diff -urN xzgv-0.8/src/Makefile xzgv/src/Makefile
  36. --- xzgv-0.8/src/Makefile Tue Jan 1 05:37:45 2002
  37. +++ xzgv/src/Makefile Wed Dec 15 03:30:46 2004
  38. @@ -84,18 +84,19 @@
  39. logo.o: logo.c logodata.h
  40. logoconv.o: logoconv.c
  41. main.o: main.c backend.h readmrf.h readgif.h readpng.h readjpeg.h \
  42. - readtiff.h resizepic.h rcfile.h filedetails.h gotodir.h updatetn.h \
  43. - confirm.h misc.h copymove.h rename.h help.h dir_icon.xpm \
  44. + readtiff.h readprf.h resizepic.h rcfile.h filedetails.h gotodir.h \
  45. + updatetn.h confirm.h misc.h copymove.h rename.h help.h dir_icon.xpm \
  46. dir_icon_small.xpm file_icon.xpm file_icon_small.xpm logo.h \
  47. icon-48.xpm main.h
  48. misc.o: misc.c misc.h
  49. rcfile.o: rcfile.c getopt.h rcfile.h rcfile_opt.h rcfile_var.h \
  50. rcfile_short.h
  51. -readgif.o: readgif.c readgif.h
  52. -readjpeg.o: readjpeg.c rcfile.h readjpeg.h
  53. -readmrf.o: readmrf.c readmrf.h
  54. +readgif.o: readgif.c reader.h readgif.h
  55. +readjpeg.o: readjpeg.c rcfile.h reader.h readjpeg.h
  56. +readmrf.o: readmrf.c reader.h readmrf.h
  57. readpng.o: readpng.c readpng.h
  58. -readtiff.o: readtiff.c readtiff.h
  59. +readprf.o: readprf.c reader.h readprf.h
  60. +readtiff.o: readtiff.c reader.h readtiff.h
  61. rename.o: rename.c backend.h main.h rename.h
  62. resizepic.o: resizepic.c resizepic.h
  63. updatetn.o: updatetn.c backend.h main.h rcfile.h dither.h resizepic.h \
  64. diff -urN xzgv-0.8/src/reader.h xzgv/src/reader.h
  65. --- xzgv-0.8/src/reader.h Thu Jan 1 01:00:00 1970
  66. +++ xzgv/src/reader.h Wed Dec 15 03:30:46 2004
  67. @@ -0,0 +1,15 @@
  68. +/* xzgv 0.8 - picture viewer for X, with file selector.
  69. + * Copyright (C) 1999-2004 Russell Marks. See main.c for license details.
  70. + *
  71. + * reader.h
  72. + */
  73. +
  74. +/* range check on width and height as a crude way of avoiding overflows
  75. + * when calling malloc/calloc. 32767 is the obvious limit to use given that
  76. + * xzgv effectively imposes such a limit anyway.
  77. + * Adds an extra 2 to height for max-height check, partly to reflect what
  78. + * the check in zgv does but also to allow for readtiff.c allocating an
  79. + * extra line (so at least an extra 1 would have been needed in any case).
  80. + */
  81. +#define WH_MAX 32767
  82. +#define WH_BAD(w,h) ((w)<=0 || (w)>WH_MAX || (h)<=0 || ((h)+2)>WH_MAX)
  83. diff -urN xzgv-0.8/src/readgif.c xzgv/src/readgif.c
  84. --- xzgv-0.8/src/readgif.c Sun Mar 3 04:34:32 2002
  85. +++ xzgv/src/readgif.c Wed Dec 15 03:30:46 2004
  86. @@ -8,6 +8,7 @@
  87. #include <string.h>
  88. #include <unistd.h>
  89. #include <stdlib.h>
  90. +#include "reader.h"
  91. #include "readgif.h"
  92. @@ -103,7 +104,7 @@
  93. if(local_colour_map) readcolmap(in);
  94. - if((image=malloc(width*height*3))==NULL)
  95. + if(WH_BAD(width,height) || (image=malloc(width*height*3))==NULL)
  96. {
  97. fclose(in);
  98. return(0);
  99. diff -urN xzgv-0.8/src/readjpeg.c xzgv/src/readjpeg.c
  100. --- xzgv-0.8/src/readjpeg.c Tue Sep 16 12:52:04 2003
  101. +++ xzgv/src/readjpeg.c Wed Dec 15 03:30:46 2004
  102. @@ -13,6 +13,7 @@
  103. #include <jpeglib.h>
  104. #include "rcfile.h"
  105. +#include "reader.h"
  106. #include "readjpeg.h"
  107. @@ -265,7 +266,7 @@
  108. /* this one shouldn't hurt */
  109. cinfo.do_block_smoothing=FALSE;
  110. -if((*imagep=image=malloc(width*height*3))==NULL)
  111. +if(WH_BAD(width,height) || (*imagep=image=malloc(width*height*3))==NULL)
  112. longjmp(jerr.setjmp_buffer,1);
  113. jpeg_start_decompress(&cinfo);
  114. diff -urN xzgv-0.8/src/readmrf.c xzgv/src/readmrf.c
  115. --- xzgv-0.8/src/readmrf.c Sat Oct 7 14:26:55 2000
  116. +++ xzgv/src/readmrf.c Wed Dec 15 03:30:46 2004
  117. @@ -7,6 +7,7 @@
  118. #include <stdio.h>
  119. #include <string.h>
  120. #include <stdlib.h>
  121. +#include "reader.h"
  122. #include "readmrf.h"
  123. @@ -91,7 +92,8 @@
  124. w64=(w+63)/64;
  125. h64=(h+63)/64;
  126. -if((*bmap=malloc(w*h*3))==NULL ||
  127. +if(WH_BAD(w64*64,h64*64) || WH_BAD(w,h) ||
  128. + (*bmap=malloc(w*h*3))==NULL ||
  129. (image=calloc(w64*h64*64*64,1))==NULL)
  130. {
  131. if(*bmap) free(*bmap),*bmap=NULL;
  132. diff -urN xzgv-0.8/src/readpng.c xzgv/src/readpng.c
  133. --- xzgv-0.8/src/readpng.c Thu Jul 10 16:13:43 2003
  134. +++ xzgv/src/readpng.c Wed Dec 15 03:32:46 2004
  135. @@ -16,6 +16,7 @@
  136. #include <stdlib.h>
  137. #include <png.h>
  138. #include <setjmp.h> /* after png.h to avoid horrible thing in pngconf.h */
  139. +#include "reader.h"
  140. #include "readpng.h"
  141. @@ -129,7 +130,8 @@
  142. }
  143. /* allocate image memory */
  144. -if((*theimageptr=theimage=malloc(width*height*3))==NULL)
  145. +if(WH_BAD(width,height) ||
  146. + (*theimageptr=theimage=malloc(width*height*3))==NULL)
  147. {
  148. png_read_end(png_ptr,info_ptr);
  149. png_destroy_read_struct(&png_ptr,&info_ptr,NULL);
  150. diff -urN xzgv-0.8/src/readprf.c xzgv/src/readprf.c
  151. --- xzgv-0.8/src/readprf.c Mon Apr 9 19:08:19 2001
  152. +++ xzgv/src/readprf.c Wed Dec 15 03:30:46 2004
  153. @@ -7,6 +7,7 @@
  154. #include <stdio.h>
  155. #include <string.h>
  156. #include <stdlib.h>
  157. +#include "reader.h"
  158. #include "readprf.h"
  159. #define squaresize 64
  160. @@ -164,7 +165,7 @@
  161. bytepp=1;
  162. n=width*squaresize;
  163. -if((planebuf[0]=calloc(n,planes))==NULL)
  164. +if(WH_BAD(width,height) || (planebuf[0]=calloc(n,planes))==NULL)
  165. {
  166. fclose(in);
  167. return(0);
  168. @@ -173,6 +174,7 @@
  169. for(f=1;f<planes;f++)
  170. planebuf[f]=planebuf[f-1]+n;
  171. +/* width/height already checked above */
  172. if((*theimageptr=malloc(width*height*3))==NULL)
  173. {
  174. free(planebuf[0]);
  175. diff -urN xzgv-0.8/src/readtiff.c xzgv/src/readtiff.c
  176. --- xzgv-0.8/src/readtiff.c Thu Dec 28 03:20:55 2000
  177. +++ xzgv/src/readtiff.c Wed Dec 15 03:30:46 2004
  178. @@ -11,7 +11,7 @@
  179. #include <setjmp.h>
  180. #include <sys/file.h> /* for open et al */
  181. #include <tiffio.h>
  182. -
  183. +#include "reader.h"
  184. #include "readtiff.h"
  185. @@ -36,7 +36,8 @@
  186. * spare for the flip afterwards.
  187. */
  188. numpix=width*height;
  189. -if((image=malloc(numpix*sizeof(uint32)+width*3))==NULL)
  190. +if(WH_BAD(width,height) ||
  191. + (image=malloc(numpix*sizeof(uint32)+width*3))==NULL)
  192. {
  193. TIFFClose(in);
  194. return(0);