summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/imports.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2002-08-01 15:10:23 +0000
committerBrian Paul <[email protected]>2002-08-01 15:10:23 +0000
commitc2656d588be17ba4bd453d2164b84f606be83dd2 (patch)
tree99c8c2a0fbd3293984142df7be3c1aefa6b4187b /src/mesa/main/imports.c
parentf1dee4fe8f2dd4049bd768ab09706f6d78cc915f (diff)
define MAXSTRING and use vsnprintf to preven overflows
Diffstat (limited to 'src/mesa/main/imports.c')
-rw-r--r--src/mesa/main/imports.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index bdeaf809a43..a1329c6c8f5 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -1,4 +1,4 @@
-/* $Id: imports.c,v 1.16 2002/07/01 08:26:00 joukj Exp $ */
+/* $Id: imports.c,v 1.17 2002/08/01 15:10:23 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -47,6 +47,8 @@
#include "imports.h"
#include "mem.h"
+#define MAXSTRING 4000 /* for vsnprintf() */
+
static void *
_mesa_Malloc(__GLcontext *gc, size_t size)
@@ -173,10 +175,10 @@ _mesa_GetDrawablePrivate(__GLcontext *gc)
void
_mesa_warning(__GLcontext *gc, const char *fmtString, ...)
{
- char str[1000];
+ char str[MAXSTRING];
va_list args;
va_start( args, fmtString );
- (void) vsprintf( str, fmtString, args );
+ (void) vsnprintf( str, MAXSTRING, fmtString, args );
va_end( args );
warning(gc, str);
}
@@ -238,11 +240,11 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... )
if (debug) {
va_list args;
- char where[1000];
+ char where[MAXSTRING];
const char *errstr;
va_start( args, fmtString );
- vsprintf( where, fmtString, args );
+ vsnprintf( where, MAXSTRING, fmtString, args );
va_end( args );
switch (error) {
@@ -287,10 +289,10 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... )
void
_mesa_debug( const GLcontext *ctx, const char *fmtString, ... )
{
- char s[1000];
+ char s[MAXSTRING];
va_list args;
va_start(args, fmtString);
- vsprintf(s, fmtString, args);
+ vsnprintf(s, MAXSTRING, fmtString, args);
if (ctx)
(void) ctx->imports.fprintf( (__GLcontext *) ctx, stderr, s );
else
@@ -305,10 +307,10 @@ _mesa_debug( const GLcontext *ctx, const char *fmtString, ... )
void
_mesa_printf( const GLcontext *ctx, const char *fmtString, ... )
{
- char s[1000];
+ char s[MAXSTRING];
va_list args;
va_start( args, fmtString );
- vsprintf(s, fmtString, args);
+ vsnprintf(s, MAXSTRING, fmtString, args);
if (ctx)
(void) ctx->imports.fprintf( (__GLcontext *) ctx, stdout, s );
else