Skip to content

Commit 70a7c96

Browse files
committed
Guard CertManager buffer null use
1 parent 10d20fe commit 70a7c96

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

native/com_wolfssl_WolfSSLCertManager.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,14 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSLCertManager_CertManagerLoadCABuff
102102
buff = (byte*)(*jenv)->GetByteArrayElements(jenv, in, NULL);
103103
buffSz = (*jenv)->GetArrayLength(jenv, in);
104104

105-
ret = wolfSSL_CertManagerLoadCABuffer(cm, buff, buffSz, format);
106-
107-
(*jenv)->ReleaseByteArrayElements(jenv, in, (jbyte*)buff, JNI_ABORT);
105+
if (buff != NULL) {
106+
ret = wolfSSL_CertManagerLoadCABuffer(cm, buff, buffSz, format);
107+
(*jenv)->ReleaseByteArrayElements(jenv, in,
108+
(jbyte*)buff, JNI_ABORT);
109+
}
110+
else {
111+
ret = BAD_FUNC_ARG;
112+
}
108113

109114
return (jint)ret;
110115
}

0 commit comments

Comments
 (0)