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

Jim Laskey jlaskey at openjdk.java.net
Thu Feb 24 14:55:37 UTC 2022


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.

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

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

Changes: https://git.openjdk.java.net/jdk/pull/7614/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7614&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8282144
  Stats: 72 lines in 2 files changed: 71 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7614.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7614/head:pull/7614

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


More information about the core-libs-dev mailing list