Skip to content

Commit

Permalink
Fix crash on long PS1 prompt (Solaris patch 195-17824699)
Browse files Browse the repository at this point in the history
Original report and info:
https://www.mail-archive.com/[email protected]/msg01677.html
https://www.mail-archive.com/[email protected]/msg01679.html

Patch pulled in from:
https://raw.githubusercontent.com/oracle/solaris-userland/master/components/ksh93/patches/195-17824699.patch

src/cmd/ksh93/edit/edit.c: ed_setup():
- Prevent the ed_setup() function from writing past ep->e_prompt,
  which is set to the local char prompt[PRSIZE] variable in
  ed_emacsread().

src/cmd/ksh93/include/edit.h:
- Increase maximum prompt size, PRSIZE, to 256.
  • Loading branch information
McDutchie committed Jan 8, 2021
1 parent 86fc4c6 commit 1de20d6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ For full details, see the git log at: https://github.com/ksh93/ksh

Any uppercase BUG_* names are modernish shell bug IDs.

2021-01-08:

- Fixed a crash on exceeding the maximum size of the $PS1 prompt.
The maximum size is also increased from 160 to 256 bytes.

2021-01-07:

- Fixed a crash that could occur while ksh updated ${.sh.match}.
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/ksh93/edit/edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,8 @@ void ed_setup(register Edit_t *ep, int fd, int reedit)
{
int skip=0;
ep->e_crlf = 0;
*pp++ = c;
if(pp<ppmax)
*pp++ = c;
for(n=1; c = *last++; n++)
{
if(pp < ppmax)
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/include/edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#endif /* SHOPT_MULTIBYTE */

#define TABSIZE 8
#define PRSIZE 160
#define PRSIZE 256
#define MAXLINE 1024 /* longest edit line permitted */

typedef struct _edit_pos
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/ksh93/include/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
#define SH_RELEASE_SVER "1.0.0-alpha" /* semantic version number: https://semver.org */
#define SH_RELEASE_DATE "2021-01-07" /* must be in this format for $((.sh.version)) */
#define SH_RELEASE_DATE "2021-01-08" /* must be in this format for $((.sh.version)) */

/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
/* Arithmetic $((.sh.version)) uses the last 10 chars, so the date must be at the end. */
Expand Down

0 comments on commit 1de20d6

Please sign in to comment.