diff options
author | Nils Larsch <nils@openssl.org> | 2006-03-18 15:27:41 +0100 |
---|---|---|
committer | Nils Larsch <nils@openssl.org> | 2006-03-18 15:27:41 +0100 |
commit | b4e88ccb2875b414c3882759a1f1c6a4a07df389 (patch) | |
tree | 414529d2ef4e94a285a19a996db7e4301a8abe6c /crypto/ts | |
parent | check if con != NULL before using it (diff) | |
download | openssl-b4e88ccb2875b414c3882759a1f1c6a4a07df389.tar.xz openssl-b4e88ccb2875b414c3882759a1f1c6a4a07df389.zip |
ensure the pointer is valid before using it
Diffstat (limited to 'crypto/ts')
-rw-r--r-- | crypto/ts/ts_rsp_sign.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/crypto/ts/ts_rsp_sign.c b/crypto/ts/ts_rsp_sign.c index 30b6498456..0c8e636fdf 100644 --- a/crypto/ts/ts_rsp_sign.c +++ b/crypto/ts/ts_rsp_sign.c @@ -466,18 +466,21 @@ TS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio) if (!result) { TSerr(TS_F_TS_RESP_CREATE_RESPONSE, TS_R_RESPONSE_SETUP_ERROR); - TS_RESP_CTX_set_status_info_cond(ctx, TS_STATUS_REJECTION, - "Error during response " - "generation."); - /* Check if the status info was set. */ - if (ctx->response - && ASN1_INTEGER_get( - TS_RESP_get_status_info(ctx->response)->status) - == TS_STATUS_GRANTED) + if (ctx != NULL) { - /* Status info wasn't set, don't return a response. */ - TS_RESP_free(ctx->response); - ctx->response = NULL; + TS_RESP_CTX_set_status_info_cond(ctx, + TS_STATUS_REJECTION, "Error during response " + "generation."); + /* Check if the status info was set. */ + if (ctx->response && ASN1_INTEGER_get( + TS_RESP_get_status_info(ctx->response)->status) + == TS_STATUS_GRANTED) + { + /* Status info wasn't set, don't + * return a response. */ + TS_RESP_free(ctx->response); + ctx->response = NULL; + } } } response = ctx->response; @@ -567,13 +570,18 @@ static int TS_RESP_check_request(TS_RESP_CTX *ctx) return 1; } -/* Returns the TSA policy based on the rqeuested and acceptable policies. */ +/* Returns the TSA policy based on the requested and acceptable policies. */ static ASN1_OBJECT *TS_RESP_get_policy(TS_RESP_CTX *ctx) { ASN1_OBJECT *requested = TS_REQ_get_policy_id(ctx->request); ASN1_OBJECT *policy = NULL; int i; + if (ctx->default_policy == NULL) + { + TSerr(TS_F_TS_RESP_GET_POLICY, TS_R_INVALID_NULL_POINTER); + return NULL; + } /* Return the default policy if none is requested or the default is requested. */ if (!requested || !OBJ_cmp(requested, ctx->default_policy)) |