[librest] rest-proxy-call: Use memdup, not strdup, as HTTP response data might be binary



commit 8449b010aa23fb3dd6add35e228a7ae5e67a598f
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Jul 9 13:50:41 2013 -0400

    rest-proxy-call: Use memdup, not strdup, as HTTP response data might be binary
    
    This fixes an issue when a GSoC student was trying to fetch images from
    gravatar using librest.

 rest/rest-proxy-call.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c
index 97ed185..c84291e 100644
--- a/rest/rest-proxy-call.c
+++ b/rest/rest-proxy-call.c
@@ -608,7 +608,7 @@ finish_call (RestProxyCall *call, SoupMessage *message, GError **error)
       (SoupMessageHeadersForeachFunc)_populate_headers_hash_table,
       priv->response_headers);
 
-  priv->payload = g_strdup (message->response_body->data);
+  priv->payload = g_memdup (message->response_body->data, message->response_body->length);
   priv->length = message->response_body->length;
 
   priv->status_code = message->status_code;


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