Chris Browne cbbrowne at lists.slony.info
Thu Feb 11 12:50:47 PST 2010
Update of /home/cvsd/slony1/slony1-engine/src/slon
In directory main.slony.info:/tmp/cvs-serv22600/slon

Modified Files:
      Tag: REL_2_0_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.


Index: misc.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slon/misc.c,v
retrieving revision 1.26.2.3
retrieving revision 1.26.2.4
diff -C 2 -d -r1.26.2.3 -r1.26.2.4
*** misc.c	9 Dec 2009 20:55:43 -0000	1.26.2.3
--- misc.c	11 Feb 2010 20:50:45 -0000	1.26.2.4
***************
*** 80,84 ****
  	char	   *level_c = NULL;
  
! 	char		time_buf[128];
  	time_t		stamp_time = time(NULL);
  
--- 80,85 ----
  	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);
  
***************
*** 174,184 ****
  			slon_retry();
  		}
! 		sprintf(outbuf, "%s ", time_buf);
  	}
  	if (logpid == true)
  	{
! 		sprintf(outbuf, "%s[%d] ", outbuf, slon_pid);
  	}
! 	sprintf(outbuf, "%s%-6.6s ", outbuf, level_c);
  
  	off = (int) strlen(outbuf);
--- 175,190 ----
  			slon_retry();
  		}
! 	} 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 = (int) strlen(outbuf);



More information about the Slony1-commit mailing list