Thu Feb 11 13:17:23 PST 2010
- Previous message: [Slony1-commit] slony1-engine/src/slon misc.c
- Next message: [Slony1-commit] slony1-engine/src/slonik dbutil.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /home/cvsd/slony1/slony1-engine/src/slon
In directory main.slony.info:/tmp/cvs-serv25779
Modified Files:
Tag: REL_1_1_STABLE
misc.c
Log Message:
Gwyn Connor pointed out a sprintf() abuse...
When log entries are generated, we're passing outbuf both as buffer and as
a source of data. Behaviour is undefined on some systems, notably including
Gentoo Linux.
Change: Make sure there are buffers for the date + process, fill them, and
reference them.
- Apply to 1.1 branch
Index: misc.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slon/misc.c,v
retrieving revision 1.18.2.1
retrieving revision 1.18.2.2
diff -C 2 -d -r1.18.2.1 -r1.18.2.2
*** misc.c 6 Jan 2006 17:07:47 -0000 1.18.2.1
--- misc.c 11 Feb 2010 21:17:21 -0000 1.18.2.2
***************
*** 76,80 ****
char *level_c = NULL;
! char time_buf[128];
time_t stamp_time = time(NULL);
--- 76,81 ----
char *level_c = NULL;
! char time_buf[128]; /* Buffer to hold timestamp */
! char ps_buf[20]; /* Buffer to hold PID */
time_t stamp_time = time(NULL);
***************
*** 151,160 ****
strftime(time_buf, sizeof(time_buf), log_timestamp_format, localtime(&stamp_time));
sprintf(outbuf, "%s ", time_buf);
}
if (logpid == true)
{
! sprintf(outbuf, "%s[%d] ", outbuf, slon_pid);
}
! sprintf(outbuf, "%s%-6.6s ", outbuf, level_c);
off = strlen(outbuf);
--- 152,167 ----
strftime(time_buf, sizeof(time_buf), log_timestamp_format, localtime(&stamp_time));
sprintf(outbuf, "%s ", time_buf);
+ } else {
+ time_buf[0] = (char) 0;
}
+
if (logpid == true)
{
! sprintf(ps_buf, "[%d] ", slon_pid);
! } else {
! ps_buf[0] = (char) 0;
}
!
! sprintf(outbuf, "%s%s%-6.6s ", time_buf, ps_buf, level_c);
off = strlen(outbuf);
- Previous message: [Slony1-commit] slony1-engine/src/slon misc.c
- Next message: [Slony1-commit] slony1-engine/src/slonik dbutil.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list