[8u] RFR for JDK-8157548: JVM crashes sometimes while starting
David Holmes
david.holmes at oracle.com
Mon Sep 19 07:03:12 UTC 2016
Hi Shafi,
This looks okay to me.
Thanks,
David
On 19/09/2016 3:14 PM, Shafi Ahmad wrote:
> Hi,
>
> Please review the small code change for bug: "JDK-8157548: JVM crashes sometimes while starting" on jdk8u-dev
>
> Summary:
> int strncmp(const char *s1, const char *s2, size_t n);
>
> s1 = "abcdefgh" // Assume this is not null terminated string.
> s2 = "abcdefghijk"
> n = 10
>
> In case if s1 is not null terminated then for above input strncmp may crash.
>
> In expression marked as (B) parsed_name->bytes() returns base address of non-null terminated string buffer.
>
> + size_t pkglen = strlen(pkg);
> if (!HAS_PENDING_EXCEPTION &&
> !class_loader.is_null() &&
> parsed_name != NULL &&
> - !strncmp((const char*)parsed_name->bytes(), pkg, strlen(pkg))) {
> + parsed_name->utf8_length() >= (int)pkglen && // ------------------------------ (A)
> + !strncmp((const char*)parsed_name->bytes(), pkg, pkglen)) { //------------------------------ (B)
>
> Adding expression marked as (A) avoid the above similar input scenario.
>
> Webrev: http://cr.openjdk.java.net/~shshahma/8157548/webrev.00/
> Jdk8 bug: https://bugs.openjdk.java.net/browse/JDK-8157548
>
> Test: Run jprt
>
> Note: Thanks to Ioi for providing the code change.
>
> Regards,
> Shafi
>
More information about the hotspot-dev
mailing list