summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2021-07-04 11:38:37 +0000
committerschwarze <>2021-07-04 11:38:37 +0000
commit1fc4eef4dab9984c6dc3598bba863591943996db (patch)
tree0f32a9a4ea2fd95395a29e327946cd1d512c7de1
parent1a1544c135b2932046e4ec6f3c09c7d6a690014b (diff)
downloadopenbsd-1fc4eef4dab9984c6dc3598bba863591943996db.tar.gz
openbsd-1fc4eef4dab9984c6dc3598bba863591943996db.tar.bz2
openbsd-1fc4eef4dab9984c6dc3598bba863591943996db.zip
Bugfix: when X509_NAME_dup(3) failed, X509_NAME_set(3) indicated success
even though it did not actually set the name. Instead, indicate failure in this case. This commit sneaks in a small, unrelated change in behaviour. If the first argument of X509_NAME_set(3) was NULL, the function used to return failure. Now it crashes the program by accessing the NULL pointer, for compatibility with the same change in OpenSSL. This merges the following two commits from the OpenSSL-1.1.1 branch, which is still available under a free license: 1. 180794c5 Rich Salz Sep 3 11:33:34 2017 -0400 2. c1c1783d Richard Levitte May 17 09:53:14 2018 +0200 OK tb@
-rw-r--r--src/lib/libcrypto/asn1/x_name.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/lib/libcrypto/asn1/x_name.c b/src/lib/libcrypto/asn1/x_name.c
index 4bf184252f..0961ee33eb 100644
--- a/src/lib/libcrypto/asn1/x_name.c
+++ b/src/lib/libcrypto/asn1/x_name.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x_name.c,v 1.34 2018/02/20 17:09:20 jsing Exp $ */ 1/* $OpenBSD: x_name.c,v 1.35 2021/07/04 11:38:37 schwarze Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -626,19 +626,13 @@ i2d_name_canon(STACK_OF(STACK_OF_X509_NAME_ENTRY) *_intname, unsigned char **in)
626int 626int
627X509_NAME_set(X509_NAME **xn, X509_NAME *name) 627X509_NAME_set(X509_NAME **xn, X509_NAME *name)
628{ 628{
629 X509_NAME *in; 629 if (*xn == name)
630 630 return *xn != NULL;
631 if (!xn || !name) 631 if ((name = X509_NAME_dup(name)) == NULL)
632 return (0); 632 return 0;
633 633 X509_NAME_free(*xn);
634 if (*xn != name) { 634 *xn = name;
635 in = X509_NAME_dup(name); 635 return 1;
636 if (in != NULL) {
637 X509_NAME_free(*xn);
638 *xn = in;
639 }
640 }
641 return (*xn != NULL);
642} 636}
643 637
644int 638int