input stringlengths 205 73.3k | output stringlengths 64 73.2k | instruction stringclasses 1
value |
|---|---|---|
#vulnerable code
@Test
public void shouldUseSameBody() throws IOException {
final HttpServletResponse mock = mock(HttpServletResponse.class);
when(mock.getOutputStream()).thenReturn(new ServletOutputStream() {
@Override
public void write(final... | #fixed code
@Test
public void shouldUseSameBody() throws IOException {
unit.getOutputStream().write("test".getBytes());
final byte[] body1 = unit.getBody();
final byte[] body2 = unit.getBody();
assertSame(body1, body2);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void doFilter(final Logbook logbook, final HttpServletRequest httpRequest,
final HttpServletResponse httpResponse, final FilterChain chain) throws ServletException, IOException {
final TeeRequest request = new TeeRequest(httpReq... | #fixed code
@Override
public void doFilter(final Logbook logbook, final HttpServletRequest httpRequest,
final HttpServletResponse httpResponse, final FilterChain chain) throws ServletException, IOException {
final RemoteRequest request = new RemoteRequest(httpReq... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public PageBean<User> findAll(PageParams pageParams, User user) {
QUser qUser = QUser.user;
// 用户名查询条件
Predicate qUserNamePredicate = null;
if (null != user && StringHelper.isNotBlank(user.getUsername())) {
qUserNamePredicate = qUser.username.like("%"... | #fixed code
@Override
public PageBean<User> findAll(PageParams pageParams, User user) {
QUser qUser = QUser.user;
// 用户名查询条件
Predicate qUserNamePredicate = null;
if (null != user && StringHelper.isNotBlank(user.getUsername())) {
qUserNamePredicate = qUser.username.like("%" + use... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public PaginationDTO list(Integer page, Integer size) {
PaginationDTO paginationDTO = new PaginationDTO();
Integer totalCount = questionMapper.count();
paginationDTO.setPagination(totalCount, page, size);
if (page < 1) {
pa... | #fixed code
public PaginationDTO list(Integer page, Integer size) {
PaginationDTO paginationDTO = new PaginationDTO();
Integer totalPage;
Integer totalCount = questionMapper.count();
if (totalCount % size == 0) {
totalPage = totalCount / si... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public long until(final Temporal endExclusive, final TemporalUnit unit) {
final PaxDate end = PaxDate.from(endExclusive);
if (unit instanceof ChronoUnit) {
switch ((ChronoUnit) unit) {
case DAYS:
... | #fixed code
@Override
public long until(final Temporal endExclusive, final TemporalUnit unit) {
final PaxDate end = PaxDate.from(endExclusive);
if (unit instanceof ChronoUnit) {
switch ((ChronoUnit) unit) {
case YEARS:
r... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public long until(final Temporal endExclusive, final TemporalUnit unit) {
final PaxDate end = PaxDate.from(endExclusive);
if (unit instanceof ChronoUnit) {
switch ((ChronoUnit) unit) {
case DAYS:
... | #fixed code
@Override
public long until(final Temporal endExclusive, final TemporalUnit unit) {
final PaxDate end = PaxDate.from(endExclusive);
if (unit instanceof ChronoUnit) {
switch ((ChronoUnit) unit) {
case YEARS:
r... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public long until(final Temporal endExclusive, final TemporalUnit unit) {
final PaxDate end = PaxDate.from(endExclusive);
if (unit instanceof ChronoUnit) {
switch ((ChronoUnit) unit) {
case DAYS:
... | #fixed code
@Override
public long until(final Temporal endExclusive, final TemporalUnit unit) {
final PaxDate end = PaxDate.from(endExclusive);
if (unit instanceof ChronoUnit) {
switch ((ChronoUnit) unit) {
case YEARS:
r... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public long until(final Temporal endExclusive, final TemporalUnit unit) {
final PaxDate end = PaxDate.from(endExclusive);
if (unit instanceof ChronoUnit) {
switch ((ChronoUnit) unit) {
case DAYS:
... | #fixed code
@Override
public long until(final Temporal endExclusive, final TemporalUnit unit) {
final PaxDate end = PaxDate.from(endExclusive);
if (unit instanceof ChronoUnit) {
switch ((ChronoUnit) unit) {
case YEARS:
r... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void writeSpecRunnerToSourceSpecDirectory() throws IOException {
Set<String> scripts = relativizesASetOfScripts.relativize(jasmineTargetDir, resolvesCompleteListOfScriptLocations.resolve(sources, specs, preloadSources));
SpecRunnerHtmlGenerator htmlGenerator... | #fixed code
private void writeSpecRunnerToSourceSpecDirectory() throws IOException {
File runnerDestination = new File(jasmineTargetDir,manualSpecRunnerHtmlFileName);
String newRunnerHtml = new SpecRunnerHtmlGenerator(scriptsForRunner(), sourceEncoding).generate(ReporterType.TrivialR... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws IOException {
GenericSignatureParser parser = new GenericSignatureParser();
// MethodSignature sig1 = parser.parseMethodSignature("<U:Ljava/lang/Object;>(Ljava/lang/Class<TU;>;)Ljava/lang/Class<+TU;>;");
// ... | #fixed code
public static void main(String[] args) throws IOException {
GenericSignatureParser parser = new GenericSignatureParser();
MethodSignature sig1 = parser.parseMethodSignature("<U:Ljava/lang/Foo;>(Ljava/lang/Class<TU;>;TU;)Ljava/lang/Class<+TU;>;");
Metho... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Index read() throws IOException {
PackedDataInputStream stream = new PackedDataInputStream(new BufferedInputStream(input));
if (stream.readInt() != MAGIC) {
stream.close();
throw new IllegalArgumentException("Not a jandex i... | #fixed code
public Index read() throws IOException {
if(version == -1) {
readVersion();
}
IndexReaderImpl reader = getReader(input, version);
if (reader == null) {
input.close();
throw new UnsupportedVersion("Version: " ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Result createJarIndex(File jarFile, Indexer indexer, boolean modify, boolean newJar, boolean verbose) throws IOException {
File tmpCopy = null;
ZipOutputStream zo = null;
OutputStream out = null;
File outputFile = null;
... | #fixed code
public static Result createJarIndex(File jarFile, Indexer indexer, boolean modify, boolean newJar, boolean verbose) throws IOException {
File tmpCopy = null;
ZipOutputStream zo = null;
OutputStream out = null;
File outputFile = null;
J... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Index read() throws IOException {
PackedDataInputStream stream = new PackedDataInputStream(new BufferedInputStream(input));
if (stream.readInt() != MAGIC) {
stream.close();
throw new IllegalArgumentException("Not a jandex i... | #fixed code
public Index read() throws IOException {
if(version == -1) {
readVersion();
}
IndexReaderImpl reader = getReader(input, version);
if (reader == null) {
input.close();
throw new UnsupportedVersion("Version: " ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Index read() throws IOException {
PackedDataInputStream stream = new PackedDataInputStream(new BufferedInputStream(input));
if (stream.readInt() != MAGIC) {
stream.close();
throw new IllegalArgumentException("Not a jandex i... | #fixed code
public Index read() throws IOException {
if(version == -1) {
readVersion();
}
IndexReaderImpl reader = getReader(input, version);
if (reader == null) {
input.close();
throw new UnsupportedVersion("Version: " ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static Result createJarIndex(File jarFile, Indexer indexer, boolean modify, boolean newJar, boolean verbose) throws IOException {
File tmpCopy = null;
ZipOutputStream zo = null;
OutputStream out = null;
File outputFile = null;
... | #fixed code
public static Result createJarIndex(File jarFile, Indexer indexer, boolean modify, boolean newJar, boolean verbose) throws IOException {
File tmpCopy = null;
ZipOutputStream zo = null;
OutputStream out = null;
File outputFile = null;
J... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
LogRecordSet.Writer getLogRecordSetWriter() {
return recordSetWriter;
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
String getStream(int streamId) {
return streams.get(streamId);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Around("within(@org.springframework.stereotype.Repository *)")
public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {
if (this.isEnabled) {
StopWatch sw = new StopWatch(joinPoint.toShortString());
sw.start("invoke");... | #fixed code
@Around("within(@org.springframework.stereotype.Repository *)")
public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {
if (this.enabled) {
StopWatch sw = new StopWatch(joinPoint.toShortString());
sw.start("invoke");
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void addAllErrors(BindingResult bindingResult) {
for (FieldError fieldError : bindingResult.getFieldErrors()) {
BindingError error = new BindingError();
error.setObjectName(fieldError.getObjectName());
error.setFieldName(fieldError.getField());
error.s... | #fixed code
public void addAllErrors(BindingResult bindingResult) {
for (FieldError fieldError : bindingResult.getFieldErrors()) {
BindingError error = new BindingError();
error.setObjectName(fieldError.getObjectName());
error.setFieldName(fieldError.getField());
error.setFiel... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private RestHighLevelClient buildRestHighLevelClient() throws Exception {
Collection<HttpHost> hosts = new ArrayList<>(esNodes.length);
for (String esNode : esNodes) {
Tuple<String, Integer> addressPort = toAddress(esNode);
hosts.add(new H... | #fixed code
private RestHighLevelClient buildRestHighLevelClient() throws Exception {
Collection<HttpHost> hosts = new ArrayList<>(esNodes.length);
for (String esNode : esNodes) {
hosts.add(HttpHost.create(esNode));
}
RestClientBuilder rcb = RestClient... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static String readFileInClasspath(String url) throws Exception {
StringBuffer bufferJSON = new StringBuffer();
try {
InputStream ips= ElasticsearchAbstractClientFactoryBean.class.getResourceAsStream(url);
InputStreamReader ipsr = new InputStreamReader(... | #fixed code
public static String readFileInClasspath(String url) throws Exception {
StringBuilder bufferJSON = new StringBuilder();
BufferedReader br = null;
try {
ClassPathResource classPathResource = new ClassPathResource(url);
InputStr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void initMappings() throws Exception {
checkClient();
// We extract indexes and mappings to manage from mappings definition
if (mappings != null && mappings.length > 0) {
Map<String, Collection<String>> indexes = new HashMap<>();
for (int i = 0; i <... | #fixed code
private void initMappings() throws Exception {
checkClient();
// We extract indexes and mappings to manage from mappings definition
if (mappings != null && mappings.length > 0) {
Map<String, Collection<String>> indices = getIndexMappings(mappings);
// Le... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void test() {
MessageHandler messageHandler = SpringContextUtil.getBean("MessageHandler","login");
messageHandler.handle(null,null,null,null);
}
#location 4
#vulnerability typ... | #fixed code
@Test
public void test() {
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Bean
public ExperimentDAO experimentDAO() {
LOGGER.debug("Setting up database.");
ApplicationContext context = new ClassPathXmlApplicationContext("/spring/database/database-context.xml");
return context.getBean(ExperimentDAO.class);
}
... | #fixed code
@Bean
public ExperimentDAO experimentDAO() {
LOGGER.debug("Setting up database.");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"/spring/database/database-context.xml");
ExperimentDAO database = conte... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
WikipediaApiInterface wikiAPI = SingletonWikipediaApi.getInstance();
ExperimentTaskConfiguration taskConfigs[] = new ExperimentTaskConfiguration[] ... | #fixed code
public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
WikipediaApiInterface wikiAPI = SingletonWikipediaApi.getInstance();
// ExperimentTaskConfiguration taskConfigs[] = new ExperimentTaskConfiguration[] { n... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void updateFileCache() {
mp3Files = getFileSet(Directories.MP3);
aaxFiles = getFileSet(Directories.AAX);
needFileCacheUpdate = System.currentTimeMillis();
HashSet<Book> c = new HashSet<>();
HashSet<Book> d = new HashSet<>();
long seconds = 0;
for... | #fixed code
public void updateFileCache() {
mp3Files = getFileSet(Directories.MP3);
aaxFiles = getFileSet(Directories.AAX);
needFileCacheUpdate = System.currentTimeMillis();
synchronized (lock) {
toDownload.clear();
toConvert.clear();
long seconds = 0;
for (Book b : getB... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public int mp3Count() {
return mp3Files.size();
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public int mp3Count() {synchronized (lock){
return mp3Files.size();}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void explore() {
try {
Book b = onlyOneSelected();
File m = audible.getMP3FileDest(b);
if (m.exists()) {
String mac = "open -R ";
String win = "Explorer /select, ";
Strin... | #fixed code
public void explore() {
try {
Book b = onlyOneSelected();
File m = audible.getMP3FileDest(b);
if (m.exists()) {
GUI.explore(m);
// Desktop.getDesktop().open(m.getParentFile());
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void updateFileCache() {
mp3Files = getFileSet(Directories.MP3);
aaxFiles = getFileSet(Directories.AAX);
needFileCacheUpdate = System.currentTimeMillis();
HashSet<Book> c = new HashSet<>();
HashSet<Book> d = new HashSet<>();
long seconds = 0;
for... | #fixed code
public void updateFileCache() {
mp3Files = getFileSet(Directories.MP3);
aaxFiles = getFileSet(Directories.AAX);
needFileCacheUpdate = System.currentTimeMillis();
synchronized (lock) {
toDownload.clear();
toConvert.clear();
long seconds = 0;
for (Book b : getB... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public int aaxCount() {
return aaxFiles.size();
}
#location 2
#vulnerability type THREAD_SAFETY_VIOLATION | #fixed code
public int aaxCount() {
synchronized (lock) {
return aaxFiles.size();
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static void explore(File m) {
String mac = "open ";
String cmd = null;
switch(Platform.getPlatform())
{
case mac:
cmd = "open ";
if (!m.isDirectory()) cmd += "-R ";
br... | #fixed code
public static void explore(File m) {
ArrayList<String>cmdLine = new ArrayList<>();
switch(Platform.getPlatform())
{
case mac:
cmdLine.add("open");
if (!m.isDirectory())
{
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
throws IOException {
// default response context
setResponseStatus(context, CacheResponseStatus.CACHE_MISS);
String via = generateViaHeader(reque... | #fixed code
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
throws IOException {
// default response context
setResponseStatus(context, CacheResponseStatus.CACHE_MISS);
String via = generateViaHeader(request);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
if (!(conn instanceof BasicPooledConnAdapter)) {
throw new IllegalArgumentException
("Connection class mismatch, " +
... | #fixed code
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
if (!(conn instanceof BasicPooledConnAdapter)) {
throw new IllegalArgumentException
("Connection class mismatch, " +
"con... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
InputStream decorate(final InputStream wrapped) throws IOException {
/*
* A zlib stream will have a header.
*
* CMF | FLG [| DICTID ] | ...compressed data | ADLER32 |
*
* * CMF is one byte.
*
... | #fixed code
@Override
InputStream decorate(final InputStream wrapped) throws IOException {
return new DeflateInputStream(wrapped);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void handleReference(Reference<?> ref) {
poolLock.lock();
try {
if (ref instanceof BasicPoolEntryRef) {
// check if the GCed pool entry was still in use
//@@@ find a way to detect this without lookup
... | #fixed code
public void handleReference(Reference<?> ref) {
poolLock.lock();
try {
if (ref instanceof BasicPoolEntryRef) {
// check if the GCed pool entry was still in use
//@@@ find a way to detect this without lookup
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testCreateSocket() throws Exception {
HttpParams params = new BasicHttpParams();
String password = "changeit";
char[] pwd = password.toCharArray();
RSAPrivateCrtKeySpec k;
k = new RSAPrivateCrtKeySpec(new BigInteger(R... | #fixed code
public void testCreateSocket() throws Exception {
HttpParams params = new BasicHttpParams();
String password = "changeit";
char[] pwd = password.toCharArray();
RSAPrivateCrtKeySpec k;
k = new RSAPrivateCrtKeySpec(new BigInteger(RSA_PUB... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void handle(final HttpRequest request,
final HttpResponse response,
final HttpContext context)
throws HttpException, IOException {
String method = request.getRequestLine().getMethod().toUpperCase();
... | #fixed code
public void handle(final HttpRequest request,
final HttpResponse response,
final HttpContext context)
throws HttpException, IOException {
String method = request.getRequestLine().getMethod().toUpperCase();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
if (!(conn instanceof BasicPooledConnAdapter)) {
throw new IllegalArgumentException
("Connection class mismatch, " +
... | #fixed code
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
if (!(conn instanceof BasicPooledConnAdapter)) {
throw new IllegalArgumentException
("Connection class mismatch, " +
"con... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void shutdown() {
this.shutdown = true;
synchronized (this) {
try {
if (this.poolEntry != null) {
this.poolEntry.close();
}
} finally {
this.poolEntry = nu... | #fixed code
public void shutdown() {
synchronized (this) {
this.shutdown = true;
try {
if (this.poolEntry != null) {
this.poolEntry.close();
}
} finally {
this.poolEntry = null... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public static PublicSuffixMatcher load(final URL url) throws IOException {
Args.notNull(url, "URL");
final InputStream in = url.openStream();
try {
final PublicSuffixList list = new PublicSuffixListParser().parse(
... | #fixed code
public static PublicSuffixMatcher load(final URL url) throws IOException {
Args.notNull(url, "URL");
final InputStream in = url.openStream();
try {
return load(in);
} finally {
in.close();
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void releaseConnection(final ManagedClientConnection conn, long keepalive, TimeUnit tunit) {
assertNotShutdown();
if (!(conn instanceof ManagedClientConnectionImpl)) {
throw new IllegalArgumentException("Connection class mismatch, " +
... | #fixed code
public void releaseConnection(final ManagedClientConnection conn, long keepalive, TimeUnit tunit) {
if (!(conn instanceof ManagedClientConnectionImpl)) {
throw new IllegalArgumentException("Connection class mismatch, " +
"connection not ob... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
InputStream decorate(final InputStream wrapped) throws IOException {
/*
* A zlib stream will have a header.
*
* CMF | FLG [| DICTID ] | ...compressed data | ADLER32 |
*
* * CMF is one byte.
*
... | #fixed code
@Override
InputStream decorate(final InputStream wrapped) throws IOException {
return new DeflateInputStream(wrapped);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCloseExpiredIdleConnections() throws Exception {
final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager();
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpR... | #fixed code
@Test
public void testCloseExpiredIdleConnections() throws Exception {
final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager();
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpRoute r... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void testBasicPoolEntry() {
HttpRoute route = new HttpRoute(TARGET);
ClientConnectionOperator ccop =
new DefaultClientConnectionOperator(supportedSchemes);
BasicPoolEntry bpe = null;
try {
bpe = new BasicPo... | #fixed code
public void testBasicPoolEntry() {
HttpRoute route = new HttpRoute(TARGET);
ClientConnectionOperator ccop =
new DefaultClientConnectionOperator(supportedSchemes);
BasicPoolEntry bpe = null;
try {
bpe = new BasicPoolEntr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
InputStream decorate(final InputStream wrapped) throws IOException {
/*
* A zlib stream will have a header.
*
* CMF | FLG [| DICTID ] | ...compressed data | ADLER32 |
*
* * CMF is one byte.
*
... | #fixed code
@Override
InputStream decorate(final InputStream wrapped) throws IOException {
return new DeflateInputStream(wrapped);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
if (!(conn instanceof BasicPooledConnAdapter)) {
throw new IllegalArgumentException
("Connection class mismatch, " +
... | #fixed code
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
if (!(conn instanceof BasicPooledConnAdapter)) {
throw new IllegalArgumentException
("Connection class mismatch, " +
"con... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void shutdown() {
this.isShutDown = true;
ConnAdapter conn = managedConn;
if (conn != null)
conn.detach();
synchronized (this) {
try {
if (uniquePoolEntry != null) // and connection open?
... | #fixed code
public void shutdown() {
this.isShutDown = true;
synchronized (this) {
try {
if (uniquePoolEntry != null) // and connection open?
uniquePoolEntry.shutdown();
} catch (IOException iox) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public synchronized void generate(final StringBuilder buffer) {
this.count++;
int rndnum = this.rnd.nextInt();
buffer.append(System.currentTimeMillis());
buffer.append('.');
Formatter formatter = new Formatter(buffer, Locale.US);
... | #fixed code
public synchronized void generate(final StringBuilder buffer) {
this.count++;
int rndnum = this.rnd.nextInt();
buffer.append(System.currentTimeMillis());
buffer.append('.');
Formatter formatter = new Formatter(buffer, Locale.US);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
if (!(conn instanceof BasicPooledConnAdapter)) {
throw new IllegalArgumentException
("Connection class mismatch, " +
... | #fixed code
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
if (!(conn instanceof BasicPooledConnAdapter)) {
throw new IllegalArgumentException
("Connection class mismatch, " +
"con... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testCloseExpiredTTLConnections() throws Exception {
final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager(
100, TimeUnit.MILLISECONDS);
mgr.setMaxTotal(1);
final HttpHost tar... | #fixed code
@Test
public void testCloseExpiredTTLConnections() throws Exception {
final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager(
100, TimeUnit.MILLISECONDS);
mgr.setMaxTotal(1);
final HttpHost target = ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void updateSecureConnection(
final OperatedClientConnection conn,
final HttpHost target,
final HttpContext context,
final HttpParams params) throws IOException {
if (conn == null) {
throw new Ill... | #fixed code
public void updateSecureConnection(
final OperatedClientConnection conn,
final HttpHost target,
final HttpContext context,
final HttpParams params) throws IOException {
if (conn == null) {
throw new IllegalAr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
throws IOException {
// default response context
setResponseStatus(context, CacheResponseStatus.CACHE_MISS);
String via = generateViaHeader(reque... | #fixed code
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
throws IOException {
// default response context
setResponseStatus(context, CacheResponseStatus.CACHE_MISS);
String via = generateViaHeader(request);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public CloseableHttpResponse execute(
final HttpRoute route,
final HttpRequestWrapper request,
final HttpClientContext context,
final HttpExecutionAware execAware) throws IOException, HttpException {
Args.notNull(r... | #fixed code
public CloseableHttpResponse execute(
final HttpRoute route,
final HttpRequestWrapper request,
final HttpClientContext context,
final HttpExecutionAware execAware) throws IOException, HttpException {
Args.notNull(route, ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
HttpResponse handleBackendResponse(
HttpHost target,
HttpRequest request,
Date requestDate,
Date responseDate,
HttpResponse backendResponse) throws IOException {
log.debug("Handling Backend response");... | #fixed code
CachingHttpClient(HttpClient backend, CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy,
CacheEntryFactory cacheEntryFactory, URIExtractor uriExtractor,
HttpCache responseCache, CachedHttp... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void shutdown() {
poolLock.lock();
try {
if (isShutDown)
return;
// no point in monitoring GC anymore
if (refWorker != null)
refWorker.shutdown();
// close all con... | #fixed code
public void shutdown() {
poolLock.lock();
try {
if (isShutDown)
return;
// close all connections that are issued to an application
Iterator<BasicPoolEntry> iter = leasedConnections.iterator();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public Socket connectSocket(
final Socket socket,
final InetSocketAddress remoteAddress,
final InetSocketAddress localAddress,
final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
... | #fixed code
public Socket connectSocket(
final Socket socket,
final InetSocketAddress remoteAddress,
final InetSocketAddress localAddress,
final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAbortBeforeSocketCreate() throws Exception {
final CountDownLatch connectLatch = new CountDownLatch(1);
final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(
connectLatch, WaitPolicy.BEFO... | #fixed code
@Test
public void testAbortBeforeSocketCreate() throws Exception {
final CountDownLatch connectLatch = new CountDownLatch(1);
final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(
connectLatch, WaitPolicy.BEFORE_CRE... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
throws IOException {
// default response context
setResponseStatus(context, CacheResponseStatus.CACHE_MISS);
String via = generateViaHeader(reque... | #fixed code
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
throws IOException {
// default response context
setResponseStatus(context, CacheResponseStatus.CACHE_MISS);
String via = generateViaHeader(request);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
public void close() {
this.connManager.shutdown();
if (this.closeables != null) {
for (final Closeable closeable: this.closeables) {
try {
closeable.close();
} catch (final IOE... | #fixed code
@Override
public void close() {
if (this.closeables != null) {
for (final Closeable closeable: this.closeables) {
try {
closeable.close();
} catch (final IOException ex) {
this.log... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
HttpCacheEntry doGetUpdatedParentEntry(
final String requestId,
final HttpCacheEntry existing,
final HttpCacheEntry entry,
final String variantURI) throws IOException {
if (existing != null) {
return ca... | #fixed code
CachingHttpClient(HttpClient backend, CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy,
CacheEntryFactory cacheEntryFactory, URIExtractor uriExtractor,
HttpCache responseCache, CachedHttp... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
ManagedClientConnection getConnection(final HttpRoute route, final Object state) {
if (route == null) {
throw new IllegalArgumentException("Route may not be null.");
}
assertNotShutdown();
if (this.log.isDebugEnabled()) {
... | #fixed code
ManagedClientConnection getConnection(final HttpRoute route, final Object state) {
if (route == null) {
throw new IllegalArgumentException("Route may not be null.");
}
synchronized (this) {
assertNotShutdown();
if (t... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testReleaseConnectionOnAbort() throws Exception {
final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager();
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpRout... | #fixed code
@Test
public void testReleaseConnectionOnAbort() throws Exception {
final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager();
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpRoute rout... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
CloseableHttpResponse revalidateCacheEntry(
final HttpRoute route,
final HttpRequestWrapper request,
final HttpClientContext context,
final HttpExecutionAware execAware,
final HttpCacheEntry cacheEntry) throws ... | #fixed code
CachingExec(
final ClientExecChain backend,
final HttpCache responseCache,
final CacheValidityPolicy validityPolicy,
final ResponseCachingPolicy responseCachingPolicy,
final CachedHttpResponseGenerator responseGenera... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected ClientConnectionManager createClientConnectionManager() {
SchemeRegistry registry = SchemeRegistryFactory.createDefault();
ClientConnectionManager connManager = null;
HttpParams params = getParams();
ClientConnectionManagerFac... | #fixed code
protected ClientConnectionManager createClientConnectionManager() {
SchemeRegistry registry = SchemeRegistryFactory.createDefault();
ClientConnectionManager connManager = null;
HttpParams params = getParams();
ClientConnectionManagerFactory f... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
if (!(conn instanceof BasicPooledConnAdapter)) {
throw new IllegalArgumentException
("Connection class mismatch, " +
... | #fixed code
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
if (!(conn instanceof BasicPooledConnAdapter)) {
throw new IllegalArgumentException
("Connection class mismatch, " +
"con... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void releaseConnection(final ManagedClientConnection conn, long keepalive, TimeUnit tunit) {
assertNotShutdown();
if (!(conn instanceof ManagedClientConnectionImpl)) {
throw new IllegalArgumentException("Connection class mismatch, " +
... | #fixed code
public void releaseConnection(final ManagedClientConnection conn, long keepalive, TimeUnit tunit) {
if (!(conn instanceof ManagedClientConnectionImpl)) {
throw new IllegalArgumentException("Connection class mismatch, " +
"connection not ob... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
CloseableHttpResponse handleBackendResponse(
final HttpRoute route,
final HttpRequestWrapper request,
final HttpClientContext context,
final HttpExecutionAware execAware,
final Date requestDate,
fin... | #fixed code
CachingExec(
final ClientExecChain backend,
final HttpCache responseCache,
final CacheValidityPolicy validityPolicy,
final ResponseCachingPolicy responseCachingPolicy,
final CachedHttpResponseGenerator responseGenera... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void updateSecureConnection(
final OperatedClientConnection conn,
final HttpHost target,
final HttpContext context,
final HttpParams params) throws IOException {
if (conn == null) {
throw new Ill... | #fixed code
public void updateSecureConnection(
final OperatedClientConnection conn,
final HttpHost target,
final HttpContext context,
final HttpParams params) throws IOException {
if (conn == null) {
throw new IllegalAr... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testReleaseConnectionWithTimeLimits() throws Exception {
final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager();
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final H... | #fixed code
@Test
public void testReleaseConnectionWithTimeLimits() throws Exception {
final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager();
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpRou... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void doWriteTo(
final HttpMultipartMode mode,
final OutputStream out,
boolean writeContent) throws IOException {
List<?> bodyParts = getBodyParts();
Charset charset = getCharset();
String boundary = getB... | #fixed code
private void doWriteTo(
final HttpMultipartMode mode,
final OutputStream out,
boolean writeContent) throws IOException {
List<BodyPart> bodyParts = getBodyParts();
Charset charset = getCharset();
ByteArrayBuffer boun... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
throws IOException {
// default response context
setResponseStatus(context, CacheResponseStatus.CACHE_MISS);
String via = generateViaHeader(reque... | #fixed code
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
throws IOException {
// default response context
setResponseStatus(context, CacheResponseStatus.CACHE_MISS);
String via = generateViaHeader(request);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
HttpCacheEntry doGetUpdatedParentEntry(
final String requestId,
final HttpCacheEntry existing,
final HttpCacheEntry entry,
final String variantURI) throws IOException {
if (existing != null) {
return ca... | #fixed code
CachingHttpClient(HttpClient backend, CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy,
CacheEntryFactory cacheEntryFactory, URIExtractor uriExtractor,
HttpCache responseCache, CachedHttp... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
if (!(conn instanceof BasicPooledConnAdapter)) {
throw new IllegalArgumentException
("Connection class mismatch, " +
... | #fixed code
public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) {
if (!(conn instanceof BasicPooledConnAdapter)) {
throw new IllegalArgumentException
("Connection class mismatch, " +
"con... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAbortAfterSocketConnect() throws Exception {
final CountDownLatch connectLatch = new CountDownLatch(1);
final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(
connectLatch, WaitPolicy.AFTE... | #fixed code
@Test
public void testAbortAfterSocketConnect() throws Exception {
final CountDownLatch connectLatch = new CountDownLatch(1);
final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(
connectLatch, WaitPolicy.AFTER_CONN... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
InputStream decorate(final InputStream wrapped) throws IOException {
/*
* A zlib stream will have a header.
*
* CMF | FLG [| DICTID ] | ...compressed data | ADLER32 |
*
* * CMF is one byte.
*
... | #fixed code
@Override
InputStream decorate(final InputStream wrapped) throws IOException {
return new DeflateInputStream(wrapped);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Before
public void setUp() throws Exception {
final Reader r = new InputStreamReader(getClass().getResourceAsStream(LIST_FILE), "UTF-8");
filter = new PublicSuffixFilter(new RFC2109DomainHandler());
final PublicSuffixListParser parser = new ... | #fixed code
@Before
public void setUp() throws Exception {
final ClassLoader classLoader = getClass().getClassLoader();
final InputStream in = classLoader.getResourceAsStream(SOURCE_FILE);
Assert.assertNotNull(in);
final PublicSuffixList suffixList;
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Override
InputStream decorate(final InputStream wrapped) throws IOException {
/*
* A zlib stream will have a header.
*
* CMF | FLG [| DICTID ] | ...compressed data | ADLER32 |
*
* * CMF is one byte.
*
... | #fixed code
@Override
InputStream decorate(final InputStream wrapped) throws IOException {
return new DeflateInputStream(wrapped);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private Header createDigestHeader(
final Credentials credentials,
final HttpRequest request) throws AuthenticationException {
String uri = getParameter("uri");
String realm = getParameter("realm");
String nonce = getParame... | #fixed code
private Header createDigestHeader(
final Credentials credentials,
final HttpRequest request) throws AuthenticationException {
String uri = getParameter("uri");
String realm = getParameter("realm");
String nonce = getParameter("n... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testAbortDuringConnecting() throws Exception {
final CountDownLatch connectLatch = new CountDownLatch(1);
final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(
connectLatch, WaitPolicy.BEFORE... | #fixed code
@Test
public void testAbortDuringConnecting() throws Exception {
final CountDownLatch connectLatch = new CountDownLatch(1);
final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(
connectLatch, WaitPolicy.BEFORE_CONNE... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
throws IOException {
// default response context
setResponseStatus(context, CacheResponseStatus.CACHE_MISS);
String via = generateViaHeader(reque... | #fixed code
public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
throws IOException {
// default response context
setResponseStatus(context, CacheResponseStatus.CACHE_MISS);
String via = generateViaHeader(request);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
HttpResponse callBackend(HttpHost target, HttpRequest request, HttpContext context)
throws IOException {
Date requestDate = getCurrentDate();
log.trace("Calling the backend");
HttpResponse backendResponse = backend.execute(target, r... | #fixed code
CachingHttpClient(
HttpClient client,
HttpCache cache,
CacheConfig config) {
super();
if (client == null) {
throw new IllegalArgumentException("HttpClient may not be null");
}
if (cache == null) {... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void enableConnectionGC()
throws IllegalStateException {
if (refQueue != null) {
throw new IllegalStateException("Connection GC already enabled.");
}
poolLock.lock();
try {
if (numConnections > 0) {... | #fixed code
public void enableConnectionGC()
throws IllegalStateException {
if (refQueue != null) {
throw new IllegalStateException("Connection GC already enabled.");
}
poolLock.lock();
try {
if (numConnections > 0) { //@@@... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
ManagedClientConnection getConnection(final HttpRoute route, final Object state) {
if (route == null) {
throw new IllegalArgumentException("Route may not be null.");
}
assertNotShutdown();
if (this.log.isDebugEnabled()) {
... | #fixed code
ManagedClientConnection getConnection(final HttpRoute route, final Object state) {
if (route == null) {
throw new IllegalArgumentException("Route may not be null.");
}
synchronized (this) {
assertNotShutdown();
if (t... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test
public void testReleaseConnection() throws Exception {
final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager();
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpRoute route... | #fixed code
@Test
public void testReleaseConnection() throws Exception {
final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager();
mgr.setMaxTotal(1);
final HttpHost target = getServerHttp();
final HttpRoute route = new... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
@Test(expected = IllegalArgumentException.class)
public void testDecorateCORSPropertiesValidRequestNullRequestType() {
HttpServletRequest request =
EasyMock.createMock(HttpServletRequest.class);
EasyMock.replay(request);
CORSF... | #fixed code
@Test(expected = IllegalArgumentException.class)
public void testDecorateCORSPropertiesValidRequestNullRequestType() {
MockHttpServletRequest request = new MockHttpServletRequest();
CORSFilter.decorateCORSProperties(request, null);
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public InputStream createInputStream(final long offset) throws IOException {
// permission check
if (!isReadable()) {
throw new IOException("No read permission : " + file.getName());
}
// move to the appropriate offset and c... | #fixed code
public InputStream createInputStream(final long offset) throws IOException {
// permission check
if (!isReadable()) {
throw new IOException("No read permission : " + file.getName());
}
// move to the appropriate offset and create ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void handleMessage(Buffer buffer) throws Exception {
SshConstants.Message cmd = buffer.getCommand();
log.debug("Received packet {}", cmd);
switch (cmd) {
case SSH_MSG_DISCONNECT: {
int code = buffer.getInt();... | #fixed code
protected void handleMessage(Buffer buffer) throws Exception {
synchronized (lock) {
doHandleMessage(buffer);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void disconnect(int reason, String msg) throws IOException {
Buffer buffer = createBuffer(SshConstants.Message.SSH_MSG_DISCONNECT);
buffer.putInt(reason);
buffer.putString(msg);
buffer.putString("");
WriteFuture f = writePa... | #fixed code
public void disconnect(int reason, String msg) throws IOException {
Buffer buffer = createBuffer(SshConstants.Message.SSH_MSG_DISCONNECT);
buffer.putInt(reason);
buffer.putString(msg);
buffer.putString("");
WriteFuture f = writePacket(b... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
private void writeFile(String header, File path) throws IOException {
if (log.isDebugEnabled()) {
log.debug("Writing file {}", path);
}
if (!header.startsWith("C")) {
throw new IOException("Expected a C message but got '" ... | #fixed code
private void writeFile(String header, File path) throws IOException {
if (log.isDebugEnabled()) {
log.debug("Writing file {}", path);
}
if (!header.startsWith("C")) {
throw new IOException("Expected a C message but got '" + head... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void exceptionCaught(Throwable t) {
log.warn("Exception caught", t);
try {
if (t instanceof SshException) {
int code = ((SshException) t).getDisconnectCode();
if (code > 0) {
disconne... | #fixed code
public void exceptionCaught(Throwable t) {
log.warn("Exception caught", t);
try {
if (t instanceof SshException) {
int code = ((SshException) t).getDisconnectCode();
if (code > 0) {
disconnect(cod... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void handleMessage(Buffer buffer) throws Exception {
SshConstants.Message cmd = buffer.getCommand();
log.debug("Received packet {}", cmd);
switch (cmd) {
case SSH_MSG_DISCONNECT: {
int code = buffer.getInt();... | #fixed code
protected void handleMessage(Buffer buffer) throws Exception {
synchronized (lock) {
doHandleMessage(buffer);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void handleOpenFailure(Buffer buffer) {
int reason = buffer.getInt();
String msg = buffer.getString();
synchronized (lock) {
this.openFailureReason = reason;
this.openFailureMsg = msg;
this.openFuture.se... | #fixed code
public void handleOpenFailure(Buffer buffer) {
int reason = buffer.getInt();
String msg = buffer.getString();
this.openFailureReason = reason;
this.openFailureMsg = msg;
this.openFuture.setException(new SshException(msg));
this.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void handleOpenFailure(Buffer buffer) {
int reason = buffer.getInt();
String msg = buffer.getString();
synchronized (lock) {
this.openFailureReason = reason;
this.openFailureMsg = msg;
this.openFuture.se... | #fixed code
public void handleOpenFailure(Buffer buffer) {
int reason = buffer.getInt();
String msg = buffer.getString();
this.openFailureReason = reason;
this.openFailureMsg = msg;
this.openFuture.setException(new SshException(msg));
this.... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected boolean handleShell(Buffer buffer) throws IOException {
boolean wantReply = buffer.getBoolean();
if (((ServerSession) session).getServerFactoryManager().getShellFactory() == null) {
return false;
}
addEnvVariable("U... | #fixed code
protected boolean handleShell(Buffer buffer) throws IOException {
boolean wantReply = buffer.getBoolean();
if (((ServerSession) session).getServerFactoryManager().getShellFactory() == null) {
return false;
}
addEnvVariable("USER", ... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void handleMessage(Buffer buffer) throws Exception {
SshConstants.Message cmd = buffer.getCommand();
log.debug("Received packet {}", cmd);
switch (cmd) {
case SSH_MSG_DISCONNECT: {
int code = buffer.getInt();... | #fixed code
protected void handleMessage(Buffer buffer) throws Exception {
synchronized (lock) {
doHandleMessage(buffer);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void setupSensibleDefaultPty() {
try {
String os = System.getProperty("os.name").toLowerCase();
if (os.indexOf("windows") < 0) {
ptyModes = SttySupport.getUnixPtyModes();
ptyColumns = SttySupport.get... | #fixed code
public void setupSensibleDefaultPty() {
try {
if (OsUtils.isUNIX()) {
ptyModes = SttySupport.getUnixPtyModes();
ptyColumns = SttySupport.getTerminalWidth();
ptyLines = SttySupport.getTerminalHeight();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
public void handleRequest(Buffer buffer) throws IOException {
log.info("Received SSH_MSG_CHANNEL_REQUEST on channel {}", id);
String req = buffer.getString();
if ("exit-status".equals(req)) {
buffer.getBoolean();
synchroni... | #fixed code
public void handleRequest(Buffer buffer) throws IOException {
log.info("Received SSH_MSG_CHANNEL_REQUEST on channel {}", id);
String req = buffer.getString();
if ("exit-status".equals(req)) {
buffer.getBoolean();
exitStatus = bu... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void handleMessage(Buffer buffer) throws Exception {
SshConstants.Message cmd = buffer.getCommand();
log.debug("Received packet {}", cmd);
switch (cmd) {
case SSH_MSG_DISCONNECT: {
int code = buffer.getInt();... | #fixed code
protected void handleMessage(Buffer buffer) throws Exception {
synchronized (lock) {
doHandleMessage(buffer);
}
} | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void doHandleMessage(Buffer buffer) throws Exception {
SshConstants.Message cmd = buffer.getCommand();
log.debug("Received packet {}", cmd);
switch (cmd) {
case SSH_MSG_DISCONNECT: {
int code = buffer.getInt(... | #fixed code
protected void doHandleMessage(Buffer buffer) throws Exception {
SshConstants.Message cmd = buffer.getCommand();
log.debug("Received packet {}", cmd);
switch (cmd) {
case SSH_MSG_DISCONNECT: {
int code = buffer.getInt();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
protected void doHandleMessage(Buffer buffer) throws Exception {
SshConstants.Message cmd = buffer.getCommand();
log.debug("Received packet {}", cmd);
switch (cmd) {
case SSH_MSG_DISCONNECT: {
int code = buffer.getInt(... | #fixed code
protected void doHandleMessage(Buffer buffer) throws Exception {
SshConstants.Message cmd = buffer.getCommand();
log.debug("Received packet {}", cmd);
switch (cmd) {
case SSH_MSG_DISCONNECT: {
int code = buffer.getInt();
... | Below is the vulnerable code, please generate the patch based on the following information. |
#vulnerable code
static String createLocalSocketAddress() throws IOException {
String name;
String os = System.getProperty("os.name").toLowerCase();
if (os.indexOf("windows") < 0) {
File socket = File.createTempFile("mina", "apr");
socket.... | #fixed code
static String createLocalSocketAddress() throws IOException {
String name;
if (OsUtils.isUNIX()) {
File socket = File.createTempFile("mina", "apr");
socket.delete();
name = socket.getAbsolutePath();
} else {
... | Below is the vulnerable code, please generate the patch based on the following information. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.