[rygel] core: Validate passed InstanceID in player



commit 575cf7e20f34f8c5244b29ae2489115689b50a1a
Author: Jens Georg <mail jensge org>
Date:   Mon Dec 26 18:14:27 2011 +0100

    core: Validate passed InstanceID in player

 src/rygel/rygel-av-transport.vala      |   14 +++++++++++---
 src/rygel/rygel-rendering-control.vala |   12 ++++++++++--
 2 files changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/src/rygel/rygel-av-transport.vala b/src/rygel/rygel-av-transport.vala
index 85511cb..339c879 100644
--- a/src/rygel/rygel-av-transport.vala
+++ b/src/rygel/rygel-av-transport.vala
@@ -199,11 +199,19 @@ internal class Rygel.AVTransport : Service {
 
     // Error out if InstanceID is not 0
     private bool check_instance_id (ServiceAction action) {
-        uint instance_id;
+        string instance_id_string;
+        int64 instance_id = -1;
+
+        action.get ("InstanceID", typeof (string), out instance_id_string);
+        if (instance_id_string == null ||
+            !int64.try_parse (instance_id_string, out instance_id)) {
+            action.return_error (402, _("Invalid Args"));
+
+            return false;
+        }
 
-        action.get ("InstanceID", typeof (uint), out instance_id);
         if (instance_id != 0) {
-            action.return_error (718, _("Invalid InstanceID"));
+            action.return_error (702, _("Invalid InstanceID"));
 
             return false;
         }
diff --git a/src/rygel/rygel-rendering-control.vala b/src/rygel/rygel-rendering-control.vala
index 7afd1c7..b42f6b3 100644
--- a/src/rygel/rygel-rendering-control.vala
+++ b/src/rygel/rygel-rendering-control.vala
@@ -114,9 +114,17 @@ internal class Rygel.RenderingControl : Service {
 
     // Error out if InstanceID is not 0
     private bool check_instance_id (ServiceAction action) {
-        uint instance_id;
+        string instance_id_string;
+        int64 instance_id = -1;
+
+        action.get ("InstanceID", typeof (string), out instance_id_string);
+        if (instance_id_string == null ||
+            !int64.try_parse (instance_id_string, out instance_id)) {
+            action.return_error (402, _("Invalid Args"));
+
+            return false;
+        }
 
-        action.get ("InstanceID", typeof (uint), out instance_id);
         if (instance_id != 0) {
             action.return_error (702, _("Invalid InstanceID"));
 



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