From: Matt Caswell Date: Wed, 29 Apr 2015 08:58:10 +0000 (+0100) Subject: Add sanity check to print_bin function X-Git-Tag: OpenSSL_1_0_1n~76 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ee900ed1f7865d12682f5dd640d7554655cb4255;p=oweals%2Fopenssl.git Add sanity check to print_bin function Add a sanity check to the print_bin function to ensure that the |off| argument is positive. Thanks to Kevin Wojtysiak (Int3 Solutions) and Paramjot Oberoi (Int3 Solutions) for reporting this issue. Reviewed-by: Andy Polyakov (cherry picked from commit 3deeeeb61b0c5b9b5f0993a67b7967d2f85186da) --- diff --git a/crypto/ec/eck_prn.c b/crypto/ec/eck_prn.c index a911a0ac40..5ef12ec024 100644 --- a/crypto/ec/eck_prn.c +++ b/crypto/ec/eck_prn.c @@ -338,12 +338,14 @@ static int print_bin(BIO *fp, const char *name, const unsigned char *buf, if (buf == NULL) return 1; - if (off) { + if (off > 0) { if (off > 128) off = 128; memset(str, ' ', off); if (BIO_write(fp, str, off) <= 0) return 0; + } else { + off = 0; } if (BIO_printf(fp, "%s", name) <= 0)