EC_KEY_priv2buf (): check parameter sanity

In EC_KEY_priv2buf(), check for pbuf sanity.
If invoked with NULL, gracefully returns the key length.

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
This commit is contained in:
J Mohan Rao Arisankala 2016-02-24 13:03:10 +05:30 committed by Rich Salz
parent 219f3ca61c
commit acae59bb29

View file

@ -583,8 +583,8 @@ size_t EC_KEY_priv2buf(const EC_KEY *eckey, unsigned char **pbuf)
size_t len;
unsigned char *buf;
len = EC_KEY_priv2oct(eckey, NULL, 0);
if (len == 0)
return 0;
if (len == 0 || pbuf == NULL)
return len;
buf = OPENSSL_malloc(len);
if (buf == NULL)
return 0;