Check ASN1_item_ndef_i2d() return value.
authorBenjamin Kaduk <bkaduk@akamai.com>
Wed, 24 Feb 2021 21:38:25 +0000 (13:38 -0800)
committerBenjamin Kaduk <bkaduk@akamai.com>
Fri, 26 Feb 2021 23:42:59 +0000 (15:42 -0800)
commit90b4247cc5dca58cee9da5f6975bb38fd200100a
treeee00f9c403b6234039ee8ae96e7463b02516552a
parentd2ccfb9caa9f69d4980f8fe49a15a043c91b40c5
Check ASN1_item_ndef_i2d() return value.

Return an error instead of trying to malloc a negative number.
The other usage in this file already had a similar check, and the caller
should have put an entry on the error stack already.

Note that we only check the initial calls to obtain the encoded length,
and assume that the follow-up call to actually encode to the allocated
storage will succeed if the first one did.

Fixes: #14177
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/14308)
crypto/asn1/bio_ndef.c