aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-05-13 00:48:09 +0000
committerEric Andersen <andersen@codepoet.org>2001-05-13 00:48:09 +0000
commitddb00545b7fb84138a14a511def4526ac2bc0709 (patch)
tree61b03801e85d3508f6330f1718c1b950279d2037
parent4819c3d477e83b846649220fc96534c9bb93d642 (diff)
downloadbusybox-ddb00545b7fb84138a14a511def4526ac2bc0709.tar.gz
A patch from Aaron Lehmann <aaronl@vitelus.com> to fix a
crash on a broken regexp.
-rw-r--r--editors/vi.c10
-rw-r--r--vi.c10
2 files changed, 18 insertions, 2 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 5a68ba9f1..6d1502966 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -19,7 +19,7 @@
*/
char *vi_Version =
- "$Id: vi.c,v 1.7 2001/05/07 22:57:47 andersen Exp $";
+ "$Id: vi.c,v 1.8 2001/05/13 00:48:09 andersen Exp $";
/*
* To compile for standalone use:
@@ -2076,8 +2076,10 @@ static void colon(Byte * buf)
c = orig_buf[1]; // what is the delimiter
F = orig_buf + 2; // start of "find"
R = (Byte *) strchr((char *) F, c); // middle delimiter
+ if (!R) goto colon_s_fail;
*R++ = '\0'; // terminate "find"
buf1 = (Byte *) strchr((char *) R, c);
+ if (!buf1) goto colon_s_fail;
*buf1++ = '\0'; // terminate "replace"
if (*buf1 == 'g') { // :s/foo/bar/g
buf1++;
@@ -2168,6 +2170,12 @@ static void colon(Byte * buf)
vc1:
dot = bound_dot(dot); // make sure "dot" is valid
return;
+#ifdef BB_FEATURE_VI_SEARCH
+colon_s_fail:
+ psb(":s expression missing delimiters");
+ return;
+#endif
+
}
static void Hit_Return(void)
diff --git a/vi.c b/vi.c
index 5a68ba9f1..6d1502966 100644
--- a/vi.c
+++ b/vi.c
@@ -19,7 +19,7 @@
*/
char *vi_Version =
- "$Id: vi.c,v 1.7 2001/05/07 22:57:47 andersen Exp $";
+ "$Id: vi.c,v 1.8 2001/05/13 00:48:09 andersen Exp $";
/*
* To compile for standalone use:
@@ -2076,8 +2076,10 @@ static void colon(Byte * buf)
c = orig_buf[1]; // what is the delimiter
F = orig_buf + 2; // start of "find"
R = (Byte *) strchr((char *) F, c); // middle delimiter
+ if (!R) goto colon_s_fail;
*R++ = '\0'; // terminate "find"
buf1 = (Byte *) strchr((char *) R, c);
+ if (!buf1) goto colon_s_fail;
*buf1++ = '\0'; // terminate "replace"
if (*buf1 == 'g') { // :s/foo/bar/g
buf1++;
@@ -2168,6 +2170,12 @@ static void colon(Byte * buf)
vc1:
dot = bound_dot(dot); // make sure "dot" is valid
return;
+#ifdef BB_FEATURE_VI_SEARCH
+colon_s_fail:
+ psb(":s expression missing delimiters");
+ return;
+#endif
+
}
static void Hit_Return(void)