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.
This commit is contained in:
parent
a7227450ca
commit
0a1e5ab9bb
|
@ -272,16 +272,35 @@ s48_extract_syslog_mask(s48_value sch_syslog_mask)
|
|||
* ### Must still prevent cores.
|
||||
*/
|
||||
|
||||
#define MAX_SYSLOG_IDENT 256 /* should be ample */
|
||||
static int syslog_open = 0;
|
||||
static char syslog_ident[MAX_SYSLOG_IDENT];
|
||||
|
||||
static s48_value
|
||||
sch_openlog(s48_value sch_ident,
|
||||
s48_value sch_options,
|
||||
s48_value sch_facility)
|
||||
{
|
||||
int i;
|
||||
char *syslog_ident_arg;
|
||||
|
||||
if (syslog_open)
|
||||
s48_raise_string_os_error("syslog is already open");
|
||||
openlog(s48_extract_string(sch_ident),
|
||||
|
||||
|
||||
/* 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));
|
||||
syslog_open = 1;
|
||||
|
|
Loading…
Reference in New Issue