output
stringlengths
64
73.2k
input
stringlengths
208
73.3k
instruction
stringclasses
1 value
#fixed code @Test public void testConnectionManager() { // 初始化 TrackerConnectionManager manager = crtInvalidateIpListManager(); List<GroupState> list = null; // 第一次执行 try { // 连接失败 list = manager.executeFdfsTrackerCmd(ne...
#vulnerable code @Test public void testConnectionManager() { // 初始化 TrackerConnectionManager manager = new TrackerConnectionManager(createPool()); manager.setTrackerList(trackerIpList); manager.initTracker(); List<GroupState> list = null; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private List<GroupState> decode(byte[] bs, Charset charset) throws IOException { // 获取对象转换定义 ObjectMataData objectMataData = FdfsParamMapper.getObjectMap(GroupState.class); int fixFieldsTotalSize = objectMataData.getFieldsFixTotalSize(); if (bs...
#vulnerable code private List<GroupState> decode(byte[] bs, Charset charset) throws IOException { // 获取对象转换定义 ObjectMateData objectMateData = FdfsParamMapper.getObjectMap(GroupState.class); int fixFieldsTotalSize = objectMateData.getFieldsFixTotalSize(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testImaging144() throws Exception { tiffOutputSet.setGPSInDegrees(1.0, 1.0); TiffOutputDirectory gpsDirectory = tiffOutputSet.getGPSDirectory(); TiffOutputField gpsVersionId = gpsDirectory.findField(GpsTagConstants.GPS_TAG_GPS_VE...
#vulnerable code @Test public void testImaging144() throws Exception { tiffOutputSet.setGPSInDegrees(1.0, 1.0); TiffOutputDirectory gpsDirectory = tiffOutputSet.getGPSDirectory(); TiffOutputField gpsVersionId = getGpsVersionId(gpsDirectory); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected List<IptcBlock> parseAllBlocks(byte bytes[], boolean verbose, boolean strict) throws ImageReadException, IOException { List<IptcBlock> blocks = new ArrayList<IptcBlock>(); BinaryInputStream bis = null; try { bis = new...
#vulnerable code protected List<IptcBlock> parseAllBlocks(byte bytes[], boolean verbose, boolean strict) throws ImageReadException, IOException { List<IptcBlock> blocks = new ArrayList<IptcBlock>(); BinaryInputStream bis = new BinaryInputStream(bytes, APP13_...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void dump() { PrintWriter pw = new PrintWriter(System.out); dump(pw); pw.flush(); }
#vulnerable code public void dump() { dump(new PrintWriter(new OutputStreamWriter(System.out))); } #location 3 #vulnerability type RESOURCE_LEAK
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public final byte[] deflate(byte bytes[]) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DeflaterOutputStream dos = new DeflaterOutputStream(baos); dos.write(bytes); dos.flush(); return baos.toByteArray(); }
#vulnerable code public final byte[] deflate(byte bytes[]) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(bytes); DeflaterInputStream zIn = new DeflaterInputStream(in); return getStreamBytes(zIn); } #location 5 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public final void debugNumber(String msg, int data, int bytes) { PrintWriter pw = new PrintWriter(System.out); debugNumber(pw, msg, data, bytes); pw.flush(); }
#vulnerable code public final void debugNumber(String msg, int data, int bytes) { debugNumber(new PrintWriter(new OutputStreamWriter(System.out)), msg, data, bytes); } #location 3 #vulnerability type RESOURCE_LEAK
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public byte[] compress(byte bytes[]) throws IOException { MyByteArrayOutputStream baos = null; try { baos = new MyByteArrayOutputStream( bytes.length * 2); // max length 1 extra byte for every 128 int ptr = 0; ...
#vulnerable code public byte[] compress(byte bytes[]) throws IOException { MyByteArrayOutputStream baos = new MyByteArrayOutputStream( bytes.length * 2); // max length 1 extra byte for every 128 int ptr = 0; int count = 0; while (ptr < by...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static byte[] decompressModifiedHuffman(final byte[] compressed, final int width, final int height) throws ImageReadException { try (ByteArrayInputStream baos = new ByteArrayInputStream(compressed); BitInputStreamFlexible inputStream...
#vulnerable code public static byte[] decompressModifiedHuffman(final byte[] compressed, final int width, final int height) throws ImageReadException { final BitInputStreamFlexible inputStream = new BitInputStreamFlexible( new ByteArrayInputStream(com...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public byte[] getAll() throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (FileInputStream fis = new FileInputStream(file); InputStream is = new BufferedInputStream(fis)) { final ...
#vulnerable code @Override public byte[] getAll() throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); InputStream is = null; boolean canThrow = false; try { is = new FileInputStream(file); is =...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void removeExifMetadata(final File jpegImageFile, final File dst) throws IOException, ImageReadException, ImageWriteException { try (FileOutputStream fos = new FileOutputStream(dst); OutputStream os = new BufferedOutputStream(fos)) {...
#vulnerable code public void removeExifMetadata(final File jpegImageFile, final File dst) throws IOException, ImageReadException, ImageWriteException { OutputStream os = null; boolean canThrow = false; try { os = new FileOutputStream(dst);...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void dump() { PrintWriter pw = new PrintWriter(System.out); dump(pw); pw.flush(); }
#vulnerable code public void dump() { dump(new PrintWriter(new OutputStreamWriter(System.out))); } #location 3 #vulnerability type RESOURCE_LEAK
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void writeImage(BufferedImage src, OutputStream os, Map params) throws ImageWriteException, IOException { // make copy of params; we'll clear keys as we consume them. params = (params == null) ? new HashMap() : new HashMap(params); ...
#vulnerable code public void writeImage(BufferedImage src, OutputStream os, Map params) throws ImageWriteException, IOException { // make copy of params; we'll clear keys as we consume them. params = (params == null) ? new HashMap() : new HashMap(params);...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static byte[] decompressModifiedHuffman(final byte[] compressed, final int width, final int height) throws ImageReadException { try (ByteArrayInputStream baos = new ByteArrayInputStream(compressed); BitInputStreamFlexible inputStream...
#vulnerable code public static byte[] decompressModifiedHuffman(final byte[] compressed, final int width, final int height) throws ImageReadException { final BitInputStreamFlexible inputStream = new BitInputStreamFlexible( new ByteArrayInputStream(com...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected List<IptcBlock> parseAllBlocks(byte bytes[], boolean verbose, boolean strict) throws ImageReadException, IOException { List<IptcBlock> blocks = new ArrayList<IptcBlock>(); BinaryInputStream bis = null; try { bis = new...
#vulnerable code protected List<IptcBlock> parseAllBlocks(byte bytes[], boolean verbose, boolean strict) throws ImageReadException, IOException { List<IptcBlock> blocks = new ArrayList<IptcBlock>(); BinaryInputStream bis = new BinaryInputStream(bytes, APP13_...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void changeExifMetadata(final File jpegImageFile, final File dst) throws IOException, ImageReadException, ImageWriteException { try (FileOutputStream fos = new FileOutputStream(dst); OutputStream os = new BufferedOutputStrea...
#vulnerable code public void changeExifMetadata(final File jpegImageFile, final File dst) throws IOException, ImageReadException, ImageWriteException { OutputStream os = null; boolean canThrow = false; try { TiffOutputSet outputSet = null;...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRemove() throws Exception { final ByteSource byteSource = new ByteSourceFile(imageFile); final Map<String, Object> params = new HashMap<String, Object>(); final boolean ignoreImageData = isPhilHarveyTestImage(imageFile); ...
#vulnerable code @Test public void testRemove() throws Exception { final ByteSource byteSource = new ByteSourceFile(imageFile); final Map<String, Object> params = new HashMap<String, Object>(); final boolean ignoreImageData = isPhilHarveyTestImage(imageFile)...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testImaging144() throws Exception { tiffOutputSet.setGPSInDegrees(1.0, 1.0); TiffOutputField gpsVersionId = tiffOutputSet.findField(GpsTagConstants.GPS_TAG_GPS_VERSION_ID); assertNotNull(gpsVersionId); assertTrue(gpsVers...
#vulnerable code @Test public void testImaging144() throws Exception { tiffOutputSet.setGPSInDegrees(1.0, 1.0); TiffOutputDirectory gpsDirectory = tiffOutputSet.getGPSDirectory(); TiffOutputField gpsVersionId = gpsDirectory.findField(GpsTagConstants.GPS_TAG_...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void test() throws Exception { String imagesFolderPath = FilenameUtils .separatorsToSystem("src\\test\\data\\images\\png\\3"); File imagesFolder = new File(imagesFolderPath); assertTrue(imagesFolder.exists() && imagesFolder.isDir...
#vulnerable code public void test() throws Exception { String imagesFolderPath = FilenameUtils .separatorsToSystem("src\\test\\data\\images\\png\\3"); File imagesFolder = new File(imagesFolderPath); assertTrue(imagesFolder.exists() && imagesFolder...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testAll5x2Images() { int[] combinations = new int[10]; BufferedImage image = new BufferedImage(5, 2, BufferedImage.TYPE_INT_RGB); do { for (int x = 0; x < 5; x++) { if (combinations[x] == 0) { ...
#vulnerable code public void testAll5x2Images() { int[] combinations = new int[10]; BufferedImage image = new BufferedImage(5, 2, BufferedImage.TYPE_INT_RGB); do { for (int x = 0; x < 5; x++) { if (combinations[x] == 0) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testAddIptcData() throws Exception { final ByteSource byteSource = new ByteSourceFile(imageFile); final Map<String, Object> params = new HashMap<String, Object>(); final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);...
#vulnerable code @Test public void testAddIptcData() throws Exception { final ByteSource byteSource = new ByteSourceFile(imageFile); final Map<String, Object> params = new HashMap<String, Object>(); final boolean ignoreImageData = isPhilHarveyTestImage(image...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void interpretStrip( final ImageBuilder imageBuilder, final byte[] bytes, final int pixelsPerStrip, final int yLimit) throws ImageReadException, IOException { if (y >= yLimit) { return; } ...
#vulnerable code private void interpretStrip( final ImageBuilder imageBuilder, final byte[] bytes, final int pixelsPerStrip, final int yLimit) throws ImageReadException, IOException { if (y >= yLimit) { return; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected List<IptcBlock> parseAllBlocks(byte bytes[], boolean verbose, boolean strict) throws ImageReadException, IOException { List<IptcBlock> blocks = new ArrayList<IptcBlock>(); BinaryInputStream bis = null; try { bis = new...
#vulnerable code protected List<IptcBlock> parseAllBlocks(byte bytes[], boolean verbose, boolean strict) throws ImageReadException, IOException { List<IptcBlock> blocks = new ArrayList<IptcBlock>(); BinaryInputStream bis = new BinaryInputStream(bytes, APP13_...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public byte[] compress(final byte[] bytes) throws IOException { // max length 1 extra byte for every 128 try (FastByteArrayOutputStream baos = new FastByteArrayOutputStream(bytes.length * 2)) { int ptr = 0; while (ptr < bytes.length) { ...
#vulnerable code public byte[] compress(final byte[] bytes) throws IOException { FastByteArrayOutputStream baos = null; boolean canThrow = false; try { baos = new FastByteArrayOutputStream( bytes.length * 2); // max length 1 extra ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void removeExifTag(final File jpegImageFile, final File dst) throws IOException, ImageReadException, ImageWriteException { try (FileOutputStream fos = new FileOutputStream(dst); OutputStream os = new BufferedOutputStream(fos)) { ...
#vulnerable code public void removeExifTag(final File jpegImageFile, final File dst) throws IOException, ImageReadException, ImageWriteException { OutputStream os = null; boolean canThrow = false; try { TiffOutputSet outputSet = null; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void performTest(final String name) { final File target = new File(name); final Formatter fmt = new Formatter(System.out); double sumTime = 0; int n = 1; for (int i = 0; i < 10; i++) { try { ByteSour...
#vulnerable code private void performTest(final String name) { final File target = new File(name); final Formatter fmt = new Formatter(System.out); double sumTime = 0; int n = 1; for (int i = 0; i < 10; i++) { try { By...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public byte[] getBlock(int blockStart, int blockLength) throws IOException { // We include a separate check for int overflow. if ((blockStart < 0) || (blockLength < 0) || (blockStart + blockLength < 0) || (bl...
#vulnerable code public byte[] getBlock(int blockStart, int blockLength) throws IOException { // We include a separate check for int overflow. if ((blockStart < 0) || (blockLength < 0) || (blockStart + blockLength < 0) ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public byte[] getBlock(final long start, final int length) throws IOException { try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { // We include a separate check for int overflow. if ((start < 0) || (length < 0) || (st...
#vulnerable code @Override public byte[] getBlock(final long start, final int length) throws IOException { RandomAccessFile raf = null; boolean canThrow = false; try { raf = new RandomAccessFile(file, "r"); // We include a separate c...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testAddIptcData() throws Exception { final ByteSource byteSource = new ByteSourceFile(imageFile); final Map<String, Object> params = new HashMap<String, Object>(); final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);...
#vulnerable code @Test public void testAddIptcData() throws Exception { final ByteSource byteSource = new ByteSourceFile(imageFile); final Map<String, Object> params = new HashMap<String, Object>(); final boolean ignoreImageData = isPhilHarveyTestImage(image...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected File createTempFile(final byte src[]) throws IOException { final File file = createTempFile("raw_", ".bin"); // write test bytes to file. try (FileOutputStream fos = new FileOutputStream(file); OutputStream os = new BufferedO...
#vulnerable code protected File createTempFile(final byte src[]) throws IOException { final File file = createTempFile("raw_", ".bin"); // write test bytes to file. OutputStream os = null; boolean canThrow = false; try { os = new File...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected static ICC_Profile getICCProfile(ByteSource byteSource, Map params) throws ImageReadException, IOException { byte bytes[] = getICCProfileBytes(byteSource, params); if (bytes == null) return null; IccProfileParser parser = new IccProfileParser(); IccProfi...
#vulnerable code protected static ICC_Profile getICCProfile(ByteSource byteSource, Map params) throws ImageReadException, IOException { byte bytes[] = getICCProfileBytes(byteSource, params); if (bytes == null) return null; IccProfileParser parser = new IccProfileParser(); Ic...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void setData(final byte[] bytes) throws IOException { data = bytes; InputStream bis = null; boolean canThrow = false; try { bis = new ByteArrayInputStream(bytes); dataTypeSignature = BinaryFunctions.read4Bytes("d...
#vulnerable code public void setData(final byte[] bytes) throws IOException { data = bytes; BinaryInputStream bis = null; boolean canThrow = false; try { bis = new BinaryInputStream(new ByteArrayInputStream( bytes), ByteOrder....
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void writeImage(BufferedImage src, OutputStream os, Map params) throws ImageWriteException, IOException { // make copy of params; we'll clear keys as we consume them. params = (params == null) ? new HashMap() : new HashMap(para...
#vulnerable code @Override public void writeImage(BufferedImage src, OutputStream os, Map params) throws ImageWriteException, IOException { // make copy of params; we'll clear keys as we consume them. params = (params == null) ? new HashMap() : new HashMa...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public byte[] getBlock(int blockStart, int blockLength) throws IOException { // We include a separate check for int overflow. if ((blockStart < 0) || (blockLength < 0) || (blockStart + blockLength < 0) || (bl...
#vulnerable code public byte[] getBlock(int blockStart, int blockLength) throws IOException { // We include a separate check for int overflow. if ((blockStart < 0) || (blockLength < 0) || (blockStart + blockLength < 0) ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void interpretTile(final ImageBuilder imageBuilder, final byte[] bytes, final int startX, final int startY, final int xLimit, final int yLimit) throws ImageReadException, IOException { // changes introduced May 2012 // The following block o...
#vulnerable code private void interpretTile(final ImageBuilder imageBuilder, final byte[] bytes, final int startX, final int startY, final int xLimit, final int yLimit) throws ImageReadException, IOException { // changes introduced May 2012 // The following b...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static byte[] decompressModifiedHuffman(final byte[] compressed, final int width, final int height) throws ImageReadException { try (ByteArrayInputStream baos = new ByteArrayInputStream(compressed); BitInputStreamFlexible inputStream...
#vulnerable code public static byte[] decompressModifiedHuffman(final byte[] compressed, final int width, final int height) throws ImageReadException { final BitInputStreamFlexible inputStream = new BitInputStreamFlexible( new ByteArrayInputStream(com...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void setExifGPSTag(final File jpegImageFile, final File dst) throws IOException, ImageReadException, ImageWriteException { try (FileOutputStream fos = new FileOutputStream(dst); OutputStream os = new BufferedOutputStream(fos)) { ...
#vulnerable code public void setExifGPSTag(final File jpegImageFile, final File dst) throws IOException, ImageReadException, ImageWriteException { OutputStream os = null; boolean canThrow = false; try { TiffOutputSet outputSet = null; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected List<IptcBlock> parseAllBlocks(final byte[] bytes, final boolean verbose, final boolean strict) throws ImageReadException, IOException { final List<IptcBlock> blocks = new ArrayList<IptcBlock>(); InputStream bis = null; boolean c...
#vulnerable code protected List<IptcBlock> parseAllBlocks(final byte[] bytes, final boolean verbose, final boolean strict) throws ImageReadException, IOException { final List<IptcBlock> blocks = new ArrayList<IptcBlock>(); BinaryInputStream bis = null; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testRemove() throws Exception { final ByteSource byteSource = new ByteSourceFile(imageFile); final Map<String, Object> params = new HashMap<String, Object>(); final boolean ignoreImageData = isPhilHarveyTestImage(imageFile); ...
#vulnerable code @Test public void testRemove() throws Exception { final ByteSource byteSource = new ByteSourceFile(imageFile); final Map<String, Object> params = new HashMap<String, Object>(); final boolean ignoreImageData = isPhilHarveyTestImage(imageFile)...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void dump() { PrintWriter pw = new PrintWriter(System.out); dump(pw); pw.flush(); }
#vulnerable code public void dump() { dump(new PrintWriter(new OutputStreamWriter(System.out))); } #location 3 #vulnerability type RESOURCE_LEAK
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static byte[] decompressT4_1D(final byte[] compressed, final int width, final int height, final boolean hasFill) throws ImageReadException { final BitInputStreamFlexible inputStream = new BitInputStreamFlexible(new ByteArrayInputStream(compressed));...
#vulnerable code public static byte[] decompressT4_1D(final byte[] compressed, final int width, final int height, final boolean hasFill) throws ImageReadException { final BitInputStreamFlexible inputStream = new BitInputStreamFlexible(new ByteArrayInputStream(compres...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void changeSelection(int row, int column, boolean toggle, boolean extend) { // For shift+click lastRow = currentRow; int lastColumn = currentColumn; currentRow = row; currentColumn = column; super.changeSel...
#vulnerable code @Override public void changeSelection(int row, int column, boolean toggle, boolean extend) { // For shift+click lastRow = currentRow; lastColumn = currentColumn; currentRow = row; currentColumn = column; super.changeS...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void performAction() { AbstractFile targetFile = mainFrame.getActiveTable().getSelectedFile(); if (targetFile == null) { targetFile = mainFrame.getActiveTable().getFileTableModel().getFileAt(0).getParent(); } Ab...
#vulnerable code @Override public void performAction() { AbstractFile targetFile = mainFrame.getActiveTable().getSelectedFile(); if (targetFile == null) { targetFile = mainFrame.getInactiveTable().getFileTableModel().getFileAt(0).getParent(); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void shouldHandleExceptionDuringRequestCreation() throws URISyntaxException, IOException { exception.expect(IOException.class); exception.expectMessage("Could not create request"); final AsyncClientHttpRequestFactory factory = (uri, ...
#vulnerable code @Test public void shouldHandleExceptionDuringRequestCreation() throws URISyntaxException, IOException { exception.expect(IOException.class); exception.expectMessage("Could not create request"); final AsyncClientHttpRequestFactory factory = ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testPublishDeleteShapeZip() throws FileNotFoundException, IOException { if (!enabled()) { return; } // Assume.assumeTrue(enabled); deleteAllWorkspaces(); assertTrue(publisher.createWorkspace(DEFAULT_WS)); // ...
#vulnerable code public void testPublishDeleteShapeZip() throws FileNotFoundException, IOException { if (!enabled()) { return; } // Assume.assumeTrue(enabled); String ns = "it.geosolutions"; String storeName = "resttestshp"; St...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Before public void setup() throws Exception { if (enabled()){ init(); } }
#vulnerable code @Before public void setup() throws Exception { String ws = "topp"; String storeName = "testshpcollection"; // Delete all resources except styles deleteAllWorkspacesRecursively(); // Create workspace ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testCreateDeletePostGISDatastore() { if (!enabled()) { return; } deleteAll(); String wsName = DEFAULT_WS; String datastoreName = "resttestpostgis"; String description = "description"; Str...
#vulnerable code public void testCreateDeletePostGISDatastore() { if (!enabled()) { return; } String wsName = "it.geosolutions"; String datastoreName = "resttestpostgis"; String description = "description"; String dsNamespace ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void deleteAllLayerGroups() { List<String> groups = reader.getLayerGroups().getNames(); LOGGER.info("Found " + groups.size() + " layerGroups"); for (String groupName : groups) { RESTLayerGroup group = reader.getLayerGroup(groupName)...
#vulnerable code private void deleteAllLayerGroups() { List<String> groups = reader.getLayerGroups().getNames(); LOGGER.info("Found " + groups.size() + " layerGroups"); for (String groupName : groups) { RESTLayerGroup group = reader.getLayerGroup(grou...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public List<String> getWorkspaceNames() { RESTWorkspaceList list = getWorkspaces(); if(list==null){ return Collections.emptyList(); } List<String> names = new ArrayList<String>(list.size()); for (RESTWorkspaceList.RESTShortWork...
#vulnerable code public List<String> getWorkspaceNames() { RESTWorkspaceList list = getWorkspaces(); List<String> names = new ArrayList<String>(list.size()); for (RESTWorkspaceList.RESTShortWorkspace item : list) { names.add(item.getName()); }...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private GSImageMosaicEncoder copyParameters(String wsName, String coverageStoreName, String csname) throws NumberFormatException { // get current config for the coverage to extract the params we want to set again final RESTCoverage coverage = reade...
#vulnerable code private GSImageMosaicEncoder copyParameters(String wsName, String coverageStoreName, String csname) throws NumberFormatException { // get current config for the coverage to extract the params we want to set again final RESTCoverage coverage =...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void deleteStylesForWorkspace(String workspace) { RESTStyleList styles = styleManager.getStyles(workspace); if (styles==null) return; for (NameLinkElem nameLinkElem : styles) { removeStyleInWorkspace(workspace, nameLinkE...
#vulnerable code private void deleteStylesForWorkspace(String workspace) { RESTStyleList styles = styleManager.getStyles(workspace); for (NameLinkElem nameLinkElem : styles) { removeStyleInWorkspace(workspace, nameLinkElem.getName(), true); } } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Before public void setup() throws Exception { if (enabled()){ init(); } }
#vulnerable code @Before public void setup() throws Exception { String ws = "topp"; String storeName = "testshpcollection"; // Delete all resources except styles deleteAllWorkspacesRecursively(); // Create workspace ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void fixDimensions(String wsName, String coverageStoreName, String csname) { final GSImageMosaicEncoder coverageEncoder = copyParameters(wsName, coverageStoreName, csname); // activate time dimension final GSD...
#vulnerable code private void fixDimensions(String wsName, String coverageStoreName, String csname) { // get current config for the coverage to extract the params we want to set again final RESTCoverage coverage = reader.getCoverage(wsName, coverageStoreName, csname); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testCreateDeletePostGISDatastore() { if (!enabled()) { return; } deleteAll(); String wsName = DEFAULT_WS; String datastoreName = "resttestpostgis"; String description = "description"; Str...
#vulnerable code public void testCreateDeletePostGISDatastore() { if (!enabled()) { return; } String wsName = "it.geosolutions"; String datastoreName = "resttestpostgis"; String description = "description"; String dsNamespace ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code ScheduledExecutorService getScheduledExecutor() { return this.scheduledExecutor; }
#vulnerable code void failRequestLimitExceeded(Operation request) { // Add a header indicating retry should be attempted after some interval. // Currently set to just one second, subject to change in the future request.addResponseHeader(Operation.RETRY_AFTER_HEAD...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void stop() { this.channelPool.stop(); if (this.sslChannelPool != null) { this.sslChannelPool.stop(); } if (this.http2ChannelPool != null) { this.http2ChannelPool.stop(); } // In prac...
#vulnerable code @Override public void stop() { this.channelPool.stop(); if (this.sslChannelPool != null) { this.sslChannelPool.stop(); } if (this.http2ChannelPool != null) { this.http2ChannelPool.stop(); } this...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void paginatedbroadcastQueryTasksOnExampleStates () throws Throwable { VerificationHost targetHost = this.host.getPeerHost(); int serviceCount = 100; int resultLimit = 30; QuerySpecification q = new QuerySpecification(); Quer...
#vulnerable code private void paginatedbroadcastQueryTasksOnExampleStates () throws Throwable { VerificationHost targetHost = this.host.getPeerHost(); URI exampleFactoryURI = UriUtils.buildUri(targetHost, ExampleFactoryService.SELF_LINK); int serviceCount = 100...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void stop() { this.channelPool.stop(); if (this.sslChannelPool != null) { this.sslChannelPool.stop(); } if (this.http2ChannelPool != null) { this.http2ChannelPool.stop(); } // In prac...
#vulnerable code @Override public void stop() { this.channelPool.stop(); if (this.sslChannelPool != null) { this.sslChannelPool.stop(); } if (this.http2ChannelPool != null) { this.http2ChannelPool.stop(); } this...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void stop() { this.channelPool.stop(); if (this.sslChannelPool != null) { this.sslChannelPool.stop(); } if (this.http2ChannelPool != null) { this.http2ChannelPool.stop(); } // In prac...
#vulnerable code @Override public void stop() { this.channelPool.stop(); if (this.sslChannelPool != null) { this.sslChannelPool.stop(); } if (this.http2ChannelPool != null) { this.http2ChannelPool.stop(); } this...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void handleRestore(Operation op, RestoreRequest req) { IndexWriter w = this.writer; if (w == null) { op.fail(new CancellationException()); return; } // We already have a slot in the semaphore. Acquire the rest....
#vulnerable code private void handleRestore(Operation op, RestoreRequest req) { IndexWriter w = this.writer; if (w == null) { op.fail(new CancellationException()); return; } // We already have a slot in the semaphore. Acquire the...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void stop() { this.channelPool.stop(); if (this.sslChannelPool != null) { this.sslChannelPool.stop(); } if (this.http2ChannelPool != null) { this.http2ChannelPool.stop(); } // In prac...
#vulnerable code @Override public void stop() { this.channelPool.stop(); if (this.sslChannelPool != null) { this.sslChannelPool.stop(); } if (this.http2ChannelPool != null) { this.http2ChannelPool.stop(); } this...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void stop() { this.channelPool.stop(); if (this.sslChannelPool != null) { this.sslChannelPool.stop(); } if (this.http2ChannelPool != null) { this.http2ChannelPool.stop(); } // In prac...
#vulnerable code @Override public void stop() { this.channelPool.stop(); if (this.sslChannelPool != null) { this.sslChannelPool.stop(); } if (this.http2ChannelPool != null) { this.http2ChannelPool.stop(); } this...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code ScheduledExecutorService getScheduledExecutor() { return this.scheduledExecutor; }
#vulnerable code void startOrSynchService(Operation post, Service child) { Service s = findService(post.getUri().getPath()); if (s == null) { startService(post, child); return; } Operation synchPut = Operation.createPut(post.getUr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Autowired(type = PandaTypes.TYPES_LABEL) @AutowiredParameters(skip = 3, value = { @Type(with = Src.class, value = "return"), @Type(with = Src.class, value = "name"), @Type(with = Src.class, value = "*parameters") }) boolean par...
#vulnerable code @Autowired(type = PandaTypes.TYPES_LABEL) @AutowiredParameters(skip = 3, value = { @Type(with = Src.class, value = "return"), @Type(with = Src.class, value = "name"), @Type(with = Src.class, value = "*parameters") }) boole...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testTokenPattern() { TokenPattern pattern = TokenPattern.builder() .compile("(method|hidden|local) [static] <return-type> <name>(<parameters>) \\{ <body> \\}[;]") .build(); LexicalPatternElement content = ...
#vulnerable code @Test public void testTokenPattern() { TokenPattern pattern = TokenPattern.builder() .compile("(method|hidden|local) [static] <return-type> <name>(<parameters>) \\{ <body> \\}[;]") .build(); LexicalPatternElement cont...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public NamedExecutable parse(Atom atom) { final String source = atom.getSourcesDivider().getLine(); final StringBuilder importBuilder = new StringBuilder(); int stage = 0; Import importElement = null; String operator = nu...
#vulnerable code @Override public NamedExecutable parse(Atom atom) { final String source = atom.getSourceCode(); final StringBuilder importBuilder = new StringBuilder(); int stage = 0; Import importElement = null; String operator = null; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Expression parse(ParserInfo info, TokenizedSource expressionSource) { if (expressionSource.size() == 1) { Token token = expressionSource.getToken(0); String value = token.getTokenValue(); if (token.getType() == TokenType.LIT...
#vulnerable code public Expression parse(ParserInfo info, TokenizedSource expressionSource) { if (expressionSource.size() == 1) { Token token = expressionSource.getToken(0); String value = token.getTokenValue(); if (token.getType() == TokenTy...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Essence run(Particle particle) { while (factors[0].getValue(PBoolean.class).isTrue()) { Essence o = super.run(particle); if (o != null) { return o; } } return null; }
#vulnerable code @Override public Essence run(Particle particle) { while (parameters[0].getValue(PBoolean.class).isTrue()) { Essence o = super.run(particle); if (o != null) { return o; } } return null; }...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean isPublic(Object o) { if (o == null) { return false; } if (o instanceof ClassFile) { return AccessFlag.isPublic(((ClassFile) o).getAccessFlags()); } if (o instanceof MethodInfo) { retu...
#vulnerable code public boolean isPublic(Object o) { int accessFlags = o instanceof ClassFile ? ((ClassFile) o).getAccessFlags() : o instanceof FieldInfo ? ((FieldInfo) o).getAccessFlags() : o instanceof MethodInfo ? ((Meth...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean extract(TokenizedSource tokenizedSource) { TokenPatternUnit[] units = pattern.getUnits(); ArrayDistributor<TokenPatternUnit> unitsDistributor = new ArrayDistributor<>(units); TokenReader tokenReader = new PandaTokenReader(tokenizedSourc...
#vulnerable code public boolean extract(TokenizedSource tokenizedSource) { TokenPatternUnit[] units = pattern.getUnits(); ArrayDistributor<TokenPatternUnit> unitsDistributor = new ArrayDistributor<>(units); TokenReader tokenReader = new PandaTokenReader(tokenize...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public @Nullable Expression parse(ParserData data, TokenizedSource expressionSource, boolean silence) { ModuleRegistry registry = data.getComponent(PandaComponents.MODULE_REGISTRY); if (expressionSource.size() == 1) { Token token = expressionSourc...
#vulnerable code public @Nullable Expression parse(ParserData data, TokenizedSource expressionSource, boolean silence) { ModuleRegistry registry = data.getComponent(PandaComponents.MODULE_REGISTRY); if (expressionSource.size() == 1) { Token token = expressio...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public @Nullable Tokens read(ExpressionParser main, Tokens source) { SourceStream stream = new PandaSourceStream(source); ExpressionSubparsers subparsers = main.getSubparsers().fork(); subparsers.removeSubparser(getName()); Expr...
#vulnerable code @Override public @Nullable Tokens read(ExpressionParser main, Tokens source) { Tokens selected = SubparserUtils.readSeparated(main, source, ARRAY_SEPARATORS, SubparserUtils.NAMES_FILTER, MatchableDistributor::hasNext); MatchableDistributor matchable...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private TokenExtractorResult matchDynamics(List<LexicalPatternElement> elements, TokenizedSource[] dynamics) { TokenExtractorResult result = new TokenExtractorResult(true); for (int i = 0; i < elements.size(); i++) { LexicalPatternElement nodeElem...
#vulnerable code private TokenExtractorResult matchDynamics(List<LexicalPatternElement> elements, TokenizedSource[] dynamics) { TokenExtractorResult result = new TokenExtractorResult(true); for (int i = 0; i < elements.size(); i++) { LexicalPatternElement no...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Variable createVariable(ParserData data, ModuleLoader loader, Scope scope, boolean mutable, boolean nullable, String type, String name) { if (StringUtils.isEmpty(type)) { throw new PandaParserFailure("Type does not specified", data); } ...
#vulnerable code public Variable createVariable(ParserData data, ModuleLoader loader, Scope scope, boolean mutable, boolean nullable, String type, String name) { ClassPrototype prototype = loader.forClass(type).fetch(); if (!StringUtils.isEmpty(type) && prototype == nul...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public List<Parameter> parse(ParserData info, @Nullable Tokens tokens) { if (TokensUtils.isEmpty(tokens)) { return new ArrayList<>(0); } TokenRepresentation[] tokenRepresentations = tokens.toArray(); List<Parameter> parameters = ne...
#vulnerable code public List<Parameter> parse(ParserData info, @Nullable Tokens tokens) { if (TokensUtils.isEmpty(tokens)) { return new ArrayList<>(0); } TokenRepresentation[] tokenRepresentations = tokens.toArray(); List<Parameter> parameter...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void parse(TokenizedSource source, ParserInfo info) { PandaScript script = info.getComponent(Components.SCRIPT); TokenReader reader = new PandaTokenReader(source); Extractor extractor = PATTERN.extractor(); List<TokenizedS...
#vulnerable code @Override public void parse(TokenizedSource source, ParserInfo info) { PandaScript script = info.getComponent(Components.SCRIPT); TokenReader reader = new PandaTokenReader(source); Extractor extractor = PATTERN.extractor(); List<Toke...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void run() { CommandLine commandLine = new CommandLine(this); if (usageHelpRequested) { CommandLine.usage(this, System.out); return; } if (versionInfoRequested) { commandLine.printVersi...
#vulnerable code @Override public void run() { CommandLine commandLine = new CommandLine(this); if (usageHelpRequested) { CommandLine.usage(this, System.out); return; } if (versionInfoRequested) { commandLine.prin...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void parse(@Nullable Tokens source, ParserData data) { PandaScript script = data.getComponent(PandaComponents.PANDA_SCRIPT); ModuleLoader registry = script.getModuleLoader(); Expression instance = null; ClassPrototype prot...
#vulnerable code @Override public void parse(@Nullable Tokens source, ParserData data) { PandaScript script = data.getComponent(PandaComponents.PANDA_SCRIPT); ModuleLoader registry = script.getModuleLoader(); Expression instance = null; ClassPrototyp...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public InterceptorData handle(UnifiedBootstrapParser parser, ParserData data) { InterceptorData interceptorData = new InterceptorData(); if (pattern != null) { TokenExtractorResult result = pattern.extract(data.getComponent(Universal...
#vulnerable code @Override public InterceptorData handle(UnifiedBootstrapParser parser, ParserData data) { InterceptorData interceptorData = new InterceptorData(); if (pattern != null) { TokenExtractorResult result = pattern.extract(null); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SafeVarargs @SuppressWarnings("unchecked") public static <T> T[] mergeArrays(T[]... arrays) { if (isEmpty(arrays)) { throw new IllegalArgumentException("Merge arrays requires at least one array as argument"); } return mergeArrays(...
#vulnerable code @SafeVarargs @SuppressWarnings("unchecked") public static <T> T[] mergeArrays(T[]... arrays) { int size = 0; Class<?> type = null; for (T[] array : arrays) { size += array.length; type = array.getClass().getCompon...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Autowired public void parse(ParserData data, LocalData localData) { localData.allocateInstance(data.getComponent(PandaComponents.CONTAINER).reserveCell()); }
#vulnerable code @Autowired public void parse(ParserData data, LocalData localData) { if (localData == null || data.getComponent(PandaComponents.CONTAINER) == null) { System.out.println("xxx"); } localData.allocateInstance(data.getComponent(Panda...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test void getURLContent() { Result<String, IOException> result = IOUtils.fetchContent("https://panda-lang.org/"); assertTrue(result.isDefined()); assertNotNull(result.getValue()); assertTrue(result.getValue().contains("<html")); }
#vulnerable code @Test void getURLContent() { String urlContent = IOUtils.getURLContent("https://panda-lang.org/"); Assertions.assertNotNull(urlContent); Assertions.assertTrue(urlContent.contains("<html")); } #location 5 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Expression parse(ParserData data, SourceStream source, ExpressionParserSettings settings) { return parse(data, source, settings, null); }
#vulnerable code public Expression parse(ParserData data, SourceStream source, ExpressionParserSettings settings) { ExpressionContext context = new ExpressionContext(this, data, source); ExpressionParserWorker worker = new ExpressionParserWorker(this, context, source, su...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public ClassPrototype generate(Class<?> type) { Module module = ModuleRegistry.getDefault().getOrCreate(type.getPackage().getName()); ClassPrototype prototype = module.get(type.getSimpleName()); if (prototype != null) { return prototype; ...
#vulnerable code public ClassPrototype generate(Class<?> type) { Module module = ModuleRegistry.getDefault().getOrCreate(type.getPackage().getName()); ClassPrototype prototype = new ClassPrototype(module, type.getSimpleName()); prototype.getAssociated().add(type...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public PandaMethodBuilder parameterTypes(ModuleLoader moduleLoader, String... parameterTypes) { ClassPrototypeReference[] prototypes = new ClassPrototypeReference[parameterTypes.length]; for (int i = 0; i < prototypes.length; i++) { prototypes[i] ...
#vulnerable code public PandaMethodBuilder parameterTypes(ModuleLoader moduleLoader, String... parameterTypes) { ClassPrototype[] prototypes = new ClassPrototype[parameterTypes.length]; for (int i = 0; i < prototypes.length; i++) { prototypes[i] = moduleLoad...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testTokenPattern() { TokenPattern pattern = TokenPattern.builder() .compile("class <name> [extends <inherited>] `{ <*body> `}") .build(); LexicalPatternElement content = pattern.getPatternContent(); ...
#vulnerable code @Test public void testTokenPattern() { TokenPattern pattern = TokenPattern.builder() .compile("(method|hidden|local) [static] <return-type> <name> `(<*parameters>`) `{ <*body> `}[;]") .build(); LexicalPatternElement c...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void prepare() { AbyssExtractorOpposites opposites = new AbyssExtractorOpposites(); for (int i = 0; i < tokenizedSource.size(); i++) { TokenRepresentation representation = tokenizedSource.get(i); if (representation == null) { ...
#vulnerable code private void prepare() { AbyssExtractorOpposites opposites = new AbyssExtractorOpposites(); for (int i = 0; i < tokenizedSource.size(); i++) { TokenRepresentation representation = tokenizedSource.get(i); Token token = representat...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static ArrayClassPrototype obtain(ModuleLoader loader, String type) { ArrayClassPrototype cached = ARRAY_PROTOTYPES.get(type); if (cached != null) { return cached; } ClassPrototype prototype = loader.forClass(type.replace(P...
#vulnerable code public static ArrayClassPrototype obtain(ModuleLoader loader, String type) { ClassPrototype prototype = loader.forClass(type.replace(PandaArray.IDENTIFIER, StringUtils.EMPTY)); if (prototype == null) { return null; } int dim...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void parse(Tokens source, ParserData data) { PandaScript script = data.getComponent(PandaComponents.PANDA_SCRIPT); TokenReader reader = new PandaTokenReader(source); GappedPatternExtractor extractor = PATTERN.extractor(); ...
#vulnerable code @Override public void parse(Tokens source, ParserData data) { PandaScript script = data.getComponent(PandaComponents.PANDA_SCRIPT); TokenReader reader = new PandaTokenReader(source); GappedPatternExtractor extractor = PATTERN.extractor(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public NamedExecutable parse(Atom atom) { final String source = atom.getSourcesDivider().getLine(); final StringBuilder groupBuilder = new StringBuilder(); boolean nsFlag = false; for (char c : source.toCharArray()) { ...
#vulnerable code @Override public NamedExecutable parse(Atom atom) { final String source = atom.getSourceCode(); final StringBuilder groupBuilder = new StringBuilder(); boolean nsFlag = false; for (char c : source.toCharArray()) { if (Cha...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Type getArrayOf(Module module, Referencable baseReferencable, int dimensions) { Reference baseReference = baseReferencable.toReference(); Class<?> componentType = ArrayUtils.getDimensionalArrayType(baseReference.getAssociatedClass().fetchImplemen...
#vulnerable code public static Type getArrayOf(Module module, Referencable baseReferencable, int dimensions) { Reference baseReference = baseReferencable.toReference(); Class<?> componentType = ArrayUtils.getDimensionalArrayType(baseReference.getAssociatedClass().fetchIm...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void assumeDocker() throws Exception { assumeDocker(new VersionNumber(DEFAULT_MINIMUM_VERSION)); }
#vulnerable code public static void assumeDocker() throws Exception { Launcher.LocalLauncher localLauncher = new Launcher.LocalLauncher(StreamTaskListener.NULL); try { Assume.assumeThat("Docker working", localLauncher.launch().cmds(DockerTool.getExecutable(nu...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void extractConfigurationParameters() { super.extractConfigurationParameters(); // Load configuration parameters. configColor = ChatColor.getByChar(mainConfig.getString("Color", "5")); configIcon = mainConfig.getString("Icon", "\u2618"); configAdditi...
#vulnerable code @Override public void extractConfigurationParameters() { super.extractConfigurationParameters(); // Load configuration parameters. configColor = ChatColor.getByChar(mainConfig.getString("Color", "5")); configIcon = StringEscapeUtils.unescapeJava(mainConfig.getStr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void saveConfig(String configString, File file) throws IOException { String configuration = this.prepareConfigString(configString); BufferedWriter writer = null; try { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); ...
#vulnerable code public void saveConfig(String configString, File file) throws IOException { String configuration = this.prepareConfigString(configString); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); writer.write(configur...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Reader getConfigContent(File file) throws IOException { if (!file.exists()) return null; int commentNum = 0; String addLine; String currentLine; StringBuilder whole = new StringBuilder(""); BufferedReader reader = null; try { reader = new BufferedRe...
#vulnerable code public Reader getConfigContent(File file) throws IOException { if (!file.exists()) return null; int commentNum = 0; String addLine; String currentLine; StringBuilder whole = new StringBuilder(""); BufferedReader reader = new BufferedReader(new InputStream...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void copyResource(InputStream resource, File file) throws IOException { OutputStream out = null; try { out = new FileOutputStream(file); int length; byte[] buf = new byte[1024]; while ((length = resource.read(buf)) > 0) out.write(buf, 0, length); ...
#vulnerable code private void copyResource(InputStream resource, File file) throws IOException { OutputStream out = new FileOutputStream(file); int length; byte[] buf = new byte[1024]; while ((length = resource.read(buf)) > 0) out.write(buf, 0, length); out.close(); reso...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public List<String> getRewardListing(String path, Player player) { List<String> rewardTypes = new ArrayList<>(); Set<String> keyNames = mainConfig.getKeys(true); if (economy != null && keyNames.contains(path + ".Money")) { int amount = getRewardAmount(path, "Money"); ...
#vulnerable code public List<String> getRewardListing(String path, Player player) { List<String> rewardTypes = new ArrayList<>(); Set<String> keyNames = mainConfig.getKeys(true); if (economy != null && keyNames.contains(path + ".Money")) { int amount = getRewardAmount(path, "Mone...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void extractConfigurationParameters() { configHideNotReceivedCategories = mainConfig.getBoolean("HideNotReceivedCategories"); configHideNoPermissionCategories = mainConfig.getBoolean("HideNoPermissionCategories"); langListGUITitle = ChatColor.translateAl...
#vulnerable code @Override public void extractConfigurationParameters() { configHideNotReceivedCategories = mainConfig.getBoolean("HideNotReceivedCategories"); configHideNoPermissionCategories = mainConfig.getBoolean("HideNoPermissionCategories"); langListGUITitle = ChatColor.trans...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onInventoryClick(InventoryClickEvent event) { Inventory inventory = event.getInventory(); if (!(inventory.getHolder() instanceof AchievementInventoryHolder) || event.getRawSlot() < 0) { retu...
#vulnerable code @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onInventoryClick(InventoryClickEvent event) { Inventory inventory = event.getInventory(); if (!(inventory.getHolder() instanceof AchievementInventoryHolder) || event.getRawSlot() < 0) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private String rewardItem(Player player, ItemStack item) { if (player.getInventory().firstEmpty() != -1) { player.getInventory().addItem(item); } else { player.getWorld().dropItem(player.getLocation(), item); } ItemMeta itemMeta = item.getItemMeta(); String name ...
#vulnerable code private String rewardItem(Player player, ItemStack item) { if (player.getInventory().firstEmpty() != -1) { player.getInventory().addItem(item); } else { player.getWorld().dropItem(player.getLocation(), item); } String name = item.getItemMeta().getDisplayName...
Below is the vulnerable code, please generate the patch based on the following information.