[grilo-plugins] jamendo: use the correct feed id and validate it



commit 84f6eaff4cedf9c22c5bc78b31343c789fcdf28c
Author: Víctor Manuel Jáquez Leal <vjaquez igalia com>
Date:   Mon May 2 16:58:47 2011 +0200

    jamendo: use the correct feed id and validate it
    
    Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez igalia com>

 src/media/jamendo/grl-jamendo.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/src/media/jamendo/grl-jamendo.c b/src/media/jamendo/grl-jamendo.c
index dc29f94..f0e2a59 100644
--- a/src/media/jamendo/grl-jamendo.c
+++ b/src/media/jamendo/grl-jamendo.c
@@ -31,6 +31,7 @@
 #include <libxml/parser.h>
 #include <libxml/xmlmemory.h>
 #include <string.h>
+#include <errno.h>
 
 #include "grl-jamendo.h"
 
@@ -1039,7 +1040,16 @@ grl_jamendo_source_metadata (GrlMediaSource *source,
       if (id_split[1]) {
         int i;
 
-        i = atoi (id_split[0]);
+        errno = 0;
+        i = strtol (id_split[1], NULL, 0);
+        if (errno != 0 || (i <= 0 && i > G_N_ELEMENTS (feeds))) {
+          error = g_error_new (GRL_CORE_ERROR,
+                               GRL_CORE_ERROR_METADATA_FAILED,
+                               "Invalid cat id: '%s'", id_split[1]);
+          g_strfreev (id_split);
+          goto send_error;
+        }
+
         update_media_from_feed (ms->media, i);
       } else {
         update_media_from_feeds (ms->media);



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