File djvulibre-CVE-2019-18804.patch of Package djvulibre.30379

Index: djvulibre-3.5.25/libdjvu/IW44EncodeCodec.cpp
===================================================================
--- djvulibre-3.5.25.orig/libdjvu/IW44EncodeCodec.cpp	2012-05-08 04:56:53.000000000 +0200
+++ djvulibre-3.5.25/libdjvu/IW44EncodeCodec.cpp	2021-05-11 15:14:07.954166235 +0200
@@ -405,7 +405,7 @@ filter_fv(short *p, int w, int h, int ro
   int y = 0;
   int s = scale*rowsize;
   int s3 = s+s+s;
-  h = ((h-1)/scale)+1;
+  h = (h>0) ? ((h-1)/scale)+1 : 0;
   y += 1;
   p += s;
   while (y-3 < h)
Index: djvulibre-3.5.25/tools/ddjvu.cpp
===================================================================
--- djvulibre-3.5.25.orig/tools/ddjvu.cpp	2012-05-08 04:56:53.000000000 +0200
+++ djvulibre-3.5.25/tools/ddjvu.cpp	2021-05-11 15:14:18.270223363 +0200
@@ -274,7 +274,7 @@ render(ddjvu_page_t *page, int pageno)
       prect.h = (ih * 100) / dpi;
     }
   /* Process aspect ratio */
-  if (flag_aspect <= 0)
+  if (flag_aspect <= 0 && iw>0 && ih>0)
     {
       double dw = (double)iw / prect.w;
       double dh = (double)ih / prect.h;
openSUSE Build Service is sponsored by