[rygel] core: Return 402 on extra argument



commit 4a6e56ade979196cfcddf9d6d503b7af28a8d02d
Author: Jens Georg <mail jensge org>
Date:   Fri Jun 10 11:06:08 2011 +0200

    core: Return 402 on extra argument
    
    Partially fixes UPnP CTT test UDA-3.1.3

 src/rygel/rygel-connection-manager.vala       |   18 ++++++++++++
 src/rygel/rygel-content-directory.vala        |   38 +++++++++++++++++++++++++
 src/rygel/rygel-media-receiver-registrar.vala |    6 ++++
 3 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/src/rygel/rygel-connection-manager.vala b/src/rygel/rygel-connection-manager.vala
index 68c74ac..bdec807 100644
--- a/src/rygel/rygel-connection-manager.vala
+++ b/src/rygel/rygel-connection-manager.vala
@@ -85,6 +85,12 @@ internal class Rygel.ConnectionManager : Service {
 
     private void get_protocol_info_cb (Service             cm,
                                        owned ServiceAction action) {
+        if (action.get_argument_count () != 0) {
+            action.return_error (402, _("Invalid argument"));
+
+            return;
+        }
+
         action.set ("Source", typeof (string), source_protocol_info,
                     "Sink",   typeof (string), sink_protocol_info);
 
@@ -93,6 +99,12 @@ internal class Rygel.ConnectionManager : Service {
 
     private void get_current_connection_ids_cb (Service             cm,
                                                 owned ServiceAction action) {
+        if (action.get_argument_count () != 0) {
+            action.return_error (402, _("Invalid argument"));
+
+            return;
+        }
+
         action.set ("ConnectionIDs", typeof (string), connection_ids);
 
         action.return ();
@@ -109,6 +121,12 @@ internal class Rygel.ConnectionManager : Service {
             return;
         }
 
+        if (action.get_argument_count () != 1) {
+            action.return_error (402, _("Invalid argument"));
+
+            return;
+        }
+
         action.set ("RcsID",
                         typeof (int),
                         this.rcs_id,
diff --git a/src/rygel/rygel-content-directory.vala b/src/rygel/rygel-content-directory.vala
index fec8db5..80da87d 100644
--- a/src/rygel/rygel-content-directory.vala
+++ b/src/rygel/rygel-content-directory.vala
@@ -194,6 +194,12 @@ internal class Rygel.ContentDirectory: Service {
     /* GetTransferProgress action implementation */
     private void get_transfer_progress_cb (Service             content_dir,
                                            owned ServiceAction action) {
+        if (action.get_argument_count () != 1) {
+            action.return_error (402, _("Invalid argument"));
+
+            return;
+        }
+
         var import = find_import_for_action (action);
         if (import != null) {
             action.set ("TransferStatus",
@@ -215,6 +221,12 @@ internal class Rygel.ContentDirectory: Service {
     /* StopTransferResource action implementation */
     private void stop_transfer_resource_cb (Service             content_dir,
                                             owned ServiceAction action) {
+        if (action.get_argument_count () != 1) {
+            action.return_error (402, _("Invalid argument"));
+
+            return;
+        }
+
         var import = find_import_for_action (action);
         if (import != null) {
             import.cancellable.cancel ();
@@ -228,6 +240,12 @@ internal class Rygel.ContentDirectory: Service {
     /* GetSystemUpdateID action implementation */
     private void get_system_update_id_cb (Service             content_dir,
                                           owned ServiceAction action) {
+        if (action.get_argument_count () != 0) {
+            action.return_error (402, _("Invalid argument"));
+
+            return;
+        }
+
         /* Set action return arguments */
         action.set ("Id", typeof (uint32), this.system_update_id);
 
@@ -257,6 +275,12 @@ internal class Rygel.ContentDirectory: Service {
     /* action GetSearchCapabilities implementation */
     private void get_search_capabilities_cb (Service             content_dir,
                                              owned ServiceAction action) {
+        if (action.get_argument_count () != 0) {
+            action.return_error (402, _("Invalid argument"));
+
+            return;
+        }
+
         /* Set action return arguments */
         action.set ("SearchCaps", typeof (string), RelationalExpression.CAPS);
 
@@ -275,6 +299,13 @@ internal class Rygel.ContentDirectory: Service {
     /* action GetSortCapabilities implementation */
     private void get_sort_capabilities_cb (Service             content_dir,
                                            owned ServiceAction action) {
+
+        if (action.get_argument_count () != 0) {
+            action.return_error (402, _("Invalid argument"));
+
+            return;
+        }
+
         /* Set action return arguments */
         action.set ("SortCaps", typeof (string), MediaObjects.SORT_CAPS);
 
@@ -293,6 +324,13 @@ internal class Rygel.ContentDirectory: Service {
     /* action GetFeatureList implementation */
     private void get_feature_list_cb (Service             content_dir,
                                       owned ServiceAction action) {
+
+        if (action.get_argument_count () != 0) {
+            action.return_error (402, _("Invalid argument"));
+
+            return;
+        }
+
         /* Set action return arguments */
         action.set ("FeatureList", typeof (string), this.feature_list);
 
diff --git a/src/rygel/rygel-media-receiver-registrar.vala b/src/rygel/rygel-media-receiver-registrar.vala
index d441725..cc007fc 100644
--- a/src/rygel/rygel-media-receiver-registrar.vala
+++ b/src/rygel/rygel-media-receiver-registrar.vala
@@ -55,6 +55,12 @@ internal class Rygel.MediaReceiverRegistrar: Service {
     /* IsAuthorized and IsValided action implementations (fake) */
     private void is_authorized_cb (Service             registrar,
                                    owned ServiceAction action) {
+        if (action.get_argument_count () != 1) {
+            action.return_error (402, _("Invalid argument"));
+
+            return;
+        }
+
         action.set ("Result", typeof (int), 1);
 
         action.return ();



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