summaryrefslogtreecommitdiffstats
path: root/lib/libssl/ssl_ciph.c
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2014-06-18 04:48:37 +0000
committermiod <miod@openbsd.org>2014-06-18 04:48:37 +0000
commit3d0b2e535e6dceeb3521ded1a430be25e99e63c6 (patch)
treea813864372c642ddcdad7e953a4c547cf47006be /lib/libssl/ssl_ciph.c
parentIn SSL_COMP_add_compression_method(), make sure error cases actually return (diff)
downloadwireguard-openbsd-3d0b2e535e6dceeb3521ded1a430be25e99e63c6.tar.xz
wireguard-openbsd-3d0b2e535e6dceeb3521ded1a430be25e99e63c6.zip
Use asprintf() instead of a fixed 128-byte size in SSL_CIPHER_description()
when no storage buffer is passed. ok deraadt@ tedu@
Diffstat (limited to 'lib/libssl/ssl_ciph.c')
-rw-r--r--lib/libssl/ssl_ciph.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/libssl/ssl_ciph.c b/lib/libssl/ssl_ciph.c
index d491a0cab6d..b8a6eaf5143 100644
--- a/lib/libssl/ssl_ciph.c
+++ b/lib/libssl/ssl_ciph.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_ciph.c,v 1.54 2014/06/18 04:47:32 miod Exp $ */
+/* $OpenBSD: ssl_ciph.c,v 1.55 2014/06/18 04:48:37 miod Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -1909,16 +1909,16 @@ SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int len)
break;
}
- if (buf == NULL) {
- len = 128;
- buf = malloc(len);
- if (buf == NULL)
- return("malloc Error");
- } else if (len < 128)
- return("Buffer too small");
-
- l = snprintf(buf, len, format, cipher->name, ver, kx, au, enc, mac, exp_str);
- if (l >= len || l == -1)
+ if (buf == NULL)
+ l = asprintf(&buf, format, cipher->name, ver, kx, au, enc,
+ mac, exp_str);
+ else {
+ l = snprintf(buf, len, format, cipher->name, ver, kx, au, enc,
+ mac, exp_str);
+ if (l >= len)
+ l = -1;
+ }
+ if (l == -1)
return("Buffer too small");
else
return (buf);