[grilo-plugins] raitv: Fix possible out-of-bounds array access



commit 32a0f4393213faf27f255bf9dac7d920778de36e
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Jan 6 17:14:32 2014 +0100

    raitv: Fix possible out-of-bounds array access
    
    get_theme_index_from_id() might return a negative value, which might
    end up causing out-of-bounds array accesses.
    
    Instead, assert when get_theme_index_from_id() fails to show that
    an internal error occurred.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=721642

 src/raitv/grl-raitv.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/raitv/grl-raitv.c b/src/raitv/grl-raitv.c
index ed1e16d..8d46f97 100644
--- a/src/raitv/grl-raitv.c
+++ b/src/raitv/grl-raitv.c
@@ -951,17 +951,17 @@ proxy_call_resolve_grlnet_async_cb (GObject *source_object,
 
 
 
-static gint
+static guint
 get_theme_index_from_id (const gchar *category_id)
 {
-  gint i;
+  guint i;
 
   for (i=0; i<root_dir[ROOT_DIR_POPULARS_INDEX].count; i++) {
     if (g_strrstr (category_id, themes_dir[i].id)) {
       return i;
     }
   }
-  return -1;
+  g_assert_not_reached ();
 }
 
 static gboolean
@@ -1082,7 +1082,7 @@ produce_from_directory (CategoryInfo *dir, gint dir_size, RaitvOperation *os,
 static void
 produce_from_popular_theme (RaitvOperation *op)
 {
-  gint category_index;
+  guint category_index;
   gchar        *start = NULL;
   gchar        *url = NULL;
 
@@ -1110,7 +1110,7 @@ produce_from_popular_theme (RaitvOperation *op)
 static void
 produce_from_recent_theme (RaitvOperation *op)
 {
-  gint category_index;
+  guint category_index;
   gchar        *start = NULL;
   gchar        *url = NULL;
 


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