output
stringlengths
64
73.2k
input
stringlengths
208
73.3k
instruction
stringclasses
1 value
#fixed code @Test public void testEmptyInput() throws Exception { final ExtendedBufferedReader br = getBufferedReader(""); assertEquals(END_OF_STREAM, br.read()); assertEquals(END_OF_STREAM, br.lookAhead()); assertEquals(END_OF_STREAM, br.getLastChar()...
#vulnerable code @Test public void testEmptyInput() throws Exception { final ExtendedBufferedReader br = getBufferedReader(""); assertEquals(END_OF_STREAM, br.read()); assertEquals(END_OF_STREAM, br.lookAhead()); assertEquals(END_OF_STREAM, br.getLast...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testReadLine() throws Exception { ExtendedBufferedReader br = getBufferedReader(""); assertNull(br.readLine()); br.close(); br = getBufferedReader("\n"); assertEquals("",br.readLine()); assertNull(br.readL...
#vulnerable code @Test public void testReadLine() throws Exception { ExtendedBufferedReader br = getBufferedReader(""); assertNull(br.readLine()); br = getBufferedReader("\n"); assertEquals("",br.readLine()); assertNull(br.readLine()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testEndOfFileBehaviourExcel() throws Exception { final String[] codes = { "hello,\r\n\r\nworld,\r\n", "hello,\r\n\r\nworld,", "hello,\r\n\r\nworld,\"\"\r\n", "hello,\r\n\r\nworld,\"\...
#vulnerable code @Test public void testEndOfFileBehaviourExcel() throws Exception { final String[] codes = { "hello,\r\n\r\nworld,\r\n", "hello,\r\n\r\nworld,", "hello,\r\n\r\nworld,\"\"\r\n", "hello,\r\n\r\nwor...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testCSVFile() throws Exception { String line = readTestData(); assertNotNull("file must contain config line", line); final String[] split = line.split(" "); assertTrue(testName+" require 1 param", split.length >= 1); ...
#vulnerable code @Test public void testCSVFile() throws Exception { String line = readTestData(); assertNotNull("file must contain config line", line); final String[] split = line.split(" "); assertTrue(testName+" require 1 param", split.length >= 1);...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testSkip0() throws Exception { ExtendedBufferedReader br = getEBR(""); assertEquals(0, br.skip(0)); assertEquals(0, br.skip(1)); br = getEBR(""); assertEquals(0, br.skip(1)); br = getEBR("abcdefg"); assertEquals(0, br.skip(...
#vulnerable code public void testSkip0() throws Exception { br = getEBR(""); assertEquals(0, br.skip(0)); assertEquals(0, br.skip(1)); br = getEBR(""); assertEquals(0, br.skip(1)); br = getEBR("abcdefg"); assertEquals(0, br.skip(0)); assertEq...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testReadLine() throws Exception { ExtendedBufferedReader br = getBufferedReader(""); assertNull(br.readLine()); br = getBufferedReader("\n"); assertEquals("",br.readLine()); assertNull(br.readLine()); br ...
#vulnerable code @Test public void testReadLine() throws Exception { ExtendedBufferedReader br = getBufferedReader(""); assertTrue(br.readLine() == null); br = getBufferedReader("\n"); assertEquals("",br.readLine()); assertTrue(br.readLine() ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testExcelPrintAllIterableOfLists() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL); printer.printRecords(Arrays.asList(new List[] { Arrays.asList(new ...
#vulnerable code @Test public void testExcelPrintAllIterableOfLists() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL); printer.printRecords(Arrays.asList(new List[] { Arrays.asLis...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testEmptyFile() throws Exception { final CSVParser parser = CSVParser.parse("", CSVFormat.DEFAULT); assertNull(parser.nextRecord()); }
#vulnerable code @Test public void testEmptyFile() throws Exception { final CSVParser parser = CSVParser.parseString("", CSVFormat.DEFAULT); assertNull(parser.nextRecord()); } #location 4 #vulnerability ty...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void testCSVLexer(final boolean newToken, String test) throws Exception { Token token = new Token(); String dynamic = ""; for (int i = 0; i < max; i++) { final ExtendedBufferedReader input = new ExtendedBufferedReader(getReader())...
#vulnerable code private static void testCSVLexer(final boolean newToken, String test) throws Exception { Token token = new Token(); for (int i = 0; i < max; i++) { final BufferedReader reader = getReader(); Lexer lexer = new CSVLexer(format, new Exten...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDelimiterIsWhitespace() throws IOException { final String code = "one\ttwo\t\tfour \t five\t six"; final Lexer parser = getLexer(code, CSVFormat.TDF); assertThat(parser.nextToken(new Token()), matches(TOKEN, "one")); a...
#vulnerable code @Test public void testDelimiterIsWhitespace() throws IOException { final String code = "one\ttwo\t\tfour \t five\t six"; final Lexer parser = getLexer(code, CSVFormat.TDF); assertTokenEquals(TOKEN, "one", parser.nextToken(new Token())); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testPrinter4() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT); printer.printRecord("a", "b\"c"); assertEquals("a,\"b\"\"c\"" + recordSepara...
#vulnerable code @Test public void testPrinter4() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT); printer.printRecord("a", "b\"c"); assertEquals("a,\"b\"\"c\"" + record...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testExcelPrintAllArrayOfLists() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL); printer.printRecords(new List[] { Arrays.asList(new String[] { "r1c1"...
#vulnerable code @Test public void testExcelPrintAllArrayOfLists() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL); printer.printRecords(new List[] { Arrays.asList(new String[] { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testEmptyLineBehaviourExcel() throws Exception { final String[] codes = { "hello,\r\n\r\n\r\n", "hello,\n\n\n", "hello,\"\"\r\n\r\n\r\n", "hello,\"\"\n\n\n" }; final ...
#vulnerable code @Test public void testEmptyLineBehaviourExcel() throws Exception { final String[] codes = { "hello,\r\n\r\n\r\n", "hello,\n\n\n", "hello,\"\"\r\n\r\n\r\n", "hello,\"\"\n\n\n" }; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testNextToken3Escaping() throws IOException { /* file: a,\,,b * \,, */ String code = "a,\\,,b\\\\\n\\,,\\\nc,d\\\r\ne"; CSVFormat format = CSVFormat.DEFAULT.withEscape('\\').withEmptyLinesIgnored(false); ...
#vulnerable code @Test public void testNextToken3Escaping() throws IOException { /* file: a,\,,b * \,, */ String code = "a,\\,,b\\\\\n\\,,\\\nc,d\\\n"; CSVFormat format = CSVFormat.DEFAULT.withEscape('\\'); assertTrue(format.isEs...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testEndOfFileBehaviorCSV() throws Exception { final String[] codes = { "hello,\r\n\r\nworld,\r\n", "hello,\r\n\r\nworld,", "hello,\r\n\r\nworld,\"\"\r\n", "hello,\r\n\r\nworld,\"\"",...
#vulnerable code @Test public void testEndOfFileBehaviorCSV() throws Exception { final String[] codes = { "hello,\r\n\r\nworld,\r\n", "hello,\r\n\r\nworld,", "hello,\r\n\r\nworld,\"\"\r\n", "hello,\r\n\r\nworld,...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void testParseCommonsCSV() throws Exception { for (int i = 0; i < max; i++) { final BufferedReader reader = getReader(); final CSVParser parser = new CSVParser(reader, format); final long t0 = System.currentTimeMillis(); ...
#vulnerable code private static void testParseCommonsCSV() throws Exception { for (int i = 0; i < max; i++) { final BufferedReader reader = getReader(); final CSVParser parser = new CSVParser(reader, format); final long t0 = System.currentTimeMilli...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDefaultFormat() throws IOException { String code = "" + "a,b\n" // 1) + "\"\n\",\" \"\n" // 2) + "\"\",#\n" // 2) ; String[][] res = { {"a"...
#vulnerable code @Test public void testDefaultFormat() throws IOException { String code = "" + "a,b\n" // 1) + "\"\n\",\" \"\n" // 2) + "\"\",#\n" // 2) ; String[][] res = { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test // TODO this may lead to strange behavior, throw an exception if iterator() has already been called? public void testMultipleIterators() throws Exception { final CSVParser parser = CSVParser.parse("a,b,c" + CR + "d,e,f", CSVFormat.DEFAULT); final It...
#vulnerable code @Test // TODO this may lead to strange behavior, throw an exception if iterator() has already been called? public void testMultipleIterators() throws Exception { final CSVParser parser = CSVParser.parse("a,b,c" + CR + "d,e,f", CSVFormat.DEFAULT); fi...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testExcelFormat2() throws Exception { final String code = "foo,baar\r\n\r\nhello,\r\n\r\nworld,\r\n"; final String[][] res = { {"foo", "baar"}, {""}, {"hello", ""}, {""}, ...
#vulnerable code @Test public void testExcelFormat2() throws Exception { final String code = "foo,baar\r\n\r\nhello,\r\n\r\nworld,\r\n"; final String[][] res = { {"foo", "baar"}, {""}, {"hello", ""}, {""...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testBackslashEscaping2() throws IOException { // To avoid confusion over the need for escaping chars in java code, // We will test with a forward slash as the escape char, and a single // quote as the encapsulator. Strin...
#vulnerable code @Test public void testBackslashEscaping2() throws IOException { // To avoid confusion over the need for escaping chars in java code, // We will test with a forward slash as the escape char, and a single // quote as the encapsulator. ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void parse() throws IOException { final BufferedReader br = new BufferedReader(getTestInput()); String s = null; int totcomment = 0; int totrecs = 0; boolean lastWasComment = false; while((s=br.readLine()) != nu...
#vulnerable code @Test public void parse() throws IOException { final File csvData = new File("src/test/resources/csv-167/sample1.csv"); final BufferedReader br = new BufferedReader(new FileReader(csvData)); String s = null; int totcomment = 0; ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testLineFeedEndings() throws IOException { final String code = "foo\nbaar,\nhello,world\n,kanu"; final CSVParser parser = CSVParser.parseString(code); final List<CSVRecord> records = parser.getRecords(); assertEquals(4, re...
#vulnerable code @Test public void testLineFeedEndings() throws IOException { final String code = "foo\nbaar,\nhello,world\n,kanu"; final CSVParser parser = new CSVParser(new StringReader(code)); final List<CSVRecord> records = parser.getRecords(); as...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testExcelFormat2() throws Exception { final String code = "foo,baar\r\n\r\nhello,\r\n\r\nworld,\r\n"; final String[][] res = { {"foo", "baar"}, {""}, {"hello", ""}, {""}, ...
#vulnerable code @Test public void testExcelFormat2() throws Exception { final String code = "foo,baar\r\n\r\nhello,\r\n\r\nworld,\r\n"; final String[][] res = { {"foo", "baar"}, {""}, {"hello", ""}, {""...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testGetLine() throws IOException { final CSVParser parser = CSVParser.parse(CSVINPUT, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); for (final String[] re : RESULT) { assertArrayEquals(re, parser.nextRecord().values())...
#vulnerable code @Test public void testGetLine() throws IOException { final CSVParser parser = CSVParser.parse(CSVINPUT, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); for (final String[] re : RESULT) { assertArrayEquals(re, parser.nextRecord().val...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testParseCustomNullValues() throws IOException { final StringWriter sw = new StringWriter(); final CSVFormat format = CSVFormat.DEFAULT.withNullString("NULL"); final CSVPrinter printer = new CSVPrinter(sw, format); printer...
#vulnerable code @Test public void testParseCustomNullValues() throws IOException { final StringWriter sw = new StringWriter(); final CSVFormat format = CSVFormat.DEFAULT.withNullString("NULL"); final CSVPrinter printer = new CSVPrinter(sw, format); p...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testPrinter2() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT); printer.printRecord("a,b", "b"); assertEquals("\"a,b\",b" + recordSeparator,...
#vulnerable code @Test public void testPrinter2() throws IOException { final StringWriter sw = new StringWriter(); final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT); printer.printRecord("a,b", "b"); assertEquals("\"a,b\",b" + recordSepa...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testReadLookahead2() throws Exception { char[] ref = new char[5]; char[] res = new char[5]; ExtendedBufferedReader br = getBufferedReader("abcdefg"); ref[0] = 'a'; ref[1] = 'b'; ref[2] = 'c'; assertE...
#vulnerable code public void testReadLookahead2() throws Exception { char[] ref = new char[5]; char[] res = new char[5]; ExtendedBufferedReader br = getEBR(""); assertEquals(0, br.read(res, 0, 0)); assertTrue(Arrays.equals(res, ref)); br...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testGetRecords() throws IOException { CSVParser parser = new CSVParser(new StringReader(code)); List<CSVRecord> records = parser.getRecords(); assertEquals(res.length, records.size()); assertTrue(records.size() > 0); ...
#vulnerable code @Test public void testGetRecords() throws IOException { CSVParser parser = new CSVParser(new StringReader(code)); String[][] tmp = parser.getRecords(); assertEquals(res.length, tmp.length); assertTrue(tmp.length > 0); for (int...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testReadLine() throws Exception { ExtendedBufferedReader br = getBufferedReader(""); assertNull(br.readLine()); br.close(); br = getBufferedReader("\n"); assertEquals("",br.readLine()); assertNull(br.readL...
#vulnerable code @Test public void testReadLine() throws Exception { ExtendedBufferedReader br = getBufferedReader(""); assertNull(br.readLine()); br = getBufferedReader("\n"); assertEquals("",br.readLine()); assertNull(br.readLine()); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void testReadLookahead2() throws Exception { char[] ref = new char[5]; char[] res = new char[5]; ExtendedBufferedReader br = getEBR(""); assertEquals(0, br.read(res, 0, 0)); assertTrue(Arrays.equals(res, ref)); br = getEBR("abcdefg");...
#vulnerable code public void testReadLookahead2() throws Exception { char[] ref = new char[5]; char[] res = new char[5]; br = getEBR(""); assertEquals(0, br.read(res, 0, 0)); assertTrue(Arrays.equals(res, ref)); br = getEBR("abcdefg"); ref[0] = 'a'...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testEmptyLineBehaviourCSV() throws Exception { final String[] codes = { "hello,\r\n\r\n\r\n", "hello,\n\n\n", "hello,\"\"\r\n\r\n\r\n", "hello,\"\"\n\n\n" }; final St...
#vulnerable code @Test public void testEmptyLineBehaviourCSV() throws Exception { final String[] codes = { "hello,\r\n\r\n\r\n", "hello,\n\n\n", "hello,\"\"\r\n\r\n\r\n", "hello,\"\"\n\n\n" }; fi...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void doOneRandom(final CSVFormat format) throws Exception { final Random r = new Random(); final int nLines = r.nextInt(4) + 1; final int nCol = r.nextInt(3) + 1; // nLines=1;nCol=2; final String[][] lines = new String[nLines][]...
#vulnerable code public void doOneRandom(final CSVFormat format) throws Exception { final Random r = new Random(); final int nLines = r.nextInt(4) + 1; final int nCol = r.nextInt(3) + 1; // nLines=1;nCol=2; final String[][] lines = new String[nLi...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testEndOfFileBehaviorCSV() throws Exception { String[] codes = { "hello,\r\n\r\nworld,\r\n", "hello,\r\n\r\nworld,", "hello,\r\n\r\nworld,\"\"\r\n", "hello,\r\n\r\nworld,\"\"", ...
#vulnerable code @Test public void testEndOfFileBehaviorCSV() throws Exception { String[] codes = { "hello,\r\n\r\nworld,\r\n", "hello,\r\n\r\nworld,", "hello,\r\n\r\nworld,\"\"\r\n", "hello,\r\n\r\nworld,\"\"",...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testGetLine() throws IOException { final CSVParser parser = CSVParser.parse(CSVINPUT, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); for (final String[] re : RESULT) { assertArrayEquals(re, parser.nextRecord().values())...
#vulnerable code @Test public void testGetLine() throws IOException { final CSVParser parser = CSVParser.parseString(CSVINPUT, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); for (final String[] re : RESULT) { assertArrayEquals(re, parser.nextRecord...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testCarriageReturnEndings() throws IOException { final String code = "foo\rbaar,\rhello,world\r,kanu"; final CSVParser parser = CSVParser.parseString(code); final List<CSVRecord> records = parser.getRecords(); assertEquals...
#vulnerable code @Test public void testCarriageReturnEndings() throws IOException { final String code = "foo\rbaar,\rhello,world\r,kanu"; final CSVParser parser = new CSVParser(new StringReader(code)); final List<CSVRecord> records = parser.getRecords(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testExcelFormat1() throws IOException { final String code = "value1,value2,value3,value4\r\na,b,c,d\r\n x,,," + "\r\n\r\n\"\"\"hello\"\"\",\" \"\"world\"\"\",\"abc\ndef\",\r\n"; final String[][] r...
#vulnerable code @Test public void testExcelFormat1() throws IOException { final String code = "value1,value2,value3,value4\r\na,b,c,d\r\n x,,," + "\r\n\r\n\"\"\"hello\"\"\",\" \"\"world\"\"\",\"abc\ndef\",\r\n"; final String...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void parseAlterColumn(final Parser parser, final PgTable table) { parser.expectOptional("COLUMN"); final String columnName = parser.parseIdentifier(); if (parser.expectOptional("SET")) { if (parser.expectOptiona...
#vulnerable code private static void parseAlterColumn(final Parser parser, final PgTable table) { parser.expectOptional("COLUMN"); final String columnName = parser.parseIdentifier(); if (parser.expectOptional("SET")) { if (parser.expectO...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("ALTER", "VIEW"); final String viewName = parser.parseIdentifier(); final String schemaName = ParserUtils.getS...
#vulnerable code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("ALTER", "VIEW"); final String viewName = parser.parseIdentifier(); final PgView view = database.getSche...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void parse(final PgDatabase database, final String command) { String line = command; final Matcher matcher = PATTERN_TABLE_NAME.matcher(line); final String tableName; if (matcher.find()) { tableName = matcher.group(1)...
#vulnerable code public static void parse(final PgDatabase database, final String command) { String line = command; final Matcher matcher = PATTERN_TABLE_NAME.matcher(line); final String tableName; if (matcher.find()) { tableName = matcher.gr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("ALTER", "TABLE"); parser.expectOptional("ONLY"); final String tableName = parser.parseIdentifier(); f...
#vulnerable code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("ALTER", "TABLE"); parser.expectOptional("ONLY"); final String tableName = parser.parseIdentifier(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("CREATE"); parser.expectOptional("OR", "REPLACE"); parser.expect("FUNCTION"); final String functionNam...
#vulnerable code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("CREATE"); parser.expectOptional("OR", "REPLACE"); parser.expect("FUNCTION"); final String funct...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void parse(final PgDatabase database, final String command) { final Parser parser = new Parser(command); parser.expect("CREATE", "TRIGGER"); final PgTrigger trigger = new PgTrigger(); trigger.setName(parser.parseIdentifier()); ...
#vulnerable code public static void parse(final PgDatabase database, final String command) { final Matcher matcher = PATTERN.matcher(command.trim()); if (matcher.matches()) { final String triggerName = matcher.group(1); final String when = matche...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private String loadText(String path) throws IOException { StringBuilder sbText = new StringBuilder(); BufferedReader br = new BufferedReader(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(path), "UTF-8")); ...
#vulnerable code private String loadText(String path) throws IOException { StringBuilder sbText = new StringBuilder(); BufferedReader br = new BufferedReader(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(path))); Str...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Set<String> loadDictionary(String path) throws IOException { Set<String> dictionary = new TreeSet<String>(); BufferedReader br = new BufferedReader(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(path), "UTF...
#vulnerable code private Set<String> loadDictionary(String path) throws IOException { Set<String> dictionary = new TreeSet<String>(); BufferedReader br = new BufferedReader(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(path)...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void deployAndExtractFunctions() throws Exception { // This one can only work if you change the boot classpath to contain reactor-core // and reactive-streams expected.expect(ClassCastException.class); @SuppressWarnings("unchecked") Flux<String> result = ...
#vulnerable code @Test public void deployAndExtractFunctions() throws Exception { // This one can only work if you change the boot classpath to contain reactor-core // and reactive-streams expected.expect(ClassCastException.class); @SuppressWarnings("unchecked") Flux<String> res...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressWarnings("unchecked") public static Message<?> toBinary(Message<?> inputMessage, MessageConverter messageConverter) { Map<String, Object> headers = inputMessage.getHeaders(); CloudEventAttributes attributes = new CloudEventAttributes(headers); // first check th...
#vulnerable code @SuppressWarnings("unchecked") public static Message<?> toBinary(Message<?> inputMessage, MessageConverter messageConverter) { Map<String, Object> headers = inputMessage.getHeaders(); CloudEventAttributes attributes = new CloudEventAttributes(headers); // first ch...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public boolean isRetainOuputAsMessage(Message<?> message) { return message.getHeaders().containsKey(MessageUtils.TARGET_PROTOCOL) || (message.getHeaders().containsKey(MessageUtils.MESSAGE_TYPE) && message.getHeaders().get(MessageUtils.MESSAGE_TYPE).equals(CloudEv...
#vulnerable code @Override public boolean isRetainOuputAsMessage(Message<?> message) { return message.getHeaders().containsKey(MessageUtils.MESSAGE_TYPE) && message.getHeaders().get(MessageUtils.MESSAGE_TYPE).equals(CloudEventMessageUtils.CLOUDEVENT_VALUE); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressWarnings("unchecked") protected void initialize(ExecutionContext ctxt) { ConfigurableApplicationContext context = AzureSpringFunctionInitializer.context; if (!this.initialized.compareAndSet(false, true)) { return; } if (ctxt != null) { ctxt.getLogger()....
#vulnerable code @SuppressWarnings("unchecked") protected void initialize(ExecutionContext ctxt) { ConfigurableApplicationContext context = AzureSpringFunctionInitializer.context; if (!this.initialized.compareAndSet(false, true)) { return; } if (ctxt != null) { ctxt.getLog...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private X509Certificate retrieveAndVerifyCertificateChain( final String signingCertificateChainUrl) throws CertificateException { try (InputStream in = proxy != null ? getAndVerifySigningCertificateChainUrl(signingCertificateChainUrl).openC...
#vulnerable code private X509Certificate retrieveAndVerifyCertificateChain( final String signingCertificateChainUrl) throws CertificateException { try (InputStream in = getAndVerifySigningCertificateChainUrl(signingCertificateChainUrl).openConnection(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private X509Certificate retrieveAndVerifyCertificateChain( final String signingCertificateChainUrl) throws CertificateException { for (int attempt = 0; attempt <= CERT_RETRIEVAL_RETRY_COUNT; attempt++) { InputStream in = null; try {...
#vulnerable code private X509Certificate retrieveAndVerifyCertificateChain( final String signingCertificateChainUrl) throws CertificateException { try (InputStream in = proxy != null ? getAndVerifySigningCertificateChainUrl(signingCertificateChainUrl)...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void load() { configuration = Configuration.load("core.yml"); registerCoreModules(); // check for upgrade before everything else new ConfigPost300().run(); plugin.loadDatabase(); Performance.init(); physicalDat...
#vulnerable code public void load() { configuration = Configuration.load("core.yml"); registerCoreModules(); // check for upgrade before everything else new ConfigPost300().run(); plugin.loadDatabase(); Performance.init(); physi...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean tryLoadProtection(Block block) { Protection protection = lwc.getPhysicalDatabase().loadProtection(block.getWorld().getName(), block.getX(), block.getY(), block.getZ()); if (protection != null) { // ensure it's the right block ...
#vulnerable code public boolean tryLoadProtection(Block block) { Protection protection = lwc.getPhysicalDatabase().loadProtection(block.getWorld().getName(), block.getX(), block.getY(), block.getZ()); if (protection != null) { // ensure it's the right block ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private int getPlayerDropTransferTarget(LWCPlayer player) { Mode mode = player.getMode("dropTransfer"); if (mode == null) { return -1; } String target = mode.getData(); try { return Integer.parseInt(target); ...
#vulnerable code private int getPlayerDropTransferTarget(LWCPlayer player) { Mode mode = player.getMode("dropTransfer"); String target = mode.getData(); try { return Integer.parseInt(target); } catch (NumberFormatException e) { } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void run() { LWC lwc = LWC.getInstance(); PhysDB physicalDatabase = lwc.getPhysicalDatabase(); // this patcher only does something exciting if you have mysql enabled // :-) if (physicalDatabase.getType() != Type.MySQL) { ...
#vulnerable code public void run() { LWC lwc = LWC.getInstance(); PhysDB physicalDatabase = lwc.getPhysicalDatabase(); // this patcher only does something exciting if you have mysql enabled // :-) if (physicalDatabase.getType() != Type.MySQL) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void postPlugin(Plugin plugin, boolean isPing) throws IOException { // Construct the post data String response = "ERR No response"; String data = encode("guid") + "=" + encode(guid) + "&" + encode("version") + "=" + encode(plugi...
#vulnerable code private void postPlugin(Plugin plugin, boolean isPing) throws IOException { // Construct the post data String response = "ERR No response"; String data = encode("guid") + "=" + encode(guid) + "&" + encode("version") + "=" + encode...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void load() { configuration = Configuration.load("core.yml"); registerCoreModules(); // check for upgrade before everything else new ConfigPost300().run(); plugin.loadDatabase(); Statistics.init(); physicalData...
#vulnerable code public void load() { configuration = Configuration.load("core.yml"); registerCoreModules(); // check for upgrade before everything else new ConfigPost300().run(); plugin.loadDatabase(); Statistics.init(); physic...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Permission decodeJSON(JSONObject node) { Permission permission = new Permission(); Access access = Access.values()[((Long) node.get("rights")).intValue()]; if (access.ordinal() == 0) { access = Access.PLAYER; ...
#vulnerable code public static Permission decodeJSON(JSONObject node) { Permission permission = new Permission(); // The values are stored as longs internally, despite us passing an int permission.setName((String) node.get("name")); permission.setType(Ty...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void postPlugin(Plugin plugin, boolean isPing) throws IOException { // Construct the post data String response = "ERR No response"; String data = encode("guid") + "=" + encode(guid) + "&" + encode("version") + "=" + encode(plugi...
#vulnerable code private void postPlugin(Plugin plugin, boolean isPing) throws IOException { // Construct the post data String response = "ERR No response"; String data = encode("guid") + "=" + encode(guid) + "&" + encode("version") + "=" + encode...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static AccessRight decodeJSON(JSONObject node) { AccessRight right = new AccessRight(); // The values are stored as longs internally, despite us passing an int // right.setProtectionId(((Long) node.get("protection")).intValue()); right....
#vulnerable code public static AccessRight decodeJSON(JSONObject node) { AccessRight right = new AccessRight(); // The values are stored as longs internally, despite us passing an int right.setProtectionId(((Long) node.get("protection")).intValue()); rig...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void initialize(final int cachePercent) throws IOException { cache = new Cache(file.length(), cachePercent); FileWord a; FileWord b = null; synchronized (cache) { position = 0; seek(position); while ((a = nextWord()) != null) { ...
#vulnerable code protected void initialize(final int cachePercent) throws IOException { final long fileBytes = file.length(); final long cacheSize = (fileBytes / 100) * cachePercent; final long cacheModulus = cacheSize == 0 ? fileBytes : cacheSize > fileBytes ? 1 : fileB...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public HttpConfig files(String[] filePaths, String inputName, boolean forceRemoveContentTypeChraset) { // synchronized (getClass()) { // if(this.map==null){ // this.map= new HashMap<String, Object>(); // } // } // map.put(Utils.ENTITY_MULTIPART, filePaths); // map.put...
#vulnerable code public HttpConfig files(String[] filePaths, String inputName, boolean forceRemoveContentTypeChraset) { synchronized (getClass()) { if(this.map==null){ this.map= new HashMap<String, Object>(); } } map.put(Utils.ENTITY_MULTIPART, filePaths); map.put(Utils.E...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public HttpConfig json(String json) { this.json = json; Map<String, Object> map = new HashMap<String, Object>(); map.put(Utils.ENTITY_STRING, json); maps.set(map); return this; }
#vulnerable code public HttpConfig json(String json) { this.json = json; map = new HashMap<String, Object>(); map.put(Utils.ENTITY_STRING, json); return this; } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public Map<String, Object> map() { // return map; return maps.get(); }
#vulnerable code public Map<String, Object> map() { return map; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public HttpConfig json(String json) { this.json = json; Map<String, Object> map = new HashMap<String, Object>(); map.put(Utils.ENTITY_STRING, json); maps.set(map); return this; }
#vulnerable code public HttpConfig json(String json) { this.json = json; map = new HashMap<String, Object>(); map.put(Utils.ENTITY_STRING, json); return this; } #location 4 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static String usageString(CommandLine commandLine, Help.Ansi ansi) throws UnsupportedEncodingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); commandLine.usage(new PrintStream(baos, true, "UTF8"), ansi); String result = bao...
#vulnerable code private static String usageString(CommandLine commandLine, Help.Ansi ansi) throws UnsupportedEncodingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); commandLine.usage(new PrintStream(baos, true, "UTF8"), ansi); String result...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void verify(final UChannel channel,String extension, final ISDKVerifyListener callback) { try{ JSONObject json = JSONObject.fromObject(extension); final String ts = json.getString("ts"); final String playerId ...
#vulnerable code @Override public void verify(final UChannel channel,String extension, final ISDKVerifyListener callback) { try{ JSONObject json = JSONObject.fromObject(extension); final String ts = json.getString("ts"); final String pla...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testOverridenFields() throws Exception { MappingFileReader fileReader = new MappingFileReader(XMLParserFactory.getInstance()); MappingFileData mappingFileData = fileReader.read("overridemapping.xml"); MappingsParser mappingsParser = MappingsParse...
#vulnerable code @Test public void testOverridenFields() throws Exception { MappingFileReader fileReader = new MappingFileReader("overridemapping.xml"); MappingFileData mappingFileData = fileReader.read(); MappingsParser mappingsParser = MappingsParser.getInstance(); map...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void writeDeepDestinationValue(Object destObj, Object destFieldValue, FieldMap fieldMap) { // follow deep field hierarchy. If any values are null along the way, then create a new instance DeepHierarchyElement[] hierarchy = getDeepFieldHierarchy(destObj, fieldM...
#vulnerable code protected void writeDeepDestinationValue(Object destObj, Object destFieldValue, FieldMap fieldMap) { // follow deep field hierarchy. If any values are null along the way, then create a new instance DeepHierarchyElement[] hierarchy = getDeepFieldHierarchy(destObj, ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testDuplicateMapIds() throws Exception { MappingFileReader fileReader = new MappingFileReader(XMLParserFactory.getInstance()); MappingFileData mappingFileData = fileReader.read("duplicateMapIdsMapping.xml"); try { parser.processMappings(ma...
#vulnerable code @Test public void testDuplicateMapIds() throws Exception { MappingFileReader fileReader = new MappingFileReader("duplicateMapIdsMapping.xml"); MappingFileData mappingFileData = fileReader.read(); try { parser.processMappings(mappingFileData.getClassMa...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void initialize(GlobalSettings globalSettings, ClassLoader classLoader) { if (globalSettings.isAutoregisterJMXBeans()) { // Register JMX MBeans. If an error occurs, don't propagate exception try { registerJMXBeans(new JMXPlatformImpl()); } catch (T...
#vulnerable code void initialize(GlobalSettings globalSettings, ClassLoader classLoader) { if (globalSettings.isAutoregisterJMXBeans()) { // Register JMX MBeans. If an error occurs, don't propagate exception try { registerJMXBeans(new JMXPlatformImpl()); } ca...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String getBeanId() { Class<?> factoryClass = objectFactory(destObjClass).getClass(); Class<?> destClass = null; String methodName = "create" + destObjClass.substring(destObjClass.lastIndexOf(".") + 1) + StringUtils.capitalize(destFieldName); try { Method metho...
#vulnerable code public String getBeanId() { Class<?> factoryClass = objectFactory(destObjClass).getClass(); Class<?> destClass = null; String methodName = "create" + destObjClass.substring(destObjClass.lastIndexOf(".") + 1) + StringUtils.capitalize(destFieldName); try { Method...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public long getValue() { return value.get(); }
#vulnerable code public long getValue() { return value; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void initialize(GlobalSettings globalSettings, ClassLoader classLoader) { if (globalSettings.isAutoregisterJMXBeans()) { // Register JMX MBeans. If an error occurs, don't propagate exception try { registerJMXBeans(new JMXPlatformImpl()); } catch (T...
#vulnerable code void initialize(GlobalSettings globalSettings, ClassLoader classLoader) { if (globalSettings.isAutoregisterJMXBeans()) { // Register JMX MBeans. If an error occurs, don't propagate exception try { registerJMXBeans(new JMXPlatformImpl()); } ca...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static boolean isEnumType(Class srcFieldClass, Class destFieldType){ if (GlobalSettings.getInstance().isJava5()){//Verify if running JRE is 1.5 or above if ( ((Boolean) ReflectionUtils.invoke(Jdk5Methods.getInstance().getIsAnonymousClassMethod(), srcFieldClass,...
#vulnerable code public static boolean isEnumType(Class srcFieldClass, Class destFieldType){ if (GlobalSettings.getInstance().isJava5()){//Verify if running JRE is 1.5 or above if (srcFieldClass.isAnonymousClass()){ //If srcFieldClass is anonymous class, replace srcField...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static String getScript(String path) { StringBuilder sb = new StringBuilder(); InputStream stream = ScriptUtil.class.getClassLoader().getResourceAsStream(path); try (BufferedReader br = new BufferedReader(new InputStreamReader(stream))){ ...
#vulnerable code public static String getScript(String path) { StringBuilder sb = new StringBuilder(); InputStream stream = ScriptUtil.class.getClassLoader().getResourceAsStream(path); BufferedReader br = new BufferedReader(new InputStreamReader(stream)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean limit() { String key = String.valueOf(System.currentTimeMillis() / 1000); Object result = null; try { RedisClusterConnection clusterConnection = jedis.getClusterConnection(); JedisCluster jedisCluster = (JedisClus...
#vulnerable code public boolean limit() { String key = String.valueOf(System.currentTimeMillis() / 1000); Object result = null; RedisClusterConnection clusterConnection = jedis.getClusterConnection(); if (clusterConnection != null){ JedisClust...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public final void build() { LOGGER.info("Starting tree reconstruction"); Project inbox = beanFactory.getBean("project", Project.class); inbox.setName("Inbox"); inbox.setId("__%%Inbox"); // to give deterministic JSON/XML output Context...
#vulnerable code public final void build() { LOGGER.info("Starting tree reconstruction"); Project inbox = new Project(); inbox.setName("Inbox"); inbox.setId("__%%Inbox"); // to give deterministic JSON/XML output Context noContext = new Context()...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean within(Date date, String lower, String upper) throws ParseException { LOGGER.debug("within({},{},{})", date, lower, upper); Date lowerDate = date(lower); Date upperDate = date(upper); boolean result = date != null && date.getTime...
#vulnerable code public boolean within(Date date, String lower, String upper) throws ParseException { Date lowerDate = date(lower); Date upperDate = date(upper); return date != null && date.getTime() >= lowerDate.getTime() && date.getTime() <= upperDate.getTime()...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void main(String[] args) throws Exception { ApplicationContext appContext = ApplicationContextFactory.getContext(); Main main = appContext.getBean("main", Main.class); if (!main.procesPreLoadOptions(args)) { LOGGER.debug("E...
#vulnerable code public static void main(String[] args) throws Exception { ApplicationContext appContext = ApplicationContextFactory.create(); Main main = appContext.getBean("main", Main.class); if (!main.procesPreLoadOptions(args)) { LOGGER.debug(...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOr...
#vulnerable code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void writeToLog(String type, String content) { writerThread.execute(()->{ String t = ServerTimeUtil.accurateToLogName(); File f = new File(logs, t + ".klog"); FileWriter fw = null; if (f.exists()) { try { fw = new FileWriter(f, true); fw.write...
#vulnerable code private void writeToLog(String type, String content) { String t = ServerTimeUtil.accurateToLogName(); File f = new File(logs, t + ".klog"); FileWriter fw = null; if (f.exists()) { try { fw = new FileWriter(f, true); fw.write("\r\n\r\nTIME:\r\n" + ServerT...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void doDownloadFile(final HttpServletRequest request, final HttpServletResponse response) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); if (ConfigureReader.instance().authorized(account, AccountAuth.DOWNLOAD_FILES)) { final String ...
#vulnerable code public void doDownloadFile(final HttpServletRequest request, final HttpServletResponse response) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); if (ConfigureReader.instance().authorized(account, AccountAuth.DOWNLOAD_FILES)) { final S...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void writeToLog(String type, String content) { writerThread.execute(()->{ String t = ServerTimeUtil.accurateToLogName(); File f = new File(logs, t + ".klog"); FileWriter fw = null; if (f.exists()) { try { fw = new FileWriter(f, true); fw.write...
#vulnerable code private void writeToLog(String type, String content) { String t = ServerTimeUtil.accurateToLogName(); File f = new File(logs, t + ".klog"); FileWriter fw = null; if (f.exists()) { try { fw = new FileWriter(f, true); fw.write("\r\n\r\nTIME:\r\n" + ServerT...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response, final MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); final String fn...
#vulnerable code public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response, final MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); final Str...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response, final MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); final String fn...
#vulnerable code public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response, final MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); final Str...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void writeRangeFileStream(HttpServletRequest request, HttpServletResponse response, File fo, String fname, String contentType) { long fileLength = fo.length(); // 记录文件大小 long pastLength = 0; // 记录已下载文件大小 int rangeSwitch = 0; // 0:从头开始的全文下载;1:从某字节开始的下载(bytes=27...
#vulnerable code protected void writeRangeFileStream(HttpServletRequest request, HttpServletResponse response, File fo, String fname, String contentType) { long skipLength = 0;// 下载时跳过的字节数 long downLength = 0;// 需要继续下载的字节数 boolean hasEnd = false;// 是否具备结束字节声明 try { response.s...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void getCondensedPicture(final HttpServletRequest request, final HttpServletResponse response) { // TODO 自动生成的方法存根 if (ConfigureReader.instance().authorized((String) request.getSession().getAttribute("ACCOUNT"), AccountAuth.DOWNLOAD_FILES)) { String ...
#vulnerable code @Override public void getCondensedPicture(final HttpServletRequest request, final HttpServletResponse response) { // TODO 自动生成的方法存根 if (ConfigureReader.instance().authorized((String) request.getSession().getAttribute("ACCOUNT"), AccountAuth.DOWNLOAD_FILES)) { S...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOriginal...
#vulnerable code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean removeAddedAuthByFolderId(List<String> fIds) { if (fIds == null || fIds.size() == 0) { return false; } Set<String> configs = accountp.stringPropertieNames(); List<String> invalidConfigs = new ArrayList<>(); for (String fId : fIds) { for (String con...
#vulnerable code public boolean removeAddedAuthByFolderId(List<String> fIds) { if(fIds == null || fIds.size() == 0) { return false; } Set<String> configs=accountp.stringPropertieNames(); List<String> invalidConfigs = new ArrayList<>(); for(String fId:fIds) { for (String con...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOr...
#vulnerable code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String checkImportFolder(HttpServletRequest request) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); final String folderName = request.getParameter("folderName"); ...
#vulnerable code @Override public String checkImportFolder(HttpServletRequest request) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); final String folderName = request.getParameter("folderName...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response, final MultipartFile file) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); final Str...
#vulnerable code public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response, final MultipartFile file) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); fin...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public boolean deleteFromFileBlocks(Node f) { // 获取对应的文件块对象 File file = getFileFromBlocks(f); if (file != null) { return file.delete();// 执行删除操作 } return false; }
#vulnerable code public boolean deleteFromFileBlocks(Node f) { // 先判断一下文件块所在的存储区 File rootPath = new File(ConfigureReader.instance().getFileBlockPath()); if (!f.getFilePath().startsWith("file_")) {// 存放于主文件系统中 short index = Short.parseShort(f.getFilePath().substring(0, f.getFilePa...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOr...
#vulnerable code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOriginal...
#vulnerable code @Override public String doImportFolder(HttpServletRequest request, MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); String folderId = request.getParameter("folderId"); final String originalFileName = new String(file.getOr...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String checkImportFolder(HttpServletRequest request) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); final String folderName = request.getParameter("folderName"); ...
#vulnerable code @Override public String checkImportFolder(HttpServletRequest request) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); final String folderName = request.getParameter("folderName...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response, final MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); final String or...
#vulnerable code public String doUploadFile(final HttpServletRequest request, final HttpServletResponse response, final MultipartFile file) { String account = (String) request.getSession().getAttribute("ACCOUNT"); final String folderId = request.getParameter("folderId"); final Str...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void getLRContextByUTF8(String fileId, HttpServletRequest request, HttpServletResponse response) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); // 权限检查 if (fileId != null) { Node n = nm.queryById(fileId); if (n != nu...
#vulnerable code @Override public void getLRContextByUTF8(String fileId, HttpServletRequest request, HttpServletResponse response) { final String account = (String) request.getSession().getAttribute("ACCOUNT"); // 权限检查 if (fileId != null) { Node n = nm.queryById(fileId); if (n...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public String checkLoginRequest(final HttpServletRequest request, final HttpSession session) { final String encrypted = request.getParameter("encrypted"); try { final String loginInfoStr = DecryptionUtil.dncryption(encrypted, ku.getPrivateKey()); final LoginInfoPojo in...
#vulnerable code public String checkLoginRequest(final HttpServletRequest request, final HttpSession session) { final String encrypted = request.getParameter("encrypted"); final String loginInfoStr = DecryptionUtil.dncryption(encrypted, ku.getPrivateKey()); try { final LoginInfoPo...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void deleteFolder(String folderId) throws SQLException { Folder f = selectFolderById(folderId); List<Node> nodes = selectNodesByFolderId(folderId); int size = nodes.size(); if(f==null) { return; } // 删除该文件夹内的所有文件 for (int i = 0; i < size && gono; i++) { ...
#vulnerable code private void deleteFolder(String folderId) throws SQLException { Folder f = selectFolderById(folderId); List<Node> nodes = selectNodesByFolderId(folderId); int size = nodes.size(); // 删除该文件夹内的所有文件 for (int i = 0; i < size && gono; i++) { deleteFile(nodes.get(i...
Below is the vulnerable code, please generate the patch based on the following information.