Skip to content
Browse files

dbus: validate search type value

This patch adds the validation of the search type input. If it is lesser than
zero o bigger than the max number of search types, it returns an error.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
  • Loading branch information...
1 parent e3a0296 commit d8c184815d7002a4fe60742f30d94eb67f0d4ad8 @ceyusa committed
Showing with 12 additions and 0 deletions.
  1. +9 −0 backend/gt-feed-server.c
  2. +2 −0 backend/gt-feed.c
  3. +1 −0 backend/gt-feed.h
View
9 backend/gt-feed-server.c
@@ -175,6 +175,15 @@ query(GtFeedServer *self,
return;
}
+ if (type < GT_FEED_SEARCH_MOVIES || type >= GT_FEED_SEARCH_MAX) {
+ g_dbus_method_invocation_return_error
+ (invocation,
+ GT_FEED_SERVER_ERROR,
+ GT_FEED_SERVICE_ERROR_MISSING_PARAMETER,
+ "Search type is not valid.");
+ return;
+ }
+
res = gt_feed_search(feed, type, query, cb, invocation);
g_free(query);
View
2 backend/gt-feed.c
@@ -229,6 +229,8 @@ gt_feed_search(GtFeed *self,
GSimpleAsyncResult *res;
g_return_val_if_fail(query != NULL, FALSE);
+ g_return_val_if_fail(type >= GT_FEED_SEARCH_MOVIES ||
+ type < GT_FEED_SEARCH_MAX, FALSE);
{
char *url = build_url(type, query, priv->apikey);
View
1 backend/gt-feed.h
@@ -31,6 +31,7 @@ typedef enum {
GT_FEED_SEARCH_MOVIES,
GT_FEED_SEARCH_SHOWS,
GT_FEED_SEARCH_EPISODES,
+ GT_FEED_SEARCH_MAX
} GtFeedSearchType;
typedef enum {

0 comments on commit d8c1848

Please sign in to comment.
Something went wrong with that request. Please try again.