From 078809e2d47e2b8bf41d39b1c111e25c0af284d6 Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 24 May 2022 19:56:13 +0000 Subject: [PATCH] Use asn1_abs_set_unused_bits() in asn1_str2type() ok jsing --- lib/libcrypto/asn1/asn1_gen.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/libcrypto/asn1/asn1_gen.c b/lib/libcrypto/asn1/asn1_gen.c index d800b77a6a1..a37091ce7d2 100644 --- a/lib/libcrypto/asn1/asn1_gen.c +++ b/lib/libcrypto/asn1/asn1_gen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_gen.c,v 1.18 2021/12/25 13:17:48 jsing Exp $ */ +/* $OpenBSD: asn1_gen.c,v 1.19 2022/05/24 19:56:13 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2002. */ @@ -62,6 +62,8 @@ #include #include +#include "asn1_locl.h" + #define ASN1_GEN_FLAG 0x10000 #define ASN1_GEN_FLAG_IMP (ASN1_GEN_FLAG|1) #define ASN1_GEN_FLAG_EXP (ASN1_GEN_FLAG|2) @@ -754,10 +756,9 @@ asn1_str2type(const char *str, int format, int utype) } if ((utype == V_ASN1_BIT_STRING) && no_unused) { - atmp->value.asn1_string->flags &= - ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); - atmp->value.asn1_string->flags |= - ASN1_STRING_FLAG_BITS_LEFT; + if (!asn1_abs_set_unused_bits(atmp->value.asn1_string, + 0)) + goto bad_str; } break; -- 2.20.1