From: schwarze Date: Sat, 13 Nov 2021 20:44:00 +0000 (+0000) Subject: Fix a nasty quirk in ASN1_STRING_copy(3). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=feb138ef8af09e31ca863424c7c9df1aac0d016c;p=openbsd Fix a nasty quirk in ASN1_STRING_copy(3). In case of failure, it reported the failure but corrupted the type of the destination string. Instead, let's make sure that in case of failure, existing objects remain in their original state. OK tb@ --- diff --git a/lib/libcrypto/asn1/asn1_lib.c b/lib/libcrypto/asn1/asn1_lib.c index d760cccd4d9..b04fa3c6012 100644 --- a/lib/libcrypto/asn1/asn1_lib.c +++ b/lib/libcrypto/asn1/asn1_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_lib.c,v 1.45 2020/12/08 15:06:42 tb Exp $ */ +/* $OpenBSD: asn1_lib.c,v 1.46 2021/11/13 20:44:00 schwarze Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -290,9 +290,9 @@ ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str) { if (str == NULL) return 0; - dst->type = str->type; if (!ASN1_STRING_set(dst, str->data, str->length)) return 0; + dst->type = str->type; dst->flags = str->flags; return 1; }