From 97e939dfe2ea44a6e243ff6f489790ccd94f39ee Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Fri, 11 May 2018 16:26:17 +0100 Subject: [PATCH] ARC: fix crash on signing with missing key file --- src/src/arc.c | 3 ++- test/confs/4560 | 4 ++++ test/log/4560 | 32 +++++++++++++++++++++++++++++--- test/mail/4560.a | 20 ++++++++++++++++++++ test/scripts/4560-ARC/4560 | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 89 insertions(+), 4 deletions(-) diff --git a/src/src/arc.c b/src/src/arc.c index 787c6e1e2..58811274e 100644 --- a/src/src/arc.c +++ b/src/src/arc.c @@ -1696,7 +1696,8 @@ g = arc_sign_append_ams(g, &arc_sign_ctx, instance, identity, selector, including self (but with an empty b= in self) */ -g = arc_sign_prepend_as(g, &arc_sign_ctx, instance, identity, selector, &ar, +if (g) + g = arc_sign_prepend_as(g, &arc_sign_ctx, instance, identity, selector, &ar, privkey, options); /* Finally, append the dkim headers and return the lot. */ diff --git a/test/confs/4560 b/test/confs/4560 index e2095af4c..ad634a42e 100644 --- a/test/confs/4560 +++ b/test/confs/4560 @@ -86,8 +86,12 @@ tsmtp: port = PORT_D allow_localhost .ifndef OPTION +.ifdef BAD + arc_sign = $primary_hostname : sel : MISSING_KEY +.else arc_sign = $primary_hostname : sel : DIR/aux-fixed/dkim/dkim.private .endif +.endif tmlist: driver = smtp diff --git a/test/log/4560 b/test/log/4560 index 153c3c7a4..c072bdda0 100644 --- a/test/log/4560 +++ b/test/log/4560 @@ -245,8 +245,6 @@ 1999-03-02 09:44:33 10HmbQ-0005vi-00 => a R=d1 T=tfile 1999-03-02 09:44:33 10HmbQ-0005vi-00 Completed 1999-03-02 09:44:33 End queue run: pid=pppp -1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port 1225 -1999-03-02 09:44:33 10HmbR-0005vi-00 H=(xxx) [127.0.0.1] Warning: ARC-FAIL 1999-03-02 09:44:33 10HmbR-0005vi-00 arc_state: 1999-03-02 09:44:33 10HmbR-0005vi-00 domains: <> 1999-03-02 09:44:33 10HmbR-0005vi-00 arc_oldest_pass <0> @@ -254,4 +252,32 @@ 1999-03-02 09:44:33 10HmbR-0005vi-00 lh_A-R: <> 1999-03-02 09:44:33 10HmbR-0005vi-00 lh-ams: <> 1999-03-02 09:44:33 10HmbR-0005vi-00 oldest-p-ams: <> -1999-03-02 09:44:33 10HmbR-0005vi-00 <= CALLER@bloggs.com H=(xxx) [127.0.0.1] P=smtp S=sss for a@test.ex +1999-03-02 09:44:33 10HmbR-0005vi-00 <= CALLER@bloggs.com H=(xxx) [127.0.0.1] P=smtp S=sss for za@test.ex +1999-03-02 09:44:33 Start queue run: pid=pppp +1999-03-02 09:44:33 10HmbR-0005vi-00 ARC: AMS signing: error:0906D06C:PEM routines:PEM_read_bio:no start line + +1999-03-02 09:44:33 10HmbS-0005vi-00 arc_state: +1999-03-02 09:44:33 10HmbS-0005vi-00 domains: <> +1999-03-02 09:44:33 10HmbS-0005vi-00 arc_oldest_pass <0> +1999-03-02 09:44:33 10HmbS-0005vi-00 reason: <> +1999-03-02 09:44:33 10HmbS-0005vi-00 lh_A-R: < test.ex;\n arc=none> +1999-03-02 09:44:33 10HmbS-0005vi-00 lh-ams: <> +1999-03-02 09:44:33 10HmbS-0005vi-00 oldest-p-ams: <> +1999-03-02 09:44:33 10HmbS-0005vi-00 <= CALLER@bloggs.com H=localhost (test.ex) [127.0.0.1] P=esmtp S=sss for a@test.ex +1999-03-02 09:44:33 10HmbR-0005vi-00 => a@test.ex R=fwd T=tsmtp H=127.0.0.1 [127.0.0.1] C="250 OK id=10HmbS-0005vi-00" +1999-03-02 09:44:33 10HmbR-0005vi-00 Completed +1999-03-02 09:44:33 End queue run: pid=pppp +1999-03-02 09:44:33 Start queue run: pid=pppp +1999-03-02 09:44:33 10HmbS-0005vi-00 => a R=d1 T=tfile +1999-03-02 09:44:33 10HmbS-0005vi-00 Completed +1999-03-02 09:44:33 End queue run: pid=pppp +1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port 1225 +1999-03-02 09:44:33 10HmbT-0005vi-00 H=(xxx) [127.0.0.1] Warning: ARC-FAIL +1999-03-02 09:44:33 10HmbT-0005vi-00 arc_state: +1999-03-02 09:44:33 10HmbT-0005vi-00 domains: <> +1999-03-02 09:44:33 10HmbT-0005vi-00 arc_oldest_pass <0> +1999-03-02 09:44:33 10HmbT-0005vi-00 reason: <> +1999-03-02 09:44:33 10HmbT-0005vi-00 lh_A-R: <> +1999-03-02 09:44:33 10HmbT-0005vi-00 lh-ams: <> +1999-03-02 09:44:33 10HmbT-0005vi-00 oldest-p-ams: <> +1999-03-02 09:44:33 10HmbT-0005vi-00 <= CALLER@bloggs.com H=(xxx) [127.0.0.1] P=smtp S=sss for a@test.ex diff --git a/test/mail/4560.a b/test/mail/4560.a index 63b432784..8f9735fe2 100644 --- a/test/mail/4560.a +++ b/test/mail/4560.a @@ -479,3 +479,23 @@ http://lists.dmarc.org/mailman/listinfo/arc-discuss --===============2728806607597782871==-- +From CALLER@bloggs.com Tue Mar 02 09:44:33 1999 +Authentication-Results: test.ex; + iprev=pass (localhost) smtp.client-ip=127.0.0.1; + arc=none +Received: from localhost ([127.0.0.1] helo=test.ex) + by test.ex with esmtp (Exim x.yz) + (envelope-from ) + id 10HmbS-0005vi-00 + for a@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 +Authentication-Results: test.ex; + arc=none +Received: from [127.0.0.1] (helo=xxx) + by test.ex with smtp (Exim x.yz) + (envelope-from ) + id 10HmbR-0005vi-00 + for za@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 +Subject: Test + +This is a test body. + diff --git a/test/scripts/4560-ARC/4560 b/test/scripts/4560-ARC/4560 index 1a0086f47..e6fba7154 100644 --- a/test/scripts/4560-ARC/4560 +++ b/test/scripts/4560-ARC/4560 @@ -388,6 +388,40 @@ exim -DSERVER=server -DNOTDAEMON -q **** # # +# Check attemtping to sign, with a missing keyfile +# It starts off bare, so the forwarder reception gets an ARC status of "none". +# The outbound tries to sign it with that. +# +client 127.0.0.1 PORT_D +??? 220 +HELO xxx +??? 250 +MAIL FROM: +??? 250 +RCPT TO: +??? 250 +DATA +??? 354 +Subject: Test + +This is a test body. +. +??? 250 +QUIT +??? 221 +**** +# +exim -DSERVER=server -DNOTDAEMON -DBAD -q +**** +exim -DSERVER=server -DNOTDAEMON -q +**** +# +# +# +# +# +# +# # killdaemon # -- 2.25.1