From: Ralph Corderoy Date: Fri, 8 Sep 2017 12:48:29 +0000 (+0100) Subject: content_error(): Don't strlen(invo_name) that might be NULL. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/bf0fa4275147d53be15621d12d6b71916f164385 content_error(): Don't strlen(invo_name) that might be NULL. Earlier in content_error(), it checks invo_name isn't NULL before using it. Later, it passes it to strlen(3) without the check. Either the former is redundant or the latter wrong. Rather than work out which, delete the strlen(invo_name) because it was only used for a variable-width indent on a second diagnostic line. Instead, indent by a fixed four spaces, which will look better when invo_name is stupidly long anyway. Bug present since pre-git. --- diff --git a/test/mhlist/test-mhlist b/test/mhlist/test-mhlist index 48a1913c..42d2f43f 100755 --- a/test/mhlist/test-mhlist +++ b/test/mhlist/test-mhlist @@ -183,7 +183,7 @@ run_test 'mhlist last -part 2 -noheader -check' \ 1 multipart/related 180 2 text/plain 36 mhlist: content integrity suspect (digest mismatch) -- continuing - (content text/plain in message 11, part 2)' + (content text/plain in message 11, part 2)' start_test '-nocheck, the default' run_test 'mhlist last -part 2 -noheader -check -nocheck' \ diff --git a/test/mhstore/test-mhstore b/test/mhstore/test-mhstore index 7235d6f4..e8866189 100755 --- a/test/mhstore/test-mhstore +++ b/test/mhstore/test-mhstore @@ -240,7 +240,7 @@ mv -f "$MH_TEST_DIR/$$.tmp" "$msgfile" run_test 'mhstore last -part 2 -check' \ 'storing message 11 part 2 as file 11.2.txt mhstore: content integrity suspect (digest mismatch) -- continuing - (content text/plain in message 11, part 2)' + (content text/plain in message 11, part 2)' check "$expected" 11.2.txt 'keep first' # check -nocheck, the default diff --git a/uip/mhmisc.c b/uip/mhmisc.c index 778d8055..dc33bc08 100644 --- a/uip/mhmisc.c +++ b/uip/mhmisc.c @@ -161,7 +161,7 @@ void content_error (char *what, CT ct, char *fmt, ...) { va_list arglist; - int i, len, buflen; + int len, buflen; char *bp, buffer[BUFSIZ]; CI ci; @@ -204,10 +204,8 @@ content_error (char *what, CT ct, char *fmt, ...) buflen -= len; } - i = strlen (invo_name) + 2; - /* Now add content type and subtype */ - snprintf (bp, buflen, "\n%*s(content %s/%s", i, "", + snprintf (bp, buflen, "\n (content %s/%s", ci->ci_type, ci->ci_subtype); len = strlen (bp); bp += len;