From: Aki Tuomi Date: Tue, 6 Jun 2017 09:47:53 +0000 (+0300) Subject: lib-oauth2: Make sure fields are always initialized X-Git-Tag: 2.3.0.rc1~1509 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bfc3dd435645e276b8cdc4fcff2613cf86fb19c8;p=thirdparty%2Fdovecot%2Fcore.git lib-oauth2: Make sure fields are always initialized --- diff --git a/src/lib-oauth2/oauth2-introspect.c b/src/lib-oauth2/oauth2-introspect.c index 79800fe0b2..62bfe11cf7 100644 --- a/src/lib-oauth2/oauth2-introspect.c +++ b/src/lib-oauth2/oauth2-introspect.c @@ -47,6 +47,7 @@ oauth2_introspect_response(const struct http_response *response, oauth2_introspect_continue(req, FALSE, "Missing response body"); return; } + p_array_init(&req->fields, req->pool, 1); req->is = response->payload; i_stream_ref(req->is); req->parser = json_parser_init(req->is); diff --git a/src/lib-oauth2/oauth2-refresh.c b/src/lib-oauth2/oauth2-refresh.c index e7b5455055..777a7cb384 100644 --- a/src/lib-oauth2/oauth2-refresh.c +++ b/src/lib-oauth2/oauth2-refresh.c @@ -87,6 +87,7 @@ oauth2_refresh_response(const struct http_response *response, oauth2_refresh_continue(req, FALSE, "Missing response body"); return; } + p_array_init(&req->fields, req->pool, 1); req->is = response->payload; i_stream_ref(req->is); req->parser = json_parser_init(req->is); diff --git a/src/lib-oauth2/oauth2-token-validate.c b/src/lib-oauth2/oauth2-token-validate.c index af47b0ac57..4982ecea95 100644 --- a/src/lib-oauth2/oauth2-token-validate.c +++ b/src/lib-oauth2/oauth2-token-validate.c @@ -30,6 +30,8 @@ oauth2_token_validate_continue(struct oauth2_request *req, bool success, struct oauth2_token_validation_result res; i_zero(&res); + i_assert(array_is_created(&req->fields)); + res.success = success; res.error = error; res.valid = req->valid; @@ -69,9 +71,9 @@ oauth2_token_validate_response(const struct http_response *response, req->valid = TRUE; else req->valid = FALSE; + p_array_init(&req->fields, req->pool, 1); /* 2xx is sufficient for token validation */ if (response->payload == NULL) { - p_array_init(&req->fields, req->pool, 1); oauth2_token_validate_continue(req, TRUE, NULL); return; }