Fix a crash when relaying with authentication but auth table is not set.
authoreric <eric@openbsd.org>
Wed, 22 Aug 2018 10:11:43 +0000 (10:11 +0000)
committereric <eric@openbsd.org>
Wed, 22 Aug 2018 10:11:43 +0000 (10:11 +0000)
found by and ok stsp@

usr.sbin/smtpd/mta.c

index 5b39838..c219b07 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: mta.c,v 1.221 2018/07/25 16:00:48 eric Exp $  */
+/*     $OpenBSD: mta.c,v 1.222 2018/08/22 10:11:43 eric Exp $  */
 
 /*
  * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -645,6 +645,17 @@ mta_handle_envelope(struct envelope *evp, const char *smarthost)
                return;
        }
 
+       if (relayh.flags & RELAY_AUTH && dispatcher->u.remote.auth == NULL) {
+               log_warnx("warn: No auth table on action \"%s\" for relay %s",
+                   evp->dispatcher, smarthost);
+               m_create(p_queue, IMSG_MTA_DELIVERY_TEMPFAIL, 0, 0, -1);
+               m_add_evpid(p_queue, evp->id);
+               m_add_string(p_queue, "No auth table for relaying");
+               m_add_int(p_queue, ESC_OTHER_STATUS);
+               m_close(p_queue);
+               return;
+       }
+
        relay = mta_relay(evp, &relayh);
        /* ignore if we don't know the limits yet */
        if (relay->limits &&