From: J Mohan Rao Arisankala Date: Wed, 24 Feb 2016 07:33:10 +0000 (+0530) Subject: EC_KEY_priv2buf (): check parameter sanity X-Git-Tag: OpenSSL_1_1_0-pre4~498 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=acae59bb29ddc769743ab4a8ae373b5ff2f42b57;p=oweals%2Fopenssl.git 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 Reviewed-by: Matt Caswell --- diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index c382e7e41e..439cfa27cc 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -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;