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

[Xen-changelog] [xen staging] libxl_json: Enable yajl_allow_trailing_garbage



commit 544c15c827d3ad6d4ccfb557a073fa78ca9f3ac2
Author:     Anthony PERARD <anthony.perard@xxxxxxxxxx>
AuthorDate: Thu May 31 11:50:03 2018 +0100
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Tue Aug 21 12:16:02 2018 +0100

    libxl_json: Enable yajl_allow_trailing_garbage
    
    This allows to parse a string that is not NUL-terminated. With that
    option disabled, YAJL v2 would look ahead on completion to find out if
    there is more to parse.
    
    YAJL v1 doesn't have this behavior.
    
    Any function that allocates a yajl_handle via this function either parse
    a NUL-terminated string, or do provide proper length. So change the
    default and allow garbage (like a different JSON document) after the end
    of the data to parse.
    
    This is important for the QMP client, as there could be more than one
    message to parse, and YAJL would consider the next message to be garbage
    and throw an error.
    
    Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
    Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/libxl/libxl_json.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_json.h b/tools/libxl/libxl_json.h
index af26e7885d..260783bfde 100644
--- a/tools/libxl/libxl_json.h
+++ b/tools/libxl/libxl_json.h
@@ -50,7 +50,10 @@ static inline yajl_handle libxl__yajl_alloc(const 
yajl_callbacks *callbacks,
                                             yajl_alloc_funcs *allocFuncs,
                                             void *ctx)
 {
-    return yajl_alloc(callbacks, allocFuncs, ctx);
+    yajl_handle hand = yajl_alloc(callbacks, allocFuncs, ctx);
+    if (hand)
+        yajl_config(hand, yajl_allow_trailing_garbage, 1);
+    return hand;
 }
 
 static inline yajl_gen libxl_yajl_gen_alloc(const yajl_alloc_funcs *allocFuncs)
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.