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

Jim Laskey jlaskey at openjdk.java.net
Tue Mar 8 13:29:08 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.

This pull request has now been integrated.

Changeset: 5fab27e1
Author:    Jim Laskey <jlaskey at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/5fab27e1b8fdf2ea27cb3b349bd339a4a6ec828b
Stats:     72 lines in 2 files changed: 71 ins; 0 del; 1 mod

8282144: RandomSupport.convertSeedBytesToLongs sign extension overwrites previous bytes

Reviewed-by: bpb

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

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


More information about the core-libs-dev mailing list