diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-11-22 02:52:07 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-11-22 03:01:38 +0100 |
commit | 0fdffa0e50036171fa6a2c7c225b035a6f4a6058 (patch) | |
tree | 97f6246a89a2238c2f5d5a7bd79fe4bfd38b9d8b | |
parent | 36c59ff375ea2399961df54403676e8e8457f4b6 (diff) | |
download | xK-0fdffa0e50036171fa6a2c7c225b035a6f4a6058.tar.gz xK-0fdffa0e50036171fa6a2c7c225b035a6f4a6058.tar.xz xK-0fdffa0e50036171fa6a2c7c225b035a6f4a6058.zip |
degesch: fix hook debug logs
Obviously we can receive back the same pointer with different contents.
I just didn't think of that.
-rw-r--r-- | degesch.c | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -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; } |