summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2015-04-13 23:55:59 +0100
committerPhilip Withnall <philip@tecnocode.co.uk>2015-04-14 00:00:25 +0100
commit94e5b8355ee3eda717c1a5e8d391478dd99a851a (patch)
treebe5a5d3dfab353eb44986b3ecc9640449f83447d
parent220b4671bc4a8f503b4fdbebb06c01dd6c016b80 (diff)
downloadlibgdata-94e5b8355ee3eda717c1a5e8d391478dd99a851a.tar.gz
core: Handle malformed OAuth2 grant response bodies
It’s possible for the server to return an empty error response, which we must handle gracefully.
-rw-r--r--gdata/gdata-oauth2-authorizer.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/gdata/gdata-oauth2-authorizer.c b/gdata/gdata-oauth2-authorizer.c
index 3117b9d3..52d66147 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);