Try to use vsnprintf where possible instead of vsprintf

This commit is contained in:
twinaphex 2020-06-26 20:56:14 +02:00
parent 5f607f5809
commit 1b86ea43c3
3 changed files with 6 additions and 6 deletions

View File

@ -443,7 +443,8 @@ int filestream_putc(RFILE *stream, int c)
int filestream_vprintf(RFILE *stream, const char* format, va_list args)
{
static char buffer[8 * 1024];
int64_t num_chars = vsprintf(buffer, format, args);
int64_t num_chars = vsnprintf(buffer, sizeof(buffer),
format, args);
if (num_chars < 0)
return -1;

View File

@ -840,7 +840,8 @@ int rzipstream_putc(rzipstream_t *stream, int c)
int rzipstream_vprintf(rzipstream_t *stream, const char* format, va_list args)
{
static char buffer[8 * 1024] = {0};
int64_t num_chars = vsprintf(buffer, format, args);
int64_t num_chars = vsnprintf(buffer,
sizeof(buffer), format, args);
if (num_chars < 0)
return -1;

View File

@ -258,13 +258,11 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
#else
FILE *fp = (FILE*)g_verbosity->fp;
#if defined(HAVE_QT) || defined(__WINRT__)
int ret;
char buffer[256];
buffer[0] = '\0';
ret = vsnprintf(buffer, sizeof(buffer), fmt, ap);
/* ensure null termination and line break in error case */
if (ret < 0)
/* Ensure null termination and line break in error case */
if (vsnprintf(buffer, sizeof(buffer), fmt, ap) < 0)
{
int end;
buffer[sizeof(buffer) - 1] = '\0';