[ofa-general] [PATCH] libibcommon: fix overflow in debug/log prints
Sasha Khapyorsky
sashak at voltaire.com
Fri Dec 21 11:50:15 PST 2007
When long strings are passed to libibcommon debug/log functions it
overflows local buffers. Use vsnprintf() instead of vsprintf() to prevent
this.
Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
libibcommon/src/util.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libibcommon/src/util.c b/libibcommon/src/util.c
index 7da967e..5ba164c 100644
--- a/libibcommon/src/util.c
+++ b/libibcommon/src/util.c
@@ -66,7 +66,7 @@ ibwarn(const char * const fn, char *msg, ...)
int n;
va_start(va, msg);
- n = vsprintf(buf, msg, va);
+ n = vsnprintf(buf, sizeof(buf), msg, va);
va_end(va);
buf[n] = 0;
@@ -81,7 +81,7 @@ ibpanic(const char * const fn, char *msg, ...)
int n;
va_start(va, msg);
- n = vsprintf(buf, msg, va);
+ n = vsnprintf(buf, sizeof(buf), msg, va);
va_end(va);
buf[n] = 0;
@@ -99,7 +99,7 @@ logmsg(const char * const fn, char *msg, ...)
int n;
va_start(va, msg);
- n = vsprintf(buf, msg, va);
+ n = vsnprintf(buf, sizeof(buf), msg, va);
va_end(va);
buf[n] = 0;
--
1.5.3.4.206.g58ba4
More information about the general
mailing list