Add CMP fuzzing to fuzz/cmp.c, including a couple of helpers in crypto/cmp/
[openssl.git] / crypto / cmp / cmp_msg.c
index 7fc51596b9a301edcfd6677f99ba39c7491bf4b9..73a9d7a267835351d52bec34ccb0397367ebd056 100644 (file)
@@ -219,8 +219,13 @@ static OSSL_CRMF_MSG *crm_new(OSSL_CMP_CTX *ctx, int bodytype, int rid)
 
     if (rkey == NULL)
         rkey = ctx->pkey; /* default is independent of ctx->oldClCert */
-    if (rkey == NULL
-            || (bodytype == OSSL_CMP_PKIBODY_KUR && refcert == NULL)) {
+    if (rkey == NULL) {
+#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+        CMPerr(0, CMP_R_NULL_ARGUMENT);
+        return NULL;
+#endif
+    }
+    if (bodytype == OSSL_CMP_PKIBODY_KUR && refcert == NULL) {
         CMPerr(0, CMP_R_INVALID_ARGS);
         return NULL;
     }