RFR: JDK-8292595: jdwp utf_util getWideString might leak memory [v2]

Chris Plummer cjplummer at openjdk.org
Sun Aug 28 22:44:16 UTC 2022


On Sat, 27 Aug 2022 18:58:40 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Introduce UTF_WARNING and use the fallback
>
> src/jdk.jdwp.agent/share/native/libjdwp/utf_util.c line 339:
> 
>> 337:     *pwlen = wlen;
>> 338:     if (wlen <= 0) {
>> 339:         UTF_WARNING(("Can't get WIDE string length"));
> 
> If you are changing this to a warning then it should probably be limited to the NO_UNICODE_TRANSLATION case, I think you still want to abort if it fails due to invalid flags or parameters or buffer issue as that would a JDK (or Windows) bug.

If you are going to do that, then you should track down all uses of this code (direct and indirect) to see if this error is ever acceptable and is handled properly. It seems that if the unicode string is bad, we should be exiting. I see this code being used indirectly from setAgentPropertyValue(), which only seems to be used for sun.jdwp.listenerAddress. Do we want the raw unicode bytes to be used in this case if they cannot be converted? It's also used from printLastError(), which gets the unicode bytes from GetLastError(). Should't they always be valid?

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

PR: https://git.openjdk.org/jdk/pull/9918


More information about the serviceability-dev mailing list