From: Lachlan McIlroy Date: Thu, 8 Mar 2007 03:02:20 +0000 (+0000) Subject: fsx was calling vfprintf twice without resetting the va_list argument X-Git-Tag: v1.1.0~511 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0e907ec7cf448ad962237e3417aa8ce5da853060;p=xfstests-dev.git fsx was calling vfprintf twice without resetting the va_list argument Merge of master-melb:xfs-cmds:28212a by kenmcd. fsx was calling vfprintf twice without resetting the va_list argument and this caused a segfault on the second call. Now uses one call to vsnprintf to print to a buffer and uses that multiple times. --- diff --git a/ltp/fsx.c b/ltp/fsx.c index e90dd79c..ebe53249 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -153,16 +153,20 @@ warn(const char * fmt, ...) { va_end(ap); } +#define BUF_SIZE 1024 + void prt(char *fmt, ...) { va_list args; + char buffer[BUF_SIZE]; va_start(args, fmt); - vfprintf(stdout, fmt, args); - if (fsxlogf) - vfprintf(fsxlogf, fmt, args); + vsnprintf(buffer, BUF_SIZE, fmt, args); va_end(args); + fprintf(stdout, buffer); + if (fsxlogf) + fprintf(fsxlogf, buffer); } void