Update of /cvsroot/scsh/scsh-0.6/scsh
In directory usw-pr-cvs1:/tmp/cvs-serv20948
Modified Files:
syslog1.c
Log Message:
sch_ident may be copied to a different location by GC,
and openlog doesn't copy the input string, at least not
on every system. That's just great.
So copy the ident to a local static string before calling openlog.
Index: syslog1.c
===================================================================
RCS file: /cvsroot/scsh/scsh-0.6/scsh/syslog1.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** syslog1.c 2001/06/20 07:48:03 1.2
--- syslog1.c 2001/07/10 12:56:25 1.3
***************
*** 273,277 ****
--- 273,279 ----
*/
+ #define MAX_SYSLOG_IDENT 256 /* should be ample */
static int syslog_open = 0;
+ static char syslog_ident[MAX_SYSLOG_IDENT];
static s48_value
***************
*** 280,286 ****
s48_value sch_facility)
{
if (syslog_open)
s48_raise_string_os_error("syslog is already open");
! openlog(s48_extract_string(sch_ident),
s48_extract_syslog_options(sch_options),
s48_extract_syslog_facility(sch_facility));
--- 282,305 ----
s48_value sch_facility)
{
+ int i;
+ char *syslog_ident_arg;
+
if (syslog_open)
s48_raise_string_os_error("syslog is already open");
!
!
! /* sch_ident may be copied to a different location by GC,
! and openlog doesn't copy the input string, at least not
! on every system. That's just great. */
!
! /* strncpy doesn't really do what we want */
! syslog_ident_arg = s48_extract_string(sch_ident);
! for (i = 0;
! (i < MAX_SYSLOG_IDENT-1) && (syslog_ident_arg[i] != '\0');
! ++i)
! syslog_ident[i] = syslog_ident_arg[i];
! syslog_ident[i] = '\0';
!
! openlog(syslog_ident,
s48_extract_syslog_options(sch_options),
s48_extract_syslog_facility(sch_facility));
|