summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2016-03-01 16:43:39 +0000
committerschwarze <schwarze@openbsd.org>2016-03-01 16:43:39 +0000
commit09f612eed43f9140caeff7415eafdc295172f52a (patch)
tree9a0e54d0d6462e3a2638f7b3803fb70804bcd073
parentCopy the stackgap_init() and stackgap_alloc() functions from (diff)
downloadwireguard-openbsd-09f612eed43f9140caeff7415eafdc295172f52a.tar.xz
wireguard-openbsd-09f612eed43f9140caeff7415eafdc295172f52a.zip
Fix a segfault and functional error in c_gets(),
which is used for extended command input and for vi search mode. It could be triggered by typing one or more characters, then pressing backspace once (functional error: the character was deleted from the screen, but not from the edit buffer) or a few more times than characters had been entered (segfault). OK czarkoff@. Also checked by Christos Zoulas.
-rw-r--r--lib/libedit/chared.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/libedit/chared.c b/lib/libedit/chared.c
index 450c75858d9..1032410b67d 100644
--- a/lib/libedit/chared.c
+++ b/lib/libedit/chared.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chared.c,v 1.16 2016/01/30 17:32:52 schwarze Exp $ */
+/* $OpenBSD: chared.c,v 1.17 2016/03/01 16:43:39 schwarze Exp $ */
/* $NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $ */
/*-
@@ -677,6 +677,7 @@ c_gets(EditLine *el, Char *buf, const Char *prompt)
len = -1;
break;
}
+ len--;
cp--;
continue;