From 3c28aa85e7a21db044a5e1a094805402e2fd6490 Mon Sep 17 00:00:00 2001 From: "Dr. David von Oheimb" Date: Mon, 21 Jun 2021 14:15:13 +0200 Subject: [PATCH] cmp_client.c: Print checkAfter value from pollRep before it may get modified Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/15848) --- crypto/cmp/cmp_client.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/crypto/cmp/cmp_client.c b/crypto/cmp/cmp_client.c index e7761ae7d94..ea6ca39fb33 100644 --- a/crypto/cmp/cmp_client.c +++ b/crypto/cmp/cmp_client.c @@ -295,18 +295,6 @@ static int poll_for_response(OSSL_CMP_CTX *ctx, int sleep, int rid, ERR_add_error_data(1, str); goto err; } - if (ctx->total_timeout > 0) { /* timeout is not infinite */ - const int exp = 5; /* expected max time per msg round trip */ - int64_t time_left = (int64_t)(ctx->end_time - exp - time(NULL)); - - if (time_left <= 0) { - ERR_raise(ERR_LIB_CMP, CMP_R_TOTAL_TIMEOUT); - goto err; - } - if (time_left < check_after) - check_after = time_left; - /* poll one last time just when timeout was reached */ - } if (pollRep->reason == NULL || (len = BIO_snprintf(str, OSSL_CMP_PKISI_BUFLEN, @@ -326,6 +314,19 @@ static int poll_for_response(OSSL_CMP_CTX *ctx, int sleep, int rid, "received polling response%s; checkAfter = %ld seconds", str, check_after); + if (ctx->total_timeout > 0) { /* timeout is not infinite */ + const int exp = 5; /* expected max time per msg round trip */ + int64_t time_left = (int64_t)(ctx->end_time - exp - time(NULL)); + + if (time_left <= 0) { + ERR_raise(ERR_LIB_CMP, CMP_R_TOTAL_TIMEOUT); + goto err; + } + if (time_left < check_after) + check_after = time_left; + /* poll one last time just when timeout was reached */ + } + OSSL_CMP_MSG_free(preq); preq = NULL; OSSL_CMP_MSG_free(prep); -- 2.47.2