From 52d93f78cfda8a1be54c9c29d2d1e25b63368239 Mon Sep 17 00:00:00 2001 From: no Date: Fri, 2 Jun 2023 10:33:57 -0700 Subject: [PATCH 1/2] Check for negative length in SemisparseByteArray.putData() --- .../ghidra/generic/util/datastruct/SemisparseByteArray.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Ghidra/Framework/Emulation/src/main/java/ghidra/generic/util/datastruct/SemisparseByteArray.java b/Ghidra/Framework/Emulation/src/main/java/ghidra/generic/util/datastruct/SemisparseByteArray.java index 69e65d2636..90ec905a56 100644 --- a/Ghidra/Framework/Emulation/src/main/java/ghidra/generic/util/datastruct/SemisparseByteArray.java +++ b/Ghidra/Framework/Emulation/src/main/java/ghidra/generic/util/datastruct/SemisparseByteArray.java @@ -242,7 +242,9 @@ public class SemisparseByteArray { */ public synchronized void putData(final long loc, final byte[] data, final int offset, final int length) { - if (length == 0) { + if (length < 0) { + throw new IllegalArgumentException("length: " + length); + } else if (length == 0) { return; } defined.add(ULongSpan.extent(loc, length)); From 0de824949c29cf2c663b63c2b9d309a6e942de5c Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Mon, 5 Jun 2023 07:41:03 -0400 Subject: [PATCH 2/2] GP-0: Formatting --- .../ghidra/generic/util/datastruct/SemisparseByteArray.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Ghidra/Framework/Emulation/src/main/java/ghidra/generic/util/datastruct/SemisparseByteArray.java b/Ghidra/Framework/Emulation/src/main/java/ghidra/generic/util/datastruct/SemisparseByteArray.java index 90ec905a56..459727858a 100644 --- a/Ghidra/Framework/Emulation/src/main/java/ghidra/generic/util/datastruct/SemisparseByteArray.java +++ b/Ghidra/Framework/Emulation/src/main/java/ghidra/generic/util/datastruct/SemisparseByteArray.java @@ -119,7 +119,7 @@ public class SemisparseByteArray { * *

* Copies {@code length} bytes of data from the semisparse array starting at index {@code loc} - * into {@code data} starting at index {@code} offset. All initialized portions within the + * into {@code data} starting at index {@code offset}. All initialized portions within the * requested region are copied. The uninitialized portions may be treated as zeroes or not * copied at all. Typically, the destination array has been initialized to zero by the caller, * such that all uninitialized portions are zero. To avoid fetching uninitialized data, use @@ -244,7 +244,8 @@ public class SemisparseByteArray { final int length) { if (length < 0) { throw new IllegalArgumentException("length: " + length); - } else if (length == 0) { + } + else if (length == 0) { return; } defined.add(ULongSpan.extent(loc, length));