From 23afb6dbb853ac5a13a5a0c7ff01697c30b18eea Mon Sep 17 00:00:00 2001 From: tg Date: Fri, 7 Oct 2011 19:45:08 +0000 Subject: [PATCH] =?UTF-8?q?merge=20=E2=80=9Cupper=20bound=20Emacs=20mode?= =?UTF-8?q?=20command=20repeat=20by=20input=20line=20length=E2=80=9D=20fro?= =?UTF-8?q?m=20oksh=20(slightly=20different=20implementation)=20and=20rema?= =?UTF-8?q?rk=20better=20plans=20(which=20doesn=E2=80=99t=20mean=20boundin?= =?UTF-8?q?g=20the=20repeat=20counter=20is=20bad,=20though=E2=80=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- edit.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/edit.c b/edit.c index fe6a12f..8242563 100644 --- a/edit.c +++ b/edit.c @@ -1,6 +1,6 @@ -;/* $OpenBSD: edit.c,v 1.34 2010/05/20 01:13:07 fgsch Exp $ */ +/* $OpenBSD: edit.c,v 1.34 2010/05/20 01:13:07 fgsch Exp $ */ /* $OpenBSD: edit.h,v 1.9 2011/05/30 17:14:35 martynas Exp $ */ -/* $OpenBSD: emacs.c,v 1.43 2011/03/14 21:20:01 okan Exp $ */ +/* $OpenBSD: emacs.c,v 1.44 2011/09/05 04:50:33 marco Exp $ */ /* $OpenBSD: vi.c,v 1.26 2009/06/29 22:50:19 martynas Exp $ */ /*- @@ -25,7 +25,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.221 2011/09/07 15:24:12 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.222 2011/10/07 19:45:08 tg Exp $"); /* * in later versions we might use libtermcap for this, but since external @@ -2878,17 +2878,21 @@ x_e_puts(const char *s) static int x_set_arg(int c) { - int n = 0; + unsigned int n = 0; bool first = true; /* strip command prefix */ c &= 255; while (c >= 0 && ksh_isdigit(c)) { n = n * 10 + (c - '0'); + if (n > LINE) + /* upper bound for repeat */ + goto x_set_arg_too_big; c = x_e_getc(); first = false; } if (c < 0 || first) { + x_set_arg_too_big: x_e_putc2(7); x_arg = 1; x_arg_defaulted = true;