Mail Archives: djgpp-workers/2002/06/02/10:34:02
Hello.
Please find below a patch that allows libemu to be built with gcc 3.1.
The changes are:
* use va_lists instead of pointers to args;
* use vsnprintf() instead of vsprintf(), to avoid
a potential buffer overflow, as suggested by Andris;
* stub out vsnprintf instead of vsprintf in emudummy.c,
for building the DXE.
OK to commit?
Thanks, bye, Rich =]
Index: ./src/libemu/src/emu387.cc
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libemu/src/emu387.cc,v
retrieving revision 1.11
diff -p -u -3 -r1.11 emu387.cc
--- ./src/libemu/src/emu387.cc 2001/03/18 15:59:22 1.11
+++ ./src/libemu/src/emu387.cc 2002/06/02 12:38:19
@@ -1,8 +1,10 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
@@ -141,8 +143,13 @@ static inline int is_zero(reg a)
#ifndef eprintf
static void eprintf(const char *f, ...)
{
+ va_list args;
char buf[1000];
- vsprintf(buf, f, (&f)+1);
+
+ va_start(args, f);
+ vsnprintf(buf, sizeof(buf), f, args);
+ va_end(args);
+
_write(1, buf, strlen(buf));
}
#endif
Index: ./src/libemu/src/emudummy.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libemu/src/emudummy.c,v
retrieving revision 1.3
diff -p -u -3 -r1.3 emudummy.c
--- ./src/libemu/src/emudummy.c 2001/12/22 12:43:45 1.3
+++ ./src/libemu/src/emudummy.c 2002/06/02 12:38:24
@@ -1,3 +1,4 @@
+/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 2001 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
@@ -15,7 +16,7 @@
#include <libc/dosio.h>
int
-vsprintf (char *buf, const char *fmt, va_list args)
+vsnprintf (char *buf, size_t buflen, const char *fmt, va_list args)
{
return 0;
}
- Raw text -