output stringlengths 64 73.2k | input stringlengths 208 73.3k | instruction stringclasses 1
value |
|---|---|---|
#fixed code
@Test
public void testLong_LittleEndian() throws Exception {
assertArrayEquals(new byte[]{0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01}, BeginBin().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Long(0x0102030405060708L).End().toByteArray());
} | #vulnerable code
@Test
public void testLong_LittleEndian() throws Exception {
assertArrayEquals(new byte[]{0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01}, binStart().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Long(0x0102030405060708L).end().toByteArray());
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public int readBits(final JBBPBitNumber numOfBitsToRead) throws IOException {
int result;
final int numOfBitsAsNumber = numOfBitsToRead.getBitNumber();
if (this.bitsInBuffer == 0 && numOfBitsAsNumber == 8) {
result = this.readByteFromStream();
this.byt... | #vulnerable code
public int readBits(final JBBPBitNumber numOfBitsToRead) throws IOException {
int result;
final int numOfBitsAsNumber = numOfBitsToRead.getBitNumber();
if (this.bitsInBuffer == 0 && numOfBitsAsNumber == 8) {
result = this.readByteFromStream();
re... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testComplexWriting_1() throws Exception {
final byte [] array =
BeginBin().
Bit(1, 2, 3, 0).
Bit(true, false, true).
Align().
Byte(5).
Short(1, 2, 3, 4, 5).
Bool(true, fal... | #vulnerable code
@Test
public void testComplexWriting_1() throws Exception {
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(16384);
final JBBPOut begin = new JBBPOut(buffer);
begin.
Bit(1, 2, 3, 0).
Bit(true, false, true).
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBit() throws Exception {
assertArrayEquals(new byte[]{1}, BeginBin().Bit(1).End().toByteArray());
} | #vulnerable code
@Test
public void testBit() throws Exception {
assertArrayEquals(new byte[]{1}, binStart().Bit(1).end().toByteArray());
}
#location 3
#vulnerability type RESOURCE_LEAK | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public JBBPOut Bin(final Object object) throws IOException {
if (this.processCommands) {
JBBPUtils.assertNotNull(object, "Object must not be null");
Field[] orderedFields = null;
final Map<Class<?>, Field[]> fieldz;
if (cachedFields == null) ... | #vulnerable code
public JBBPOut Bin(final Object object) throws IOException {
if (this.processCommands) {
Field[] orderedFields = null;
final Map<Class<?>, Field[]> fieldz;
if (cachedFields == null) {
fieldz = new HashMap<Class<?>, Field[]>();
cache... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBitArrayAsInts() throws Exception {
assertArrayEquals(new byte[]{(byte) 0xE3}, BeginBin().Bit(1, 3, 0, 2, 4, 1, 3, 7).End().toByteArray());
assertArrayEquals(new byte[]{(byte) 0x0B}, BeginBin().Bit(1, 3, 0, 7).End().toByteArray());
} | #vulnerable code
@Test
public void testBitArrayAsInts() throws Exception {
assertArrayEquals(new byte[]{(byte) 0xE3}, binStart().Bit(1, 3, 0, 2, 4, 1, 3, 7).end().toByteArray());
assertArrayEquals(new byte[]{(byte) 0x0B}, binStart().Bit(1, 3, 0, 7).end().toByteArray());
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testShort_LittleEndian() throws Exception {
assertArrayEquals(new byte []{0x02,01}, BeginBin().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Short(0x0102).End().toByteArray());
} | #vulnerable code
@Test
public void testShort_LittleEndian() throws Exception {
assertArrayEquals(new byte []{0x02,01}, binStart().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Short(0x0102).end().toByteArray());
}
#location 3
#vul... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testExceptionForOperatioOverEndedProcess() throws Exception {
final JBBPOut out = BeginBin();
out.ByteOrder(JBBPByteOrder.BIG_ENDIAN).Long(0x0102030405060708L).End();
try{
out.Align();
fail("Must throw ISE");
}catch(IllegalStateEx... | #vulnerable code
@Test
public void testExceptionForOperatioOverEndedProcess() throws Exception {
final JBBPOut out = binStart();
out.ByteOrder(JBBPByteOrder.BIG_ENDIAN).Long(0x0102030405060708L).end();
try{
out.Align();
fail("Must throw ISE");
}catch(IllegalS... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBitArrayAsBytes() throws Exception {
assertArrayEquals(new byte[]{(byte) 0xE3}, BeginBin().Bit(new byte[]{(byte) 1, (byte) 3, (byte) 0, (byte) 2, (byte) 4, (byte) 1, (byte) 3, (byte) 7}).End().toByteArray());
assertArrayEquals(new byte[]{(byte) 0... | #vulnerable code
@Test
public void testBitArrayAsBytes() throws Exception {
assertArrayEquals(new byte[]{(byte) 0xE3}, binStart().Bit(new byte[]{(byte) 1, (byte) 3, (byte) 0, (byte) 2, (byte) 4, (byte) 1, (byte) 3, (byte) 7}).end().toByteArray());
assertArrayEquals(new byte[]{(b... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testAlign() throws Exception {
assertArrayEquals(new byte[]{(byte) 0x01, (byte) 0xFF}, JBBPOut.BeginBin().Bit(1).Align().Byte(0xFF).End().toByteArray());
} | #vulnerable code
@Test
public void testAlign() throws Exception {
assertArrayEquals(new byte[]{(byte) 0x01, (byte) 0xFF}, new JBBPOut(new ByteArrayOutputStream()).Bit(1).Align().Byte(0xFF).End().toByteArray());
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testIntArray() throws Exception {
assertArrayEquals(new byte []{0x01,02,0x03,0x04,0x05,0x06,0x07,0x08}, BeginBin().Int(0x01020304, 0x05060708).End().toByteArray());
} | #vulnerable code
@Test
public void testIntArray() throws Exception {
assertArrayEquals(new byte []{0x01,02,0x03,0x04,0x05,0x06,0x07,0x08}, binStart().Int(0x01020304, 0x05060708).end().toByteArray());
}
#location 3
#vulnerab... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testShortArray_AsShortArray() throws Exception {
assertArrayEquals(new byte[]{1, 2, 3, 4}, BeginBin().Short(new short[]{(short)0x0102, (short)0x0304}).End().toByteArray());
} | #vulnerable code
@Test
public void testShortArray_AsShortArray() throws Exception {
assertArrayEquals(new byte[]{1, 2, 3, 4}, binStart().Short(new short[]{(short)0x0102, (short)0x0304}).end().toByteArray());
}
#location 3
#... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testGetLineSeparator() throws Exception {
assertEquals("hello", new JBBPTextWriter(writer, JBBPByteOrder.BIG_ENDIAN, "hello", 11, "", "", "","", "").getLineSeparator());
} | #vulnerable code
@Test
public void testGetLineSeparator() throws Exception {
assertEquals("hello", new JBBPTextWriter(writer, JBBPByteOrder.BIG_ENDIAN, "hello", 11, "", "", "", "").getLineSeparator());
}
#location 3
#vulner... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testShort() throws Exception {
assertArrayEquals(new byte []{0x01,02}, BeginBin().Short(0x0102).End().toByteArray());
} | #vulnerable code
@Test
public void testShort() throws Exception {
assertArrayEquals(new byte []{0x01,02}, binStart().Short(0x0102).end().toByteArray());
}
#location 3
#vulnerability type RESOURCE_LEAK | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBits_Int() throws Exception {
assertArrayEquals(new byte[]{0xD}, BeginBin().Bits(JBBPNumberOfBits.BITS_4, 0xFD).End().toByteArray());
} | #vulnerable code
@Test
public void testBits_Int() throws Exception {
assertArrayEquals(new byte[]{0xD}, binStart().Bits(JBBPNumberOfBits.BITS_4, 0xFD).end().toByteArray());
}
#location 3
#vulnerability type RESOURCE_LEAK | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testEmptyArray() throws Exception {
assertEquals(0, JBBPOut.BeginBin().End().toByteArray().length);
} | #vulnerable code
@Test
public void testEmptyArray() throws Exception {
assertEquals(0, new JBBPOut(new ByteArrayOutputStream()).End().toByteArray().length);
}
#location 3
#vulnerability type RESOURCE_LEAK | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testShortArray_AsIntegers_LittleEndian() throws Exception {
assertArrayEquals(new byte []{2,1,4,3}, BeginBin().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Short(0x0102,0x0304).End().toByteArray());
} | #vulnerable code
@Test
public void testShortArray_AsIntegers_LittleEndian() throws Exception {
assertArrayEquals(new byte []{2,1,4,3}, binStart().ByteOrder(JBBPByteOrder.LITTLE_ENDIAN).Short(0x0102,0x0304).end().toByteArray());
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public byte[] readByteArray(final int items) throws IOException {
return _readArray(items, null);
} | #vulnerable code
public byte[] readByteArray(final int items) throws IOException {
int pos = 0;
if (items < 0) {
byte[] buffer = new byte[INITIAL_ARRAY_BUFFER_SIZE];
// till end
while (true) {
final int next = read();
if (next < 0) {
bre... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBitArrayAsBooleans() throws Exception {
assertArrayEquals(new byte[]{(byte) 0xE3}, BeginBin().Bit(true, true, false, false, false, true, true, true).End().toByteArray());
assertArrayEquals(new byte[]{(byte) 0x0B}, BeginBin().Bit(true, true, false... | #vulnerable code
@Test
public void testBitArrayAsBooleans() throws Exception {
assertArrayEquals(new byte[]{(byte) 0xE3}, binStart().Bit(true, true, false, false, false, true, true, true).end().toByteArray());
assertArrayEquals(new byte[]{(byte) 0x0B}, binStart().Bit(true, true,... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testLongArray() throws Exception {
assertArrayEquals(new byte []{0x01,02,0x03,0x04,0x05,0x06,0x07,0x08, 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18}, BeginBin().Long(0x0102030405060708L,0x1112131415161718L).End().toByteArray());
} | #vulnerable code
@Test
public void testLongArray() throws Exception {
assertArrayEquals(new byte []{0x01,02,0x03,0x04,0x05,0x06,0x07,0x08, 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18}, binStart().Long(0x0102030405060708L,0x1112131415161718L).end().toByteArray());
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBeginBin() throws Exception {
assertArrayEquals(new byte[]{1}, BeginBin().Byte(1).End().toByteArray());
assertArrayEquals(new byte[]{0x02, 0x01}, BeginBin(JBBPByteOrder.LITTLE_ENDIAN).Short(0x0102).End().toByteArray());
assertArrayEquals(new ... | #vulnerable code
@Test
public void testBeginBin() throws Exception {
assertArrayEquals(new byte[]{1}, BeginBin().Byte(1).End().toByteArray());
assertArrayEquals(new byte[]{0x02, 0x01}, BeginBin(JBBPByteOrder.LITTLE_ENDIAN).Short(0x0102).End().toByteArray());
assertArrayEqual... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testShort_BigEndian() throws Exception {
assertArrayEquals(new byte []{0x01,02}, BeginBin().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Short(0x0102).End().toByteArray());
} | #vulnerable code
@Test
public void testShort_BigEndian() throws Exception {
assertArrayEquals(new byte []{0x01,02}, binStart().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Short(0x0102).end().toByteArray());
}
#location 3
#vulnerabi... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBits_ByteArray() throws Exception {
assertArrayEquals(new byte[]{(byte) 0xED}, BeginBin().Bits(JBBPNumberOfBits.BITS_4, (byte) 0xFD, (byte) 0x8E).End().toByteArray());
} | #vulnerable code
@Test
public void testBits_ByteArray() throws Exception {
assertArrayEquals(new byte[]{(byte) 0xED}, binStart().Bits(JBBPNumberOfBits.BITS_4, (byte) 0xFD, (byte) 0x8E).end().toByteArray());
}
#location 3
#v... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testLong_BigEndian() throws Exception {
assertArrayEquals(new byte []{0x01, 02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}, BeginBin().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Long(0x0102030405060708L).End().toByteArray());
} | #vulnerable code
@Test
public void testLong_BigEndian() throws Exception {
assertArrayEquals(new byte []{0x01, 02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}, binStart().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Long(0x0102030405060708L).end().toByteArray());
}
#lo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public byte[] readBitsArray(final int items, final JBBPBitNumber bitNumber) throws IOException {
return _readArray(items, bitNumber);
} | #vulnerable code
public byte[] readBitsArray(final int items, final JBBPBitNumber bitNumber) throws IOException {
int pos = 0;
if (items < 0) {
byte[] buffer = new byte[INITIAL_ARRAY_BUFFER_SIZE];
// till end
while (true) {
final int next = readBits(bitNu... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testInt_BigEndian() throws Exception {
assertArrayEquals(new byte []{0x01,0x02,0x03,0x04}, BeginBin().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Int(0x01020304).End().toByteArray());
} | #vulnerable code
@Test
public void testInt_BigEndian() throws Exception {
assertArrayEquals(new byte []{0x01,0x02,0x03,0x04}, binStart().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Int(0x01020304).end().toByteArray());
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testComplexWriting_1() throws Exception {
final byte [] array =
BeginBin().
Bit(1, 2, 3, 0).
Bit(true, false, true).
Align().
Byte(5).
Short(1, 2, 3, 4, 5).
Bool(true, fal... | #vulnerable code
@Test
public void testComplexWriting_1() throws Exception {
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(16384);
final JBBPOut begin = new JBBPOut(buffer);
begin.
Bit(1, 2, 3, 0).
Bit(true, false, true).
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBit_LSB0() throws Exception {
assertArrayEquals(new byte[]{(byte) 0x01}, BeginBin(JBBPByteOrder.BIG_ENDIAN, JBBPBitOrder.LSB0).Bit(1).End().toByteArray());
} | #vulnerable code
@Test
public void testBit_LSB0() throws Exception {
assertArrayEquals(new byte[]{(byte) 0x01}, binStart(JBBPByteOrder.BIG_ENDIAN, JBBPBitOrder.LSB0).Bit(1).end().toByteArray());
}
#location 3
#vulnerability... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testShortArray_AsIntegers_BigEndian() throws Exception {
assertArrayEquals(new byte []{1,2,3,4}, BeginBin().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Short(0x0102,0x0304).End().toByteArray());
} | #vulnerable code
@Test
public void testShortArray_AsIntegers_BigEndian() throws Exception {
assertArrayEquals(new byte []{1,2,3,4}, binStart().ByteOrder(JBBPByteOrder.BIG_ENDIAN).Short(0x0102,0x0304).end().toByteArray());
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBitArrayAsBooleans() throws Exception {
assertArrayEquals(new byte[]{(byte) 0xE3}, BeginBin().Bit(true, true, false, false, false, true, true, true).End().toByteArray());
assertArrayEquals(new byte[]{(byte) 0x0B}, BeginBin().Bit(true, true, false... | #vulnerable code
@Test
public void testBitArrayAsBooleans() throws Exception {
assertArrayEquals(new byte[]{(byte) 0xE3}, binStart().Bit(true, true, false, false, false, true, true, true).end().toByteArray());
assertArrayEquals(new byte[]{(byte) 0x0B}, binStart().Bit(true, true,... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testBits_IntArray() throws Exception {
assertArrayEquals(new byte[]{(byte) 0xED}, BeginBin().Bits(JBBPNumberOfBits.BITS_4, 0xFD, 0xFE).End().toByteArray());
} | #vulnerable code
@Test
public void testBits_IntArray() throws Exception {
assertArrayEquals(new byte[]{(byte) 0xED}, binStart().Bits(JBBPNumberOfBits.BITS_4, 0xFD, 0xFE).end().toByteArray());
}
#location 3
#vulnerability ty... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testParse_StructArray_IgnoredForZeroLength() throws Exception {
final JBBPFieldStruct parsed = JBBPParser.prepare("byte len; sss [len] { byte a; byte b; byte c;} ushort;").parse(new byte[]{0x0, 0x01, (byte) 0x02});
assertEquals(0,parsed.findFieldFor... | #vulnerable code
@Test
public void testParse_StructArray_IgnoredForZeroLength() throws Exception {
final JBBPFieldStruct parsed = JBBPParser.prepare("byte len; sss [len] { byte a; byte b; byte c;} ushort;").parse(new byte[]{0x0, 0x01, (byte) 0x02});
assertNull(parsed.findFieldF... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private byte[] callWrite(final Object instance) throws Exception {
final ByteArrayOutputStream bout = new ByteArrayOutputStream();
final JBBPBitOutputStream bitout = new JBBPBitOutputStream(bout);
instance.getClass().getMethod("write", JBBPBitOutputStream.class).inv... | #vulnerable code
private byte[] callWrite(final Object instance) throws Exception {
final ByteArrayOutputStream bout = new ByteArrayOutputStream();
instance.getClass().getMethod("write", JBBPBitOutputStream.class).invoke(instance, new JBBPBitOutputStream(bout));
bout.close();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public int readBits(final JBBPBitNumber numOfBitsToRead) throws IOException {
int result;
final int numOfBitsAsNumber = numOfBitsToRead.getBitNumber();
if (this.bitsInBuffer == 0 && numOfBitsAsNumber == 8) {
result = this.readByteFromStream();
this.byt... | #vulnerable code
public int readBits(final JBBPBitNumber numOfBitsToRead) throws IOException {
int result;
final int numOfBitsAsNumber = numOfBitsToRead.getBitNumber();
if (this.bitsInBuffer == 0 && numOfBitsAsNumber == 8) {
result = this.readByteFromStream();
re... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testAlignWithArgument() throws Exception {
assertEquals(0, JBBPOut.BeginBin().Align(2).End().toByteArray().length);
assertArrayEquals(new byte[]{(byte) 0x01, (byte) 0xFF}, JBBPOut.BeginBin().Bit(1).Align(1).Byte(0xFF).End().toByteArray());
assert... | #vulnerable code
@Test
public void testAlignWithArgument() throws Exception {
assertEquals(0, new JBBPOut(new ByteArrayOutputStream()).Align(2).End().toByteArray().length);
assertArrayEquals(new byte[]{(byte) 0x01, (byte) 0xFF}, new JBBPOut(new ByteArrayOutputStream()).Bit(1).Al... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testShortArray_AsIntegers() throws Exception {
assertArrayEquals(new byte []{1,2,3,4}, BeginBin().Short(0x0102,0x0304).End().toByteArray());
} | #vulnerable code
@Test
public void testShortArray_AsIntegers() throws Exception {
assertArrayEquals(new byte []{1,2,3,4}, binStart().Short(0x0102,0x0304).end().toByteArray());
}
#location 3
#vulnerability type RESOURCE_LEAK | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testInt() throws Exception {
assertArrayEquals(new byte []{0x01,02,0x03,0x04}, BeginBin().Int(0x01020304).End().toByteArray());
} | #vulnerable code
@Test
public void testInt() throws Exception {
assertArrayEquals(new byte []{0x01,02,0x03,0x04}, binStart().Int(0x01020304).end().toByteArray());
}
#location 3
#vulnerability type RESOURCE_LEAK | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testByteArrayAsInts() throws Exception {
assertArrayEquals(new byte[]{1, 3, 0, 2, 4, 1, 3, 7}, BeginBin().Byte(1, 3, 0, 2, 4, 1, 3, 7).End().toByteArray());
} | #vulnerable code
@Test
public void testByteArrayAsInts() throws Exception {
assertArrayEquals(new byte[]{1, 3, 0, 2, 4, 1, 3, 7}, binStart().Byte(1, 3, 0, 2, 4, 1, 3, 7).end().toByteArray());
}
#location 3
#vulnerability ty... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testLong() throws Exception {
assertArrayEquals(new byte []{0x01,02,0x03,0x04,0x05,0x06,0x07,0x08}, BeginBin().Long(0x0102030405060708L).End().toByteArray());
} | #vulnerable code
@Test
public void testLong() throws Exception {
assertArrayEquals(new byte []{0x01,02,0x03,0x04,0x05,0x06,0x07,0x08}, binStart().Long(0x0102030405060708L).end().toByteArray());
}
#location 3
#vulnerability ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testComplexWriting_1() throws Exception {
final byte [] array =
BeginBin().
Bit(1, 2, 3, 0).
Bit(true, false, true).
Align().
Byte(5).
Short(1, 2, 3, 4, 5).
Bool(true, fal... | #vulnerable code
@Test
public void testComplexWriting_1() throws Exception {
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(16384);
final JBBPOut begin = new JBBPOut(buffer);
begin.
Bit(1, 2, 3, 0).
Bit(true, false, true).
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public BigDecimal convert(Currency from, Currency to, BigDecimal amount) {
Assert.notNull(amount);
Map<Currency, BigDecimal> rates = getCurrentRates();
BigDecimal ratio = rates.get(to).divide(rates.get(from), 4, RoundingMode.HALF_UP);
return amount.multiply... | #vulnerable code
@Override
public BigDecimal convert(Currency from, Currency to, BigDecimal amount) {
Map<Currency, BigDecimal> rates = getCurrentRates();
BigDecimal baseRatio = rates.get(to).divide(rates.get(from), 4, RoundingMode.HALF_UP);
return amount.multiply(baseRatio);
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void debugLocal() {
if (!traceDebugEnabled) {
return;
}
System.out.println("---------------- Trace Information ---------------");
String traceId = getTraceId();
String spanId = getSpanId();
System.out.println... | #vulnerable code
public void debugLocal() {
if (!traceDebugEnabled) {
return;
}
System.out.println("---------------- Trace Information ---------------");
String traceId = getTraceId();
String spanId = getSpanId();
System.out.p... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean apply(Server server, Map<String, String> metadata) {
// 1.对Rest调用传来的Header的路由Version做策略。注意这个Version不是灰度发布的Version
boolean enabled = super.apply(server, metadata);
if (!enabled) {
return false;
}
... | #vulnerable code
@Override
public boolean apply(Server server, Map<String, String> metadata) {
GatewayStrategyContext context = GatewayStrategyContext.getCurrentContext();
String token = context.getExchange().getRequest().getHeaders().getFirst("token");
// St... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Server choose(Object key) {
WeightFilterEntity weightFilterEntity = weightRandomLoadBalance.getWeightFilterEntity();
if (weightFilterEntity == null) {
return super.choose(key);
}
if (!weightFilterEntity.hasWeig... | #vulnerable code
@Override
public Server choose(Object key) {
WeightFilterEntity weightFilterEntity = weightRandomLoadBalance.getWeightFilterEntity();
if (!weightFilterEntity.hasWeight()) {
return super.choose(key);
}
List<Server> eligibl... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void applyVersionFilter(String consumerServiceId, String consumerServiceVersion, String providerServiceId, List<ServiceInstance> instances) {
// 如果消费端未配置版本号,那么它可以调用提供端所有服务,需要符合规范,极力避免该情况发生
if (StringUtils.isEmpty(consumerServiceVersion)) {
... | #vulnerable code
private void applyVersionFilter(String consumerServiceId, String consumerServiceVersion, String providerServiceId, List<ServiceInstance> instances) {
// 如果消费端未配置版本号,那么它可以调用提供端所有服务,需要符合规范,极力避免该情况发生
if (StringUtils.isEmpty(consumerServiceVersion)) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void mdcLocal() {
if (!traceLoggerEnabled) {
return;
}
Map<String, String> customizationMap = getCustomizationMap();
if (MapUtils.isNotEmpty(customizationMap)) {
for (Map.Entry<String, String> entry : customizati... | #vulnerable code
public void mdcLocal() {
if (!traceLoggerEnabled) {
return;
}
Map<String, String> customizationMap = getCustomizationMap();
if (MapUtils.isNotEmpty(customizationMap)) {
for (Map.Entry<String, String> entry : custo... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void mdcHeader() {
if (!traceLoggerEnabled) {
return;
}
Map<String, String> customizationMap = getCustomizationMap();
if (MapUtils.isNotEmpty(customizationMap)) {
for (Map.Entry<String, String> entry : customizat... | #vulnerable code
public void mdcHeader() {
if (!traceLoggerEnabled) {
return;
}
Map<String, String> customizationMap = getCustomizationMap();
if (MapUtils.isNotEmpty(customizationMap)) {
for (Map.Entry<String, String> entry : cust... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void debugHeader() {
if (!traceDebugEnabled) {
return;
}
System.out.println("---------------- Trace Information ---------------");
String traceId = getTraceId();
String spanId = getSpanId();
System.out.printl... | #vulnerable code
public void debugHeader() {
if (!traceDebugEnabled) {
return;
}
System.out.println("---------------- Trace Information ---------------");
String traceId = getTraceId();
String spanId = getSpanId();
System.out.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private String createSpanId() {
try {
return StrategySkywalkingTracerResolver.getSpanId();
} catch (Exception e) {
return null;
}
} | #vulnerable code
private String createSpanId() {
if (System.getProperties().get("skywalking.agent.service_name") == null) {
return null;
}
try {
Object traceContext = StrategySkywalkingTracerResolver.invokeStaticMethod("org.apache.skywalk... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private boolean applyFromHeader(Server server, Map<String, String> metadata) {
String mobile = zuulStrategyContextHolder.getHeader("mobile");
String version = metadata.get(DiscoveryConstant.VERSION);
String serviceId = pluginAdapter.getServerServiceId(... | #vulnerable code
private boolean applyFromHeader(Server server, Map<String, String> metadata) {
String token = zuulStrategyContextHolder.getHeader("token");
String serviceId = pluginAdapter.getServerServiceId(server);
LOG.info("Zuul端负载均衡用户定制触发:token={}, serviceI... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@SuppressWarnings("rawtypes")
private void parseStrategyCondition(Element element, List<StrategyConditionEntity> strategyConditionEntityList) {
for (Iterator elementIterator = element.elementIterator(); elementIterator.hasNext();) {
Object childElement... | #vulnerable code
@SuppressWarnings("rawtypes")
private void parseStrategyCondition(Element element, List<StrategyConditionEntity> strategyConditionEntityList) {
for (Iterator elementIterator = element.elementIterator(); elementIterator.hasNext();) {
Object childE... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private boolean applyFromHeader(Server server, Map<String, String> metadata) {
String mobile = gatewayStrategyContextHolder.getHeader("mobile");
String version = metadata.get(DiscoveryConstant.VERSION);
String serviceId = pluginAdapter.getServerService... | #vulnerable code
private boolean applyFromHeader(Server server, Map<String, String> metadata) {
String token = gatewayStrategyContextHolder.getHeader("token");
String serviceId = pluginAdapter.getServerServiceId(server);
LOG.info("Gateway端负载均衡用户定制触发:token={}, se... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public int compare(@Nullable Object left, @Nullable Object right) throws SpelEvaluationException {
if (left == null) {
return right == null ? 0 : -1;
} else if (right == null) {
return 1;
}
try {
... | #vulnerable code
@Override
public int compare(@Nullable Object left, @Nullable Object right) throws SpelEvaluationException {
if (left == null) {
return 0;
}
try {
BigDecimal leftValue = new BigDecimal(left.toString());
Bi... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void update(N node) {
Point2D location = layoutModel.apply(node);
if (!this.getLayoutArea().contains(location)) {
log.trace(location + " outside of spatial " + this.getLayoutArea());
this.setBounds(this.getUnion(this.getLayoutArea(), locat... | #vulnerable code
@Override
public void update(N node) {
Point2D location = layoutModel.apply(node);
if (!this.getLayoutArea().contains(location)) {
log.trace(location + " outside of spatial " + this.getLayoutArea());
this.setBounds(this.getUnion(this.getLayoutArea(),... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void testBasicWrite() throws IOException, ParserConfigurationException, SAXException {
Network<String, Number> g = TestGraphs.createTestGraph(true);
GraphMLWriter<String, Number> gmlw = new GraphMLWriter<String, Number>();
Function<Number, String> edge_weight... | #vulnerable code
public void testBasicWrite() throws IOException, ParserConfigurationException, SAXException {
Network<String, Number> g = TestGraphs.createTestGraph(true);
GraphMLWriter<String, Number> gmlw = new GraphMLWriter<String, Number>();
Function<Number, String> edge_... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected V getClosest(
SpatialQuadTree<V> spatial, LayoutModel<V, Point2D> layoutModel, double x, double y) {
// move the x,y to layout coordinates
Point2D pickPointInView = new Point2D.Double(x, y);
Point2D pickPointInLayout =
vv.getRenderContext()
... | #vulnerable code
protected V getClosest(
SpatialQuadTree<V> spatial, LayoutModel<V, Point2D> layoutModel, double x, double y) {
SpatialQuadTree<V> leaf = spatial.getContainingQuadTreeLeaf(x, y);
double diameter = leaf.getLayoutArea().getWidth();
double radius = diameter ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void testBasicWrite() throws IOException, ParserConfigurationException, SAXException {
Network<String, Number> g = TestGraphs.createTestGraph(true);
GraphMLWriter<String, Number> gmlw = new GraphMLWriter<String, Number>();
Function<Number, String> edge_weight... | #vulnerable code
public void testBasicWrite() throws IOException, ParserConfigurationException, SAXException {
Network<String, Number> g = TestGraphs.createTestGraph(true);
GraphMLWriter<String, Number> gmlw = new GraphMLWriter<String, Number>();
Function<Number, String> edge_... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Before
@SuppressWarnings({ "unchecked", "deprecation" })
public void before() throws IllegalArgumentException, IllegalAccessException, SQLException, SecurityException, NoSuchFieldException, CloneNotSupportedException{
driver = new MockJDBCDriver(new MockJDBCAnswer() {
p... | #vulnerable code
@Before
@SuppressWarnings({ "unchecked", "deprecation" })
public void before() throws IllegalArgumentException, IllegalAccessException, SQLException, SecurityException, NoSuchFieldException, CloneNotSupportedException{
mockConfig = EasyMock.createNiceMock(BoneCPConfig.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCreatePool() throws SQLException, ClassNotFoundException, CloneNotSupportedException {
BoneCPConfig mockConfig = createNiceMock(BoneCPConfig.class);
expect(mockConfig.getPartitionCount()).andReturn(1).anyTimes();
expect(mockConfig.getMaxConnections... | #vulnerable code
@Test
public void testCreatePool() throws SQLException, ClassNotFoundException {
BoneCPConfig mockConfig = createNiceMock(BoneCPConfig.class);
expect(mockConfig.getPartitionCount()).andReturn(1).anyTimes();
expect(mockConfig.getMaxConnectionsPerPartition()).andRet... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testCreatePool() throws SQLException, ClassNotFoundException, CloneNotSupportedException {
BoneCPConfig mockConfig = createNiceMock(BoneCPConfig.class);
expect(mockConfig.getPartitionCount()).andReturn(1).anyTimes();
expect(mockConfig.getMaxConnections... | #vulnerable code
@Test
public void testCreatePool() throws SQLException, ClassNotFoundException {
BoneCPConfig mockConfig = createNiceMock(BoneCPConfig.class);
expect(mockConfig.getPartitionCount()).andReturn(1).anyTimes();
expect(mockConfig.getMaxConnectionsPerPartition()).andRet... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void initializer_same_key() {
App app = new App(AppConfig.builder().signingSecret("secret").build());
final AtomicBoolean called = new AtomicBoolean(false);
assertThat(called.get(), is(false));
app.initializer("foo", (theApp) ... | #vulnerable code
@Test
public void initializer_same_key() {
App app = new App();
final AtomicBoolean called = new AtomicBoolean(false);
assertThat(called.get(), is(false));
app.initializer("foo", (theApp) -> {
called.set(true);
})... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public Request<?> toSlackRequest(HttpRequest<?> req, LinkedHashMap<String, String> body) {
String requestBody = body.entrySet().stream().map(e -> {
try {
String k = URLEncoder.encode(e.getKey(), "UTF-8");
String v = URLEncod... | #vulnerable code
public Request<?> toSlackRequest(HttpRequest<?> req, LinkedHashMap<String, String> body) {
String requestBody = body.entrySet().stream().map(e -> {
try {
String k = URLEncoder.encode(e.getKey(), "UTF-8");
String v = UR... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void rtmStart() throws Exception {
// TODO: "prefs" support
SlackConfig config = new SlackConfig();
config.setLibraryMaintainerMode(false);
config.getHttpClientResponseHandlers().add(new JsonDataRecordingListener());
Sl... | #vulnerable code
@Test
public void rtmStart() throws Exception {
// TODO: "prefs" support
SlackConfig config = new SlackConfig();
config.setLibraryMaintainerMode(false);
config.getHttpClientResponseHandlers().add(new JsonDataRecordingListener());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Bot findBot(String enterpriseId, String teamId) {
AmazonS3 s3 = this.createS3Client();
String fullKey = getBotKey(enterpriseId, teamId);
if (isHistoricalDataEnabled()) {
fullKey = fullKey + "-latest";
}
... | #vulnerable code
@Override
public Bot findBot(String enterpriseId, String teamId) {
AmazonS3 s3 = this.createS3Client();
String fullKey = getBotKey(enterpriseId, teamId);
if (isHistoricalDataEnabled()) {
fullKey = fullKey + "-latest";
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void initializer_start() {
App app = new App(AppConfig.builder().signingSecret("secret").build());
final AtomicBoolean called = new AtomicBoolean(false);
assertThat(called.get(), is(false));
app.initializer("foo", (theApp) -> ... | #vulnerable code
@Test
public void initializer_start() {
App app = new App();
final AtomicBoolean called = new AtomicBoolean(false);
assertThat(called.get(), is(false));
app.initializer("foo", (theApp) -> {
called.set(true);
});
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void rtmStart() throws Exception {
// TODO: "prefs" support
SlackConfig config = new SlackConfig();
config.setLibraryMaintainerMode(false);
config.getHttpClientResponseHandlers().add(new JsonDataRecordingListener());
Sl... | #vulnerable code
@Test
public void rtmStart() throws Exception {
// TODO: "prefs" support
SlackConfig config = new SlackConfig();
config.setLibraryMaintainerMode(false);
config.getHttpClientResponseHandlers().add(new JsonDataRecordingListener());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void initializer_called() {
App app = new App(AppConfig.builder().signingSecret("secret").build());
final AtomicBoolean called = new AtomicBoolean(false);
assertThat(called.get(), is(false));
app.initializer("foo", (theApp) ->... | #vulnerable code
@Test
public void initializer_called() {
App app = new App();
final AtomicBoolean called = new AtomicBoolean(false);
assertThat(called.get(), is(false));
app.initializer("foo", (theApp) -> {
called.set(true);
});
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void test() throws Exception {
String channelName = "test" + System.currentTimeMillis();
TestChannelGenerator channelGenerator = new TestChannelGenerator(testConfig, channelCreationToken);
Conversation channel = channelGenerator.create... | #vulnerable code
@Test
public void test() throws Exception {
String channelName = "test" + System.currentTimeMillis();
TestChannelGenerator channelGenerator = new TestChannelGenerator(testConfig, channelCreationToken);
Conversation channel = channelGenerator.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void status() {
App app = new App(AppConfig.builder().signingSecret("secret").build());
assertThat(app.status(), is(App.Status.Stopped));
app.start();
assertThat(app.status(), is(App.Status.Running));
app.stop();
... | #vulnerable code
@Test
public void status() {
App app = new App();
assertThat(app.status(), is(App.Status.Stopped));
app.start();
assertThat(app.status(), is(App.Status.Running));
app.stop();
assertThat(app.status(), is(App.Status.Stop... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void builder_config() {
App app = new App(AppConfig.builder().signingSecret("secret").build());
assertNotNull(app.config());
app = app.toBuilder().build();
assertNotNull(app.config());
app = app.toOAuthCallbackApp();
... | #vulnerable code
@Test
public void builder_config() {
App app = new App();
assertNotNull(app.config());
app = app.toBuilder().build();
assertNotNull(app.config());
app = app.toOAuthCallbackApp();
assertNotNull(app.config());
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
protected Request<?> toSlackRequest(ApiGatewayRequest awsReq) {
if (log.isDebugEnabled()) {
log.debug("AWS API Gateway Request: {}", awsReq);
}
RequestContext context = awsReq.getRequestContext();
SlackRequestParser.HttpRequest rawR... | #vulnerable code
protected Request<?> toSlackRequest(ApiGatewayRequest awsReq) {
if (log.isDebugEnabled()) {
log.debug("AWS API Gateway Request: {}", awsReq);
}
SlackRequestParser.HttpRequest rawRequest = SlackRequestParser.HttpRequest.builder()
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void builder_status() {
App app = new App(AppConfig.builder().signingSecret("secret").build());
assertNotNull(app.status());
assertThat(app.status(), is(App.Status.Stopped));
app = app.toBuilder().build();
assertThat(a... | #vulnerable code
@Test
public void builder_status() {
App app = new App();
assertNotNull(app.status());
assertThat(app.status(), is(App.Status.Stopped));
app = app.toBuilder().build();
assertThat(app.status(), is(App.Status.Stopped));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Installer findInstaller(String enterpriseId, String teamId, String userId) {
AmazonS3 s3 = this.createS3Client();
String fullKey = getInstallerKey(enterpriseId, teamId, userId);
if (isHistoricalDataEnabled()) {
fullKey ... | #vulnerable code
@Override
public Installer findInstaller(String enterpriseId, String teamId, String userId) {
AmazonS3 s3 = this.createS3Client();
String fullKey = getInstallerKey(enterpriseId, teamId, userId);
if (isHistoricalDataEnabled()) {
fu... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void main(String[] args) throws Exception {
test();
} | #vulnerable code
public static void main(String[] args) throws Exception {
DebugProtocol protocol = new DebugProtocol(new EventListener() {
@Override
public void onPageLoad() {
//To change body of implemented methods use File | Settings | File Templates.
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void canSwitchToTheWebViewAndFindByCSS() throws Exception {
IOSCapabilities safari = IOSCapabilities.iphone("UICatalog");
safari.setCapability(IOSCapabilities.TIME_HACK, false);
RemoteUIADriver driver = null;
try {
driver = new RemoteUIADri... | #vulnerable code
@Test
public void canSwitchToTheWebViewAndFindByCSS() throws Exception {
IOSCapabilities safari = IOSCapabilities.iphone("UICatalog");
safari.setCapability(IOSCapabilities.TIME_HACK, false);
RemoteUIADriver driver = null;
try {
driver = new Remote... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public View handle(HttpServletRequest req) throws IOSAutomationException {
String path = req.getPathInfo();
String pattern = "/resources/";
int end = path.indexOf(pattern) + pattern.length();
String resource = path.substring(end);
InputStream is = null;
... | #vulnerable code
public View handle(HttpServletRequest req) throws IOSAutomationException {
String path = req.getPathInfo();
String pattern = "/resources/";
int end = path.indexOf(pattern) + pattern.length();
String resource = path.substring(end);
InputStream is = nu... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Response handle() throws Exception {
waitForPageToLoad();
int implicitWait = (Integer) getConf("implicit_wait", 0);
long deadline = System.currentTimeMillis() + implicitWait;
List<RemoteWebElement> elements = null;
do {
try {
... | #vulnerable code
@Override
public Response handle() throws Exception {
JSONObject payload = getRequest().getPayload();
String type = payload.getString("using");
String value = payload.getString("value");
RemoteWebElement element = null;
if (getRequest().hasVariable... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Set<String> getWindowHandles() {
WebDriverLikeRequest request = buildRequest(WebDriverLikeCommand.WINDOW_HANDLES);
List<String> all = execute(request);
Set<String> res = new HashSet<String>();
res.addAll(all);
return res;
} | #vulnerable code
@Override
public Set<String> getWindowHandles() {
try {
JSONObject payload = new JSONObject();
WebDriverLikeCommand command = WebDriverLikeCommand.WINDOW_HANDLES;
Path p = new Path(command).withSession(getSessionId());
WebDriverLikeRequest ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Response handle() throws Exception {
waitForPageToLoad();
int implicitWait = (Integer) getConf("implicit_wait", 0);
long deadline = System.currentTimeMillis() + implicitWait;
RemoteWebElement rwe = null;
do {
try {
rwe = fin... | #vulnerable code
@Override
public Response handle() throws Exception {
JSONObject payload = getRequest().getPayload();
String type = payload.getString("using");
String value = payload.getString("value");
RemoteWebElement element = null;
if (getRequest().hasVariable... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void onPageLoad() {
System.err.println("new page loaded");
pageLoaded = true;
reset();
try {
Thread.sleep(5000);
System.out.println(
"on page load:" + session.getWebInspector().getProtocol().sendCommand(DOM.getDocument())... | #vulnerable code
@Override
public void onPageLoad() {
System.err.println("new page loaded");
pageLoaded = true;
reset();
}
#location 5
#vulnerability type THREAD_SAFETY_VIOLATION | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void onPageLoad() {
pageLoaded = true;
reset();
} | #vulnerable code
@Override
public void onPageLoad() {
System.err.println("new page loaded");
pageLoaded = true;
reset();
try {
Thread.sleep(5000);
System.out.println(
"on page load:" + session.getWebInspector().getProtocol().sendCommand(DOM.getDocum... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void onPageLoad() {
pageLoaded = true;
reset();
} | #vulnerable code
@Override
public void onPageLoad() {
System.err.println("new page loaded");
pageLoaded = true;
reset();
try {
Thread.sleep(5000);
System.out.println(
"on page load:" + session.getWebInspector().getProtocol().sendCommand(DOM.getDocum... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void onPageLoad() {
pageLoaded = true;
reset();
} | #vulnerable code
@Override
public void onPageLoad() {
System.err.println("new page loaded");
pageLoaded = true;
reset();
try {
Thread.sleep(5000);
System.out.println(
"on page load:" + session.getWebInspector().getProtocol().sendCommand(DOM.getDocum... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void persist(File screenshot, JSONObject tree, File dest) throws FileNotFoundException, IOException,
JSONException {
IOUtils.copy(new StringReader(tree.toString(2)), new FileOutputStream(dest), "UTF-8");
} | #vulnerable code
public static void persist(File screenshot, JSONObject tree, File dest)
throws FileNotFoundException, IOException, JSONException {
System.out.println(screenshot.getAbsolutePath());
FileWriter write = new FileWriter(dest);
IOUtils.copy(new StringReader(tr... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void onPageLoad() {
pageLoaded = true;
reset();
} | #vulnerable code
@Override
public void onPageLoad() {
System.err.println("new page loaded");
pageLoaded = true;
reset();
try {
Thread.sleep(5000);
System.out.println(
"on page load:" + session.getWebInspector().getProtocol().sendCommand(DOM.getDocum... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void setValueNative(String value) throws Exception {
/*WebElement el = getNativeElement();
WorkingMode origin = session.getMode();
try {
session.setMode(WorkingMode.Native);
el.click();
RemoteUIAKeyboard keyboard = (RemoteUIAKeyboard) sessio... | #vulnerable code
public void setValueNative(String value) throws Exception {
UIAElement el = getNativeElement();
WorkingMode origin = session.getMode();
try {
session.setMode(WorkingMode.Native);
UIARect rect = el.getRect();
int x = rect.getX() + rect.getWidt... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private File createTmpScript(String content) throws IOException {
File res=null;
if (DEBUG){
res = new File("/Users/freynaud/Documents/debug.js");
}else {
res = File.createTempFile(FILE_NAME, ".js");
}
Writer writer = new FileWriter(res);
... | #vulnerable code
private File createTmpScript(String content) throws IOException {
File res = File.createTempFile(FILE_NAME, ".js");
BufferedWriter out = new BufferedWriter(new FileWriter(res));
out.write(content);
out.close();
return res;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testTrivialMethod() throws Exception {
Object obj = makeCall("someMethod");
assertEquals(1, obj.getClass().getField("runCounter").get(obj));
checkStats("someMethod", 1, 0, 1);
} | #vulnerable code
@Test
public void testTrivialMethod() throws Exception {
lib.simple("com.jitlogic.zorka.spy.unittest.SomeClass", "someMethod",
"zorka:type=ZorkaStats,name=SomeClass", "stats");
Object obj = TestUtil.instrumentAndInstantiate(spy,
"com.jitlogic.zorka.spy.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean onActivate(Item item, Player player) {
if (player == null) {
return false;
}
double rotation = (player.yaw - 90) % 360;
if (rotation < 0) {
rotation += 360.0;
}
int[][] face... | #vulnerable code
@Override
public boolean onActivate(Item item, Player player) {
int[] faces = new int[]{3, 0, 1, 2};
this.meta = (faces[(player != null) ? player.getDirection() : 0] & 0x03) | ((~this.meta) & 0x04);
this.getLevel().setBlock(this, this, true);... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void openSession(String identifier, String address, int port, long clientID) {
PlayerCreationEvent ev = new PlayerCreationEvent(this, Player.class, Player.class, null, address, port);
this.server.getPluginManager().callEvent(ev);
C... | #vulnerable code
@Override
public void openSession(String identifier, String address, int port, long clientID) {
PlayerCreationEvent ev = new PlayerCreationEvent(this, Player.class, Player.class, null, address, port);
this.server.getPluginManager().callEvent(ev);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean getDataFlag(int propertyId, int id) {
return ((this.getDataPropertyByte(propertyId).data & 0xff) & (1 << id)) > 0;
} | #vulnerable code
public boolean getDataFlag(int propertyId, int id) {
return ((this.getDataPropertyByte(propertyId) == null ? 0 : this.getDataPropertyByte(propertyId).data & 0xff) & (1 << id)) > 0;
}
#location 2
#vuln... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(Workbook wb = StreamingReader.builder().open(f)) {
for(Row row : wb.getSheetAt(0)) ... | #vulnerable code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(StreamingReader reader = StreamingReader.builder().read(f)) {
for(Row row : r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(Workbook wb = StreamingReader.builder().open(f)) {
for(Row row : wb.getSheetAt(0)) ... | #vulnerable code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(StreamingReader reader = StreamingReader.builder().read(f)) {
for(Row row : r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(Workbook wb = StreamingReader.builder().open(f)) {
for(Row row : wb.getSheetAt(0)) ... | #vulnerable code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(StreamingReader reader = StreamingReader.builder().read(f)) {
for(Row row : r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(Workbook wb = StreamingReader.builder().open(f)) {
for(Row row : wb.getSheetAt(0)) ... | #vulnerable code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(StreamingReader reader = StreamingReader.builder().read(f)) {
for(Row row : r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(Workbook wb = StreamingReader.builder().open(f)) {
for(Row row : wb.getSheetAt(0)) ... | #vulnerable code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(StreamingReader reader = StreamingReader.builder().read(f)) {
for(Row row : r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(Workbook wb = StreamingReader.builder().open(f)) {
for(Row row : wb.getSheetAt(0)) ... | #vulnerable code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(StreamingReader reader = StreamingReader.builder().read(f)) {
for(Row row : r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(Workbook wb = StreamingReader.builder().open(f)) {
for(Row row : wb.getSheetAt(0)) ... | #vulnerable code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(StreamingReader reader = StreamingReader.builder().read(f)) {
for(Row row : r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(Workbook wb = StreamingReader.builder().open(f)) {
for(Row row : wb.getSheetAt(0)) ... | #vulnerable code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(StreamingReader reader = StreamingReader.builder().read(f)) {
for(Row row : r... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(Workbook wb = StreamingReader.builder().open(f)) {
for(Row row : wb.getSheetAt(0)) ... | #vulnerable code
@Test
public void testSpecialStyles() throws Exception {
File f = new File("src/test/resources/special_types.xlsx");
Map<Integer, List<Cell>> contents = new HashMap<>();
try(StreamingReader reader = StreamingReader.builder().read(f)) {
for(Row row : r... | Below is the vulnerable code, please generate the patch based on the following information. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.