From: Jeremy Harris Date: Wed, 6 Jun 2018 10:19:23 +0000 (+0100) Subject: Fix logging of cmdline args when starting in an unlinked cwd. Bug 2274 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/d5bd2a53d8a226793321b0c3011092ab97e63902?hp=3b9730e3deaf4eb03a99977d830da446dcc85cfb Fix logging of cmdline args when starting in an unlinked cwd. Bug 2274 --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 3edcb12fd..5fb0149dc 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -31,6 +31,9 @@ JH/06 Bug 2275: The MIME ACL unlocked the received message files early, and JH/08 When generating a selfsigned cert, use serial number 1 since zero is not legitimate. +JH/09 Bug 2274: Fix logging of cmdline args when starting in an unlinked cwd. + Previously this would segfault. + Exim version 4.91 ----------------- diff --git a/src/src/exim.c b/src/src/exim.c index d740814f9..93a65dbcb 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -4083,14 +4083,23 @@ a debugging feature for finding out what arguments certain MUAs actually use. 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)) - && really_exim && !list_options && !checking) +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);