[PATCH plugins 4/4] 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);
-- 
1.7.4.4



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