From 666d98246ffec467cced3798a97a31940f42673a Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Sat, 23 Apr 2005 15:10:24 +0000 Subject: fix lies about snprintf --- src/lib/libcrypto/bio/b_print.c | 5 +++-- src/lib/libssl/src/crypto/bio/b_print.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c index fbff331796..880dc69303 100644 --- a/src/lib/libcrypto/bio/b_print.c +++ b/src/lib/libcrypto/bio/b_print.c @@ -806,6 +806,7 @@ int BIO_vprintf (BIO *bio, const char *format, va_list args) } /* As snprintf is not available everywhere, we provide our own implementation. + * In case of overflow or error, this returns -1. * This function has nothing to do with BIOs, but it's closely related * to BIO_printf, and we need *some* name prefix ... * (XXX the function should be renamed, but to what?) */ @@ -830,10 +831,10 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) _dopr(&buf, NULL, &n, &retlen, &truncated, format, args); if (truncated) - /* In case of truncation, return -1 like traditional snprintf. + /* In case of truncation, return -1 unlike traditional snprintf. * (Current drafts for ISO/IEC 9899 say snprintf should return * the number of characters that would have been written, - * had the buffer been large enough.) */ + * had the buffer been large enough, as it did historically.) */ return -1; else return (retlen <= INT_MAX) ? (int)retlen : -1; diff --git a/src/lib/libssl/src/crypto/bio/b_print.c b/src/lib/libssl/src/crypto/bio/b_print.c index fbff331796..880dc69303 100644 --- a/src/lib/libssl/src/crypto/bio/b_print.c +++ b/src/lib/libssl/src/crypto/bio/b_print.c @@ -806,6 +806,7 @@ int BIO_vprintf (BIO *bio, const char *format, va_list args) } /* As snprintf is not available everywhere, we provide our own implementation. + * In case of overflow or error, this returns -1. * This function has nothing to do with BIOs, but it's closely related * to BIO_printf, and we need *some* name prefix ... * (XXX the function should be renamed, but to what?) */ @@ -830,10 +831,10 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) _dopr(&buf, NULL, &n, &retlen, &truncated, format, args); if (truncated) - /* In case of truncation, return -1 like traditional snprintf. + /* In case of truncation, return -1 unlike traditional snprintf. * (Current drafts for ISO/IEC 9899 say snprintf should return * the number of characters that would have been written, - * had the buffer been large enough.) */ + * had the buffer been large enough, as it did historically.) */ return -1; else return (retlen <= INT_MAX) ? (int)retlen : -1; -- cgit v1.2.3-55-g6feb