instruction stringclasses 1
value | output stringlengths 64 69.4k | input stringlengths 205 32.4k |
|---|---|---|
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
private static void extractLibrary(File librarySystemPath, InputStream input) throws IOException {
if (input != null) {
try (FileOutputStream output = new FileOutputStream(librarySystemPath)) {
byte[] buffer = new byte[4096];
while (true) {
int length = input.r... | #vulnerable code
private static void extractLibrary(File librarySystemPath, InputStream input) throws IOException {
if (input != null) {
try {
FileOutputStream output = new FileOutputStream(librarySystemPath);
byte[] buffer = new byte[4096];
while (true) {
int length ... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
protected void processInput(String input) throws SteamException {
if (input.equals("stats request")) {
userStats.requestCurrentStats();
} else if (input.equals("stats store")) {
userStats.storeStats();
} else if (input.startsWith("achievement set ")) {
... | #vulnerable code
@Override
protected void processInput(String input) throws SteamException {
if (input.equals("stats request")) {
userStats.requestCurrentStats();
} else if (input.equals("stats store")) {
userStats.storeStats();
} else if (input.equals("file list")) {
int ... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
private void incrementalCompile( Set<Object> drivers )
{
for( Object driver: drivers )
{
//noinspection unchecked
Set<IFile> files = ((Collection<File>)ReflectUtil.method( driver, "getResourceFiles" ).invoke() ).stream().map( (File f) -> ManifoldHost.getFi... | #vulnerable code
private void incrementalCompile( Set<Object> drivers )
{
JavacElements elementUtils = JavacElements.instance( _tp.getContext() );
for( Object driver: drivers )
{
//noinspection unchecked
Set<IFile> files = ((Collection<File>)ReflectUtil.method( d... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@SuppressWarnings("WeakerAccess")
public String findTopLevelFqn( String fqn )
{
FqnCache<LocklessLazyVar<M>> fqnCache = _fqnToModel.get();
if( fqnCache.isEmpty() )
{
return null;
}
while( true )
{
LocklessLazyVar<M> lazyModel = fqnCache.... | #vulnerable code
@SuppressWarnings("WeakerAccess")
public String findTopLevelFqn( String fqn )
{
while( true )
{
LocklessLazyVar<M> lazyModel = _fqnToModel.get().get( fqn );
if( lazyModel != null )
{
return fqn;
}
int iDot = fqn.lastIndexO... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
public Collection<String> getAllTypeNames()
{
FqnCache<LocklessLazyVar<M>> fqnCache = _fqnToModel.get();
if( fqnCache.isEmpty() )
{
return Collections.emptySet();
}
return fqnCache.getFqns();
} | #vulnerable code
@Override
public Collection<String> getAllTypeNames()
{
return _fqnToModel.get().getFqns();
}
#location 4
#vulnerability type NULL_DEREFERENCE |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
private static boolean hasCallHandlerMethod( Class rootClass )
{
if( ICallHandler.class.isAssignableFrom( rootClass ) )
{
// Nominally implements ICallHandler
return true;
}
if( ReflectUtil.method( rootClass, "call", Class.class, String.class, Stri... | #vulnerable code
private static boolean hasCallHandlerMethod( Class rootClass )
{
String fqn = rootClass.getCanonicalName();
BasicJavacTask javacTask = RuntimeManifoldHost.get().getJavaParser().getJavacTask();
Pair<Symbol.ClassSymbol, JCTree.JCCompilationUnit> classSymbol = ... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
public boolean isTopLevelType( String fqn )
{
FqnCache<LocklessLazyVar<M>> fqnCache = _fqnToModel.get();
if( fqnCache.isEmpty() )
{
return false;
}
return fqnCache.get( fqn ) != null;
} | #vulnerable code
@Override
public boolean isTopLevelType( String fqn )
{
return _fqnToModel.get().get( fqn ) != null;
}
#location 4
#vulnerability type NULL_DEREFERENCE |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public Tree getParent( Tree node )
{
return _parents.getParent( node );
} | #vulnerable code
public Tree getParent( Tree node )
{
TreePath2 path = TreePath2.getPath( getCompilationUnit(), node );
if( path == null )
{
// null is indiciative of Generation phase where trees are no longer attached to symobls so the comp unit is detached
// u... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public Rune getDataRune(int id) throws RiotApiException {
return StaticDataMethod.getDataRune(getRegion(), getKey(), id, null, null, (RuneData) null);
} | #vulnerable code
public Rune getDataRune(int id) throws RiotApiException {
return StaticDataMethod.getDataRune(getRegion(), getKey(), id, null, null, null);
}
#location 3
#vulnerability type NULL_DEREFERENCE |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public dto.Static.Champion getDataChampion(Region region, int id) throws RiotApiException {
return StaticDataMethod.getDataChampion(region.getName(), getKey(), id, null, null, false, (ChampData) null);
} | #vulnerable code
public dto.Static.Champion getDataChampion(Region region, int id) throws RiotApiException {
return StaticDataMethod.getDataChampion(region.getName(), getKey(), id, null, null, false, null);
}
#location 3
... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public ItemList getDataItemList(Region region) throws RiotApiException {
return StaticDataMethod.getDataItemList(region.getName(), getKey(), null, null, (ItemListData) null);
} | #vulnerable code
public ItemList getDataItemList(Region region) throws RiotApiException {
return StaticDataMethod.getDataItemList(region.getName(), getKey(), null, null, null);
}
#location 3
#vulnerability type NULL_... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public ChampionList getDataChampionList(Region region) throws RiotApiException {
return StaticDataMethod.getDataChampionList(region.getName(), getKey(), null, null, false, (ChampData) null);
} | #vulnerable code
public ChampionList getDataChampionList(Region region) throws RiotApiException {
return StaticDataMethod.getDataChampionList(region.getName(), getKey(), null, null, false, null);
}
#location 3
#vulne... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public Rune getDataRune(Region region, int id) throws RiotApiException {
return StaticDataMethod.getDataRune(region.getName(), getKey(), id, null, null, (RuneData) null);
} | #vulnerable code
public Rune getDataRune(Region region, int id) throws RiotApiException {
return StaticDataMethod.getDataRune(region.getName(), getKey(), id, null, null, null);
}
#location 3
#vulnerability type NULL_... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
public boolean cancel() {
synchronized (signal) {
boolean cancelled = super.cancel();
if (!cancelled) {
return false;
}
signal.notifyAll();
// Try to force-quit the connection
if (connection != null) {
setTimeout(1);
connection.disconne... | #vulnerable code
@Override
public boolean cancel() {
boolean cancelled = super.cancel();
if (!cancelled) {
return false;
}
synchronized (signal) {
signal.notifyAll();
}
// Try to force-quit the connection
if (connection != null) {
setTimeout(1);
connection.discon... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public void await(long timeout, TimeUnit unit, boolean cancelOnTimeout) throws InterruptedException, TimeoutException {
final long end = System.currentTimeMillis() + unit.toMillis(timeout);
if (!isDone() && System.currentTimeMillis() < end) {
synchronized (signal) {
w... | #vulnerable code
public void await(long timeout, TimeUnit unit, boolean cancelOnTimeout) throws InterruptedException, TimeoutException {
final long end = System.currentTimeMillis() + unit.toMillis(timeout);
while (!isDone() && System.currentTimeMillis() < end) {
synchronized (signal... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public RuneList getDataRuneList() throws RiotApiException {
return StaticDataMethod.getDataRuneList(getRegion(), getKey(), null, null, (RuneListData) null);
} | #vulnerable code
public RuneList getDataRuneList() throws RiotApiException {
return StaticDataMethod.getDataRuneList(getRegion(), getKey(), null, null, null);
}
#location 3
#vulnerability type NULL_DEREFERENCE |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public SummonerSpellList getDataSummonerSpellList() throws RiotApiException {
return StaticDataMethod.getDataSummonerSpellList(getRegion(), getKey(), null, null, false, (SpellData) null);
} | #vulnerable code
public SummonerSpellList getDataSummonerSpellList() throws RiotApiException {
return StaticDataMethod.getDataSummonerSpellList(getRegion(), getKey(), null, null, false, null);
}
#location 3
#vulnerab... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
public boolean cancel() {
synchronized (signal) {
boolean cancelled = super.cancel();
if (!cancelled) {
return false;
}
signal.notifyAll();
// Try to force-quit the connection
if (connection != null) {
setTimeout(1);
connection.disconne... | #vulnerable code
@Override
public boolean cancel() {
boolean cancelled = super.cancel();
if (!cancelled) {
return false;
}
synchronized (signal) {
signal.notifyAll();
}
// Try to force-quit the connection
if (connection != null) {
setTimeout(1);
connection.discon... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public MasteryList getDataMasteryList(Region region) throws RiotApiException {
return StaticDataMethod.getDataMasteryList(region.getName(), getKey(), null, null, (MasteryListData) null);
} | #vulnerable code
public MasteryList getDataMasteryList(Region region) throws RiotApiException {
return StaticDataMethod.getDataMasteryList(region.getName(), getKey(), null, null, null);
}
#location 3
#vulnerability t... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
protected void init(ApiConfig config, ApiMethod method) {
this.config = config;
this.method = method;
} | #vulnerable code
protected void init(ApiConfig config, ApiMethod method) {
this.config = config;
this.method = method;
setTimeout();
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public <T> T getDto(Class<T> desiredDto) throws RiotApiException, RateLimitException {
requireSucceededRequestState();
if (responseCode == CODE_SUCCESS_NOCONTENT) {
// The Riot Api is fine with the request, and explicitly sends no content
return null;
}
T dto = nul... | #vulnerable code
public <T> T getDto(Class<T> desiredDto) throws RiotApiException, RateLimitException {
if (!response.isSuccessful()) {
// I think we can never get here. Let's make sure though
throw new RiotApiException(RiotApiException.IOEXCEPTION);
}
if (response.getCode() ==... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public Item getDataItem(Region region, int id) throws RiotApiException {
return StaticDataMethod.getDataItem(region.getName(), getKey(), id, null, null, (ItemData) null);
} | #vulnerable code
public Item getDataItem(Region region, int id) throws RiotApiException {
return StaticDataMethod.getDataItem(region.getName(), getKey(), id, null, null, null);
}
#location 3
#vulnerability type NULL_... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public int getResponseCode() {
requireSucceededRequestState();
return responseCode;
} | #vulnerable code
public int getResponseCode() {
if (response == null) {
throw new IllegalStateException("The request must first be executed");
}
return response.getCode();
}
#location 5
#vulnerability type THREAD_SAFETY_VI... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public MasteryList getDataMasteryList() throws RiotApiException {
return StaticDataMethod.getDataMasteryList(getRegion(), getKey(), null, null, (MasteryListData) null);
} | #vulnerable code
public MasteryList getDataMasteryList() throws RiotApiException {
return StaticDataMethod.getDataMasteryList(getRegion(), getKey(), null, null, null);
}
#location 3
#vulnerability type NULL_DEREFEREN... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void testJoinString() throws RiotApiException {
// Valid Usage for Strings
assertEquals("abc", Convert.joinString(",", "abc"));
assertEquals("abc,def,ghi", Convert.joinString(",", "abc", "def", "ghi"));
// Valid Usage for other objects
assertEquals("RANKE... | #vulnerable code
@Test
public void testJoinString() throws RiotApiException {
// Valid Usage
assertEquals("abc", Convert.joinString(",", "abc"));
assertEquals("abc,def,ghi", Convert.joinString(",", "abc", "def", "ghi"));
// NullPointerException
thrown.expect(NullPointerException... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public RuneList getDataRuneList(Region region) throws RiotApiException {
return StaticDataMethod.getDataRuneList(region.getName(), getKey(), null, null, (RuneListData) null);
} | #vulnerable code
public RuneList getDataRuneList(Region region) throws RiotApiException {
return StaticDataMethod.getDataRuneList(region.getName(), getKey(), null, null, null);
}
#location 3
#vulnerability type NULL_... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
protected boolean setState(RequestState state) {
boolean success = super.setState(state);
if (!success) {
return false;
}
if (!listeners.isEmpty()) {
if (state == RequestState.Succeeded) {
for (RequestListener listener : listeners) {
listener.on... | #vulnerable code
@Override
protected boolean setState(RequestState state) {
boolean success = super.setState(state);
if (!success) {
return false;
}
if (listener != null) {
if (state == RequestState.Succeeded) {
listener.onRequestSucceeded(this);
} else if (state == R... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public SummonerSpell getDataSummonerSpell(int id) throws RiotApiException {
return StaticDataMethod.getDataSummonerSpell(getRegion(), getKey(), id, null, null, (SpellData) null);
} | #vulnerable code
public SummonerSpell getDataSummonerSpell(int id) throws RiotApiException {
return StaticDataMethod.getDataSummonerSpell(getRegion(), getKey(), id, null, null, null);
}
#location 3
#vulnerability typ... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public Mastery getDataMastery(Region region, int id) throws RiotApiException {
return StaticDataMethod.getDataMastery(region.getName(), getKey(), id, null, null, (MasteryData) null);
} | #vulnerable code
public Mastery getDataMastery(Region region, int id) throws RiotApiException {
return StaticDataMethod.getDataMastery(region.getName(), getKey(), id, null, null, null);
}
#location 3
#vulnerability t... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public SummonerSpell getDataSummonerSpell(Region region, int id) throws RiotApiException {
return StaticDataMethod.getDataSummonerSpell(region.getName(), getKey(), id, null, null, (SpellData) null);
} | #vulnerable code
public SummonerSpell getDataSummonerSpell(Region region, int id) throws RiotApiException {
return StaticDataMethod.getDataSummonerSpell(region.getName(), getKey(), id, null, null, null);
}
#location 3
... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public ChampionList getDataChampionList() throws RiotApiException {
return StaticDataMethod.getDataChampionList(getRegion(), getKey(), null, null, false, (ChampData) null);
} | #vulnerable code
public ChampionList getDataChampionList() throws RiotApiException {
return StaticDataMethod.getDataChampionList(getRegion(), getKey(), null, null, false, null);
}
#location 3
#vulnerability type NULL... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
protected static CharSequence encodeUriQuery(CharSequence in) {
//Note that I can't simply use URI.java to encode because it will escape pre-existing escaped things.
StringBuilder outBuf = null;
Formatter formatter = null;
for(int i = 0; i < in.length(); i++) {
... | #vulnerable code
protected static CharSequence encodeUriQuery(CharSequence in) {
//Note that I can't simply use URI.java to encode because it will escape pre-existing escaped things.
StringBuilder outBuf = null;
Formatter formatter = null;
for(int i = 0; i < in.length(); i... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
protected void changeRole(Role new_role) {
final RaftImpl new_impl=new_role == Role.Follower? new Follower(this) : new_role == Role.Candidate? new Candidate(this) : new Leader(this);
withLockDo(impl_lock, new Callable<Void>() {
public Void call() t... | #vulnerable code
protected void changeRole(Role new_role) {
RaftImpl new_impl=null;
switch(new_role) {
case Follower:
new_impl=new Follower(this);
break;
case Candidate:
new_impl=new Follower(this);
... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
private static String readResource(final String name) {
final StringBuilder ret = new StringBuilder();
InputStream is = null;
InputStreamReader reader = null;
try {
is = UrlRegularExpressions.class.getClassLoader().getResourceAsStre... | #vulnerable code
private static String readResource(final String name) {
final StringBuilder ret = new StringBuilder();
InputStream is = null;
try {
is = UrlRegularExpressions.class.getClassLoader().getResourceAsStream(name);
final InputSt... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public static ClassName get(Class<?> clazz) {
checkNotNull(clazz, "clazz == null");
checkArgument(!clazz.isPrimitive(), "primitive types cannot be represented as a ClassName");
checkArgument(!void.class.equals(clazz), "'void' type cannot be represented as a ClassNam... | #vulnerable code
public static ClassName get(Class<?> clazz) {
checkNotNull(clazz, "clazz == null");
checkArgument(!clazz.isPrimitive(), "primitive types cannot be represented as a ClassName");
checkArgument(!void.class.equals(clazz), "'void' type cannot be represented as a Cl... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
protected void populateJMeterDirectoryTree() throws MojoExecutionException {
for (Artifact artifact : pluginArtifacts) {
try {
if (artifact.getArtifactId().startsWith("ApacheJMeter_")) {
if (artifact.getArtifactId().startsWith("ApacheJMeter_config")) {
JarFil... | #vulnerable code
protected void populateJMeterDirectoryTree() throws MojoExecutionException {
for (Artifact artifact : pluginArtifacts) {
try {
if (artifact.getArtifactId().startsWith("ApacheJMeter_")) {
if (artifact.getArtifactId().startsWith("ApacheJMeter_config")) {
... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
public int blockSize() {
return blockSize;
} | #vulnerable code
@Override
public int blockSize() {
return BLOCK_SIZE;
}
#location 3
#vulnerability type THREAD_SAFETY_VIOLATION |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
static void setBlockSize(int blockSize) {
synchronized (BlocksPool.class) { // can be easily changed to lock-free
instance = new BlocksPool(blockSize);
}
} | #vulnerable code
static void setBlockSize(int blockSize) {
BLOCK_SIZE = blockSize;
synchronized (BlocksPool.class) { // can be easily changed to lock-free
instance = new BlocksPool();
}
}
#location 2
... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
InternalOakMap(K minKey,
OakSerializer<K> keySerializer,
OakSerializer<V> valueSerializer,
OakComparator<K> oakComparator,
MemoryManager memoryManager,
int chunkMaxItems) {
... | #vulnerable code
Result<V> putIfAbsent(K key, V value, Function<ByteBuffer, V> transformer) {
if (key == null || value == null) {
throw new NullPointerException();
}
Chunk<K, V> c = findChunk(key); // find chunk matching key
Chunk.LookUp look... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void testUnsafeCopy() {
IntHolder minKey = new IntHolder(0, new int[0]);
OakMapBuilder<IntHolder, IntHolder> builder =
new OakMapBuilder<IntHolder, IntHolder>(
new UnsafeTestComparator(),
new Unsaf... | #vulnerable code
@Test
public void testUnsafeCopy() {
IntHolder minKey = new IntHolder(0, new int[0]);
OakMapBuilder<IntHolder, IntHolder> builder =
new OakMapBuilder<IntHolder, IntHolder>(
new UnsafeTestComparator(),new UnsafeTestSerial... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
XSSFUnmarshaller(PoijiOptions options) {
this.options = options;
} | #vulnerable code
<T> void unmarshal0(Class<T> type, Consumer<? super T> consumer, OPCPackage open) throws IOException, SAXException, OpenXML4JException {
//ISSUE #55
XSSFWorkbook wb = new XSSFWorkbook(open);
Workbook workbook = new SXSSFWorkbook(wb);
//w... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public static ZipInputStream createZipInputStream(ZipModel zipModel, FileHeader fileHeader, char[] password)
throws IOException {
SplitInputStream splitInputStream = null;
try {
splitInputStream = new SplitInputStream(zipModel.getZipFile(), zipModel.isSplit... | #vulnerable code
public static ZipInputStream createZipInputStream(ZipModel zipModel, FileHeader fileHeader, char[] password)
throws ZipException {
try {
SplitInputStream splitInputStream = new SplitInputStream(zipModel.getZipFile(), zipModel.isSplitArchive(),
zi... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
private ZipInputStream prepareZipInputStream() throws ZipException {
try {
splitInputStream = new SplitInputStream(getZipModel().getZipFile(),
getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk());
FileH... | #vulnerable code
private ZipInputStream prepareZipInputStream() throws ZipException {
try {
SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(),
getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfTh... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
private ZipInputStream prepareZipInputStream() throws ZipException {
try {
splitInputStream = new SplitInputStream(getZipModel().getZipFile(),
getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk());
FileH... | #vulnerable code
private ZipInputStream prepareZipInputStream() throws ZipException {
try {
SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(),
getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfTh... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
private ZipInputStream prepareZipInputStream() throws ZipException {
try {
splitInputStream = new SplitInputStream(getZipModel().getZipFile(),
getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk());
FileH... | #vulnerable code
private ZipInputStream prepareZipInputStream() throws ZipException {
try {
SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(),
getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfTh... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public static ZipInputStream createZipInputStream(ZipModel zipModel, FileHeader fileHeader, char[] password)
throws IOException {
SplitInputStream splitInputStream = null;
try {
splitInputStream = new SplitInputStream(zipModel.getZipFile(), zipModel.isSplit... | #vulnerable code
public static ZipInputStream createZipInputStream(ZipModel zipModel, FileHeader fileHeader, char[] password)
throws ZipException {
try {
SplitInputStream splitInputStream = new SplitInputStream(zipModel.getZipFile(), zipModel.isSplitArchive(),
zi... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public static void setFileAttributes(Path file, byte[] fileAttributes) {
if (fileAttributes == null || fileAttributes.length == 0) {
return;
}
if (isWindows()) {
applyWindowsFileAttributes(file, fileAttributes);
} else if (isMac() || isUnix()) {
... | #vulnerable code
public static void setFileAttributes(Path file, byte[] fileAttributes) {
if (fileAttributes == null || fileAttributes.length == 0) {
return;
}
String os = System.getProperty("os.name").toLowerCase();
if (isWindows(os)) {
applyWindowsFileAttrib... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
protected ZipInputStream createZipInputStream(FileHeader fileHeader) throws IOException {
splitInputStream = new SplitInputStream(getZipModel().getZipFile(),
getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk());
s... | #vulnerable code
protected ZipInputStream createZipInputStream(FileHeader fileHeader) throws IOException {
SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(),
getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNum... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void clientToServerBackpressure() throws InterruptedException {
ReactorNumbersGrpc.ReactorNumbersStub stub = ReactorNumbersGrpc.newReactorStub(channel);
Flux<NumberProto.Number> reactorRequest = Flux
.fromIterable(IntStream.ra... | #vulnerable code
@Test
public void clientToServerBackpressure() throws InterruptedException {
Object lock = new Object();
ReactorNumbersGrpc.ReactorNumbersStub stub = ReactorNumbersGrpc.newReactorStub(channel);
BackpressureDetector clientBackpressureDetector... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void serverToClientBackpressure() throws InterruptedException {
RxNumbersGrpc.RxNumbersStub stub = RxNumbersGrpc.newRxStub(channel);
Single<Empty> rxRequest = Single.just(Empty.getDefaultInstance());
TestSubscriber<NumberProto.Number... | #vulnerable code
@Test
public void serverToClientBackpressure() throws InterruptedException {
Object lock = new Object();
BackpressureDetector clientBackpressureDetector = new BackpressureDetector(madMultipleCutoff);
RxNumbersGrpc.RxNumbersStub stub = RxNumb... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
public void run() {
final Set<String> artifacts = new HashSet<>();
installNodeModules(artifacts);
final File base = new File(cwd, "node_modules");
final File libs = new File(base, ".lib");
if (force || libs.exists()) {
final double versio... | #vulnerable code
@Override
public void run() {
final Set<String> artifacts = new HashSet<>();
installNodeModules(artifacts);
final File base = new File(cwd, "node_modules");
final File libs = new File(base, ".lib");
if (force || libs.exists()) {
final double ... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public String injectVersion(String resourcePath) {
String version = getResourceVersion(resourcePath);
if (StringUtils.isNullOrEmpty(version)) {
// unversioned, pass-through resource path
return resourcePath;
}
// check ... | #vulnerable code
public String injectVersion(String resourcePath) {
URL resourceUrl = getResourceUrl(resourcePath);
try {
long lastModified = resourceUrl.openConnection().getLastModified();
// check for extension
int extensionAt = res... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@BeforeClass
public static void setUpClass() throws IOException {
MemcachedStarter runtime = MemcachedStarter.getDefaultInstance();
memcachedExe = runtime.prepare(
new MemcachedConfig(Version.Main.PRODUCTION, PORT));
memcached = mem... | #vulnerable code
@BeforeClass
public static void setUpClass() {
application = new Application();
client = XmemcachedFactory.create(application.getPippoSettings());
}
#location 4
#vulnerability type NULL_DE... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public TemplateEngine getTemplateEngine() {
return templateEngine;
} | #vulnerable code
public TemplateEngine getTemplateEngine() {
if (templateEngine == null) {
TemplateEngine engine = ServiceLocator.locate(TemplateEngine.class);
setTemplateEngine(engine);
}
return templateEngine;
}
... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void classpathResourceHandlerTest() throws URISyntaxException {
ClasspathResourceHandler handler = new ClasspathResourceHandler("/", "/public");
URL resourceUrl = handler.getResourceUrl("VISIBLE");
assertNotNull(resourceUrl);
... | #vulnerable code
@Test
public void classpathResourceHandlerTest() throws URISyntaxException {
ClasspathResourceHandler handler = new ClasspathResourceHandler("/", "/public");
URL resourceUrl = handler.getResourceUrl("VISIBLE");
assertNotNull(resourceUrl);
... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
String buildRealData(final ConditionZkDTO condition, final ServerWebExchange exchange) {
String realData = "";
if (condition.getParamType().equals(ParamTypeEnum.QUERY.getName())) {
final MultiValueMap<String, String> queryParams = exchange.getReque... | #vulnerable code
String buildRealData(final ConditionZkDTO condition, final ServerWebExchange exchange) {
String realData = "";
if (condition.getParamType().equals(ParamTypeEnum.QUERY.getName())) {
final MultiValueMap<String, String> queryParams = exchange.ge... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void agentLoads() throws IOException, InterruptedException {
// If not starting the testcase via Maven, set the buildDirectory and finalName system properties manually.
final String buildDirectory = (String) System.getProperties().get("buildDi... | #vulnerable code
@Test
public void agentLoads() throws IOException, InterruptedException {
// If not starting the testcase via Maven, set the buildDirectory and finalName system properties manually.
final String buildDirectory = (String) System.getProperties().get("b... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public static void main(String[] args) throws Exception {
if (args.length < 2) {
System.err.println("Usage: WebServer <port> <yaml configuration file>");
System.exit(1);
}
JmxCollector jc = new JmxCollector(new File(args[1])).register();
int ... | #vulnerable code
public static void main(String[] args) throws Exception {
if (args.length < 2) {
System.err.println("Usage: WebServer <port> <yaml configuration file>");
System.exit(1);
}
JmxCollector jc = new JmxCollector(new FileReader(args[1])).register()... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void agentLoads() throws IOException, InterruptedException {
// If not starting the testcase via Maven, set the buildDirectory and finalName system properties manually.
final String buildDirectory = (String) System.getProperties().get("buildDi... | #vulnerable code
@Test
public void agentLoads() throws IOException, InterruptedException {
// If not starting the testcase via Maven, set the buildDirectory and finalName system properties manually.
final String buildDirectory = (String) System.getProperties().get("b... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception {
String[] args = agentArgument.split(":");
if (args.length < 2 || args.length > 3) {
System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<port>:... | #vulnerable code
public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception {
String[] args = agentArgument.split(":");
if (args.length < 2 || args.length > 3) {
System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception {
String[] args = agentArgument.split(":");
if (args.length < 2 || args.length > 3) {
System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<port>:... | #vulnerable code
public static void premain(String agentArgument, Instrumentation instrumentation) throws Exception {
String[] args = agentArgument.split(":");
if (args.length < 2 || args.length > 3) {
System.err.println("Usage: -javaagent:/path/to/JavaAgent.jar=[host:]<... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@BeforeClass
public static void beforeClass() {
File[] traceFiles = customFileLog("").listFiles();
if (traceFiles == null) {
return;
}
for (File file : traceFiles) {
if (file.getPath().contains("tracer-self.log") || ... | #vulnerable code
@BeforeClass
public static void beforeClass() {
for (File file : customFileLog("").listFiles()) {
if (file.getPath().contains("tracer-self.log") || file.getPath().contains("sync.log")
|| file.getPath().contains("rpc-profile.log")
... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public GraphEdge<V,E> connect(V v1, V v2, E value){
// Check non-null arguments
if(v1 == null || v2 == null) throw new IllegalArgumentException("Vertices cannot be null");
// Ensure that the vertices are in the graph
add(v1);
add(v2);
... | #vulnerable code
public GraphEdge<V,E> connect(V v1, V v2, E value){
//check input
if(v1 == null || v2 == null) throw new IllegalArgumentException("Vertices cannot be null");
GraphEdge<V,E> edge = new GraphEdge<V, E>(v1, v2, value);
GraphEdge<V,E> edgeRev... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void test() {
String[] testMaze = {
"XX@XXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"XX XXXXXXXXXXXXX XXXXXXXXXXX",
"XX XXXXXXXXXX XXX XX XXXX",
"XXXXX XXXXXX XXX XX XXX XXXX",
"XXX XX XXX... | #vulnerable code
@Test
public void test() {
String[] testMaze = {
"XX@XXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"XX XXXXXXXXXXXXX XXXXXXXXXXX",
"XX XXXXXXXXXX XXX XX XXXX",
"XXXXX XXXXXX XXX XX XXX XXXX",
"XXX ... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public GraphEdge<V,E> connect(V v1, V v2, E value){
// Check non-null arguments
if(v1 == null || v2 == null) throw new IllegalArgumentException("Vertices cannot be null");
// Ensure that the vertices are in the graph
add(v1);
add(v2);
... | #vulnerable code
public GraphEdge<V,E> connect(V v1, V v2, E value){
//check input
if(v1 == null || v2 == null) throw new IllegalArgumentException("Vertices cannot be null");
GraphEdge<V,E> edge = new GraphEdge<V, E>(v1, v2, value);
GraphEdge<V,E> edgeRev... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void testRestartAuditorBookieAfterCrashing() throws Exception {
BookieServer auditor = verifyAuditor();
shudownBookie(auditor);
// restarting Bookie with same configurations.
int indexOfDownBookie = bs.indexOf(auditor);
... | #vulnerable code
@Test
public void testRestartAuditorBookieAfterCrashing() throws Exception {
BookieServer auditor = verifyAuditor();
shudownBookie(auditor);
// restarting Bookie with same configurations.
int indexOfDownBookie = bs.indexOf(auditor);... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public void handleSubscribeMessage(PubSubResponse response) {
if (logger.isDebugEnabled()) {
logger.debug("Handling a Subscribe message in response: {}, topic: {}, subscriberId: {}",
new Object[] { response, getOrigSubData().topic.toStr... | #vulnerable code
public void handleSubscribeMessage(PubSubResponse response) {
if (logger.isDebugEnabled())
logger.debug("Handling a Subscribe message in response: " + response + ", topic: "
+ origSubData.topic.toStringUtf8() + ", subscriberI... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public void close() {
closeInternal(true);
} | #vulnerable code
public void close() {
synchronized (this) {
state = ConnectionState.DISCONNECTED;
}
if (channel != null) {
channel.close().awaitUninterruptibly();
}
if (readTimeoutTimer != null) {
readTimeoutTi... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
public byte[] readMasterKey(long ledgerId) throws IOException, BookieException {
synchronized(fileInfoCache) {
FileInfo fi = fileInfoCache.get(ledgerId);
if (fi == null) {
File lf = findIndexFile(ledgerId);
... | #vulnerable code
@Override
public byte[] readMasterKey(long ledgerId) throws IOException, BookieException {
synchronized(fileInfoCache) {
FileInfo fi = fileInfoCache.get(ledgerId);
if (fi == null) {
File lf = findIndexFile(ledgerId);
... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
LOG.info("Disconnected from bookie: " + addr);
errorOutOutstandingEntries();
channel.close();
synchronized (this) {
sta... | #vulnerable code
@Override
public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
LOG.info("Disconnected from bookie: " + addr);
errorOutOutstandingEntries();
channel.close();
state = ConnectionState.DISCONN... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void testReadWriteSyncSingleClient() throws IOException {
try {
// Create a ledger
lh = bkc.createLedger(digestType, ledgerPassword);
// bkc.initMessageDigest("SHA1");
ledgerId = lh.getId();
... | #vulnerable code
@Test
public void testReadWriteSyncSingleClient() throws IOException {
try {
// Create a ledger
lh = bkc.createLedger(digestType, ledgerPassword);
// bkc.initMessageDigest("SHA1");
ledgerId = lh.getId();
... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void testSyncReadAsyncWriteStringsSingleClient() throws IOException {
SyncObj sync = new SyncObj();
LOG.info("TEST READ WRITE STRINGS MIXED SINGLE CLIENT");
String charset = "utf-8";
LOG.debug("Default charset: " + Charset.defa... | #vulnerable code
@Test
public void testSyncReadAsyncWriteStringsSingleClient() throws IOException {
LOG.info("TEST READ WRITE STRINGS MIXED SINGLE CLIENT");
String charset = "utf-8";
LOG.debug("Default charset: " + Charset.defaultCharset());
try {
... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
public void close() {
closeInternal(true);
} | #vulnerable code
public void close() {
synchronized (this) {
state = ConnectionState.DISCONNECTED;
}
if (channel != null) {
channel.close().awaitUninterruptibly();
}
if (readTimeoutTimer != null) {
readTimeoutTi... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) {
SyncObj sync = (SyncObj) ctx;
sync.setLedgerEntries(seq);
sync.setReturnCode(rc);
synchronized (sync) {
sync.value = true;
... | #vulnerable code
@Override
public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) {
if(rc != BKException.Code.OK) fail("Return code is not OK: " + rc);
ls = seq;
synchronized (sync) {
sync.value = true;
... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
public StatsLogger getStatsLogger(String name) {
initIfNecessary();
return new CodahaleStatsLogger(getMetrics(), name);
} | #vulnerable code
@Override
public StatsLogger getStatsLogger(String name) {
initIfNecessary();
return new CodahaleStatsLogger(metrics, name);
}
#location 4
#vulnerability type THREAD_SAFETY_VIOLATION |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
FileInfo getFileInfo(Long ledger, byte masterKey[]) throws IOException {
synchronized(fileInfoCache) {
FileInfo fi = fileInfoCache.get(ledger);
if (fi == null) {
File lf = findIndexFile(ledger);
if (lf == null) {... | #vulnerable code
FileInfo getFileInfo(Long ledger, byte masterKey[]) throws IOException {
synchronized(fileInfoCache) {
FileInfo fi = fileInfoCache.get(ledger);
if (fi == null) {
File lf = findIndexFile(ledger);
if (lf == n... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void testSimpleBookieLedgerMapping() throws Exception {
for (int i = 0; i < numberOfLedgers; i++) {
createAndAddEntriesToLedger().close();
}
BookieLedgerIndexer bookieLedgerIndex = new BookieLedgerIndexer(
... | #vulnerable code
@Test
public void testSimpleBookieLedgerMapping() throws Exception {
LedgerManagerFactory newLedgerManagerFactory = LedgerManagerFactory
.newLedgerManagerFactory(baseConf, zkc);
LedgerManager ledgerManager = newLedgerManagerFactory
... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void testReadWriteZero() throws IOException {
try {
// Create a ledger
lh = bkc.createLedger(digestType, ledgerPassword);
// bkc.initMessageDigest("SHA1");
ledgerId = lh.getId();
LOG.info("Le... | #vulnerable code
@Test
public void testReadWriteZero() throws IOException {
try {
// Create a ledger
lh = bkc.createLedger(digestType, ledgerPassword);
// bkc.initMessageDigest("SHA1");
ledgerId = lh.getId();
LOG.in... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test
public void testGarbageCollectLedgers() throws Exception {
int numLedgers = 100;
int numRemovedLedgers = 10;
final Set<Long> createdLedgers = new HashSet<Long>();
final Set<Long> removedLedgers = new HashSet<Long>();
// crea... | #vulnerable code
@Test
public void testGarbageCollectLedgers() throws Exception {
int numLedgers = 100;
int numRemovedLedgers = 10;
final Set<Long> createdLedgers = new HashSet<Long>();
final Set<Long> removedLedgers = new HashSet<Long>();
/... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
public void start(Configuration conf) {
initIfNecessary();
int metricsOutputFrequency = conf.getInt("codahaleStatsOutputFrequencySeconds", 60);
String prefix = conf.getString("codahaleStatsPrefix", "");
String graphiteHost = conf... | #vulnerable code
@Override
public void start(Configuration conf) {
initIfNecessary();
int metricsOutputFrequency = conf.getInt("codahaleStatsOutputFrequencySeconds", 60);
String prefix = conf.getString("codahaleStatsPrefix", "");
String graphiteHost ... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
protected void doPublish(PubSubData pubSubData, Channel channel) {
// Create a PubSubRequest
PubSubRequest.Builder pubsubRequestBuilder = PubSubRequest.newBuilder();
pubsubRequestBuilder.setProtocolVersion(ProtocolVersion.VERSION_ONE);
pubsubRe... | #vulnerable code
protected void doPublish(PubSubData pubSubData, Channel channel) {
// Create a PubSubRequest
PubSubRequest.Builder pubsubRequestBuilder = PubSubRequest.newBuilder();
pubsubRequestBuilder.setProtocolVersion(ProtocolVersion.VERSION_ONE);
pu... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
private void setLastLogId(File dir, long logId) throws IOException {
FileOutputStream fos;
fos = new FileOutputStream(new File(dir, "lastId"));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
try {
bw.write(Long... | #vulnerable code
private void setLastLogId(File dir, long logId) throws IOException {
FileOutputStream fos;
fos = new FileOutputStream(new File(dir, "lastId"));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
try {
bw.writ... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Override
public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) {
SyncObj x = (SyncObj) ctx;
if (rc != 0) {
LOG.error("Failure during add {}", rc);
x.failureOccurred = true;
}
sy... | #vulnerable code
@Override
public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq, Object ctx) {
if (rc != 0)
fail("Failed to write entry");
ls = seq;
synchronized (sync) {
sync.value = true;
sync.no... |
Below is the vulnerable code, please generate the patch based on the following information. | #fixed code
@Test(timeout=60000)
public void testReadFromOpenLedger() throws Exception {
try {
// Create a ledger
lh = bkc.createLedger(digestType, ledgerPassword);
// bkc.initMessageDigest("SHA1");
ledgerId = lh.getId();
... | #vulnerable code
@Test(timeout=60000)
public void testReadFromOpenLedger() throws IOException {
try {
// Create a ledger
lh = bkc.createLedger(digestType, ledgerPassword);
// bkc.initMessageDigest("SHA1");
ledgerId = lh.getId()... |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 10