From 84dfba6fd9b11427d1a3675481facc7686a424c1 Mon Sep 17 00:00:00 2001 From: Andy Nguyen Date: Fri, 6 Dec 2024 12:54:12 +0100 Subject: [PATCH] Fix array allocation. --- src/com/bdjb/api/Int16Array.java | 2 +- src/com/bdjb/api/Int32Array.java | 2 +- src/com/bdjb/api/Int64Array.java | 2 +- src/com/bdjb/api/Int8Array.java | 2 +- src/com/bdjb/api/KernelAPI.java | 22 +++++++--------------- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/com/bdjb/api/Int16Array.java b/src/com/bdjb/api/Int16Array.java index e9f0be7..2a71fa5 100644 --- a/src/com/bdjb/api/Int16Array.java +++ b/src/com/bdjb/api/Int16Array.java @@ -9,7 +9,7 @@ package com.bdjb.api; public final class Int16Array extends Buffer { public Int16Array(int length) { - super(Int16.SIZE); + super(length * Int16.SIZE); } public short get(int index) { diff --git a/src/com/bdjb/api/Int32Array.java b/src/com/bdjb/api/Int32Array.java index 6588a6c..9016a1c 100644 --- a/src/com/bdjb/api/Int32Array.java +++ b/src/com/bdjb/api/Int32Array.java @@ -9,7 +9,7 @@ package com.bdjb.api; public final class Int32Array extends Buffer { public Int32Array(int length) { - super(Int32.SIZE); + super(length * Int32.SIZE); } public int get(int index) { diff --git a/src/com/bdjb/api/Int64Array.java b/src/com/bdjb/api/Int64Array.java index b182524..81d4dd5 100644 --- a/src/com/bdjb/api/Int64Array.java +++ b/src/com/bdjb/api/Int64Array.java @@ -9,7 +9,7 @@ package com.bdjb.api; public final class Int64Array extends Buffer { public Int64Array(int length) { - super(Int64.SIZE); + super(length * Int64.SIZE); } public long get(int index) { diff --git a/src/com/bdjb/api/Int8Array.java b/src/com/bdjb/api/Int8Array.java index ac463c3..68aca82 100644 --- a/src/com/bdjb/api/Int8Array.java +++ b/src/com/bdjb/api/Int8Array.java @@ -9,7 +9,7 @@ package com.bdjb.api; public final class Int8Array extends Buffer { public Int8Array(int length) { - super(Int8.SIZE); + super(length * Int8.SIZE); } public byte get(int index) { diff --git a/src/com/bdjb/api/KernelAPI.java b/src/com/bdjb/api/KernelAPI.java index 99af4fc..c199289 100644 --- a/src/com/bdjb/api/KernelAPI.java +++ b/src/com/bdjb/api/KernelAPI.java @@ -42,6 +42,9 @@ public class KernelAPI { private long kaslrOffset; + private Int32Array masterPipeFd = new Int32Array(2); + private Int32Array victimPipeFd = new Int32Array(2); + private int masterRpipeFd; private int masterWpipeFd; private int victimRpipeFd; @@ -79,9 +82,6 @@ public class KernelAPI { } private void initPipes() { - Int32Array masterPipeFd = new Int32Array(2); - Int32Array victimPipeFd = new Int32Array(2); - pipe(masterPipeFd); pipe(victimPipeFd); @@ -179,20 +179,12 @@ public class KernelAPI { kwrite(addr, tmp, Int64.SIZE); } - public int getMasterRpipeFd() { - return masterRpipeFd; + public Int32Array getMasterPipeFd() { + return masterPipeFd; } - public int getMasterWpipeFd() { - return masterWpipeFd; - } - - public int getVictimRpipeFd() { - return victimRpipeFd; - } - - public int getVictimWpipeFd() { - return victimWpipeFd; + public Int32Array getVictimPipeFd() { + return victimPipeFd; } public long getKaslrOffset() {