-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
line editors: make putstring functions multibyte aware
Symptom on (at least) some Linux systems: $ bin/package use [blurb skipped] «0»37:â�¦/local/src/ksh[dev] $ «0»37:…/local/src/ksh[dev] $ «0»37:…/local/src/ksh[dev] $ ▂ If the line editor is emacs, the first prompt is corrupted. The prompt printed after ^L in emacs is also corrupted. The cause is the putstring() function in emacs. It calls ed_putchar() for each byte in the string. This is incorrect for multibyte characters, as ed_putchar() *is* multibyte aware and calls mbconv() for each character passed to it. There is a very similar ed_putstring() function in edit.c that has the same problem. There is also a pr_string() function in vi.c that is used for printing the prompt there; it is not multibyte-aware either, but the bug is not triggered in vi because pr_string() copies bytes directly into the output buffer. But it does so without bounds checking, so a very long prompt could cause a buffer overflow. src/cmd/ksh93/edit/edit.{c,h}: - Make ed_putstring() multibyte-aware by using the mbchar macro from ast.h. This function is only used for printing the prompt and some escape sequences from tput, so also print '?' for invalid multibyte characters as this is more useful than just copying the invalid byte. - Make ed_putstring() an extern and declare it in the header. - While we're here, further cleanup of ed_putchar(). (re: 1eb0b06) src/cmd/ksh93/edit/{emacs,vi}.c: - Remove putstring() and pr_string() functions. - Replace with ed_putstring() calls.
- Loading branch information
Showing
6 changed files
with
22 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters