From 0fdffa0e50036171fa6a2c7c225b035a6f4a6058 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Sun, 22 Nov 2015 02:52:07 +0100 Subject: degesch: fix hook debug logs Obviously we can receive back the same pointer with different contents. I just didn't think of that. --- degesch.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/degesch.c b/degesch.c index bc70a7a..5dc902c 100644 --- a/degesch.c +++ b/degesch.c @@ -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; } -- cgit v1.2.3-70-g09d2