Mercurial > illumos > illumos-gate
changeset 9830:eed00643bbdd
6837738 ssh and javaws dump core in libsoftcrypto when freeing memory under libumem
author | Dina K Nimeh <Dina.Nimeh@Sun.COM> |
---|---|
date | Tue, 09 Jun 2009 07:24:43 -0700 |
parents | e8059fcaee97 |
children | 60c34c50144c |
files | usr/src/lib/pkcs11/pkcs11_softtoken/common/softAttributeUtil.c |
diffstat | 1 files changed, 27 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/lib/pkcs11/pkcs11_softtoken/common/softAttributeUtil.c Tue Jun 09 10:11:35 2009 -0400 +++ b/usr/src/lib/pkcs11/pkcs11_softtoken/common/softAttributeUtil.c Tue Jun 09 07:24:43 2009 -0700 @@ -1573,7 +1573,33 @@ if (isModulus && isPubExpo) { /* - * Copy big integer attribute value to the + * Derive modulus_bits attribute from modulus. + * Save modulus_bits integer value to the + * designated place in the public key object. + */ + n.malloced = 0; +#ifdef __sparcv9 + if (big_init(&n, (int)CHARLEN2BIGNUMLEN( + modulus.big_value_len)) != BIG_OK) { +#else /* !__sparcv9 */ + if (big_init(&n, CHARLEN2BIGNUMLEN( + modulus.big_value_len)) != BIG_OK) { +#endif /* __sparcv9 */ + rv = CKR_HOST_MEMORY; + big_finish(&n); + goto fail_cleanup; + } + bytestring2bignum(&n, modulus.big_value, + modulus.big_value_len); + + modulus_bits = big_bitlength(&n); + KEY_PUB_RSA_MOD_BITS(pbk) = modulus_bits; + big_finish(&n); + + /* + * After modulus_bits has been computed, + * it is safe to move modulus and pubexpo + * big integer attribute value to the * designated place in the public key object. */ copy_bigint_attr(&modulus, @@ -1585,33 +1611,6 @@ rv = CKR_TEMPLATE_INCOMPLETE; goto fail_cleanup; } - - /* - * Derive modulus_bits attribute from modulus. - * Copy big integer attribute value to the - * designated place in the public key object. - */ - n.malloced = 0; -#ifdef __sparcv9 - if (big_init(&n, - (int)CHARLEN2BIGNUMLEN(modulus.big_value_len)) - != BIG_OK) { -#else /* !__sparcv9 */ - if (big_init(&n, - CHARLEN2BIGNUMLEN(modulus.big_value_len)) - != BIG_OK) { -#endif /* __sparcv9 */ - rv = CKR_HOST_MEMORY; - big_finish(&n); - goto fail_cleanup; - } - bytestring2bignum(&n, modulus.big_value, - modulus.big_value_len); - - modulus_bits = big_bitlength(&n); - KEY_PUB_RSA_MOD_BITS(pbk) = modulus_bits; - - big_finish(&n); } else { /* mode is SOFT_GEN_KEY */