File libraw-SA79000.patch of Package libraw

Index: LibRaw-0.15.4/internal/dcraw_common.cpp
===================================================================
--- LibRaw-0.15.4.orig/internal/dcraw_common.cpp	2018-03-12 10:59:23.931588395 +0100
+++ LibRaw-0.15.4/internal/dcraw_common.cpp	2018-03-12 11:13:35.878175827 +0100
@@ -1769,6 +1769,8 @@ void CLASS sinar_4shot_load_raw()
   image = (ushort (*)[4])
 	calloc ((iheight=height)*(iwidth=width), sizeof *image);
   merror (image, "sinar_4shot_load_raw()");
+  if(!image)
+    throw LIBRAW_EXCEPTION_IO_CORRUPT;
 #endif
   pixel = (ushort *) calloc (raw_width, sizeof *pixel);
   merror (pixel, "sinar_4shot_load_raw()");
@@ -2077,6 +2079,11 @@ void CLASS quicktake_100_load_raw()
 
 void CLASS kodak_radc_load_raw()
 {
+#ifdef LIBRAW_LIBRARY_BUILD
+  // All kodak radc images are 768x512
+  if(width>768 || raw_width>768 || height > 512 || raw_height>512 )
+    throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
   static const char src[] = {
     1,1, 2,3, 3,4, 4,2, 5,7, 6,5, 7,6, 7,8,
     1,0, 2,1, 3,3, 4,4, 5,2, 6,7, 7,6, 8,5, 8,8,
@@ -2257,6 +2264,10 @@ void CLASS kodak_jpeg_load_raw()
 
 void CLASS lossy_dng_load_raw()
 {
+#ifdef LIBRAW_LIBRARY_BUILD
+  if(!image)
+    throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
   struct jpeg_decompress_struct cinfo;
   struct jpeg_error_mgr jerr;
   JSAMPARRAY buf;
@@ -2356,6 +2367,10 @@ void CLASS eight_bit_load_raw()
 
 void CLASS kodak_yrgb_load_raw()
 {
+#ifdef LIBRAW_LIBRARY_BUILD
+  if(!image)
+    throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
   uchar *pixel;
   int row, col, y, cb, cr, rgb[3], c;
 
@@ -2490,6 +2505,10 @@ void CLASS kodak_65000_load_raw()
 
 void CLASS kodak_ycbcr_load_raw()
 {
+#ifdef LIBRAW_LIBRARY_BUILD
+  if(!image)
+    throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
   short buf[384], *bp;
   int row, col, len, c, i, j, k, y[2][2], cb, cr, rgb[3];
   ushort *ip;
@@ -2517,6 +2536,10 @@ void CLASS kodak_ycbcr_load_raw()
 
 void CLASS kodak_rgb_load_raw()
 {
+#ifdef LIBRAW_LIBRARY_BUILD
+  if(!image)
+    throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
   short buf[768], *bp;
   int row, col, len, c, i, rgb[3];
   ushort *ip=image[0];
@@ -2537,6 +2560,10 @@ void CLASS kodak_rgb_load_raw()
 
 void CLASS kodak_thumb_load_raw()
 {
+#ifdef LIBRAW_LIBRARY_BUILD
+  if(!image)
+    throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
   int row, col;
   colors = thumb_misc >> 5;
   for (row=0; row < height; row++)
Index: LibRaw-0.15.4/src/libraw_cxx.cpp
===================================================================
--- LibRaw-0.15.4.orig/src/libraw_cxx.cpp	2018-03-12 10:59:23.887587639 +0100
+++ LibRaw-0.15.4/src/libraw_cxx.cpp	2018-03-12 10:59:23.947588670 +0100
@@ -1138,7 +1138,7 @@ int LibRaw::unpack(void)
             S.raw_pitch = S.width*8;
             // allocate image as temporary buffer, size 
             imgdata.rawdata.raw_alloc = 0;
-            imgdata.image = (ushort (*)[4]) calloc(S.iwidth*S.iheight,sizeof(*imgdata.image));
+            imgdata.image = (ushort(*)[4])calloc(unsigned(MAX(S.width,S.raw_width)) * unsigned(MAX(S.height,S.raw_height)), sizeof(*imgdata.image));
 	    imgdata.rawdata.raw_image = (ushort*) imgdata.image ;
 	    zero_rawimage = 1;
           }
openSUSE Build Service is sponsored by