mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
lib/debug: retain full string in state.prog_name global
setup_logging() retains a global pointer to the provided const string in state.prog_name, which is later used in the debug_backend->reload() callback. Some setup_logging() callers, such as popt_common_callback(), incorrectly assume that a dynamic buffer is safe to provide as a prog_name parameter. Fix this by copying the entire string in setup_logging(). Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
parent
61670169d5
commit
c824240cd4
@ -87,7 +87,7 @@
|
|||||||
static struct {
|
static struct {
|
||||||
bool initialized;
|
bool initialized;
|
||||||
enum debug_logtype logtype; /* The type of logging we are doing: eg stdout, file, stderr */
|
enum debug_logtype logtype; /* The type of logging we are doing: eg stdout, file, stderr */
|
||||||
const char *prog_name;
|
char prog_name[255];
|
||||||
bool reopening_logs;
|
bool reopening_logs;
|
||||||
bool schedule_reopen_logs;
|
bool schedule_reopen_logs;
|
||||||
|
|
||||||
@ -227,11 +227,15 @@ static void debug_syslog_reload(bool enabled, bool previously_enabled,
|
|||||||
const char *prog_name, char *option)
|
const char *prog_name, char *option)
|
||||||
{
|
{
|
||||||
if (enabled && !previously_enabled) {
|
if (enabled && !previously_enabled) {
|
||||||
|
const char *ident = NULL;
|
||||||
|
if ((prog_name != NULL) && (prog_name[0] != '\0')) {
|
||||||
|
ident = prog_name;
|
||||||
|
}
|
||||||
#ifdef LOG_DAEMON
|
#ifdef LOG_DAEMON
|
||||||
openlog(prog_name, LOG_PID, SYSLOG_FACILITY);
|
openlog(ident, LOG_PID, SYSLOG_FACILITY);
|
||||||
#else
|
#else
|
||||||
/* for old systems that have no facility codes. */
|
/* for old systems that have no facility codes. */
|
||||||
openlog(prog_name, LOG_PID );
|
openlog(ident, LOG_PID);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1001,7 +1005,7 @@ void setup_logging(const char *prog_name, enum debug_logtype new_logtype)
|
|||||||
prog_name = p + 1;
|
prog_name = p + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.prog_name = prog_name;
|
strlcpy(state.prog_name, prog_name, sizeof(state.prog_name));
|
||||||
}
|
}
|
||||||
reopen_logs_internal();
|
reopen_logs_internal();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user