File libcaca-prevent-overflow.patch of Package libcaca.18503

Author: Josef Möllers <jmoellers@suse.de>
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/dither.c
===================================================================
--- libcaca-da28e9684ef445ac8d42745644336b8a75c01855.orig/caca/dither.c
+++ libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/dither.c
@@ -116,7 +116,7 @@ enum color_mode
 struct caca_dither
 {
     int bpp, has_palette, has_alpha;
-    int w, h, pitch;
+    size_t w, h, pitch;
     int rmask, gmask, bmask, amask;
     int rright, gright, bright, aright;
     int rleft, gleft, bleft, aleft;
@@ -991,10 +991,10 @@ int caca_dither_bitmap(caca_canvas_t *cv
         /* First get RGB */
         if(d->antialias)
         {
-            fromx = (x - x1) * w / deltax;
-            fromy = (y - y1) * h / deltay;
-            tox = (x - x1 + 1) * w / deltax;
-            toy = (y - y1 + 1) * h / deltay;
+            fromx = (uint64_t)(x - x1) * w / deltax;
+            fromy = (uint64_t)(y - y1) * h / deltay;
+            tox = (uint64_t)(x - x1 + 1) * w / deltax;
+            toy = (uint64_t)(y - y1 + 1) * h / deltay;
 
             /* We want at least one pixel */
             if(tox == fromx) tox++;
@@ -1017,10 +1017,10 @@ int caca_dither_bitmap(caca_canvas_t *cv
         }
         else
         {
-            fromx = (x - x1) * w / deltax;
-            fromy = (y - y1) * h / deltay;
-            tox = (x - x1 + 1) * w / deltax;
-            toy = (y - y1 + 1) * h / deltay;
+            fromx = (uint64_t)(x - x1) * w / deltax;
+            fromy = (uint64_t)(y - y1) * h / deltay;
+            tox = (uint64_t)(x - x1 + 1) * w / deltax;
+            toy = (uint64_t)(y - y1 + 1) * h / deltay;
 
             /* tox and toy can overflow the canvas, but they cannot overflow
              * when averaged with fromx and fromy because these are guaranteed
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/src/common-image.h
===================================================================
--- libcaca-da28e9684ef445ac8d42745644336b8a75c01855.orig/src/common-image.h
+++ libcaca-da28e9684ef445ac8d42745644336b8a75c01855/src/common-image.h
@@ -13,7 +13,7 @@
 struct image
 {
     char *pixels;
-    unsigned int w, h;
+    size_t w, h;
     struct caca_dither *dither;
     void *priv;
 };
openSUSE Build Service is sponsored by