From: Stephan Bosch Date: Thu, 4 Dec 2025 22:20:14 +0000 (+0100) Subject: lib: process-title - Support re-initialization X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afeec001ef51d72cc7601baf550f97736e404366;p=thirdparty%2Fdovecot%2Fcore.git lib: process-title - Support re-initialization Make sure global state is reset properly through deinit->init cycle. This is needed for fuzzing with address sanitizer. --- diff --git a/src/lib/process-title.c b/src/lib/process-title.c index 15192ce5c3..8ec6d03543 100644 --- a/src/lib/process-title.c +++ b/src/lib/process-title.c @@ -33,6 +33,7 @@ static unsigned int process_title_counter = 0; static char *process_title; static size_t process_title_len, process_title_clean_pos; static void *argv_memblock, *environ_memblock; +static char *environ_dummy = NULL; static void proctitle_hack_init(char *argv[], char *env[]) { @@ -128,6 +129,9 @@ static void proctitle_hack_set(const char *title) void process_title_init(int argc ATTR_UNUSED, char **argv[]) { + process_name = NULL; + process_title_counter = 0; + #ifdef PROCTITLE_HACK char ***environ_p = env_get_environ_p(); char **orig_argv = *argv; @@ -188,7 +192,7 @@ void process_title_deinit(void) Alternatively we could remove the free() calls above, but that would annoy memory leak checking tools. Also we could attempt to restore the environ_p to its original state, but that's a bit complicated. */ - *environ_p = NULL; + *environ_p = &environ_dummy; #endif i_free(current_process_title); }