RFR: JDK-8282144 RandomSupport.convertSeedBytesToLongs sign extension overwrites previous bytes

Brian Burkhalter bpb at openjdk.java.net
Mon Mar 7 22:46:03 UTC 2022


On Thu, 24 Feb 2022 14:47:50 GMT, Jim Laskey <jlaskey at openjdk.org> wrote:

> Class: ./java.base/share/classes/jdk/internal/util/random/RandomSupport.java 
> Method: public static long[] convertSeedBytesToLongs(byte[] seed, int n, int z) 
> 
> The method attempts to create an array of longs by consuming the input bytes most significant bit first. New bytes are appended to the existing long using the OR operator on the signed byte. Due to sign extension this will overwrite all the existing bits from 63 to 8 if the next byte is negative.

Marked as reviewed by bpb (Reviewer).

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

PR: https://git.openjdk.java.net/jdk/pull/7614


More information about the core-libs-dev mailing list