Fix handling of length upon vsprintf error
@@ -1006,9 +1006,10 @@ void picoquic_binlog_message_v(picoquic_cnx_t* cnx, const char* fmt, va_list var
message_len = (written < 0) ? ps_msg->size - ps_msg->ptr - 1 : written;
#else
written = vsnprintf(message_text, ps_msg->size - ps_msg->ptr, fmt, vargs);
- message_len = (written < 0) ? strlen(message_text):written;
- if (written <= 0) {
- fprintf(stderr, "vsnprintf error, written: %d, message_len: %zu", written, message_len);
+ if (written < 0 || written >= ps_msg->size - ps_msg->ptr){
+ message_len = ps_msg->size - ps_msg->ptr - 1;
+ } else {
+ message_len = written;
}
#endif
ps_msg->ptr += message_len;
