gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-twister] 27/34: fix last path token detection.


From: gnunet
Subject: [GNUnet-SVN] [taler-twister] 27/34: fix last path token detection.
Date: Sat, 17 Mar 2018 01:58:18 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository twister.

commit 8d7076f423d3909068c2f79cadcec37a033d4e6a
Author: Marcello Stanisci <address@hidden>
AuthorDate: Sat Mar 10 14:37:20 2018 +0100

    fix last path token detection.
    
    The object walker now checks if the last path's token
    does exist in the parent object, before returning to
    the caller.
---
 src/twister/taler-twister-service.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/twister/taler-twister-service.c 
b/src/twister/taler-twister-service.c
index 7d37198..d819473 100644
--- a/src/twister/taler-twister-service.c
+++ b/src/twister/taler-twister-service.c
@@ -880,6 +880,22 @@ walk_response_object (const char *path,
     return GNUNET_NO;
   }
 
+  if ( (NULL == json_object_get (element,
+                                 last_token) ) &&
+       /* NOTE: if token is bad but converts to either 0, or
+        * ULONG max AND the array has such a index, then this
+        * test won't detect any error. Likewise, the method for
+        * deleting/modifying the response will operate on that
+        * same random array element. */
+       (NULL == json_array_get (element, (unsigned int) strtoul
+         (token, NULL, 10))) )
+  {
+    TALER_LOG_WARNING ("(Last) path token '%s' not found",
+                       last_token); 
+    GNUNET_free (path_dup);
+    return GNUNET_NO;
+  }
+
   *target = GNUNET_strdup (last_token);
   *parent = element;
   GNUNET_free (path_dup);
@@ -927,14 +943,15 @@ modify_object (struct MHD_Connection *con,
   TALER_LOG_ERROR ("Unvalid new value given: %s\n", modify_value);
   modify_path[0] = '\0'; 
   GNUNET_free (target);
+  json_decref (new_value);
   return;
 
   perform_modbody:
     ret_modify = -1;
     if (json_is_object (parent))
-      ret_modify = json_object_set_new (parent,
-                                        target,
-                                        new_value);
+      ret_modify = json_object_set (parent,
+                                    target,
+                                    new_value);
     if (json_is_array (parent))
       ret_modify = json_array_set_new
         (parent,
@@ -945,6 +962,7 @@ modify_object (struct MHD_Connection *con,
     
     modify_path[0] = '\0';
     GNUNET_free (target);
+    json_decref (new_value);
     return;
 }
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]