summaryrefslogtreecommitdiffstats
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authorgilles <gilles@openbsd.org>2020-01-06 11:02:38 +0000
committergilles <gilles@openbsd.org>2020-01-06 11:02:38 +0000
commit74c984d4143993de6734355d92bec1a35265172c (patch)
tree583e3055cfb08dee398be1c35a9ecdb74d111ec3 /usr.sbin/smtpd
parentUse type M_KEVENT instead of M_TEMP when allocating kqueue-related (diff)
downloadwireguard-openbsd-74c984d4143993de6734355d92bec1a35265172c.tar.xz
wireguard-openbsd-74c984d4143993de6734355d92bec1a35265172c.zip
provide a better error message for invalid smtpctl commands
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/parser.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/parser.c b/usr.sbin/smtpd/parser.c
index df90e50839e..24b920948c2 100644
--- a/usr.sbin/smtpd/parser.c
+++ b/usr.sbin/smtpd/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.41 2017/07/31 16:38:33 gilles Exp $ */
+/* $OpenBSD: parser.c,v 1.42 2020/01/06 11:02:38 gilles Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -219,6 +219,11 @@ cmd_run(int argc, char **argv)
return (node->cmd(np, np ? param : NULL));
fail:
+ if (TAILQ_FIRST(&node->children) == NULL) {
+ fprintf(stderr, "invalid command\n");
+ return (-1);
+ }
+
fprintf(stderr, "possibilities are:\n");
TAILQ_FOREACH(tmp, &node->children, entry) {
for (j = 0; j < i; j++)