Skip to content

Commit

Permalink
lib-oauth2: Make sure fields are always initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
cmouse authored and villesavolainen committed Jun 16, 2017
1 parent de59864 commit 537f120
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lib-oauth2/oauth2-introspect.c
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/lib-oauth2/oauth2-refresh.c
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/lib-oauth2/oauth2-token-validate.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 537f120

Please sign in to comment.