-
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.
Fix 'printf -v varname %B' overwriting/truncating data
Reproducer: typeset -b foo read -N8 foo <<<abcdefghijklmnop printf -v got '%s / %B\n' "$foo" foo print -rn "$got" Expected output: YWJjZGVmZ2g= / abcdefgh Actual output: YWJjZGVm Thanks to @JohnoKing for finding the cause, which is a conflicting use of sh.strbuf2 by the code handling the %B format specifier. The many formatting specifiers to printf involve code paths into various parts of the shell, some of which use both sh.strbuf and sh.strbuf2, so neither of those are safe to use here. src/cmd/ksh93/bltins/print.c: b_print(): - To avoid the possibility of any conflict, use a dedicated locally scoped Sfio string buffer instead of sh.strbuf2. Resolves: #608
- Loading branch information
Showing
4 changed files
with
24 additions
and
4 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