From 304686cfc0cb11be9e4d941de0c3722108218028 Mon Sep 17 00:00:00 2001 From: Andy Nguyen Date: Wed, 27 Oct 2021 21:06:56 +0200 Subject: [PATCH] Check for negative offsets. --- com/bdjb/JIT.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/com/bdjb/JIT.java b/com/bdjb/JIT.java index a365462..6fb3417 100644 --- a/com/bdjb/JIT.java +++ b/com/bdjb/JIT.java @@ -142,11 +142,11 @@ public final class JIT { RandomAccessFile file = new RandomAccessFile(path, "r"); if ((dataSectionOffset & (PAGE_SIZE - 1)) != 0) { - throw new IllegalArgumentException("Ddata section offset is not page aligned."); + throw new IllegalArgumentException("Unaligned data section offset."); } - if (dataSectionOffset > file.length()) { - throw new IllegalArgumentException("Data section offset is too big."); + if (dataSectionOffset < 0 || dataSectionOffset > file.length()) { + throw new IllegalArgumentException("Invalid data section offset."); } // TODO: Currently we just use maximum size so that the address is predictable.