7eb5fa
Author: Filip Hroch <hroch@physics.muni.cz>
7eb5fa
Description: stack-based buffer overflow bug
7eb5fa
--- a/dcraw.c
7eb5fa
+++ b/dcraw.c
7eb5fa
@@ -8345,9 +8345,15 @@
7eb5fa
 {
7eb5fa
   UINT64 bitbuf=0;
7eb5fa
   int vbits, col, i, c;
7eb5fa
-  ushort img[2][2064];
7eb5fa
+  ushort *img;
7eb5fa
   double sum[]={0,0};
7eb5fa
 
7eb5fa
+#define IMG2D(row,col) \
7eb5fa
+  img[(row)*width+(col)]
7eb5fa
+
7eb5fa
+  img = (ushort *) malloc(2*width*sizeof(ushort));
7eb5fa
+  merror (img, "find_green()");
7eb5fa
+
7eb5fa
   FORC(2) {
7eb5fa
     fseek (ifp, c ? off1:off0, SEEK_SET);
7eb5fa
     for (vbits=col=0; col < width; col++) {
7eb5fa
@@ -8356,13 +8362,14 @@
7eb5fa
 	for (i=0; i < bite; i+=8)
7eb5fa
 	  bitbuf |= (unsigned) (fgetc(ifp) << i);
7eb5fa
       }
7eb5fa
-      img[c][col] = bitbuf << (64-bps-vbits) >> (64-bps);
7eb5fa
+      IMG2D(c,col) = bitbuf << (64-bps-vbits) >> (64-bps);
7eb5fa
     }
7eb5fa
   }
7eb5fa
   FORC(width-1) {
7eb5fa
-    sum[ c & 1] += ABS(img[0][c]-img[1][c+1]);
7eb5fa
-    sum[~c & 1] += ABS(img[1][c]-img[0][c+1]);
7eb5fa
+    sum[ c & 1] += ABS(IMG2D(0,c)-IMG2D(1,c+1));
7eb5fa
+    sum[~c & 1] += ABS(IMG2D(1,c)-IMG2D(0,c+1));
7eb5fa
   }
7eb5fa
+  free(img);
7eb5fa
   return 100 * log(sum[0]/sum[1]);
7eb5fa
 }
7eb5fa