Skip to content

Commit c6dd1a7

Browse files
committed
boundary check
1 parent c923c4c commit c6dd1a7

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

tests/api/test_ossl_x509_str.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,15 @@ static int X509Callback(int ok, X509_STORE_CTX *ctx)
5959
static int X509CallbackCount(int ok, X509_STORE_CTX *ctx)
6060
{
6161
if (!ok) {
62-
last_errcodes[err_index] = X509_STORE_CTX_get_error(ctx);
63-
last_errdepths[err_index] = X509_STORE_CTX_get_error_depth(ctx);
64-
err_index++;
62+
if (err_index < 10) {
63+
last_errcodes[err_index] = X509_STORE_CTX_get_error(ctx);
64+
last_errdepths[err_index] = X509_STORE_CTX_get_error_depth(ctx);
65+
err_index++;
66+
} else {
67+
/* Should not happen in test */
68+
WOLFSSL_MSG("Error index overflow in X509CallbackCount");
69+
err_index = 0;
70+
}
6571
}
6672
/* Always return OK to allow verification to continue.*/
6773
return 1;

0 commit comments

Comments
 (0)