From: Jeremy Harris Date: Fri, 6 Oct 2017 17:11:22 +0000 (+0100) Subject: Better handling of printing NULL pointers X-Git-Tag: exim-4_90_RC1~52 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/81f358daccc6f759456eb1ae0f8e456a9118ca9f Better handling of printing NULL pointers --- diff --git a/src/src/string.c b/src/src/string.c index 3857e1120..f3bf34315 100644 --- a/src/src/string.c +++ b/src/src/string.c @@ -1366,13 +1366,13 @@ while (*fp != 0) { void * ptr; if (p >= last - 24) { yield = FALSE; goto END_FORMAT; } - /* sprintf() saying "(nil)" for a null pointer doesn't work - on FreeBSD; we get "0xAAAAAAAA". Handle it explicitly. */ + /* sprintf() saying "(nil)" for a null pointer seems unreliable. + Handle it explicitly. */ if ((ptr = va_arg(ap, void *))) { strncpy(newformat, item_start, fp - item_start); newformat[fp - item_start] = 0; - p += sprintf(CS p, newformat, va_arg(ap, void *)); + p += sprintf(CS p, newformat, ptr); } else p += sprintf(CS p, "(nil)"); diff --git a/test/stderr/0388 b/test/stderr/0388 index f758b0a23..5a21445c9 100644 --- a/test/stderr/0388 +++ b/test/stderr/0388 @@ -141,7 +141,7 @@ Deferred addresses: locking TESTSUITE/spool/db/retry.lockfile locked TESTSUITE/spool/db/retry.lockfile EXIM_DBOPEN: file dir flags 0x2 -returned from EXIM_DBOPEN: (nil) +returned from EXIM_DBOPEN: 0xAAAAAAAA opened hints database TESTSUITE/spool/db/retry: flags=O_RDWR address match test: subject=x@y pattern=* y in "*"? yes (matched "*") @@ -241,7 +241,7 @@ set_process_info: pppp delivering 10HmaY-0005vi-00 locking TESTSUITE/spool/db/retry.lockfile locked TESTSUITE/spool/db/retry.lockfile EXIM_DBOPEN: file dir flags 0x0 -returned from EXIM_DBOPEN: (nil) +returned from EXIM_DBOPEN: 0xAAAAAAAA opened hints database TESTSUITE/spool/db/retry: flags=O_RDONLY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Considering: CALLER@myhost.test.ex @@ -252,7 +252,7 @@ dbfn_read: key=R:CALLER@myhost.test.ex:<> no domain retry record no address retry record CALLER@myhost.test.ex: queued for routing -EXIM_DBCLOSE((nil)) +EXIM_DBCLOSE(0xAAAAAAAA) closed hints database and lockfile >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> routing CALLER@myhost.test.ex diff --git a/test/stderr/0398 b/test/stderr/0398 index 4a92dc698..f61f37457 100644 --- a/test/stderr/0398 +++ b/test/stderr/0398 @@ -121,13 +121,13 @@ Attempting full verification using callout locking TESTSUITE/spool/db/callout.lockfile locked TESTSUITE/spool/db/callout.lockfile EXIM_DBOPEN: file dir flags 0x2 -returned from EXIM_DBOPEN: (nil) +returned from EXIM_DBOPEN: 0xAAAAAAAA opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR dbfn_read: key=remote callout cache: found domain record for remote dbfn_read: key=qq@remote callout cache: no address record found for qq@remote -EXIM_DBCLOSE((nil)) +EXIM_DBCLOSE(0xAAAAAAAA) closed hints database and lockfile interface=NULL port=1224 Connecting to 127.0.0.1 [127.0.0.1]:1224 ... connected @@ -152,14 +152,14 @@ cmd buf flush ddd bytes locking TESTSUITE/spool/db/callout.lockfile locked TESTSUITE/spool/db/callout.lockfile EXIM_DBOPEN: file dir flags 0x42 -returned from EXIM_DBOPEN: (nil) +returned from EXIM_DBOPEN: 0xAAAAAAAA opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR|O_CREAT dbfn_write: key=remote wrote callout cache domain record for remote: result=1 postmaster=0 random=0 dbfn_write: key=qq@remote wrote negative callout cache address record for qq@remote -EXIM_DBCLOSE((nil)) +EXIM_DBCLOSE(0xAAAAAAAA) closed hints database and lockfile ----------- end verify ------------ l_message: $acl_verify_message @@ -234,14 +234,14 @@ Attempting full verification using callout locking TESTSUITE/spool/db/callout.lockfile locked TESTSUITE/spool/db/callout.lockfile EXIM_DBOPEN: file dir flags 0x2 -returned from EXIM_DBOPEN: (nil) +returned from EXIM_DBOPEN: 0xAAAAAAAA opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR dbfn_read: key=remote callout cache: found domain record for remote dbfn_read: key=qq@remote callout cache: found address record for qq@remote callout cache: address record is negative -EXIM_DBCLOSE((nil)) +EXIM_DBCLOSE(0xAAAAAAAA) closed hints database and lockfile ----------- end verify ------------ l_message: $acl_verify_message diff --git a/test/stderr/0432 b/test/stderr/0432 index 69d929b71..79117e25a 100644 --- a/test/stderr/0432 +++ b/test/stderr/0432 @@ -82,13 +82,13 @@ Attempting full verification using callout locking TESTSUITE/spool/db/callout.lockfile locked TESTSUITE/spool/db/callout.lockfile EXIM_DBOPEN: file dir flags 0x2 -returned from EXIM_DBOPEN: (nil) +returned from EXIM_DBOPEN: 0xAAAAAAAA opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR dbfn_read: key=y callout cache: no domain record found for y dbfn_read: key=x@y callout cache: no address record found for x@y -EXIM_DBCLOSE((nil)) +EXIM_DBCLOSE(0xAAAAAAAA) closed hints database and lockfile interface=NULL port=1224 Connecting to 127.0.0.1 [127.0.0.1]:1224 ... connected @@ -113,14 +113,14 @@ cmd buf flush ddd bytes locking TESTSUITE/spool/db/callout.lockfile locked TESTSUITE/spool/db/callout.lockfile EXIM_DBOPEN: file dir flags 0x42 -returned from EXIM_DBOPEN: (nil) +returned from EXIM_DBOPEN: 0xAAAAAAAA opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR|O_CREAT dbfn_write: key=y wrote callout cache domain record for y: result=1 postmaster=0 random=0 dbfn_write: key=x@y wrote positive callout cache address record for x@y -EXIM_DBCLOSE((nil)) +EXIM_DBCLOSE(0xAAAAAAAA) closed hints database and lockfile ----------- end verify ------------ sender x@y verified ok @@ -192,14 +192,14 @@ Attempting full verification using callout locking TESTSUITE/spool/db/callout.lockfile locked TESTSUITE/spool/db/callout.lockfile EXIM_DBOPEN: file dir flags 0x2 -returned from EXIM_DBOPEN: (nil) +returned from EXIM_DBOPEN: 0xAAAAAAAA opened hints database TESTSUITE/spool/db/callout: flags=O_RDWR dbfn_read: key=y callout cache: found domain record for y dbfn_read: key=x@y callout cache: found address record for x@y callout cache: address record is positive -EXIM_DBCLOSE((nil)) +EXIM_DBCLOSE(0xAAAAAAAA) closed hints database and lockfile ----------- end verify ------------ sender x@y verified ok diff --git a/test/stderr/5005 b/test/stderr/5005 index af664aedb..7e6ea98b2 100644 --- a/test/stderr/5005 +++ b/test/stderr/5005 @@ -554,7 +554,7 @@ Deferred addresses: locking TESTSUITE/spool/db/retry.lockfile locked TESTSUITE/spool/db/retry.lockfile EXIM_DBOPEN: file dir flags 0x2 -returned from EXIM_DBOPEN: (nil) +returned from EXIM_DBOPEN: 0xAAAAAAAA opened hints database TESTSUITE/spool/db/retry: flags=O_RDWR address match test: subject=userx@test.ex pattern=* test.ex in "*"? yes (matched "*") @@ -566,7 +566,7 @@ Writing retry data for T:userx@test.ex first failed=dddd last try=dddd next try=+86400 expired=0 errno=-22 more_errno=dd mailbox is full (MTA-imposed quota exceeded while writing to tmp/MAILDIR.myhost.test.ex) dbfn_write: key=T:userx@test.ex -EXIM_DBCLOSE((nil)) +EXIM_DBCLOSE(0xAAAAAAAA) closed hints database and lockfile end of retry processing delivery deferred: update_spool=1 header_rewritten=0 @@ -659,7 +659,7 @@ Delivery address list: locking TESTSUITE/spool/db/retry.lockfile locked TESTSUITE/spool/db/retry.lockfile EXIM_DBOPEN: file dir flags 0x0 -returned from EXIM_DBOPEN: (nil) +returned from EXIM_DBOPEN: 0xAAAAAAAA opened hints database TESTSUITE/spool/db/retry: flags=O_RDONLY >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Considering: userx@test.ex @@ -670,7 +670,7 @@ dbfn_read: key=R:userx@test.ex: no domain retry record no address retry record userx@test.ex: queued for routing -EXIM_DBCLOSE((nil)) +EXIM_DBCLOSE(0xAAAAAAAA) closed hints database and lockfile >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> routing userx@test.ex @@ -700,12 +700,12 @@ search_tidyup called locking TESTSUITE/spool/db/retry.lockfile locked TESTSUITE/spool/db/retry.lockfile EXIM_DBOPEN: file dir flags 0x0 -returned from EXIM_DBOPEN: (nil) +returned from EXIM_DBOPEN: 0xAAAAAAAA opened hints database TESTSUITE/spool/db/retry: flags=O_RDONLY dbfn_read: key=T:userx@test.ex retry record exists: age=ttt (max 1w) time to retry = tttt expired = 0 -EXIM_DBCLOSE((nil)) +EXIM_DBCLOSE(0xAAAAAAAA) closed hints database and lockfile search_tidyup called changed uid/gid: local delivery to userx transport=t1 @@ -750,7 +750,7 @@ Deferred addresses: locking TESTSUITE/spool/db/retry.lockfile locked TESTSUITE/spool/db/retry.lockfile EXIM_DBOPEN: file dir flags 0x2 -returned from EXIM_DBOPEN: (nil) +returned from EXIM_DBOPEN: 0xAAAAAAAA opened hints database TESTSUITE/spool/db/retry: flags=O_RDWR address match test: subject=userx@test.ex pattern=* test.ex in "*"? yes (matched "*") @@ -762,7 +762,7 @@ Writing retry data for T:userx@test.ex first failed=dddd last try=dddd next try=+86400 expired=0 errno=-22 more_errno=dd mailbox is full (MTA-imposed quota exceeded while writing to tmp/MAILDIR.myhost.test.ex) dbfn_write: key=T:userx@test.ex -EXIM_DBCLOSE((nil)) +EXIM_DBCLOSE(0xAAAAAAAA) closed hints database and lockfile end of retry processing delivery deferred: update_spool=1 header_rewritten=0