--- src/exim.c.orig 2018-07-10 17:39:47.965000000 -0600 +++ src/exim.c 2018-07-10 17:42:42.077000000 -0600 @@ -4083,16 +4083,24 @@ Don't attempt it if logging is disabled, or if listing variables or if verifying/testing addresses or expansions. */ -if (((debug_selector & D_any) != 0 || LOGGING(arguments)) +if ( (debug_selector & D_any || LOGGING(arguments)) && really_exim && !list_options && !checking) { int i; uschar *p = big_buffer; Ustrcpy(p, "cwd= (failed)"); - Ustrncpy(p + 4, initial_cwd, big_buffer_size-5); + if (!initial_cwd) + p += 13; + else + { + Ustrncpy(p + 4, initial_cwd, big_buffer_size-5); + p += 4 + Ustrlen(initial_cwd); + /* in case p is near the end and we don't provide enough space for + * string_format to be willing to write. */ + *p = '\0'; + } - while (*p) p++; (void)string_format(p, big_buffer_size - (p - big_buffer), " %d args:", argc); while (*p) p++; for (i = 0; i < argc; i++)