RFR: 8373474: 2 Unintentional format string defect groups in jabswitch.cpp

Alexander Zvegintsev azvegint at openjdk.org
Mon Dec 22 14:34:02 UTC 2025


On Mon, 22 Dec 2025 05:18:34 GMT, Damon Nguyen <dnguyen at openjdk.org> wrote:

> This issue is not currently causing any problems, but I am adding specifiers to explicitly print these strings. This is to avoid any issues down the line where changes to the lines building the string can cause any accidental formatting. Overall, this should be a harmless update and improves the stability and reliability of printing these strings.

src/jdk.accessibility/windows/native/jabswitch/jabswitch.cpp line 231:

> 229:                 char str[100] = "assistive_technologies=com.sun.java.accessibility.AccessBridge\n";
> 230:                 strcat_s(str, "screen_magnifier_present=true\n");
> 231:                 fprintf(origFile, "%s", str);

Why do we need the `str` buffer at all?

Shouldn't `fprintf` be enough?


fprintf(origFile,
    "assistive_technologies=com.sun.java.accessibility.AccessBridge\n"
    "screen_magnifier_present=true\n");

src/jdk.accessibility/windows/native/jabswitch/jabswitch.cpp line 321:

> 319:     strcat_s(outputString, versionString);
> 320:     strcat_s(outputString, "\njabswitch enables or disables the Java Access Bridge.\n");
> 321:     printf("%s", outputString);

Same for the `outputString`


printf(
    "jabswitch %s\n"
    "jabswitch enables or disables the Java Access Bridge.\n",
    versionString
);

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28949#discussion_r2640052922
PR Review Comment: https://git.openjdk.org/jdk/pull/28949#discussion_r2640065588


More information about the client-libs-dev mailing list