summaryrefslogtreecommitdiffstats
path: root/crypto/ec
diff options
context:
space:
mode:
authorJ Mohan Rao Arisankala <mohan@barracuda.com>2016-02-24 13:03:10 +0530
committerRich Salz <rsalz@openssl.org>2016-02-26 11:18:18 -0500
commitacae59bb29ddc769743ab4a8ae373b5ff2f42b57 (patch)
tree096a136a046e251528ba8e37caf9a2091f9a965f /crypto/ec
parent219f3ca61c2902425047974441d953e6042250ec (diff)
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>
Diffstat (limited to 'crypto/ec')
-rw-r--r--crypto/ec/ec_key.c4
1 files changed, 2 insertions, 2 deletions
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;