Date: Sun, 02 Jun 2002 13:47:00 +0100 From: "Richard Dawe" Sender: rich AT phekda DOT freeserve DOT co DOT uk To: djgpp-workers AT delorie DOT com X-Mailer: Emacs 21.2.50 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6 Subject: Patch for building libemu with gcc 3.1 Message-Id: Reply-To: djgpp-workers AT delorie DOT com 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 #include #include #include @@ -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 int -vsprintf (char *buf, const char *fmt, va_list args) +vsnprintf (char *buf, size_t buflen, const char *fmt, va_list args) { return 0; }