File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2241,15 +2241,20 @@ void client_update_icons(ObClient *self)
22412241 while (i + 2 < num ) { /* +2 is to make sure there is a w and h */
22422242 w = data [i ++ ];
22432243 h = data [i ++ ];
2244+ /* calculate the data size as guint64 to prevent integer
2245+ overflow due to invalid data */
2246+ guint64 size = w * h ;
22442247 /* watch for the data being too small for the specified size,
22452248 or for zero sized icons. */
2246- if (i + w * h > num || w == 0 || h == 0 ) {
2247- i += w * h ;
2249+ if (i + size > num || size < w || size < h ) {
2250+ break ;
2251+ } else if (w == 0 || h == 0 ) {
2252+ i += size ;
22482253 continue ;
22492254 }
22502255
22512256 /* convert it to the right bit order for ObRender */
2252- for (j = 0 ; j < w * h ; ++ j )
2257+ for (j = 0 ; j < size ; ++ j )
22532258 data [i + j ] =
22542259 (((data [i + j ] >> 24 ) & 0xff ) << RrDefaultAlphaOffset ) +
22552260 (((data [i + j ] >> 16 ) & 0xff ) << RrDefaultRedOffset ) +
@@ -2262,7 +2267,7 @@ void client_update_icons(ObClient *self)
22622267 else
22632268 RrImageAddFromData (img , & data [i ], w , h );
22642269
2265- i += w * h ;
2270+ i += size ;
22662271 }
22672272
22682273 g_free (data );
You can’t perform that action at this time.
0 commit comments