Blob Blame Raw
From d55ae8ec77a7ef24ee5a6ea5a0eb5bf8febc6cca Mon Sep 17 00:00:00 2001
From: Michael Catanzaro <mcatanzaro@igalia.com>
Date: Wed, 3 Jul 2019 21:35:12 -0500
Subject: [PATCH] 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 53e2ce9a..81052dfe 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;
-- 
2.21.0