output
stringlengths
64
73.2k
input
stringlengths
208
73.3k
instruction
stringclasses
1 value
#fixed code public Result<AccessToken> accessToken(String clientId, String clientSecret, String grantType, String code, String redirectUri, Boolean wap) { List<NameValuePair> params = new ArrayList<NameValuePair>(); connect.addParameter(params, "client_id", clientId); con...
#vulnerable code public Result<AccessToken> accessToken(String clientId, String clientSecret, String grantType, String code, String redirectUri, Boolean wap) { List<NameValuePair> params = new ArrayList<NameValuePair>(); connect.addParameter(params, "client_id", clientId); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testUserInfo() { String openId = System.getProperty("weixin.openid"); Result<com.belerweb.social.weixin.bean.User> result = weixin.getUser().userInfo(weixin.getAccessToken().getToken(), openId); Assert.assertTrue(result.success()); Sy...
#vulnerable code @Test public void testUserInfo() { String accessToken = System.getProperty("weixin.atoken"); String openId = System.getProperty("weixin.openid"); Result<com.belerweb.social.weixin.bean.User> result = weixin.getUser().userInfo(accessToken, openId); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Result<TokenInfo> getTokenInfo(String accessToken) { List<NameValuePair> params = new ArrayList<NameValuePair>(); weibo.addParameter(params, "access_token", accessToken); String result = weibo.post("https://api.weibo.com/oauth2/get_token_info", params); r...
#vulnerable code public Result<TokenInfo> getTokenInfo(String accessToken) { List<NameValuePair> params = new ArrayList<NameValuePair>(); weibo.addParameter(params, "access_token", accessToken); String result = weibo.post("https://api.weibo.com/oauth2/get_token_info", params);...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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); }
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public HttpRequest withBody() throws IOException { body = ByteStreams.toByteArray(super.getInputStream()); return this; }
#vulnerable code @Override public HttpRequest withBody() throws IOException { body = ByteStreams.toByteArray(getInputStream()); return this; } #location 3 #vulnerability type RESOURCE_LEAK
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldUseSameBody() throws IOException { unit.getOutputStream().write("test".getBytes()); final byte[] body1 = unit.getBody(); final byte[] body2 = unit.getBody(); assertSame(body1, body2); }
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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("%"...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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: ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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: ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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: ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void writeSpecRunnerToSourceSpecDirectory() throws IOException { File runnerDestination = new File(jasmineTargetDir,manualSpecRunnerHtmlFileName); String newRunnerHtml = new SpecRunnerHtmlGenerator(scriptsForRunner(), sourceEncoding).generate(ReporterType.TrivialR...
#vulnerable code private void writeSpecRunnerToSourceSpecDirectory() throws IOException { Set<String> scripts = relativizesASetOfScripts.relativize(jasmineTargetDir, resolvesCompleteListOfScriptLocations.resolve(sources, specs, preloadSources)); SpecRunnerHtmlGenerator htmlGenerator...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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;>;"); // ...
Below is the vulnerable code, please generate the patch based on the following information.
#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: " ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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; ...
Below is the vulnerable code, please generate the patch based on the following information.
#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: " ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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: " ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code String getStream(int streamId) { return streams.get(streamId); }
#vulnerable code LogRecordSet.Writer getLogRecordSetWriter() { return recordSetWriter; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#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"); ...
#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");...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String readFileInClasspath(String url) throws Exception { StringBuilder bufferJSON = new StringBuilder(); BufferedReader br = null; try { ClassPathResource classPathResource = new ClassPathResource(url); InputStr...
#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(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void test() { }
#vulnerable code @Test public void test() { MessageHandler messageHandler = SpringContextUtil.getBean("MessageHandler","login"); messageHandler.handle(null,null,null,null); } #location 4 #vulnerability typ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Bean public ExperimentDAO experimentDAO() { LOGGER.debug("Setting up database."); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "/spring/database/database-context.xml"); ExperimentDAO database = conte...
#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); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException { WikipediaApiInterface wikiAPI = SingletonWikipediaApi.getInstance(); // ExperimentTaskConfiguration taskConfigs[] = new ExperimentTaskConfiguration[] { n...
#vulnerable code public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException { WikipediaApiInterface wikiAPI = SingletonWikipediaApi.getInstance(); ExperimentTaskConfiguration taskConfigs[] = new ExperimentTaskConfiguration[] ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public int mp3Count() {synchronized (lock){ return mp3Files.size();} }
#vulnerable code public int mp3Count() { return mp3Files.size(); } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#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()); } ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public int aaxCount() { synchronized (lock) { return aaxFiles.size(); } }
#vulnerable code public int aaxCount() { return aaxFiles.size(); } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void explore(File m) { ArrayList<String>cmdLine = new ArrayList<>(); switch(Platform.getPlatform()) { case mac: cmdLine.add("open"); if (!m.isDirectory()) { ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) { if (!(conn instanceof BasicPooledConnAdapter)) { throw new IllegalArgumentException ("Connection class mismatch, " + "con...
#vulnerable code public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) { if (!(conn instanceof BasicPooledConnAdapter)) { throw new IllegalArgumentException ("Connection class mismatch, " + ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override InputStream decorate(final InputStream wrapped) throws IOException { return new DeflateInputStream(wrapped); }
#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. * ...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void handle(final HttpRequest request, final HttpResponse response, final HttpContext context) throws HttpException, IOException { String method = request.getRequestLine().getMethod().toUpperCase(); ...
#vulnerable 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.
#fixed code public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) { if (!(conn instanceof BasicPooledConnAdapter)) { throw new IllegalArgumentException ("Connection class mismatch, " + "con...
#vulnerable code public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) { if (!(conn instanceof BasicPooledConnAdapter)) { throw new IllegalArgumentException ("Connection class mismatch, " + ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void shutdown() { synchronized (this) { this.shutdown = true; try { if (this.poolEntry != null) { this.poolEntry.close(); } } finally { this.poolEntry = null...
#vulnerable code public void shutdown() { this.shutdown = true; synchronized (this) { try { if (this.poolEntry != null) { this.poolEntry.close(); } } finally { this.poolEntry = nu...
Below is the vulnerable code, please generate the patch based on the following information.
#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(); } }
#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( ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#vulnerable code public void releaseConnection(final ManagedClientConnection conn, long keepalive, TimeUnit tunit) { assertNotShutdown(); if (!(conn instanceof ManagedClientConnectionImpl)) { throw new IllegalArgumentException("Connection class mismatch, " + ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override InputStream decorate(final InputStream wrapped) throws IOException { return new DeflateInputStream(wrapped); }
#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. * ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testBasicPoolEntry() { HttpRoute route = new HttpRoute(TARGET); ClientConnectionOperator ccop = new DefaultClientConnectionOperator(supportedSchemes); BasicPoolEntry bpe = null; try { bpe = new BasicPoolEntr...
#vulnerable code public void testBasicPoolEntry() { HttpRoute route = new HttpRoute(TARGET); ClientConnectionOperator ccop = new DefaultClientConnectionOperator(supportedSchemes); BasicPoolEntry bpe = null; try { bpe = new BasicPo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override InputStream decorate(final InputStream wrapped) throws IOException { return new DeflateInputStream(wrapped); }
#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. * ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) { if (!(conn instanceof BasicPooledConnAdapter)) { throw new IllegalArgumentException ("Connection class mismatch, " + "con...
#vulnerable code public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) { if (!(conn instanceof BasicPooledConnAdapter)) { throw new IllegalArgumentException ("Connection class mismatch, " + ...
Below is the vulnerable code, please generate the patch based on the following information.
#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); ...
#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); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) { if (!(conn instanceof BasicPooledConnAdapter)) { throw new IllegalArgumentException ("Connection class mismatch, " + "con...
#vulnerable code public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) { if (!(conn instanceof BasicPooledConnAdapter)) { throw new IllegalArgumentException ("Connection class mismatch, " + ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testCloseExpiredTTLConnections() throws Exception { final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager( 100, TimeUnit.MILLISECONDS); mgr.setMaxTotal(1); final HttpHost target = ...
#vulnerable code @Test public void testCloseExpiredTTLConnections() throws Exception { final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager( 100, TimeUnit.MILLISECONDS); mgr.setMaxTotal(1); final HttpHost tar...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public CloseableHttpResponse execute( final HttpRoute route, final HttpRequestWrapper request, final HttpClientContext context, final HttpExecutionAware execAware) throws IOException, HttpException { Args.notNull(route, ...
#vulnerable code public CloseableHttpResponse execute( final HttpRoute route, final HttpRequestWrapper request, final HttpClientContext context, final HttpExecutionAware execAware) throws IOException, HttpException { Args.notNull(r...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code CachingHttpClient(HttpClient backend, CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy, CacheEntryFactory cacheEntryFactory, URIExtractor uriExtractor, HttpCache responseCache, CachedHttp...
#vulnerable code HttpResponse handleBackendResponse( HttpHost target, HttpRequest request, Date requestDate, Date responseDate, HttpResponse backendResponse) throws IOException { log.debug("Handling Backend response");...
Below is the vulnerable code, please generate the patch based on the following information.
#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(); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Socket connectSocket( final Socket socket, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { ...
#vulnerable 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.
#fixed code @Test public void testAbortBeforeSocketCreate() throws Exception { final CountDownLatch connectLatch = new CountDownLatch(1); final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory( connectLatch, WaitPolicy.BEFORE_CRE...
#vulnerable code @Test public void testAbortBeforeSocketCreate() throws Exception { final CountDownLatch connectLatch = new CountDownLatch(1); final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory( connectLatch, WaitPolicy.BEFO...
Below is the vulnerable code, please generate the patch based on the following information.
#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); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code CachingHttpClient(HttpClient backend, CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy, CacheEntryFactory cacheEntryFactory, URIExtractor uriExtractor, HttpCache responseCache, CachedHttp...
#vulnerable code HttpCacheEntry doGetUpdatedParentEntry( final String requestId, final HttpCacheEntry existing, final HttpCacheEntry entry, final String variantURI) throws IOException { if (existing != null) { return ca...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testReleaseConnectionOnAbort() throws Exception { final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager(); mgr.setMaxTotal(1); final HttpHost target = getServerHttp(); final HttpRoute rout...
#vulnerable code @Test public void testReleaseConnectionOnAbort() throws Exception { final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager(); mgr.setMaxTotal(1); final HttpHost target = getServerHttp(); final HttpRout...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code CachingExec( final ClientExecChain backend, final HttpCache responseCache, final CacheValidityPolicy validityPolicy, final ResponseCachingPolicy responseCachingPolicy, final CachedHttpResponseGenerator responseGenera...
#vulnerable code CloseableHttpResponse revalidateCacheEntry( final HttpRoute route, final HttpRequestWrapper request, final HttpClientContext context, final HttpExecutionAware execAware, final HttpCacheEntry cacheEntry) throws ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected ClientConnectionManager createClientConnectionManager() { SchemeRegistry registry = SchemeRegistryFactory.createDefault(); ClientConnectionManager connManager = null; HttpParams params = getParams(); ClientConnectionManagerFactory f...
#vulnerable code protected ClientConnectionManager createClientConnectionManager() { SchemeRegistry registry = SchemeRegistryFactory.createDefault(); ClientConnectionManager connManager = null; HttpParams params = getParams(); ClientConnectionManagerFac...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) { if (!(conn instanceof BasicPooledConnAdapter)) { throw new IllegalArgumentException ("Connection class mismatch, " + "con...
#vulnerable code public void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit) { if (!(conn instanceof BasicPooledConnAdapter)) { throw new IllegalArgumentException ("Connection class mismatch, " + ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#vulnerable code public void releaseConnection(final ManagedClientConnection conn, long keepalive, TimeUnit tunit) { assertNotShutdown(); if (!(conn instanceof ManagedClientConnectionImpl)) { throw new IllegalArgumentException("Connection class mismatch, " + ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code CachingExec( final ClientExecChain backend, final HttpCache responseCache, final CacheValidityPolicy validityPolicy, final ResponseCachingPolicy responseCachingPolicy, final CachedHttpResponseGenerator responseGenera...
#vulnerable code CloseableHttpResponse handleBackendResponse( final HttpRoute route, final HttpRequestWrapper request, final HttpClientContext context, final HttpExecutionAware execAware, final Date requestDate, fin...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void doWriteTo( final HttpMultipartMode mode, final OutputStream out, boolean writeContent) throws IOException { List<BodyPart> bodyParts = getBodyParts(); Charset charset = getCharset(); ByteArrayBuffer boun...
#vulnerable code private void doWriteTo( final HttpMultipartMode mode, final OutputStream out, boolean writeContent) throws IOException { List<?> bodyParts = getBodyParts(); Charset charset = getCharset(); String boundary = getB...
Below is the vulnerable code, please generate the patch based on the following information.
#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); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code CachingHttpClient(HttpClient backend, CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy, CacheEntryFactory cacheEntryFactory, URIExtractor uriExtractor, HttpCache responseCache, CachedHttp...
#vulnerable code HttpCacheEntry doGetUpdatedParentEntry( final String requestId, final HttpCacheEntry existing, final HttpCacheEntry entry, final String variantURI) throws IOException { if (existing != null) { return ca...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testAbortAfterSocketConnect() throws Exception { final CountDownLatch connectLatch = new CountDownLatch(1); final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory( connectLatch, WaitPolicy.AFTER_CONN...
#vulnerable code @Test public void testAbortAfterSocketConnect() throws Exception { final CountDownLatch connectLatch = new CountDownLatch(1); final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory( connectLatch, WaitPolicy.AFTE...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override InputStream decorate(final InputStream wrapped) throws IOException { return new DeflateInputStream(wrapped); }
#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. * ...
Below is the vulnerable code, please generate the patch based on the following information.
#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; ...
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override InputStream decorate(final InputStream wrapped) throws IOException { return new DeflateInputStream(wrapped); }
#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. * ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#vulnerable code private Header createDigestHeader( final Credentials credentials, final HttpRequest request) throws AuthenticationException { String uri = getParameter("uri"); String realm = getParameter("realm"); String nonce = getParame...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testAbortDuringConnecting() throws Exception { final CountDownLatch connectLatch = new CountDownLatch(1); final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory( connectLatch, WaitPolicy.BEFORE_CONNE...
#vulnerable code @Test public void testAbortDuringConnecting() throws Exception { final CountDownLatch connectLatch = new CountDownLatch(1); final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory( connectLatch, WaitPolicy.BEFORE...
Below is the vulnerable code, please generate the patch based on the following information.
#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); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code CachingHttpClient( HttpClient client, HttpCache cache, CacheConfig config) { super(); if (client == null) { throw new IllegalArgumentException("HttpClient may not be null"); } if (cache == null) {...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void enableConnectionGC() throws IllegalStateException { if (refQueue != null) { throw new IllegalStateException("Connection GC already enabled."); } poolLock.lock(); try { if (numConnections > 0) { //@@@...
#vulnerable 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.
#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...
#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()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testReleaseConnection() throws Exception { final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager(); mgr.setMaxTotal(1); final HttpHost target = getServerHttp(); final HttpRoute route = new...
#vulnerable code @Test public void testReleaseConnection() throws Exception { final PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager(); mgr.setMaxTotal(1); final HttpHost target = getServerHttp(); final HttpRoute route...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test(expected = IllegalArgumentException.class) public void testDecorateCORSPropertiesValidRequestNullRequestType() { MockHttpServletRequest request = new MockHttpServletRequest(); CORSFilter.decorateCORSProperties(request, null); }
#vulnerable code @Test(expected = IllegalArgumentException.class) public void testDecorateCORSPropertiesValidRequestNullRequestType() { HttpServletRequest request = EasyMock.createMock(HttpServletRequest.class); EasyMock.replay(request); CORSF...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void handleMessage(Buffer buffer) throws Exception { synchronized (lock) { doHandleMessage(buffer); } }
#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();...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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 '" ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void handleMessage(Buffer buffer) throws Exception { synchronized (lock) { doHandleMessage(buffer); } }
#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();...
Below is the vulnerable code, please generate the patch based on the following information.
#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....
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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....
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected boolean handleShell(Buffer buffer) throws IOException { boolean wantReply = buffer.getBoolean(); if (((ServerSession) session).getServerFactoryManager().getShellFactory() == null) { return false; } addEnvVariable("USER", ...
#vulnerable code protected boolean handleShell(Buffer buffer) throws IOException { boolean wantReply = buffer.getBoolean(); if (((ServerSession) session).getServerFactoryManager().getShellFactory() == null) { return false; } addEnvVariable("U...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void handleMessage(Buffer buffer) throws Exception { synchronized (lock) { doHandleMessage(buffer); } }
#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();...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void setupSensibleDefaultPty() { try { if (OsUtils.isUNIX()) { ptyModes = SttySupport.getUnixPtyModes(); ptyColumns = SttySupport.getTerminalWidth(); ptyLines = SttySupport.getTerminalHeight(); ...
#vulnerable code public void setupSensibleDefaultPty() { try { String os = System.getProperty("os.name").toLowerCase(); if (os.indexOf("windows") < 0) { ptyModes = SttySupport.getUnixPtyModes(); ptyColumns = SttySupport.get...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void handleMessage(Buffer buffer) throws Exception { synchronized (lock) { doHandleMessage(buffer); } }
#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();...
Below is the vulnerable code, please generate the patch based on the following information.