File libraw-CVE-2018-5811,5812.patch of Package libraw.8527

--- a/internal/dcraw_common.cpp
+++ b/internal/dcraw_common.cpp
@@ -1228,9 +1228,14 @@ void CLASS pentax_load_raw()
 
 void CLASS nikon_coolscan_load_raw()
 {
-  int bufsize = width*3*tiff_bps/8;
-  if(tiff_bps <= 8)
-    gamma_curve(1.0/imgdata.params.coolscan_nef_gamma,0.,1,255);
+  if(!image)
+    throw LIBRAW_EXCEPTION_IO_CORRUPT;
+
+  int bypp = tiff_bps <= 8 ? 1 : 2;
+  int bufsize = width * 3 * bypp;
+
+  if (tiff_bps <= 8)
+    gamma_curve(1.0 / imgdata.params.coolscan_nef_gamma, 0., 1, 255);
   else
     gamma_curve(1.0/imgdata.params.coolscan_nef_gamma,0.,1,65535);
   fseek (ifp, data_offset, SEEK_SET);
openSUSE Build Service is sponsored by