Skip to content

Commit 648b0a5

Browse files
committed
wolfSSL_X509_get_ext_by_OBJ: check we don't deref a NULL ptr
1 parent 1d64a4e commit 648b0a5

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/x509.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,12 @@ int wolfSSL_X509_get_ext_by_OBJ(const WOLFSSL_X509 *x,
463463
lastpos++;
464464
if (lastpos < 0)
465465
lastpos = 0;
466-
for (; lastpos < wolfSSL_sk_num(sk); lastpos++)
467-
if (wolfSSL_OBJ_cmp(wolfSSL_sk_X509_EXTENSION_value(sk,
468-
lastpos)->obj, obj) == 0)
466+
for (; lastpos < wolfSSL_sk_num(sk); lastpos++) {
467+
WOLFSSL_X509_EXTENSION* ext = wolfSSL_sk_X509_EXTENSION_value(sk,
468+
lastpos);
469+
if (ext != NULL && wolfSSL_OBJ_cmp(ext->obj, obj) == 0)
469470
return lastpos;
471+
}
470472
return WOLFSSL_FATAL_ERROR;
471473
}
472474

0 commit comments

Comments
 (0)