Error on setting an invalid CSR version
authorjob <job@openbsd.org>
Mon, 25 Mar 2024 11:27:00 +0000 (11:27 +0000)
committerjob <job@openbsd.org>
Mon, 25 Mar 2024 11:27:00 +0000 (11:27 +0000)
Reported by David Benjamin (BoringSSL)

OK tb@

lib/libcrypto/x509/x509rset.c

index f097a37..9154e33 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509rset.c,v 1.12 2023/02/16 08:38:17 tb Exp $ */
+/* $OpenBSD: x509rset.c,v 1.13 2024/03/25 11:27:00 job Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -68,7 +68,7 @@
 int
 X509_REQ_set_version(X509_REQ *x, long version)
 {
-       if (x == NULL)
+       if (x == NULL || version != 0)
                return (0);
        x->req_info->enc.modified = 1;
        return (ASN1_INTEGER_set(x->req_info->version, version));