[tracker-miners/wip/carlosg/coverity-fixes: 25/28] tracker-extract: Set a fixed max to look for the biggest image in ICO




commit 15ec4dbb45069221cde7f8888df29cc920e99370
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Oct 24 12:49:08 2021 +0200

    tracker-extract: Set a fixed max to look for the biggest image in ICO
    
    Coverity complains we are looping based on untrusted data, which is
    true. Set a reasonable maximum of images to look for the biggest one.
    
    CID: #365682

 src/tracker-extract/tracker-extract-icon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/src/tracker-extract/tracker-extract-icon.c b/src/tracker-extract/tracker-extract-icon.c
index ecdbb3a2c..d73ad7d4e 100644
--- a/src/tracker-extract/tracker-extract-icon.c
+++ b/src/tracker-extract/tracker-extract-icon.c
@@ -24,6 +24,7 @@
 
 #define ICON_HEADER_SIZE_16 3
 #define ICON_IMAGE_METADATA_SIZE_8 16
+#define MAX_IMAGES 16
 
 static gboolean
 find_max_width_and_height (const gchar *uri,
@@ -77,7 +78,7 @@ find_max_width_and_height (const gchar *uri,
        g_debug ("Found '%u' images in the icon file...", n_images);
 
        /* Loop images looking for the biggest one... */
-       for (i = 0; i < n_images; i++) {
+       for (i = 0; i < MIN (MAX_IMAGES, n_images); i++) {
                guint8 image_metadata [ICON_IMAGE_METADATA_SIZE_8];
 
                /* Image metadata chunk consists of:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]