Skip to content

Commit

Permalink
Correct buffer size to fix memory corruption
Browse files Browse the repository at this point in the history
The analysis in eclipse-openj9/openj9#5696 shows that there
is a out of bounds access that is fixed by increasing
the buffer size by 8.  Validated by having the VM
increase all unsafe allocates by 8 and the problem
no longer occurs.

fixes: kohsuke#79

Signed-off-by: Dan Heidinga <daniel_heidinga@ca.ibm.com>
  • Loading branch information
DanHeidinga committed May 14, 2019
1 parent 1e690b8 commit 000a42a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions runtime/src/main/java/com4j/Variant.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ public int comEnumValue() {
* Creates an empty {@link Variant}.
*/
public Variant() {
image = ByteBuffer.allocateDirect(16);
image = ByteBuffer.allocateDirect(24);
image.order(ByteOrder.LITTLE_ENDIAN);
// The initial content of a buffer is, in general, undefined. See the documentation of java.nio.Buffer.
byte[] b = new byte[16]; // this initializes the array with zeros
byte[] b = new byte[24]; // this initializes the array with zeros
image.put(b); // this prints the zeros to the buffer to guarantee, that the buffer is initialized with zeros.
image.position(0);
}
Expand Down

0 comments on commit 000a42a

Please sign in to comment.