summaryrefslogtreecommitdiffstats
path: root/lib/libedit/parse.c
diff options
context:
space:
mode:
authorpascal <pascal@openbsd.org>2011-11-27 21:46:44 +0000
committerpascal <pascal@openbsd.org>2011-11-27 21:46:44 +0000
commit17bf7f0ec2a8af334cbe6c8eccfcfe7f1c74def5 (patch)
treeb0af3fe07c45074d6dcbbad97b2640b09510fb25 /lib/libedit/parse.c
parentWhen checking for offset wrap around in vn_read(), compare against (diff)
downloadwireguard-openbsd-17bf7f0ec2a8af334cbe6c8eccfcfe7f1c74def5.tar.xz
wireguard-openbsd-17bf7f0ec2a8af334cbe6c8eccfcfe7f1c74def5.zip
Don't segfault when trying to bind to an invalid command. While here,
kill a C++-style comment. ok nicm@
Diffstat (limited to 'lib/libedit/parse.c')
-rw-r--r--lib/libedit/parse.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libedit/parse.c b/lib/libedit/parse.c
index 844b3b4b622..9a2d6808139 100644
--- a/lib/libedit/parse.c
+++ b/lib/libedit/parse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.c,v 1.10 2010/06/30 00:05:35 nicm Exp $ */
+/* $OpenBSD: parse.c,v 1.11 2011/11/27 21:46:44 pascal Exp $ */
/* $NetBSD: parse.c,v 1.23 2009/12/30 22:37:40 christos Exp $ */
/*-
@@ -271,9 +271,10 @@ protected int
parse_cmd(EditLine *el, const Char *cmd)
{
el_bindings_t *b;
+ int i;
- for (b = el->el_map.help; b->name != NULL; b++)
- if (Strcmp(b->name, cmd) == 0)
- return (b->func);
+ for (b = el->el_map.help, i = 0; i < el->el_map.nfunc; i++)
+ if (Strcmp(b[i].name, cmd) == 0)
+ return (b[i].func);
return (-1);
}