Gwyn Connor gwyn.connor at googlemail.com
Fri Jan 15 05:22:35 PST 2010
Hi,

the slon_log function in 2.0.3-rc3 contains a very bad sprintf bug,
where source and target buffer are the same. In such a case the
standard says that the result of sprintf is undefined (according to
the sprintf man page). And this causes slon to not log timestamps on
my Gentoo machine.

I am not a C coder, so I don't know the proper way of fixing it. I
simply hacked in a quick and extremely dirty workaround (it also
breaks logpid support, but I don't use that anyways):

--- src/slon/misc.c.bak 2010-01-15 12:11:48.254746186 +0100
+++ src/slon/misc.c     2010-01-15 12:12:25.550750724 +0100
@@ -162,6 +162,7 @@
        }
        outbuf[0] = (char) 0;

+       time_buf[0] = (char) 0;
        if (logtimestamp == true && (Use_syslog != 1)
 #ifdef WIN32
                && !win32_isservice
@@ -179,7 +180,7 @@
        {
                sprintf(outbuf, "%s[%d] ", outbuf, slon_pid);
        }
-       sprintf(outbuf, "%s%-6.6s ", outbuf, level_c);
+       sprintf(outbuf, "%s %-6.6s ", time_buf, level_c);

        off = (int) strlen(outbuf);


Regards,
gwyn


More information about the Slony1-general mailing list