diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2014-06-18 04:48:38 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2014-06-18 04:48:38 +0000 |
commit | cbce60998e4c71f3e68292c82792422a8a227cc3 (patch) | |
tree | 8834e5a07b585844bfd8231d4f094a0ca89c7cfe /lib | |
parent | 9cd22f5bd3070c82074af48185fe8b3144c69ac2 (diff) |
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')
-rw-r--r-- | lib/libssl/ssl_ciph.c | 22 |
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); |