RFR: 8196882: VS2017 Hotspot Defined vsnprintf Function Causes C2084 Already Defined Compilation Error
Kim Barrett
kim.barrett at oracle.com
Tue Feb 27 21:28:49 UTC 2018
> On Feb 27, 2018, at 5:14 AM, Thomas Stüfe <thomas.stuefe at gmail.com> wrote:
> (Interestingly, the Java Access Bridge (jdk.accessibility) native
> windows code uses wide char/string format directives, and appears to
> in at least some cases write them using bare vsnprintf, and that's
> irrespective of which VS version is being used.)
>
>
> Where? I took a short look and did not find it.
>
> However, I found a number of wcsncpy() with no truncation handling, so, no zero-termination upon truncation (I think, but I may be mistaken, just had a very quick look).
For example, in
src/jdk.accessibility/windows/native/toolscommon/AccessInfo.cpp
there are calls to appendToBuffer and PrintDebugString that have
format strings containing %ls. appendToBuffer is defined in that file,
and calls vsnprintf. It presumes the buffer will be NUL-terminated;
see its call to strlen(buf).
PrintDebugString is in
src/jdk.accessibility/windows/native/common/AccessBridgeDebug.cpp
It also calls vsnprintf, and assumes the buffer will be
NUL-terminated, since it is passed to OutputDebugString and/or
printf. For the call to printf, better hope there's no "%" in the
output of the vsnprintf. And all the variadic functions in this file
seem to be missing the va_end associated with va_start. Maybe that
works on Windows...
>
> New webrevs:
> full: http://cr.openjdk.java.net/~kbarrett/8196882/open.03/
> incr: http://cr.openjdk.java.net/~kbarrett/8196882/open.03.inc/
>
>
>
> All looks well. Thank you.
>
> Best Regards, Thomas
>
Thanks.
More information about the hotspot-dev
mailing list