RFR: 8341495: JShell crashes with java.util.MissingFormatArgumentException [v5]

Chen Liang liach at openjdk.org
Fri Nov 8 16:22:39 UTC 2024


On Fri, 8 Nov 2024 16:15:38 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

>> JShell prints some of its output using `printf()` formatted strings. However, there are a few spots where a string `str` to be printed is passed directly as a format string like `format(str)` instead of indirectly like `format("%s", str)`, even though the string `str` contains unknown or arbitrary content outside of JShell's control. As a result, JShell can crash suddenly with a `MissingFormatArgumentException` or similar exception if the string `str` happens to contain a `%` format specifier, etc.
>> 
>> Please review this patch which attempts to fix the places where an unknown string is passed directly as a format string.
>
> Archie Cobbs has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
> 
>  - Merge branch 'master' into JDK-8341495
>  - Rename another String parameter to "format" to reflect its purpose.
>  - Revert previous change to unrelated JLine prompt substitution.
>  - Use replace() instead of replaceAll() for literal string substitution.
>  - Fix  prefixing/postfixing logic broken by previous commit.
>  - Avoid invoking out.printf() with unknown format strings that might contain escapes.

@lahodaj Can you take a look at this fix?

-------------

PR Comment: https://git.openjdk.org/jdk/pull/21339#issuecomment-2465183314


More information about the kulla-dev mailing list