Skip to content

Commit 3f38f8a

Browse files
committed
emacs: Fix crash on inputting Asian chars (Solaris 240-22461939)
This change is pulled from here: https://github.com/oracle/solaris-userland/blob/master/components/ksh93/patches/240-22461939.patch Information: att#6 George Lijo wrote on 14 Mar 2016: > I observed this issue in a Solaris 11 system on ksh2012-08-01 > [...]. The issue can be reproduced if we add Asian locales to > ibus (such as Korean). In the ksh93 shell prompt, input some > Asian character. ksh promptly dumps core [...]. > > The coredump happens at the following line no 320 in > src/cmd/ksh93/edit/emacs.c > if(c!='\t' && c!=ESC && !isdigit(c)). > > I referred the vi.c code and added the digit(c) macro, i.e. > ((c&~STRIP)==0 && isdigit(c)) and replaced the isdigit(c) usage > with the "digit(c)" macro.
1 parent a3ccff6 commit 3f38f8a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎src/cmd/ksh93/edit/emacs.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,15 @@ One line screen editor for any program
9090
static int print(int);
9191
static int _isword(int);
9292
# define isword(c) _isword(out[c])
93+
# define digit(c) ((c&~STRIP)==0 && isdigit(c))
9394

9495
#else
9596
# define gencpy(a,b) strcpy((char*)(a),(char*)(b))
9697
# define genncpy(a,b,n) strncpy((char*)(a),(char*)(b),n)
9798
# define genlen(str) strlen(str)
9899
# define print(c) isprint(c)
99100
# define isword(c) (isalnum(out[c]) || (out[c]=='_'))
101+
# define digit(c) isdigit(c)
100102
#endif /*SHOPT_MULTIBYTE */
101103

102104
typedef struct _emacs_
@@ -323,7 +325,7 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit)
323325
count = 1;
324326
adjust = -1;
325327
i = cur;
326-
if(c!='\t' && c!=ESC && !isdigit(c))
328+
if(c!='\t' && c!=ESC && !digit(c))
327329
ep->ed->e_tabcount = 0;
328330
switch(c)
329331
{
@@ -782,7 +784,7 @@ static int escape(register Emacs_t* ep,register genchar *out,int count)
782784
int digit,ch;
783785
digit = 0;
784786
value = 0;
785-
while ((i=ed_getchar(ep->ed,0)),isdigit(i))
787+
while ((i=ed_getchar(ep->ed,0)),digit(i))
786788
{
787789
value *= 10;
788790
value += (i - '0');
@@ -1020,7 +1022,7 @@ static int escape(register Emacs_t* ep,register genchar *out,int count)
10201022
{
10211023
i=ed_getchar(ep->ed,0);
10221024
ed_ungetchar(ep->ed,i);
1023-
if(isdigit(i))
1025+
if(digit(i))
10241026
ed_ungetchar(ep->ed,ESC);
10251027
}
10261028
}

0 commit comments

Comments
 (0)