mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-02-15 23:20:15 +00:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
c7317be465
@ -1117,7 +1117,7 @@ public class ChainedBuffer implements Buffer {
|
||||
/**
|
||||
* Fill the buffer over the specified range with a byte value.
|
||||
* @param startOffset starting offset, inclusive
|
||||
* @param endOffset ending offset, exclusive
|
||||
* @param endOffset ending offset, inclusive
|
||||
* @param fillByte byte value
|
||||
* @throws IOException thrown if an IO error occurs
|
||||
*/
|
||||
@ -1126,10 +1126,10 @@ public class ChainedBuffer implements Buffer {
|
||||
if (readOnly) {
|
||||
throw new UnsupportedOperationException("Read-only buffer");
|
||||
}
|
||||
if (endOffset <= startOffset) {
|
||||
if (endOffset < startOffset) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (startOffset < 0 || endOffset > size) {
|
||||
if (startOffset < 0 || endOffset >= size) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
byte[] fillData = new byte[dataSpace];
|
||||
|
@ -100,7 +100,7 @@ public abstract class AbstractChainedBufferTest extends AbstractGenericTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillChainnedBuffer() throws IOException {
|
||||
public void testFillChainedBuffer() throws IOException {
|
||||
|
||||
ChainedBuffer cb =
|
||||
new ChainedBuffer(BIG_DATA_SIZE, obfuscated, sourceData, sourceDataOffset, mgr);
|
||||
@ -126,7 +126,42 @@ public abstract class AbstractChainedBufferTest extends AbstractGenericTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBigChainnedBuffer() throws IOException {
|
||||
public void testSmallFillChainedBuffer() throws IOException {
|
||||
|
||||
ChainedBuffer cb = new ChainedBuffer(1, obfuscated, sourceData, sourceDataOffset, mgr);
|
||||
|
||||
// Fill
|
||||
cb.fill(0, 0, (byte) 0x12);
|
||||
|
||||
// Verify data
|
||||
assertEquals(cb.getByte(0), (byte) 0x12);
|
||||
|
||||
// Re-instantiate buffer
|
||||
int id = cb.getId();
|
||||
cb = new ChainedBuffer(mgr, id);
|
||||
|
||||
// Re-verify data
|
||||
assertEquals(cb.getByte(0), (byte) 0x12);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChainedBufferOverflow() throws IOException {
|
||||
|
||||
ChainedBuffer cb = new ChainedBuffer(1, obfuscated, sourceData, sourceDataOffset, mgr);
|
||||
|
||||
// Fill too much by 1 byte to test generated exception bounds
|
||||
try {
|
||||
cb.fill(0, 1, (byte) 0x12);
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
fail("Overflow was not correctly detected");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBigChainedBuffer() throws IOException {
|
||||
|
||||
ChainedBuffer cb =
|
||||
new ChainedBuffer(BIG_DATA_SIZE, obfuscated, sourceData, sourceDataOffset, mgr);
|
||||
|
Loading…
Reference in New Issue
Block a user