[gnome-calendar/mcatanzaro/#425] Fix buffer overflow in get_icon_name_sortkey()



commit 94569afa6d631ccaa703b251c404ca86f9e3778c
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Wed Jul 3 21:35:12 2019 -0500

    Fix buffer overflow in get_icon_name_sortkey()
    
    We can just use strlen() here.
    
    Fixes #425

 src/weather/gcal-weather-service.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/src/weather/gcal-weather-service.c b/src/weather/gcal-weather-service.c
index 5ca08a27..0f721049 100644
--- a/src/weather/gcal-weather-service.c
+++ b/src/weather/gcal-weather-service.c
@@ -311,7 +311,8 @@ get_icon_name_sortkey (const gchar *icon_name,
 
   for (i = 0; i < G_N_ELEMENTS (icons); i++)
     {
-      if (icons[i].name[normalized_name_len] == '\0' && strncmp (icon_name, icons[i].name, 
normalized_name_len) == 0)
+      if (normalized_name_len == strlen (icons[i].name) &&
+          strncmp (icon_name, icons[i].name, normalized_name_len) == 0)
         {
           *supports_night_icon = icons[i].night_support;
           return i;


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