input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code private String extractLibrary(String sharedLibName) throws IOException { File nativesPath = new File(System.getProperty("java.io.tmpdir") + "/steamworks4j/" + libraryCrc); File nativeFile = new File(nativesPath, sharedLibName); if (!nativesPath.exists()) { if (!...
#fixed code private String extractLibrary(String sharedLibName) throws IOException { File nativesPath = new File(System.getProperty("java.io.tmpdir") + "/steamworks4j/" + libraryCrc); File nativeFile = new File(nativesPath, sharedLibName); if (!nativesPath.exists()) { if (!native...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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 ")) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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 ")) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void precompile( Map<String, Set<String>> typeNames ) { for( ITypeManifold tm: ManifoldHost.instance().getCurrentModule().getTypeManifolds() ) { for( Map.Entry<String, Set<String>> entry: typeNames.entrySet() ) { String typeManifoldCl...
#fixed code private void precompile( Map<String, Set<String>> typeNames ) { for( ITypeManifold tm: ManifoldHost.instance().getCurrentModule().getTypeManifolds() ) { for( Map.Entry<String, Set<String>> entry: typeNames.entrySet() ) { String typeManifoldClassNam...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Pair<Symbol.ClassSymbol, JCTree.JCCompilationUnit> getClassSymbolForProducedClass( String fqn, BasicJavacTask[] task ) { init(); Pair<JavaFileObject, String> fileObj = JavaParser.instance().findJavaSource( fqn, null ); if( fileObj == null ) { ...
#fixed code private Pair<Symbol.ClassSymbol, JCTree.JCCompilationUnit> getClassSymbolForProducedClass( String fqn, BasicJavacTask[] task ) { StringWriter errors = new StringWriter(); // need javac with ManifoldJavaFileManager because the produced class must come from manifold ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static SrcClass genClass(String fqn, ProgramNode programNode) { ClassNode classNode = programNode.getFirstChild(ClassNode.class); SrcClass clazz = new SrcClass(fqn, SrcClass.Kind.Class); String superClass = classNode.getSuperClass(); i...
#fixed code static SrcClass genClass(String fqn, ProgramNode programNode) { ClassNode classNode = programNode.getFirstChild(ClassNode.class); SrcClass clazz = new SrcClass(fqn, SrcClass.Kind.Class); clazz.addAnnotation( new SrcAnnotationExpression( Sou...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Collection<String> getAllTypeNames() { return _fqnToModel.get().getFqns(); } #location 4 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public Collection<String> getAllTypeNames() { FqnCache<LocklessLazyVar<M>> fqnCache = _fqnToModel.get(); if( fqnCache.isEmpty() ) { return Collections.emptySet(); } return fqnCache.getFqns(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static boolean hasCallHandlerMethod( Class rootClass ) { String fqn = rootClass.getCanonicalName(); BasicJavacTask javacTask = RuntimeManifoldHost.get().getJavaParser().getJavacTask(); Pair<Symbol.ClassSymbol, JCTree.JCCompilationUnit> classSymbol = ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public boolean isTopLevelType( String fqn ) { return _fqnToModel.get().get( fqn ) != null; } #location 4 #vulnerability type NULL_DEREFERENCE
#fixed code @Override public boolean isTopLevelType( String fqn ) { FqnCache<LocklessLazyVar<M>> fqnCache = _fqnToModel.get(); if( fqnCache.isEmpty() ) { return false; } return fqnCache.get( fqn ) != null; }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#fixed code public Tree getParent( Tree node ) { return _parents.getParent( node ); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String getResponseBody() { if (response == null) { throw new IllegalStateException("The request must first be executed"); } if (!response.isSuccessful()) { throw new IllegalStateException("The request threw an exception"); } return response.getBody()...
#fixed code public String getResponseBody() { requireSucceededRequestState(); return responseBody; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Rune getDataRune(int id) throws RiotApiException { return StaticDataMethod.getDataRune(getRegion(), getKey(), id, null, null, null); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code public Rune getDataRune(int id) throws RiotApiException { return StaticDataMethod.getDataRune(getRegion(), getKey(), id, null, null, (RuneData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ItemList getDataItemList(Region region) throws RiotApiException { return StaticDataMethod.getDataItemList(region.getName(), getKey(), null, null, null); } #location 3 #vulnerability type NULL_...
#fixed code public ItemList getDataItemList(Region region) throws RiotApiException { return StaticDataMethod.getDataItemList(region.getName(), getKey(), null, null, (ItemListData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ChampionList getDataChampionList(Region region) throws RiotApiException { return StaticDataMethod.getDataChampionList(region.getName(), getKey(), null, null, false, null); } #location 3 #vulne...
#fixed code public ChampionList getDataChampionList(Region region) throws RiotApiException { return StaticDataMethod.getDataChampionList(region.getName(), getKey(), null, null, false, (ChampData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#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_...
#fixed code public Rune getDataRune(Region region, int id) throws RiotApiException { return StaticDataMethod.getDataRune(region.getName(), getKey(), id, null, null, (RuneData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public dto.Static.Champion getDataChampion(int id) throws RiotApiException { return StaticDataMethod.getDataChampion(getRegion(), getKey(), id, null, null, false, null); } #location 3 #vulnerability ...
#fixed code public dto.Static.Champion getDataChampion(int id) throws RiotApiException { return StaticDataMethod.getDataChampion(getRegion(), getKey(), id, null, null, false, (ChampData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public RuneList getDataRuneList() throws RiotApiException { return StaticDataMethod.getDataRuneList(getRegion(), getKey(), null, null, null); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code public RuneList getDataRuneList() throws RiotApiException { return StaticDataMethod.getDataRuneList(getRegion(), getKey(), null, null, (RuneListData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public SummonerSpellList getDataSummonerSpellList() throws RiotApiException { return StaticDataMethod.getDataSummonerSpellList(getRegion(), getKey(), null, null, false, null); } #location 3 #vulnerab...
#fixed code public SummonerSpellList getDataSummonerSpellList() throws RiotApiException { return StaticDataMethod.getDataSummonerSpellList(getRegion(), getKey(), null, null, false, (SpellData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public MasteryList getDataMasteryList(Region region) throws RiotApiException { return StaticDataMethod.getDataMasteryList(region.getName(), getKey(), null, null, null); } #location 3 #vulnerability t...
#fixed code public MasteryList getDataMasteryList(Region region) throws RiotApiException { return StaticDataMethod.getDataMasteryList(region.getName(), getKey(), null, null, (MasteryListData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void init(ApiConfig config, ApiMethod method) { this.config = config; this.method = method; setTimeout(); } #location 4 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code protected void init(ApiConfig config, ApiMethod method) { this.config = config; this.method = method; }
Below is the vulnerable code, please generate the patch based on the following information.
#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() ==...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Mastery getDataMastery(int id) throws RiotApiException { return StaticDataMethod.getDataMastery(getRegion(), getKey(), id, null, null, null); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code public Mastery getDataMastery(int id) throws RiotApiException { return StaticDataMethod.getDataMastery(getRegion(), getKey(), id, null, null, (MasteryData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#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_...
#fixed code public Item getDataItem(Region region, int id) throws RiotApiException { return StaticDataMethod.getDataItem(region.getName(), getKey(), id, null, null, (ItemData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected boolean setState(RequestState state) { if (isDone()) { return false; } for (RequestListener listener : listeners) { if (state == RequestState.Succeeded) { listener.onRequestSucceeded(this); } else if (state == RequestState.Failed) { ...
#fixed code @Override protected boolean setState(RequestState state) { if (isDone()) { return false; } notifyListeners(state); super.setState(state); if (isDone()) { synchronized (signal) { signal.notifyAll(); } } return true; }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#fixed code public int getResponseCode() { requireSucceededRequestState(); return responseCode; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public MasteryList getDataMasteryList() throws RiotApiException { return StaticDataMethod.getDataMasteryList(getRegion(), getKey(), null, null, null); } #location 3 #vulnerability type NULL_DEREFEREN...
#fixed code public MasteryList getDataMasteryList() throws RiotApiException { return StaticDataMethod.getDataMasteryList(getRegion(), getKey(), null, null, (MasteryListData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public SummonerSpellList getDataSummonerSpellList(Region region) throws RiotApiException { return StaticDataMethod.getDataSummonerSpellList(region.getName(), getKey(), null, null, false, null); } #location 3 ...
#fixed code public SummonerSpellList getDataSummonerSpellList(Region region) throws RiotApiException { return StaticDataMethod.getDataSummonerSpellList(region.getName(), getKey(), null, null, false, (SpellData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public RuneList getDataRuneList(Region region) throws RiotApiException { return StaticDataMethod.getDataRuneList(region.getName(), getKey(), null, null, null); } #location 3 #vulnerability type NULL_...
#fixed code public RuneList getDataRuneList(Region region) throws RiotApiException { return StaticDataMethod.getDataRuneList(region.getName(), getKey(), null, null, (RuneListData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void await() throws InterruptedException { while (!isDone()) { synchronized (signal) { signal.wait(); } } } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public void await() throws InterruptedException { if (!isDone()) { synchronized (signal) { while (!isDone()) { signal.wait(); } } } }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ItemList getDataItemList() throws RiotApiException { return StaticDataMethod.getDataItemList(getRegion(), getKey(), null, null, null); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code public ItemList getDataItemList() throws RiotApiException { return StaticDataMethod.getDataItemList(getRegion(), getKey(), null, null, (ItemListData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public SummonerSpell getDataSummonerSpell(int id) throws RiotApiException { return StaticDataMethod.getDataSummonerSpell(getRegion(), getKey(), id, null, null, null); } #location 3 #vulnerability typ...
#fixed code public SummonerSpell getDataSummonerSpell(int id) throws RiotApiException { return StaticDataMethod.getDataSummonerSpell(getRegion(), getKey(), id, null, null, (SpellData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#fixed code public Mastery getDataMastery(Region region, int id) throws RiotApiException { return StaticDataMethod.getDataMastery(region.getName(), getKey(), id, null, null, (MasteryData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Item getDataItem(int id) throws RiotApiException { return StaticDataMethod.getDataItem(getRegion(), getKey(), id, null, null, null); } #location 3 #vulnerability type NULL_DEREFERENCE
#fixed code public Item getDataItem(int id) throws RiotApiException { return StaticDataMethod.getDataItem(getRegion(), getKey(), id, null, null, (ItemData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void await() throws InterruptedException { if (!isDone()) { synchronized (signal) { while (!isDone()) { signal.wait(); } } } } #location 4 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public void await() throws InterruptedException { while (!isDone()) { synchronized (signal) { signal.wait(); } } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public SummonerSpell getDataSummonerSpell(Region region, int id) throws RiotApiException { return StaticDataMethod.getDataSummonerSpell(region.getName(), getKey(), id, null, null, null); } #location 3 ...
#fixed code public SummonerSpell getDataSummonerSpell(Region region, int id) throws RiotApiException { return StaticDataMethod.getDataSummonerSpell(region.getName(), getKey(), id, null, null, (SpellData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> T getDto(Type 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() == Req...
#fixed code public <T> T getDto(Type 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 = null; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ChampionList getDataChampionList() throws RiotApiException { return StaticDataMethod.getDataChampionList(getRegion(), getKey(), null, null, false, null); } #location 3 #vulnerability type NULL...
#fixed code public ChampionList getDataChampionList() throws RiotApiException { return StaticDataMethod.getDataChampionList(getRegion(), getKey(), null, null, false, (ChampData) null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public RiotApiException getException() { if (!isFailed()) { return null; } return exception; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public RiotApiException getException() { return exception; }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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++) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void initCommitAndTermFromLog() { DBIterator iterator = db.iterator(); try { iterator.seekToLast(); byte[] keyBytes = iterator.peekNext().getKey(); commitIndex = new Integer(asString(keyBytes)); //...
#fixed code private void initCommitAndTermFromLog() throws Exception { DBIterator iterator = db.iterator(); try { iterator.seekToLast(); byte[] keyBytes = iterator.peekNext().getKey(); commitIndex = new Integer(asString(keyBytes)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#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); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void handleEvent(Message msg, RaftHeader hdr) { log.trace("%s: received %s from %s", local_addr, hdr, msg.src()); impl_lock.lock(); try { if(hdr instanceof AppendEntriesRequest) { AppendEntriesRequest req=(Ap...
#fixed code protected void handleEvent(Message msg, RaftHeader hdr) { // log.trace("%s: received %s from %s", local_addr, hdr, msg.src()); impl_lock.lock(); try { if(hdr instanceof AppendEntriesRequest) { AppendEntriesRequest req=(Appen...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static UrlBuilder fromString(final String url, final Charset inputEncoding) { if (url.isEmpty()) { return new UrlBuilder(); } final Matcher m = URI_PATTERN.matcher(url); String protocol = null, hostName = null, path = n...
#fixed code public static UrlBuilder fromString(final String url, final Charset inputEncoding) { if (url.isEmpty()) { return new UrlBuilder(); } final Matcher m = URI_PATTERN.matcher(url); String protocol = null, hostName = null, path = null, a...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void populateJMeterDirectoryTree() throws MojoExecutionException { for (Artifact artifact : pluginArtifacts) { try { if (artifact.getArtifactId().startsWith("ApacheJMeter_")) { if (artifact.getArtifactId().startsWith("ApacheJMeter_config")) { ...
#fixed code protected void populateJMeterDirectoryTree() throws MojoExecutionException { for (Artifact artifact : pluginArtifacts) { try { if (artifact.getArtifactId().startsWith("ApacheJMeter_")) { if (artifact.getArtifactId().startsWith("ApacheJMeter_config")) { JarFil...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void populateJMeterDirectoryTree() throws MojoExecutionException { for (Artifact artifact : pluginArtifacts) { try { if (artifact.getArtifactId().startsWith("ApacheJMeter_")) { if (artifact.getArtifactId().startsWith("ApacheJMeter_config")) { ...
#fixed code protected void populateJMeterDirectoryTree() throws MojoExecutionException { for (Artifact artifact : pluginArtifacts) { try { if (artifact.getArtifactId().startsWith("ApacheJMeter_")) { if (artifact.getArtifactId().startsWith("ApacheJMeter_config")) { JarFil...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public int blockSize() { return BLOCK_SIZE; } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @Override public int blockSize() { return blockSize; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void releaseValue(long newValueReference) { memoryManager.releaseSlice(buildValueSlice(newValueReference)); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code Chunk(ByteBuffer minKey, Chunk<K, V> creator, OakComparator<K> comparator, MemoryManager memoryManager, int maxItems, AtomicInteger externalSize, OakSerializer<K> keySerializer, OakSerializer<V> valueSerializer) { this.memoryManager = memoryManager...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#fixed code static void setBlockSize(int blockSize) { synchronized (BlocksPool.class) { // can be easily changed to lock-free instance = new BlocksPool(blockSize); } }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#fixed code InternalOakMap(K minKey, OakSerializer<K> keySerializer, OakSerializer<V> valueSerializer, OakComparator<K> oakComparator, MemoryManager memoryManager, int chunkMaxItems) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testResizeWithZCGetNewBuffer() { String smallValue = ""; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.setLength((BLOCK_SIZE / Character.BYTES) / 2); String longValue = stringBuilder.toString(); ...
#fixed code @Test public void testResizeWithZCGetNewBuffer() { final int blockSize = BlocksPool.getInstance().blockSize(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.setLength((blockSize / Character.BYTES) / 2); String longValue ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static void setBlockSize(int blockSize) { BLOCK_SIZE = blockSize; synchronized (BlocksPool.class) { // can be easily changed to lock-free instance = new BlocksPool(); } } #location 4 ...
#fixed code static void setBlockSize(int blockSize) { synchronized (BlocksPool.class) { // can be easily changed to lock-free instance = new BlocksPool(blockSize); } }
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#fixed code XSSFUnmarshaller(PoijiOptions options) { this.options = options; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") private static Deserializer deserializer(File file) throws FileNotFoundException { final PoijiStream poiParser = new PoijiStream(fileInputStream(file)); final PoiWorkbook workbook = PoiWorkbook.workbook(Files.getExtensi...
#fixed code @SuppressWarnings("unchecked") private static Deserializer deserializer(File file) throws FileNotFoundException { final PoijiStream poiParser = new PoijiStream(fileInputStream(file)); final PoiWorkbook workbook = PoiWorkbook.workbook(Files.getExtension(fil...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public <T> void unmarshal(Class<T> type, Consumer<? super T> consumer) { HSSFWorkbook workbook = (HSSFWorkbook) workbook(); Optional<String> maybeSheetName = this.getSheetName(type, options); hssfFormulaEvaluator = HSSFFormulaEvalu...
#fixed code @Override public <T> void unmarshal(Class<T> type, Consumer<? super T> consumer) { HSSFWorkbook workbook = (HSSFWorkbook) workbook(); Optional<String> maybeSheetName = this.getSheetName(type, options); baseFormulaEvaluator = HSSFFormulaEvaluator.c...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") private static Deserializer deserializer(File file, PoijiOptions options) throws FileNotFoundException { final PoijiStream poiParser = new PoijiStream(fileInputStream(file)); final PoiWorkbook workbook = PoiWorkbook.wor...
#fixed code @SuppressWarnings("unchecked") private static Deserializer deserializer(File file, PoijiOptions options) { final PoijiStream poiParser = new PoijiStream(file); final PoiWorkbook workbook = PoiWorkbook.workbook(Files.getExtension(file.getName()), poiParser)...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static ZipInputStream createZipInputStream(ZipModel zipModel, FileHeader fileHeader, char[] password) throws ZipException { try { SplitInputStream splitInputStream = new SplitInputStream(zipModel.getZipFile(), zipModel.isSplitArchive(), zi...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private ZipInputStream prepareZipInputStream() throws ZipException { try { SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfTh...
#fixed code private ZipInputStream prepareZipInputStream() throws ZipException { try { splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk()); FileH...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private ZipInputStream prepareZipInputStream() throws ZipException { try { SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfTh...
#fixed code private ZipInputStream prepareZipInputStream() throws ZipException { try { splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk()); FileH...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private ZipInputStream prepareZipInputStream() throws ZipException { try { SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfTh...
#fixed code private ZipInputStream prepareZipInputStream() throws ZipException { try { splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk()); FileH...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static ZipInputStream createZipInputStream(ZipModel zipModel, FileHeader fileHeader, char[] password) throws ZipException { try { SplitInputStream splitInputStream = new SplitInputStream(zipModel.getZipFile(), zipModel.isSplitArchive(), zi...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private ZipInputStream prepareZipInputStream() throws ZipException { try { SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfTh...
#fixed code private ZipInputStream prepareZipInputStream() throws ZipException { try { splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk()); FileH...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static ZipInputStream createZipInputStream(ZipModel zipModel, FileHeader fileHeader, char[] password) throws ZipException { try { SplitInputStream splitInputStream = new SplitInputStream(zipModel.getZipFile(), zipModel.isSplitArchive(), zi...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void executeTask(RenameFilesTaskParameters taskParameters, ProgressMonitor progressMonitor) throws IOException { Map<String, String> fileNamesMap = filterNonExistingEntriesAndAddSeparatorIfNeeded(taskParameters.fileNamesMap); if (fileNamesMap...
#fixed code @Override protected void executeTask(RenameFilesTaskParameters taskParameters, ProgressMonitor progressMonitor) throws IOException { Map<String, String> fileNamesMap = filterNonExistingEntriesAndAddSeparatorIfNeeded(taskParameters.fileNamesMap); if (fileNamesMap.size(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static byte[] getFileAttributes(File file) { try { if (file == null || (!Files.isSymbolicLink(file.toPath()) && !file.exists())) { return new byte[4]; } Path path = file.toPath(); String os = System.getProperty("os.name").toLow...
#fixed code public static byte[] getFileAttributes(File file) { try { if (file == null || (!Files.isSymbolicLink(file.toPath()) && !file.exists())) { return new byte[4]; } Path path = file.toPath(); if (isWindows()) { return getWindowsFileAttri...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected ZipInputStream createZipInputStream(FileHeader fileHeader) throws IOException { SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNum...
#fixed code protected ZipInputStream createZipInputStream(FileHeader fileHeader) throws IOException { splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk()); s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void executeTask(RenameFilesTaskParameters taskParameters, ProgressMonitor progressMonitor) throws IOException { Map<String, String> fileNamesMap = filterNonExistingEntriesAndAddSeparatorIfNeeded(taskParameters.fileNamesMap); if (fileNamesMap...
#fixed code @Override protected void executeTask(RenameFilesTaskParameters taskParameters, ProgressMonitor progressMonitor) throws IOException { Map<String, String> fileNamesMap = filterNonExistingEntriesAndAddSeparatorIfNeeded(taskParameters.fileNamesMap); if (fileNamesMap.size(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static boolean isWindows() { String os = System.getProperty("os.name").toLowerCase(); return isWindows(os); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code public static boolean isWindows() { return (OPERATING_SYSTEM_NAME.contains("win")); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected ZipInputStream createZipInputStream(FileHeader fileHeader) throws IOException { SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNum...
#fixed code protected ZipInputStream createZipInputStream(FileHeader fileHeader) throws IOException { splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk()); s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private DecompressedInputStream initializeEntryInputStream(LocalFileHeader localFileHeader) throws IOException { ZipEntryInputStream zipEntryInputStream = new ZipEntryInputStream(inputStream); CipherInputStream cipherInputStream = initializeCipherInputStream(zipEn...
#fixed code private DecompressedInputStream initializeEntryInputStream(LocalFileHeader localFileHeader) throws IOException { ZipEntryInputStream zipEntryInputStream = new ZipEntryInputStream(inputStream, getCompressedSize(localFileHeader)); CipherInputStream cipherInputStream = ini...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected ZipInputStream createZipInputStream(FileHeader fileHeader) throws IOException { SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNum...
#fixed code protected ZipInputStream createZipInputStream(FileHeader fileHeader) throws IOException { splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk()); s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private ZipInputStream prepareZipInputStream() throws ZipException { try { SplitInputStream splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfTh...
#fixed code private ZipInputStream prepareZipInputStream() throws ZipException { try { splitInputStream = new SplitInputStream(getZipModel().getZipFile(), getZipModel().isSplitArchive(), getZipModel().getEndOfCentralDirectoryRecord().getNumberOfThisDisk()); FileH...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void bidiBackpressure() throws InterruptedException { Object lock = new Object(); BackpressureDetector clientReqBPDetector = new BackpressureDetector(madMultipleCutoff); BackpressureDetector clientRespBPDetector = new Backpressur...
#fixed code @Test public void bidiBackpressure() throws InterruptedException { RxNumbersGrpc.RxNumbersStub stub = RxNumbersGrpc.newRxStub(channel); Flowable<NumberProto.Number> rxRequest = Flowable .fromIterable(IntStream.range(0, NUMBER_OF_STREAM_ELE...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void serverToClientBackpressure() throws InterruptedException { Object lock = new Object(); BackpressureDetector clientBackpressureDetector = new BackpressureDetector(madMultipleCutoff); ReactorNumbersGrpc.ReactorNumbersStub stu...
#fixed code @Test public void serverToClientBackpressure() throws InterruptedException { ReactorNumbersGrpc.ReactorNumbersStub stub = ReactorNumbersGrpc.newReactorStub(channel); Mono<Empty> reactorRequest = Mono.just(Empty.getDefaultInstance()); Flux<NumberP...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void clientToServerBackpressure() throws InterruptedException { Object lock = new Object(); RxNumbersGrpc.RxNumbersStub stub = RxNumbersGrpc.newRxStub(channel); BackpressureDetector clientBackpressureDetector = new BackpressureD...
#fixed code @Test public void clientToServerBackpressure() throws InterruptedException { RxNumbersGrpc.RxNumbersStub stub = RxNumbersGrpc.newRxStub(channel); Flowable<NumberProto.Number> rxRequest = Flowable .fromIterable(IntStream.range(0, NUMBER_OF_...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void clientToServerBackpressure() throws InterruptedException { Object lock = new Object(); ReactorNumbersGrpc.ReactorNumbersStub stub = ReactorNumbersGrpc.newReactorStub(channel); BackpressureDetector clientBackpressureDetector...
#fixed code @Test public void clientToServerBackpressure() throws InterruptedException { ReactorNumbersGrpc.ReactorNumbersStub stub = ReactorNumbersGrpc.newReactorStub(channel); Flux<NumberProto.Number> reactorRequest = Flux .fromIterable(IntStream.ra...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void serverToClientBackpressure() throws InterruptedException { Object lock = new Object(); BackpressureDetector clientBackpressureDetector = new BackpressureDetector(madMultipleCutoff); RxNumbersGrpc.RxNumbersStub stub = RxNumb...
#fixed code @Test public void serverToClientBackpressure() throws InterruptedException { RxNumbersGrpc.RxNumbersStub stub = RxNumbersGrpc.newRxStub(channel); Single<Empty> rxRequest = Single.just(Empty.getDefaultInstance()); TestSubscriber<NumberProto.Number...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String render(ClassModel model, int index, int size, Map<String, Object> session) { if (isExcludedClass(model.getType().getName())) { return null; } StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); ...
#fixed code @Override public String render(ClassModel model, int index, int size, Map<String, Object> session) { if (isExcludedClass(model.getType().getName())) { return null; } StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); C...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String render(ClassModel model, int index, int size, Map<String, Object> session) { if (isExcludedClass(model.getType().getName())) { return null; } StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); ...
#fixed code @Override public String render(ClassModel model, int index, int size, Map<String, Object> session) { if (isExcludedClass(model.getType().getName())) { return null; } StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); C...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String injectVersion(String resourcePath) { URL resourceUrl = getResourceUrl(resourcePath); try { long lastModified = resourceUrl.openConnection().getLastModified(); // check for extension int extensionAt = res...
#fixed code public String injectVersion(String resourcePath) { String version = getResourceVersion(resourcePath); if (StringUtils.isNullOrEmpty(version)) { // unversioned, pass-through resource path return resourcePath; } // check ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @BeforeClass public static void setUpClass() { application = new Application(); client = XmemcachedFactory.create(application.getPippoSettings()); } #location 4 #vulnerability type NULL_DE...
#fixed code @BeforeClass public static void setUpClass() throws IOException { MemcachedStarter runtime = MemcachedStarter.getDefaultInstance(); memcachedExe = runtime.prepare( new MemcachedConfig(Version.Main.PRODUCTION, PORT)); memcached = mem...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public TemplateEngine getTemplateEngine() { if (templateEngine == null) { TemplateEngine engine = ServiceLocator.locate(TemplateEngine.class); setTemplateEngine(engine); } return templateEngine; } ...
#fixed code public TemplateEngine getTemplateEngine() { return templateEngine; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @BeforeClass public static void setUpClass() { application = new Application(); client = SpymemcachedFactory.create(application.getPippoSettings()); } #location 4 #vulnerability type NULL_...
#fixed code @BeforeClass public static void setUpClass() throws IOException { MemcachedStarter runtime = MemcachedStarter.getDefaultInstance(); memcachedExe = runtime.prepare( new MemcachedConfig(Version.Main.PRODUCTION, PORT)); memcached = mem...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void classpathResourceHandlerTest() throws URISyntaxException { ClasspathResourceHandler handler = new ClasspathResourceHandler("/", "/public"); URL resourceUrl = handler.getResourceUrl("VISIBLE"); assertNotNull(resourceUrl); ...
#fixed 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.
#vulnerable code public List<String> toList(List<String> defaultValue) { if (isNull() || (values.length == 1 && StringUtils.isNullOrEmpty(values[0]))) { return defaultValue; } if (values.length == 1) { String tmp = values[0]; ...
#fixed code public List<String> toList(List<String> defaultValue) { if (isNull() || (values.length == 1 && StringUtils.isNullOrEmpty(values[0]))) { return defaultValue; } if (values.length == 1) { String tmp = values[0]; tmp = ...
Below is the vulnerable code, please generate the patch based on the following information.