summaryrefslogtreecommitdiff
path: root/shells/tcsh/patches/patch-ed.inputl.c
diff options
context:
space:
mode:
Diffstat (limited to 'shells/tcsh/patches/patch-ed.inputl.c')
-rw-r--r--shells/tcsh/patches/patch-ed.inputl.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/shells/tcsh/patches/patch-ed.inputl.c b/shells/tcsh/patches/patch-ed.inputl.c
new file mode 100644
index 00000000000..b8b88a3b35a
--- /dev/null
+++ b/shells/tcsh/patches/patch-ed.inputl.c
@@ -0,0 +1,35 @@
+$NetBSD: patch-ed.inputl.c,v 1.1 2017/02/17 19:21:44 he Exp $
+
+Add fix from upstream: Unfortunately the AsciiOnly reversion causes
+a SEGV because *ch is used to index in the command array, and now contains
+INVALID_BYTE. Reproduce error with:
+ env -i ./tcsh
+ <meta>b
+
+--- ed.inputl.c.orig 2012-10-19 15:23:32.000000000 +0000
++++ ed.inputl.c
+@@ -800,13 +800,17 @@ GetNextChar(Char *cp)
+ return -1;
+ }
+ }
+- cbp++;
+- if (normal_mbtowc(cp, cbuf, cbp) == -1) {
+- reset_mbtowc();
+- if (cbp < MB_CUR_MAX)
+- continue; /* Maybe a partial character */
+- /* And drop the following bytes, if any */
+- *cp = (unsigned char)*cbuf | INVALID_BYTE;
++ if (AsciiOnly) {
++ *cp = (unsigned char)*cbuf;
++ } else {
++ cbp++;
++ if (normal_mbtowc(cp, cbuf, cbp) == -1) {
++ reset_mbtowc();
++ if (cbp < MB_CUR_MAX)
++ continue; /* Maybe a partial character */
++ /* And drop the following bytes, if any */
++ *cp = (unsigned char)*cbuf | INVALID_BYTE;
++ }
+ }
+ break;
+ }