1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

eventscript: fix bug when script is aborted

Another corner case when we terminate running monitor scripts to run
something else: logging can flush the output and we write to a NULL
pointer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

(This used to be ctdb commit eb22c34bccc8a04fcf63efa2bc48d9788709382e)
This commit is contained in:
Rusty Russell 2009-12-18 14:13:09 +10:30 committed by Ronnie Sahlberg
parent e757b7c4bf
commit 565b2cda11

View File

@ -87,9 +87,16 @@ static void log_event_script_output(const char *str, uint16_t len, void *p)
{
struct ctdb_event_script_state *state
= talloc_get_type(p, struct ctdb_event_script_state);
struct ctdb_script_wire *current = get_current_script(state);
struct ctdb_script_wire *current;
unsigned int slen, min;
/* We may have been aborted to run something else. Discard */
if (state->scripts == NULL) {
return;
}
current = get_current_script(state);
/* Append, but don't overfill buffer. It starts zero-filled. */
slen = strlen(current->output);
min = MIN(len, sizeof(current->output) - slen - 1);