diff -r -C3 -p old/src/sockets.c new/src/sockets.c *** old/src/sockets.c Sun Apr 11 13:43:56 2004 --- new/src/sockets.c Fri Jun 23 17:15:35 2006 *************** *** 2,7 **** --- 2,13 ---- * $Copyright$ */ + /* + * 2006/06/23 Alessandro Di Marco + * Fixed some illegal va_arg() invocations (see below for details.) + * + */ + #include "nglobal.h" #include "network.h" #include "group.h" *************** EXPORT int emitf (char *fmt, ...) EXP_(G *** 604,609 **** --- 610,630 ---- { char buf[MAX_SYSLOG]; /* should be more than enough */ vsnprintf(buf, MAX_SYSLOG-1, fmt, ap); + + /* WARNING: multiple va_arg() invocations in the same + * va_start() / va_end() block are forbidden (see the + * man page!) Although these give no apparent problems + * on the i386 architecture, for instance on amd64 are + * very likely to produce sigsegves (page errors). As a + * consequence, I have switched to a more legacy + * behaviour. + * + * 2006/06/23 Alessandro Di Marco + */ + + va_end(ap); + va_start(ap, fmt); + logToClient (buf); } i=vfprintf(clientout, fmt, ap); *************** EXPORT int Cemitf (char *fmt, ...) EXP_( *** 632,637 **** --- 653,661 ---- char buf[MAX_SYSLOG]; vsnprintf(buf, MAX_SYSLOG-1, fmt, ap); logToServer (scfg->host, buf); + + va_end(ap); + va_start(ap, fmt); } i=vfprintf(scfg->fh, fmt, ap); va_end(ap); *************** EXPORT int Cfemitf (struct server_cfg *s *** 657,662 **** --- 681,689 ---- char buf[MAX_SYSLOG]; vsnprintf(buf, MAX_SYSLOG-1, fmt, ap); logToServer (scfg->host, buf); + + va_end(ap); + va_start(ap, fmt); } i=vfprintf(scfg->fh, fmt, ap); va_end(ap);