[libgdata] core: Handle malformed OAuth2 grant response bodies



commit 94e5b8355ee3eda717c1a5e8d391478dd99a851a
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Apr 13 23:55:59 2015 +0100

    core: Handle malformed OAuth2 grant response bodies
    
    It’s possible for the server to return an empty error response, which we
    must handle gracefully.

 gdata/gdata-oauth2-authorizer.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/gdata/gdata-oauth2-authorizer.c b/gdata/gdata-oauth2-authorizer.c
index 3117b9d..52d6614 100644
--- a/gdata/gdata-oauth2-authorizer.c
+++ b/gdata/gdata-oauth2-authorizer.c
@@ -1019,6 +1019,15 @@ parse_grant_error (GDataOAuth2Authorizer *self, guint status,
        /* Parse the error response */
        parser = json_parser_new ();
 
+       if (response_body == NULL) {
+               g_clear_error (&child_error);
+               g_set_error_literal (&child_error, GDATA_SERVICE_ERROR,
+                                    GDATA_SERVICE_ERROR_PROTOCOL_ERROR,
+                                    _("The server returned a malformed response."));
+
+               goto done;
+       }
+
        json_parser_load_from_data (parser, response_body, length,
                                    &child_error);
 


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