Fix long multibyte characters paste issue via ssh
Resolves: RHEL-87561
This commit is contained in:
parent
33cd7bddee
commit
4512a15f36
94
ksh-1.0.11-ssh-multibyte-long-paste.patch
Normal file
94
ksh-1.0.11-ssh-multibyte-long-paste.patch
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
From 96d73c08a2786806f3def1fda66641b81e0af988 Mon Sep 17 00:00:00 2001
|
||||||
|
From: SHIMIZU Akifumi <shimizu.akifumi@fujitsu.com>
|
||||||
|
Date: Mon, 7 Apr 2025 19:47:16 +0900
|
||||||
|
Subject: [PATCH] Fix long multibyte characters paste issue via ssh (#840)
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
When I paste long multibyte characters(over 80 byte) to ksh via
|
||||||
|
SSH, the characters are not displayed correctly. For example, the
|
||||||
|
following input demonstrates the issue. ja_JP.UTF-8 encoding is
|
||||||
|
used.
|
||||||
|
|
||||||
|
Expected command line display:
|
||||||
|
$ echo "長い文字列を入れるとkshで文字列が乱れる場合があるようです"
|
||||||
|
|
||||||
|
Actual command line display:
|
||||||
|
$ です"echo "長い文字列を入れるとkshで文字列が乱れる場合がある
|
||||||
|
...with the cursor over the 'e' in 'echo'.
|
||||||
|
|
||||||
|
This issue appears to be caused by the ed_read() function splitting
|
||||||
|
a multibyte character sequence when reading into an 80-byte buffer.
|
||||||
|
This leads to incorrect character interpretation and display.
|
||||||
|
|
||||||
|
Therefore, we edited the code to handle the case where the buffer
|
||||||
|
size is full in the middle of a multi-byte character.
|
||||||
|
|
||||||
|
src/cmd/ksh93/sh/edit.c:
|
||||||
|
- putstack():
|
||||||
|
- Before retrying to interpret a multibyte character in case of a
|
||||||
|
split due to end of buffer, restore the start position 'p'.
|
||||||
|
- Fix zeroing out errno = EILSEQ.
|
||||||
|
- ed_getchar(): Avoid a potential buffer overflow in 'readin';
|
||||||
|
allow for an extra multibyte character, not merely an extra byte.
|
||||||
|
|
||||||
|
Co-authored-by: Martijn Dekker <martijn@inlv.org>
|
||||||
|
---
|
||||||
|
src/cmd/ksh93/edit/edit.c | 13 ++++++++-----
|
||||||
|
1 files changed, 8 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/cmd/ksh93/edit/edit.c b/src/cmd/ksh93/edit/edit.c
|
||||||
|
index 0ac54ba..1dcef1b 100644
|
||||||
|
--- a/src/cmd/ksh93/edit/edit.c
|
||||||
|
+++ b/src/cmd/ksh93/edit/edit.c
|
||||||
|
@@ -15,6 +15,7 @@
|
||||||
|
* Johnothan King <johnothanking@protonmail.com> *
|
||||||
|
* Anuradha Weeraman <anuradha@debian.org> *
|
||||||
|
* K. Eugene Carlson <kvngncrlsn@gmail.com> *
|
||||||
|
+* SHIMIZU Akifumi <shimizu.akifumi@fujitsu.com> *
|
||||||
|
* *
|
||||||
|
***********************************************************************/
|
||||||
|
/*
|
||||||
|
@@ -861,6 +862,7 @@ static int putstack(Edit_t *ep,char string[], int nbyte, int type)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
+ char *prevp = p;
|
||||||
|
again:
|
||||||
|
if((c=mbchar(p)) >=0)
|
||||||
|
{
|
||||||
|
@@ -868,19 +870,20 @@ static int putstack(Edit_t *ep,char string[], int nbyte, int type)
|
||||||
|
if(type)
|
||||||
|
c = -c;
|
||||||
|
}
|
||||||
|
-#ifdef EILSEQ
|
||||||
|
- else if(errno == EILSEQ)
|
||||||
|
- errno = 0;
|
||||||
|
-#endif
|
||||||
|
else if((endp-p) < mbmax())
|
||||||
|
{
|
||||||
|
+ if(errno == EILSEQ)
|
||||||
|
+ errno = 0;
|
||||||
|
if ((c=ed_read(ep,ep->e_fd,endp, 1,0)) == 1)
|
||||||
|
{
|
||||||
|
+ p = prevp;
|
||||||
|
*++endp = 0;
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
+ else if(errno == EILSEQ)
|
||||||
|
+ errno = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ed_ringbell();
|
||||||
|
@@ -930,7 +933,7 @@ static int putstack(Edit_t *ep,char string[], int nbyte, int type)
|
||||||
|
int ed_getchar(Edit_t *ep,int mode)
|
||||||
|
{
|
||||||
|
int n, c;
|
||||||
|
- char readin[LOOKAHEAD+1];
|
||||||
|
+ char *readin = fmtbuf(LOOKAHEAD + mbmax());
|
||||||
|
if(!ep->e_lookahead)
|
||||||
|
{
|
||||||
|
ed_flush(ep);
|
9
ksh.spec
9
ksh.spec
@ -4,7 +4,7 @@ URL: http://www.kornshell.com/
|
|||||||
License: EPL-1.0
|
License: EPL-1.0
|
||||||
Epoch: 3
|
Epoch: 3
|
||||||
Version: 1.0.6
|
Version: 1.0.6
|
||||||
Release: 9%{?dist}
|
Release: 10%{?dist}
|
||||||
Source0: https://github.com/ksh93/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
|
Source0: https://github.com/ksh93/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
|
||||||
Source1: kshcomp.conf
|
Source1: kshcomp.conf
|
||||||
Source2: kshrc.rhs
|
Source2: kshrc.rhs
|
||||||
@ -45,6 +45,9 @@ Patch9: ksh-1.0.9-no-TERM-env-segfault.patch
|
|||||||
# upstream commit: https://github.com/ksh93/ksh/commit/4350174a5d4acabf78f97b28c6d0ae68ec703e78
|
# upstream commit: https://github.com/ksh93/ksh/commit/4350174a5d4acabf78f97b28c6d0ae68ec703e78
|
||||||
Patch10: ksh-1.0.11-stty-noecho.patch
|
Patch10: ksh-1.0.11-stty-noecho.patch
|
||||||
|
|
||||||
|
# upstream commit: https://github.com/ksh93/ksh/commit/96d73c08a2786806f3def1fda66641b81e0af988
|
||||||
|
Patch11: ksh-1.0.11-ssh-multibyte-long-paste.patch
|
||||||
|
|
||||||
Conflicts: pdksh
|
Conflicts: pdksh
|
||||||
Requires: coreutils, diffutils
|
Requires: coreutils, diffutils
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
@ -166,6 +169,10 @@ fi
|
|||||||
%config(noreplace) %{_sysconfdir}/binfmt.d/kshcomp.conf
|
%config(noreplace) %{_sysconfdir}/binfmt.d/kshcomp.conf
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Apr 16 2025 Vincent Mihalkovic <vmihalko@redhat.com> - 3:1.0.6-10
|
||||||
|
- Fix long multibyte characters paste issue via ssh
|
||||||
|
Resolves: RHEL-87561
|
||||||
|
|
||||||
* Mon Mar 31 2025 Vincent Mihalkovic <vmihalko@redhat.com> - 3:1.0.6-9
|
* Mon Mar 31 2025 Vincent Mihalkovic <vmihalko@redhat.com> - 3:1.0.6-9
|
||||||
- Fix 'stty -echo' in scripts
|
- Fix 'stty -echo' in scripts
|
||||||
Resolves: RHEL-83043
|
Resolves: RHEL-83043
|
||||||
|
Loading…
Reference in New Issue
Block a user