diff options
author | 2014-09-21 12:17:42 +0000 | |
---|---|---|
committer | 2014-09-21 12:17:42 +0000 | |
commit | 36787e0156e77a4d65b5181891b6c92d4de961df (patch) | |
tree | a70fcf0989b3ad6f63e7f375f85f2c7b8bd8124a /lib/libssl/src | |
parent | Fix a memory leak in the error path in ASN1_mbstring_ncopy(). (diff) | |
download | wireguard-openbsd-36787e0156e77a4d65b5181891b6c92d4de961df.tar.xz wireguard-openbsd-36787e0156e77a4d65b5181891b6c92d4de961df.zip |
a_enum.c used to be a copy of a_int.c with s/INTEGER/ENUMERATED/g , but
some changes an a_int.c did not get applied to a_enum.c; despite style
changes, make sure BN_to_ASN1_ENUMERATED() correctly handles a zero value
the same way BN_to_ASN1_INTEGER() does.
ok bcook@ beck@ jsing@
Diffstat (limited to 'lib/libssl/src')
-rw-r--r-- | lib/libssl/src/crypto/asn1/a_enum.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/libssl/src/crypto/asn1/a_enum.c b/lib/libssl/src/crypto/asn1/a_enum.c index 35cb0eaff5f..3c059266be1 100644 --- a/lib/libssl/src/crypto/asn1/a_enum.c +++ b/lib/libssl/src/crypto/asn1/a_enum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_enum.c,v 1.15 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: a_enum.c,v 1.16 2014/09/21 12:17:42 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -97,7 +97,7 @@ ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v) d >>= 8; } j = 0; - for (k = i - 1; k >=0; k--) + for (k = i - 1; k >= 0; k--) a->data[j++] = buf[k]; a->length = j; return (1); @@ -119,7 +119,7 @@ ASN1_ENUMERATED_get(ASN1_ENUMERATED *a) if (a->length > (int)sizeof(long)) { /* hmm... a bit ugly */ - return (0xffffffffL); + return -1; } if (a->data == NULL) return 0; @@ -161,8 +161,13 @@ BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai) } ret->data = new_data; } - ret->length = BN_bn2bin(bn, ret->data); + + /* Correct zero case */ + if (!ret->length) { + ret->data[0] = 0; + ret->length = 1; + } return (ret); err: |