Ghidra is a software reverse engineering (SRE) framework
Corrected convertBytesToString with offset and length
ghidra14614567590b6
diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/util/NumericUtilities.java b/Ghidra/Framework/Generic/src/main/java/ghidra/util/NumericUtilities.javaindex d8467cfe0d..6a5a371ea0 100644--- a/Ghidra/Framework/Generic/src/main/java/ghidra/util/NumericUtilities.java+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/util/NumericUtilities.java@@ -670,7 +670,7 @@ public final class NumericUtilities {*/public static String convertBytesToString(byte[] bytes, int start, int len, String delimeter) {- Iterator<Byte> iterator = IteratorUtils.arrayIterator(bytes, start, len);+ Iterator<Byte> iterator = IteratorUtils.arrayIterator(bytes, start, start + len);return convertBytesToString(iterator, delimeter);}diff --git a/Ghidra/Framework/Generic/src/test/java/ghidra/util/NumericUtilitiesTest.java b/Ghidra/Framework/Generic/src/test/java/ghidra/util/NumericUtilitiesTest.javaindex fbbf16207f..bb0bc19eac 100644--- a/Ghidra/Framework/Generic/src/test/java/ghidra/util/NumericUtilitiesTest.java+++ b/Ghidra/Framework/Generic/src/test/java/ghidra/util/NumericUtilitiesTest.java@@ -15,7 +15,8 @@*/package ghidra.util;-import static org.junit.Assert.*;+import static org.junit.Assert.assertEquals;+import static org.junit.Assert.fail;import java.util.*;import java.util.stream.Collectors;@@ -95,6 +96,13 @@ public class NumericUtilitiesTest {assertEquals("012380ff00", str);}+ @Test+ public void testConvertBytesToStringWithOffsetAndLength() {+ byte[] bytes = new byte[] { (byte) 0x1, (byte) 0x23, (byte) 0x80, (byte) 0xff, (byte) 0 };+ String str = NumericUtilities.convertBytesToString(bytes, 2, 2, " ");+ assertEquals("80 ff", str);+ }+@Testpublic void testConvertBytesToStringWithDelimiter() {byte[] bytes = new byte[] { (byte) 0x1, (byte) 0x23, (byte) 0x80, (byte) 0xff, (byte) 0 };