From 53197fa2c21b25bbe10c188ecc79010086749353 Mon Sep 17 00:00:00 2001 From: miod <> Date: Wed, 18 Jun 2014 04:48:37 +0000 Subject: Use asprintf() instead of a fixed 128-byte size in SSL_CIPHER_description() when no storage buffer is passed. ok deraadt@ tedu@ --- src/lib/libssl/src/ssl/ssl_ciph.c | 22 +++++++++++----------- src/lib/libssl/ssl_ciph.c | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/lib/libssl/src/ssl/ssl_ciph.c b/src/lib/libssl/src/ssl/ssl_ciph.c index d491a0cab6..b8a6eaf514 100644 --- a/src/lib/libssl/src/ssl/ssl_ciph.c +++ b/src/lib/libssl/src/ssl/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); diff --git a/src/lib/libssl/ssl_ciph.c b/src/lib/libssl/ssl_ciph.c index d491a0cab6..b8a6eaf514 100644 --- a/src/lib/libssl/ssl_ciph.c +++ b/src/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); -- cgit v1.2.3-55-g6feb