[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Replace vsprintf with vsnprintf in ext2fs/msg.c
From: |
Flavio Cruz |
Subject: |
[PATCH] Replace vsprintf with vsnprintf in ext2fs/msg.c |
Date: |
Sun, 6 Nov 2022 01:23:00 -0400 |
---
ext2fs/msg.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/ext2fs/msg.c b/ext2fs/msg.c
index 83939b06..af636b7c 100644
--- a/ext2fs/msg.c
+++ b/ext2fs/msg.c
@@ -38,7 +38,8 @@ int printf (const char *fmt, ...)
return done;
}
-static char error_buf[1024];
+#define ERROR_BUF_SIZE 1024
+static char error_buf[ERROR_BUF_SIZE];
void _ext2_error (const char * function, const char * fmt, ...)
{
@@ -47,7 +48,7 @@ void _ext2_error (const char * function, const char * fmt,
...)
pthread_mutex_lock (&printf_lock);
va_start (args, fmt);
- vsprintf (error_buf, fmt, args);
+ vsnprintf (error_buf, ERROR_BUF_SIZE, fmt, args);
va_end (args);
fprintf (stderr, "ext2fs: %s: %s: %s\n", diskfs_disk_name, function,
error_buf);
@@ -62,7 +63,7 @@ void _ext2_panic (const char * function, const char * fmt,
...)
pthread_mutex_lock (&printf_lock);
va_start (args, fmt);
- vsprintf (error_buf, fmt, args);
+ vsnprintf (error_buf, ERROR_BUF_SIZE, fmt, args);
va_end (args);
fprintf(stderr, "ext2fs: %s: panic: %s: %s\n",
@@ -80,7 +81,7 @@ void ext2_warning (const char * fmt, ...)
pthread_mutex_lock (&printf_lock);
va_start (args, fmt);
- vsprintf (error_buf, fmt, args);
+ vsnprintf (error_buf, ERROR_BUF_SIZE, fmt, args);
va_end (args);
fprintf (stderr, "ext2fs: %s: warning: %s\n", diskfs_disk_name, error_buf);
--
2.35.1
- [PATCH] Replace vsprintf with vsnprintf in ext2fs/msg.c,
Flavio Cruz <=