Fix BIO_printf on Windows.
vsnprintf returns -1 on Windows on truncation, not the needed size. Change-Id: I0a9f32504127b2fb740244c3b59132e201d14234 Reviewed-on: https://boringssl-review.googlesource.com/1870 Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
fb3ff2c66c
commit
66a3531237
@ -75,6 +75,17 @@ int BIO_printf(BIO *bio, const char *format, ...) {
|
||||
out_len = vsnprintf(buf, sizeof(buf), format, args);
|
||||
va_end(args);
|
||||
|
||||
#if defined(OPENSSL_WINDOWS)
|
||||
/* On Windows, vsnprintf returns -1 rather than the requested length on
|
||||
* truncation */
|
||||
if (out_len < 0) {
|
||||
va_start(args, format);
|
||||
out_len = _vscprintf(format, args);
|
||||
va_end(args);
|
||||
assert(out_len >= sizeof(buf));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (out_len >= sizeof(buf)) {
|
||||
const int requested_len = out_len;
|
||||
/* The output was truncated. Note that vsnprintf's return value
|
||||
|
Loading…
Reference in New Issue
Block a user