From 38b53eb311811e96533b06c20e0f3eded6ff7b30 Mon Sep 17 00:00:00 2001 From: eric Date: Wed, 22 Apr 2020 11:35:34 +0000 Subject: [PATCH] Check for the dispatcher name in the envelope validation function. Fixes a possible crash and caching issue when manually moving an envelope to the queue with smtpctl discover. ok millert@ --- usr.sbin/smtpd/queue.c | 11 +---------- usr.sbin/smtpd/queue_backend.c | 5 ++++- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index 8380c7b5ea5..3739fe22750 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.189 2018/12/30 23:09:58 guenther Exp $ */ +/* $OpenBSD: queue.c,v 1.190 2020/04/22 11:35:34 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -686,7 +686,6 @@ static void queue_timeout(int fd, short event, void *p) { static uint32_t msgid = 0; - struct dispatcher *dsp; struct envelope evp; struct event *ev = p; struct timeval tv; @@ -705,13 +704,6 @@ queue_timeout(int fd, short event, void *p) } if (r) { - dsp = dict_get(env->sc_dispatchers, evp.dispatcher); - if (dsp == NULL) { - log_warnx("warn: queue: missing dispatcher \"%s\"" - " for envelope %016"PRIx64", ignoring", - evp.dispatcher, evp.id); - goto reset; - } if (msgid && evpid_to_msgid(evp.id) != msgid) { m_create(p_scheduler, IMSG_QUEUE_MESSAGE_COMMIT, 0, 0, -1); @@ -724,7 +716,6 @@ queue_timeout(int fd, short event, void *p) m_close(p_scheduler); } -reset: tv.tv_sec = 0; tv.tv_usec = 10; evtimer_add(ev, &tv); diff --git a/usr.sbin/smtpd/queue_backend.c b/usr.sbin/smtpd/queue_backend.c index 5e7c38fa712..a33f91f45f4 100644 --- a/usr.sbin/smtpd/queue_backend.c +++ b/usr.sbin/smtpd/queue_backend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_backend.c,v 1.65 2018/12/30 23:09:58 guenther Exp $ */ +/* $OpenBSD: queue_backend.c,v 1.66 2020/04/22 11:35:34 eric Exp $ */ /* * Copyright (c) 2011 Gilles Chehade @@ -730,6 +730,9 @@ envelope_validate(struct envelope *ep) if (memchr(ep->errorline, '\0', sizeof(ep->errorline)) == NULL) return "invalid error line"; + if (dict_get(env->sc_dispatchers, ep->dispatcher) == NULL) + return "unknown dispatcher"; + return NULL; } -- 2.20.1