summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2018-12-21 20:38:43 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2018-12-21 20:38:43 +0000
commit4014ecb37423fedc8d1ee85d5bc2fd411838c67d (patch)
tree45d50b8e1c49a9b6e2de836a818a67437f191eb9
parentda3588742df9052a925d973446f22b64551d2943 (diff)
do not tree_xget() sessions in filter_protocol_next(), filter_data_next() &
lka_proc_filter_in_session() because there are legitimate reasons a session would no longer be around.
-rw-r--r--usr.sbin/smtpd/lka_filter.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.sbin/smtpd/lka_filter.c b/usr.sbin/smtpd/lka_filter.c
index a2b8b446204..f9e472dfef6 100644
--- a/usr.sbin/smtpd/lka_filter.c
+++ b/usr.sbin/smtpd/lka_filter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka_filter.c,v 1.20 2018/12/21 19:07:47 gilles Exp $ */
+/* $OpenBSD: lka_filter.c,v 1.21 2018/12/21 20:38:42 gilles Exp $ */
/*
* Copyright (c) 2018 Gilles Chehade <gilles@poolp.org>
@@ -264,9 +264,10 @@ lka_filter_proc_in_session(uint64_t reqid, const char *proc)
struct filter *filter;
size_t i;
- fs = tree_xget(&sessions, reqid);
- filter = dict_get(&filters, fs->filter_name);
+ if ((fs = tree_get(&sessions, reqid)) == NULL)
+ return 0;
+ filter = dict_get(&filters, fs->filter_name);
if (filter->proc == NULL && filter->chain == NULL)
return 0;
@@ -531,9 +532,11 @@ filter_protocol_next(uint64_t token, uint64_t reqid, const char *param)
struct filter_entry *filter_entry;
struct filter *filter;
- fs = tree_xget(&sessions, reqid);
- filter_chain = dict_get(&filter_chains, fs->filter_name);
+ /* client session may have disappeared while we were in proc */
+ if ((fs = tree_xget(&sessions, reqid)) == NULL)
+ return;
+ filter_chain = dict_get(&filter_chains, fs->filter_name);
TAILQ_FOREACH(filter_entry, &filter_chain->chain[fs->phase], entries)
if (filter_entry->id == token)
break;
@@ -591,7 +594,7 @@ filter_data_next(uint64_t token, uint64_t reqid, const char *line)
struct filter_entry *filter_entry;
struct filter *filter;
- /* client session may have disappeared since we started streaming data */
+ /* client session may have disappeared while we were in proc */
if ((fs = tree_get(&sessions, reqid)) == NULL)
return;