RFR: 8074895: os::getenv is inadequate

David Holmes david.holmes at oracle.com
Thu Mar 12 02:39:04 UTC 2015


Hi Jeremy,

On 11/03/2015 7:08 AM, Jeremy Manson wrote:
> Hi, David,
>
> I'd like you to do a code review, please.  Original discussion:
>
> http://mail.openjdk.java.net/pipermail/serviceability-dev/2015-March/016851.html
>
> Per this discussion, I'm just getting rid of the os::getenv interface,
> and using straight getenv() everywhere.
>
> Bug:
> https://bugs.openjdk.java.net/browse/JDK-8074895
>
> Webrev:
> http://cr.openjdk.java.net/~jmanson/8074895/webrev.00/

In arguments.cpp the headless property setting could have been left 
using a local buffer rather than introducing NEW_C_HEAP_ARRAY. The value 
should only be true or false so there's no size issue regarding the 
local buffer.

3566   if ((buffer = os::strdup(buffer)) == NULL) {
3567     return JNI_OK;
3568   }

So this silently hides failures?


The only minor concern I have is whether os::print_environment_variables 
is now susceptible to any issues caused by arbitrarily long environment 
variables? But I suspect there is already a maximum permitted length for 
environment variables.

Also you could now do the same for os::unsetenv :)

Thanks,
David

> Jeremy


More information about the hotspot-runtime-dev mailing list