From: Pauli Date: Mon, 12 Apr 2021 21:47:31 +0000 (+1000) Subject: bio_printf: add \0 terminators for error returns in floating point conversions. X-Git-Tag: openssl-3.0.0-alpha15~108 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d32fc2c51b74c135ae09c3bb04ebe5781edd7571;p=thirdparty%2Fopenssl.git bio_printf: add \0 terminators for error returns in floating point conversions. Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14829) --- diff --git a/crypto/bio/b_print.c b/crypto/bio/b_print.c index ba2c6c5b1fd..2f012f42f22 100644 --- a/crypto/bio/b_print.c +++ b/crypto/bio/b_print.c @@ -620,6 +620,7 @@ fmtfp(char **sbuffer, /* * Should not happen. If we're in F_FORMAT then exp < max? */ + (void)doapr_outch(sbuffer, buffer, currlen, maxlen, '\0'); return 0; } } else { @@ -641,6 +642,7 @@ fmtfp(char **sbuffer, */ if (ufvalue >= (double)(ULONG_MAX - 65535) + 65536.0) { /* Number too big */ + (void)doapr_outch(sbuffer, buffer, currlen, maxlen, '\0'); return 0; } intpart = (unsigned long)ufvalue; @@ -704,8 +706,10 @@ fmtfp(char **sbuffer, tmpexp = (tmpexp / 10); } while (tmpexp > 0 && eplace < (int)sizeof(econvert)); /* Exponent is huge!! Too big to print */ - if (tmpexp > 0) + if (tmpexp > 0) { + (void)doapr_outch(sbuffer, buffer, currlen, maxlen, '\0'); return 0; + } /* Add a leading 0 for single digit exponents */ if (eplace == 1) econvert[eplace++] = '0';