degesch: fix hook debug logs

Obviously we can receive back the same pointer with different contents.

I just didn't think of that.
This commit is contained in:
Přemysl Eric Janouch 2015-11-22 02:52:07 +01:00
parent 36c59ff375
commit 0fdffa0e50
1 changed files with 12 additions and 13 deletions

View File

@ -4147,20 +4147,20 @@ static char *
irc_process_hooks (struct server *s, char *input)
{
log_server_debug (s, "#a>> \"#S\"#r", ATTR_JOIN, input);
uint64_t hash = siphash_wrapper (input, strlen (input));
LIST_FOR_EACH (struct hook, iter, s->ctx->irc_hooks)
{
struct irc_hook *hook = (struct irc_hook *) iter;
char *processed = hook->vtable->filter (hook, s, input);
if (input == processed)
continue;
if (processed == NULL)
if (!(input = hook->vtable->filter (hook, s, input)))
{
log_server_debug (s, "#a>= #s#r", ATTR_JOIN, "thrown away by hook");
return NULL;
}
log_server_debug (s, "#a>= \"#S\"#r", ATTR_JOIN, (input = processed));
uint64_t new_hash = siphash_wrapper (input, strlen (input));
if (new_hash != hash)
log_server_debug (s, "#a>= \"#S\"#r", ATTR_JOIN, input);
hash = new_hash;
}
return input;
}
@ -9546,21 +9546,20 @@ static char *
process_input_hooks (struct app_context *ctx, struct buffer *buffer,
char *input)
{
uint64_t hash = siphash_wrapper (input, strlen (input));
LIST_FOR_EACH (struct hook, iter, ctx->input_hooks)
{
struct input_hook *hook = (struct input_hook *) iter;
char *processed = hook->vtable->filter (hook, buffer, input);
if (input == processed)
continue;
if (processed == NULL)
if (!(input = hook->vtable->filter (hook, buffer, input)))
{
log_global_debug (ctx, "Input thrown away by hook");
return NULL;
}
log_global_debug (ctx,
"Input transformed to \"#s\"#r", (input = processed));
uint64_t new_hash = siphash_wrapper (input, strlen (input));
if (new_hash != hash)
log_global_debug (ctx, "Input transformed to \"#s\"#r", input);
hash = new_hash;
}
return input;
}