input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code public int getSize() { return size; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public int getSize() { synchronized (lock) { return size; } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void init(int size, int packetSize) { this.size = size; this.maxSize = size; this.packetSize = packetSize; } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public void init(int size, int packetSize) { synchronized (lock) { this.size = size; this.maxSize = size; this.packetSize = packetSize; lock.notifyAll(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public OutputStream createOutputStream(final long offset) throws IOException { // permission check if (!isWritable()) { throw new IOException("No write permission : " + file.getName()); } // create output stream ...
#fixed code public OutputStream createOutputStream(final long offset) throws IOException { // permission check if (!isWritable()) { throw new IOException("No write permission : " + file.getName()); } // move to the appropriate off...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void handleMessage(Buffer buffer) throws Exception { SshConstants.Message cmd = buffer.getCommand(); log.debug("Received packet {}", cmd); switch (cmd) { case SSH_MSG_DISCONNECT: { int code = buffer.getInt();...
#fixed code protected void handleMessage(Buffer buffer) throws Exception { synchronized (lock) { doHandleMessage(buffer); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setAttributes(Map<Attribute, Object> attributes) throws IOException { for (Attribute attribute : attributes.keySet()) { String name = null; Object value = attributes.get(attribute); switch (attribute) { ...
#fixed code public void setAttributes(Map<Attribute, Object> attributes) throws IOException { if (!attributes.isEmpty()) { throw new UnsupportedOperationException(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code static void secureLocalSocket(String authSocket, long handle) throws IOException { String os = System.getProperty("os.name").toLowerCase(); if (os.indexOf("windows") < 0) { File file = new File(authSocket); if (!file.setReadable(f...
#fixed code static void secureLocalSocket(String authSocket, long handle) throws IOException { if (OsUtils.isUNIX()) { File file = new File(authSocket); if (!file.setReadable(false, false) || !file.setReadable(true, true) || !file.setEx...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void handleMessage(Buffer buffer) throws Exception { SshConstants.Message cmd = buffer.getCommand(); log.debug("Received packet {}", cmd); switch (cmd) { case SSH_MSG_DISCONNECT: { int code = buffer.getInt();...
#fixed code protected void handleMessage(Buffer buffer) throws Exception { synchronized (lock) { doHandleMessage(buffer); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void setAttributes(Map<Attribute, Object> attributes) throws IOException { for (Attribute attribute : attributes.keySet()) { String name = null; Object value = attributes.get(attribute); switch (attribute) { ...
#fixed code public void setAttributes(Map<Attribute, Object> attributes) throws IOException { if (!attributes.isEmpty()) { throw new UnsupportedOperationException(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void doHandleMessage(Buffer buffer) throws Exception { SshConstants.Message cmd = buffer.getCommand(); log.debug("Received packet {}", cmd); switch (cmd) { case SSH_MSG_DISCONNECT: { int code = buffer.getInt(...
#fixed code protected void doHandleMessage(Buffer buffer) throws Exception { SshConstants.Message cmd = buffer.getCommand(); log.debug("Received packet {}", cmd); switch (cmd) { case SSH_MSG_DISCONNECT: { int code = buffer.getInt(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void handleEof() throws IOException { log.debug("Received SSH_MSG_CHANNEL_EOF on channel {}", id); synchronized (lock) { eof = true; lock.notifyAll(); } } #location 2 ...
#fixed code public void handleEof() throws IOException { log.debug("Received SSH_MSG_CHANNEL_EOF on channel {}", id); eof = true; notifyStateChanged(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void readFile(File path) throws IOException { if (log.isDebugEnabled()) { log.debug("Reading file {}", path); } StringBuffer buf = new StringBuffer(); buf.append("C"); buf.append("0644"); // what about perms ...
#fixed code private void readFile(File path) throws IOException { if (log.isDebugEnabled()) { log.debug("Reading file {}", path); } StringBuffer buf = new StringBuffer(); buf.append("C"); buf.append("0644"); // what about perms ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void truncate() throws IOException{ new RandomAccessFile(file, "rw").setLength(0); } #location 2 #vulnerability type RESOURCE_LEAK
#fixed code public void truncate() throws IOException{ RandomAccessFile tempFile = new RandomAccessFile(file, "rw"); tempFile.setLength(0); tempFile.close(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) throws Exception { int port = 8000; boolean error = false; for (int i = 0; i < args.length; i++) { if ("-p".equals(args[i])) { if (i + 1 >= args.length) { Sys...
#fixed code public static void main(String[] args) throws Exception { int port = 8000; boolean error = false; for (int i = 0; i < args.length; i++) { if ("-p".equals(args[i])) { if (i + 1 >= args.length) { System.er...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void check(int maxFree) throws IOException { int threshold = Math.min(packetSize * 8, maxSize / 4); synchronized (lock) { if ((maxFree - size) > packetSize && (maxFree - size > threshold || size < threshold)) { if (log....
#fixed code public void check(int maxFree) throws IOException { synchronized (lock) { if ((size < maxFree) && (maxFree - size > packetSize * 3 || size < maxFree / 2)) { if (log.isDebugEnabled()) { log.debug("Increase " + name + " by...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void handleRequest(Buffer buffer) throws IOException { log.info("Received SSH_MSG_CHANNEL_REQUEST on channel {}", id); String req = buffer.getString(); if ("exit-status".equals(req)) { buffer.getBoolean(); synchroni...
#fixed code public void handleRequest(Buffer buffer) throws IOException { log.info("Received SSH_MSG_CHANNEL_REQUEST on channel {}", id); String req = buffer.getString(); if ("exit-status".equals(req)) { buffer.getBoolean(); exitStatus = bu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void doWriteKeyPair(KeyPair kp, OutputStream os) throws Exception { PEMWriter w = new PEMWriter(new OutputStreamWriter(os)); w.writeObject(kp); } #location 3 #vulnerability type RESO...
#fixed code protected void doWriteKeyPair(KeyPair kp, OutputStream os) throws Exception { PEMWriter w = new PEMWriter(new OutputStreamWriter(os)); try { w.writeObject(kp); } finally { w.close(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void doHandleMessage(Buffer buffer) throws Exception { SshConstants.Message cmd = buffer.getCommand(); log.debug("Received packet {}", cmd); switch (cmd) { case SSH_MSG_DISCONNECT: { int code = buffer.getInt(...
#fixed code protected void doHandleMessage(Buffer buffer) throws Exception { SshConstants.Message cmd = buffer.getCommand(); log.debug("Received packet {}", cmd); switch (cmd) { case SSH_MSG_DISCONNECT: { int code = buffer.getInt(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void close() { if (!closed) { synchronized (lock) { if (!closed) { try { log.info("Closing session"); Channel[] channelToClose = channels.values().toArray(new ...
#fixed code public void close() { if (!closed) { synchronized (lock) { if (!closed && !closing) { try { closing = true; log.info("Closing session"); Channel[] c...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testAgentForwarding() throws Exception { int port1 = getFreePort(); int port2 = getFreePort(); TestEchoShellFactory shellFactory = new TestEchoShellFactory(); ProxyAgentFactory agentFactory = new ProxyAgentFactory(...
#fixed code @Test public void testAgentForwarding() throws Exception { int port1 = getFreePort(); int port2 = getFreePort(); TestEchoShellFactory shellFactory = new TestEchoShellFactory(); ProxyAgentFactory agentFactory = new ProxyAgentFactory(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void handleClose() throws IOException { log.debug("Received SSH_MSG_CHANNEL_CLOSE on channel {}", id); synchronized (lock) { closedByOtherSide = !closing; if (closedByOtherSide) { close(false); }...
#fixed code public void handleClose() throws IOException { log.debug("Received SSH_MSG_CHANNEL_CLOSE on channel {}", id); closedByOtherSide = !closing.get(); if (closedByOtherSide) { close(false); } else { close(false).setClosed(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void readBySax(File file, int sheetIndex, RowHandler rowHandler) { BufferedInputStream in = null; try { in = FileUtil.getInputStream(file); readBySax(in, sheetIndex, rowHandler); } finally { IoUtil.close(in); } } ...
#fixed code public static void readBySax(File file, int sheetIndex, RowHandler rowHandler) { if (ExcelFileUtil.isXlsx(file)) { read07BySax(file, sheetIndex, rowHandler); } else { read03BySax(file, sheetIndex, rowHandler); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void rythmEngineTest() { // 字符串模板 TemplateEngine engine = new RythmEngine(new TemplateConfig("templates")); Template template = engine.getTemplate("hello,@name"); String result = template.render(Dict.create().set("name", "hutool")); Assert.assertEqu...
#fixed code @Test public void rythmEngineTest() { // 字符串模板 TemplateEngine engine = TemplateUtil.createEngine( new TemplateConfig("templates").setCustomEngine(RythmEngine.class)); Template template = engine.getTemplate("hello,@name"); String result = template.render(Dict.create(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public byte[] encrypt(byte[] data, KeyType keyType) throws CryptoException { if (KeyType.PublicKey != keyType) { throw new IllegalArgumentException("Encrypt is only support by public key"); } ckeckKey(keyType); lock.lock(); final SM2Engine engine =...
#fixed code @Override public byte[] encrypt(byte[] data, KeyType keyType) throws CryptoException { if (KeyType.PublicKey != keyType) { throw new IllegalArgumentException("Encrypt is only support by public key"); } checkKey(keyType); lock.lock(); final SM2Engine engine = getEn...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void toJsonStrTest2() { Map<String, Object> model = new HashMap<String, Object>(); model.put("mobile", "17610836523"); model.put("type", 1); Map<String, Object> data = new HashMap<String, Object>(); data.put("model", model); data.put("model2", mo...
#fixed code @Test public void toJsonStrTest2() { Map<String, Object> model = new HashMap<>(); model.put("mobile", "17610836523"); model.put("type", 1); Map<String, Object> data = new HashMap<>(); data.put("model", model); data.put("model2", model); JSONObject jsonObject = J...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") public <T> T convert(Type type, Object value, T defaultValue, boolean isCustomFirst) throws ConvertException { if (TypeUtil.isUnknow(type) && null == defaultValue) { // 对于用户不指定目标类型的情况,返回原值 return (T) value; } if (ObjectUtil.isNul...
#fixed code @SuppressWarnings("unchecked") public <T> T convert(Type type, Object value, T defaultValue, boolean isCustomFirst) throws ConvertException { if (TypeUtil.isUnknow(type) && null == defaultValue) { // 对于用户不指定目标类型的情况,返回原值 return (T) value; } if (ObjectUtil.isNull(valu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public byte[] decrypt(byte[] data, KeyType keyType) { final Key key = getKeyByType(keyType); final int maxBlockSize = this.decryptBlockSize < 0 ? data.length : this.decryptBlockSize; lock.lock(); try { cipher.init(Cipher.DECRYPT_MODE, key); return...
#fixed code @Override public byte[] decrypt(byte[] data, KeyType keyType) { final Key key = getKeyByType(keyType); lock.lock(); try { cipher.init(Cipher.DECRYPT_MODE, key); if(this.decryptBlockSize < 0){ // 在引入BC库情况下,自动获取块大小 final int blockSize = this.cipher.getBlockSi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public byte[] decrypt(byte[] data, KeyType keyType) throws CryptoException { if (KeyType.PrivateKey != keyType) { throw new IllegalArgumentException("Decrypt is only support by private key"); } ckeckKey(keyType); lock.lock(); final SM2Engine engine...
#fixed code @Override public byte[] decrypt(byte[] data, KeyType keyType) throws CryptoException { if (KeyType.PrivateKey != keyType) { throw new IllegalArgumentException("Decrypt is only support by private key"); } checkKey(keyType); lock.lock(); final SM2Engine engine = get...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public byte[] encrypt(byte[] data, KeyType keyType) { final Key key = getKeyByType(keyType); final int maxBlockSize = this.encryptBlockSize < 0 ? data.length : this.encryptBlockSize; lock.lock(); try { cipher.init(Cipher.ENCRYPT_MODE, key); return...
#fixed code @Override public byte[] encrypt(byte[] data, KeyType keyType) { final Key key = getKeyByType(keyType); lock.lock(); try { cipher.init(Cipher.ENCRYPT_MODE, key); if(this.encryptBlockSize < 0){ // 在引入BC库情况下,自动获取块大小 final int blockSize = this.cipher.getBlockSi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void thymeleafEngineTest() { // 字符串模板 TemplateEngine engine = new ThymeleafEngine(new TemplateConfig("templates")); Template template = engine.getTemplate("<h3 th:text=\"${message}\"></h3>"); String result = template.render(Dict.create().set("message"...
#fixed code @Test public void thymeleafEngineTest() { // 字符串模板 TemplateEngine engine = TemplateUtil.createEngine( new TemplateConfig("templates").setCustomEngine(ThymeleafEngine.class)); Template template = engine.getTemplate("<h3 th:text=\"${message}\"></h3>"); String result =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void rythmEngineTest() { // 字符串模板 TemplateEngine engine = new RythmEngine(new TemplateConfig("templates")); Template template = engine.getTemplate("hello,@name"); String result = template.render(Dict.create().set("name", "hutool")); Assert.assertEqu...
#fixed code @Test public void rythmEngineTest() { // 字符串模板 TemplateEngine engine = TemplateUtil.createEngine( new TemplateConfig("templates").setCustomEngine(RythmEngine.class)); Template template = engine.getTemplate("hello,@name"); String result = template.render(Dict.create(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ClassLoader compile() { // 获得classPath final List<File> classPath = getClassPath(); final URL[] urLs = URLUtil.getURLs(classPath.toArray(new File[0])); final URLClassLoader ucl = URLClassLoader.newInstance(urLs, this.parentClassLoader); if (sourceCodeMap.i...
#fixed code public ClassLoader compile() { // 获得classPath final List<File> classPath = getClassPath(); final URL[] urLs = URLUtil.getURLs(classPath.toArray(new File[0])); final URLClassLoader ucl = URLClassLoader.newInstance(urLs, this.parentClassLoader); if (sourceCodeMap.isEmpty...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static DataSize parse(CharSequence text, DataUnit defaultUnit) { Assert.notNull(text, "Text must not be null"); try { Matcher matcher = PATTERN.matcher(text); Assert.state(matcher.matches(), "Does not match data size pattern"); DataUnit unit = determine...
#fixed code public static DataSize parse(CharSequence text, DataUnit defaultUnit) { Assert.notNull(text, "Text must not be null"); try { final Matcher matcher = PATTERN.matcher(text); Assert.state(matcher.matches(), "Does not match data size pattern"); final DataUnit unit = de...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void enjoyEngineTest() { // 字符串模板 TemplateEngine engine = new EnjoyEngine(new TemplateConfig("templates")); Template template = engine.getTemplate("#(x + 123)"); String result = template.render(Dict.create().set("x", 1)); Assert.assertEquals("124", ...
#fixed code @Test public void enjoyEngineTest() { // 字符串模板 TemplateEngine engine = TemplateUtil.createEngine( new TemplateConfig("templates").setCustomEngine(EnjoyEngine.class)); Template template = engine.getTemplate("#(x + 123)"); String result = template.render(Dict.create()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void copyPropertiesBeanToMapTest() { // 测试BeanToMap SubPerson p1 = new SubPerson(); p1.setSlow(true); p1.setName("测试"); p1.setSubName("sub测试"); Map<String, Object> map = MapUtil.newHashMap(); BeanUtil.copyProperties(p1, map); Assert.assertTru...
#fixed code @Test public void copyPropertiesBeanToMapTest() { // 测试BeanToMap SubPerson p1 = new SubPerson(); p1.setSlow(true); p1.setName("测试"); p1.setSubName("sub测试"); Map<String, Object> map = MapUtil.newHashMap(); BeanUtil.copyProperties(p1, map); Assert.assertTrue((Boo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static byte[] readBytes(InputStream in, boolean isCloseStream) throws IORuntimeException { final FastByteArrayOutputStream out = new FastByteArrayOutputStream(); copy(in, out); if (isCloseStream) { close(in); } return out.toByteArray(); } ...
#fixed code public static byte[] readBytes(InputStream in, boolean isCloseStream) throws IORuntimeException { final InputStream availableStream = toAvailableStream(in); try{ final int available = availableStream.available(); if(available > 0){ byte[] result = new byte[availabl...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void readBySax(String path, int sheetIndex, RowHandler rowHandler) { BufferedInputStream in = null; try { in = FileUtil.getInputStream(path); readBySax(in, sheetIndex, rowHandler); } finally { IoUtil.close(in); } } ...
#fixed code public static void readBySax(String path, int sheetIndex, RowHandler rowHandler) { readBySax(FileUtil.file(path), sheetIndex, rowHandler); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void freemarkerEngineTest() { // 字符串模板 TemplateEngine engine = new FreemarkerEngine(new TemplateConfig("templates", ResourceMode.STRING)); Template template = engine.getTemplate("hello,${name}"); String result = template.render(Dict.create().set("name...
#fixed code @Test public void freemarkerEngineTest() { // 字符串模板 TemplateEngine engine = TemplateUtil.createEngine( new TemplateConfig("templates", ResourceMode.STRING).setCustomEngine(FreemarkerEngine.class)); Template template = engine.getTemplate("hello,${name}"); String resu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void enjoyEngineTest() { // 字符串模板 TemplateEngine engine = new EnjoyEngine(new TemplateConfig("templates")); Template template = engine.getTemplate("#(x + 123)"); String result = template.render(Dict.create().set("x", 1)); Assert.assertEquals("124", ...
#fixed code @Test public void enjoyEngineTest() { // 字符串模板 TemplateEngine engine = TemplateUtil.createEngine( new TemplateConfig("templates").setCustomEngine(EnjoyEngine.class)); Template template = engine.getTemplate("#(x + 123)"); String result = template.render(Dict.create()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static PemObject readPemObject(InputStream keyStream) { PemReader pemReader = null; try { pemReader = new PemReader(IoUtil.getReader(keyStream, CharsetUtil.CHARSET_UTF_8)); return pemReader.readPemObject(); } catch (IOException e) { throw new IORuntim...
#fixed code public static PemObject readPemObject(InputStream keyStream) { return readPemObject(IoUtil.getUtf8Reader(keyStream)); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ClassLoader compile() { // 获得classPath final List<File> classPath = getClassPath(); final URL[] urLs = URLUtil.getURLs(classPath.toArray(new File[0])); final URLClassLoader ucl = URLClassLoader.newInstance(urLs, this.parentClassLoader); if (sourceCodeMap.i...
#fixed code public ClassLoader compile() { // 获得classPath final List<File> classPath = getClassPath(); final URL[] urLs = URLUtil.getURLs(classPath.toArray(new File[0])); final URLClassLoader ucl = URLClassLoader.newInstance(urLs, this.parentClassLoader); if (sourceCodeMap.isEmpty...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void copyPropertiesHasBooleanTest() { SubPerson p1 = new SubPerson(); p1.setSlow(true); // 测试boolean参数值isXXX形式 SubPerson p2 = new SubPerson(); BeanUtil.copyProperties(p1, p2); Assert.assertTrue(p2.isSlow()); // 测试boolean参数值非isXXX形式 SubPerson...
#fixed code @Test public void copyPropertiesHasBooleanTest() { SubPerson p1 = new SubPerson(); p1.setSlow(true); // 测试boolean参数值isXXX形式 SubPerson p2 = new SubPerson(); BeanUtil.copyProperties(p1, p2); Assert.assertTrue(p2.getSlow()); // 测试boolean参数值非isXXX形式 SubPerson2 p3 ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public SM2 setMode(SM2Engine.Mode mode) { this.mode = mode; if (null != this.engine) { this.engine = null; } return this; } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public SM2 setMode(SM2Engine.Mode mode) { this.mode = mode; this.engine = null; return this; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void freemarkerEngineTest() { // 字符串模板 TemplateEngine engine = new FreemarkerEngine(new TemplateConfig("templates", ResourceMode.STRING)); Template template = engine.getTemplate("hello,${name}"); String result = template.render(Dict.create().set("name...
#fixed code @Test public void freemarkerEngineTest() { // 字符串模板 TemplateEngine engine = TemplateUtil.createEngine( new TemplateConfig("templates", ResourceMode.STRING).setCustomEngine(FreemarkerEngine.class)); Template template = engine.getTemplate("hello,${name}"); String resu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Deprecated public CellStyle createStyleForCell(int x, int y) { final Cell cell = getOrCreateCell(x, y); final CellStyle cellStyle = this.workbook.createCellStyle(); cell.setCellStyle(cellStyle); return cellStyle; } #location 5 ...
#fixed code @Deprecated public CellStyle createStyleForCell(int x, int y) { return createCellStyle(x, y); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void thymeleafEngineTest() { // 字符串模板 TemplateEngine engine = new ThymeleafEngine(new TemplateConfig("templates")); Template template = engine.getTemplate("<h3 th:text=\"${message}\"></h3>"); String result = template.render(Dict.create().set("message"...
#fixed code @Test public void thymeleafEngineTest() { // 字符串模板 TemplateEngine engine = TemplateUtil.createEngine( new TemplateConfig("templates").setCustomEngine(ThymeleafEngine.class)); Template template = engine.getTemplate("<h3 th:text=\"${message}\"></h3>"); String result =...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public byte[] decryptFromBcd(String data, KeyType keyType, Charset charset) { final byte[] dataBytes = BCD.ascToBcd(StrUtil.bytes(data, charset)); return decrypt(dataBytes, keyType); } #location 2 #vulnerabilit...
#fixed code public byte[] decryptFromBcd(String data, KeyType keyType, Charset charset) { Assert.notNull(data, "Bcd string must be not null!"); final byte[] dataBytes = BCD.ascToBcd(StrUtil.bytes(data, charset)); return decrypt(dataBytes, keyType); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public CellStyle getOrCreateCellStyle(int x, int y) { final Cell cell = getOrCreateCell(x, y); CellStyle cellStyle = cell.getCellStyle(); if (null == cellStyle) { cellStyle = this.workbook.createCellStyle(); cell.setCellStyle(cellStyle); } return cellStyle;...
#fixed code public CellStyle getOrCreateCellStyle(int x, int y) { final CellStyle cellStyle = getOrCreateCell(x, y).getCellStyle(); return StyleUtil.isNullOrDefaultStyle(this.workbook, cellStyle) ? createCellStyle(x, y) : cellStyle; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private List<GalenSuite> read(InputStream inputStream, String filePath) throws IOException { try { GalenSuiteLineProcessor lineProcessor = new GalenSuiteLineProcessor(); BufferedReader bufferedReader = new BufferedReader(new ...
#fixed code private List<GalenSuite> read(InputStream inputStream, String filePath) throws IOException { try { GalenSuiteLineProcessor lineProcessor = new GalenSuiteLineProcessor(getContextPath(filePath)); lineProcessor.readLines(inputStream); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { AnnotationAttributes annoAttrs = AnnotationAttributes.fromMap(importingClassMetadata.getAnnotationAttributes(MapperScan.class.getName())); ...
#fixed code @Override public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { AnnotationAttributes mapperScanAttrs = AnnotationAttributes .fromMap(importingClassMetadata.getAnnotationAttributes(MapperScan.class.getName...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code boolean processRequest(String nick, String login, String hostname, String request) { StringTokenizer tokenizer = new StringTokenizer(request); tokenizer.nextToken(); String type = tokenizer.nextToken(); String filename = tokenizer.nextToken(); if (type.equals("S...
#fixed code DccManager(PircBotX bot) { _bot = bot; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void sendTest() { //Setup PircBotX bot = new PircBotX() { @Override public void sendAction(String target, String action) { signal.set(target, action); } @Override public void sendCTCPCommand(String target, String command) { signal....
#fixed code @Test public void sendTest() { //Make sure all methods call each other appropiatly final String string = "AString"; final User user = new User(bot, "AUser"); final Channel chan = new Channel(bot, "AChannel"); final BaseEvent event = new Action.Event(bot, user, chan, s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void handleLine(String line) throws Throwable { try { log(line); // Check for server pings. if (line.startsWith("PING ")) { // Respond to the ping and return immediately. onServerPing(line.substring(5)); return; } String sourceNick ...
#fixed code protected void handleLine(String line) throws Throwable { try { log(line); // Check for server pings. if (line.startsWith("PING ")) { // Respond to the ping and return immediately. onServerPing(line.substring(5)); return; } String sourceNick = ""; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void processServerResponseTest() { PircBotXVisible bot = new PircBotXVisible() { }; final Signal signal = new Signal(); bot.getListeners().addListener(new MetaListener() { @Override public void onChannelInfo(Event event) { signal.event = eve...
#fixed code @Test public void processServerResponseTest() { String aString = "I'm some super long string that has multiple words"; //Simulate /LIST response bot.processServerResponse(321, "Channel :Users Name"); bot.processServerResponse(322, "PircBotXUser #PircBotXChannel 99 :" +...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void handleLine(String line) throws Throwable { try { log(line); // Check for server pings. if (line.startsWith("PING ")) { // Respond to the ping and return immediately. onServerPing(line.substring(5)); return; } String sourceNick ...
#fixed code protected void handleLine(String line) throws Throwable { try { log(line); // Check for server pings. if (line.startsWith("PING ")) { // Respond to the ping and return immediately. onServerPing(line.substring(5)); return; } String sourceNick = ""; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //payPackage 的商品信息,总价可以通过前端传入 Unifiedorder unifiedorder = new Unifiedorder(); unifiedorder.setAppid(appid); unifiedorder.setMch_id(...
#fixed code @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //payPackage 的商品信息,总价可以通过前端传入 Unifiedorder unifiedorder = new Unifiedorder(); unifiedorder.setAppid(appid); unifiedorder.setMch_id(mch_id...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGenerateRepository() throws IOException { new RepositoryGenerateJava().generate("User", null, "template-repository.txt"); File repositoryJavaFile = new File("src/main/java/br/com/example/repository/UserRepository.java"); File newTextFile = Co...
#fixed code @Test public void testGenerateRepository() throws IOException { boolean validateFileEquals = FileUtils.contentEquals(convertRepositoryToText, new File("src/test/resources/templates/java/repository/UserRepository.txt")); assertEquals("should be true", true, validateFileEqual...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void logGuildLeave(GuildMemberRemoveEvent event) { TextChannel tc = vortex.getDatabase().settings.getSettings(event.getGuild()).getServerLogChannel(event.getGuild()); if(tc==null) return; OffsetDateTime now = OffsetDateTime...
#fixed code public void logGuildLeave(GuildMemberRemoveEvent event) { TextChannel tc = vortex.getDatabase().settings.getSettings(event.getGuild()).getServerLogChannel(event.getGuild()); if(tc==null) return; OffsetDateTime now = OffsetDateTime.now()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected final void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws ServletException, IOException { // Get the transform names from the suffix final List<NamedImageTransformer> sele...
#fixed code @Override protected final void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws ServletException, IOException { // Get the transform names from the suffix final List<NamedImageTransformer> selectedNa...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Designer getDesigner(Object adaptable) { return getResourceResolver(adaptable).adaptTo(Designer.class); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code private Designer getDesigner(Object adaptable) { ResourceResolver resolver = getResourceResolver(adaptable); if(resolver != null) { return resolver.adaptTo(Designer.class); } return null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public final String get(final String path, final SlingHttpServletRequest request, final SlingHttpServletResponse response) { if (!serveAuthenticatedFromCache && !isAnonymousRequest(request))...
#fixed code @Override public final String get(final String path, final SlingHttpServletRequest request, final SlingHttpServletResponse response) { if (!serveAuthenticatedFromCache && !isAnonymousRequest(request)) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public final void addThumbnail(final JcrPackage jcrPackage, Resource thumbnailResource) { ResourceResolver resourceResolver = null; if (jcrPackage == null) { log.error("JCR Package is null; no package thumbnail needed for null packages!"); ...
#fixed code public final void addThumbnail(final JcrPackage jcrPackage, Resource thumbnailResource) { ResourceResolver resourceResolver = null; if (jcrPackage == null) { log.error("JCR Package is null; no package thumbnail needed for null packages!"); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testStart_WFData() throws Exception { Map<Object, Object> map = new HashMap<Object, Object>(); map.put("process.label", "test"); swr.bindWorkflowProcesses(new WFDataWorkflowProcess(), map); Map<String, Map<String, ...
#fixed code @Test public void testStart_WFData() throws Exception { Map<Object, Object> map = new HashMap<Object, Object>(); map.put("process.label", "test"); swr.bindWorkflowProcesses(new WFDataWorkflowProcess(), map); Map<String, Map<String, Object...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Session getSession(Object adaptable) { return getResourceResolver(adaptable).adaptTo(Session.class); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code private Session getSession(Object adaptable) { ResourceResolver resolver = getResourceResolver(adaptable); return resolver != null ? resolver.adaptTo(Session.class) : null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public final void initialize(Resource resource, final ValueMap params) throws PersistenceException, RepositoryException { final ModifiableValueMap properties = resource.adaptTo(ModifiableValueMap.class); if (properties.get(KEY_...
#fixed code @Override public final void initialize(Resource resource, final ValueMap params) throws PersistenceException, RepositoryException { final ModifiableValueMap properties = resource.adaptTo(ModifiableValueMap.class); log.trace("Entering initializ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public final void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); L...
#fixed code @Override public final void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); List<St...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void handleRequest(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException, RepositoryException, ServletException { response.setContentType("application/json"); response.setCharacterEncoding("UT...
#fixed code private void handleRequest(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException, RepositoryException, ServletException { response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); // Generate current date ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public final void clearCache() { synchronized (this.cache) { this.cache.clear(); } } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code @Override public final void clearCache() { this.cache.clear(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Activate protected final void activate(Map<String, Object> config) throws RepositoryException { if (!capabilityHelper.isOak()) { log.info("Cowardly refusing to create indexes on non-Oak instance."); return; } final S...
#fixed code @Activate protected final void activate(Map<String, Object> config) throws RepositoryException { if (!capabilityHelper.isOak()) { log.info("Cowardly refusing to create indexes on non-Oak instance."); return; } final String ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected int resize(int newSize) { if (newSize != timestamps.length) { LOG.debug("Resizing throttling queue from {} to {}", timestamps.length, newSize); Instant[] newQueue = new Instant[newSize]; int result = 0; ...
#fixed code protected int resize(int newSize) { if (newSize != timestamps.length) { LOG.debug("Resizing throttling queue from {} to {}", timestamps.length, newSize); Instant[] newQueue = new Instant[newSize]; int result = 0; if (...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected final void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws ServletException, IOException { final String transformName = PathInfoUtil.getSuffixSegment(request, 0); final Nam...
#fixed code @Override protected final void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws ServletException, IOException { final String transformName = PathInfoUtil.getSuffixSegment(request, 0); final NamedImag...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public final String get(final String path, final SlingHttpServletRequest request, final SlingHttpServletResponse response) { if (!serveAuthenticatedFromCache && !isAnonymousRequest(request))...
#fixed code @Override public final String get(final String path, final SlingHttpServletRequest request, final SlingHttpServletResponse response) { if (!serveAuthenticatedFromCache && !isAnonymousRequest(request)) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected String getRawFormData(final String formName, final SlingHttpServletRequest request, final SlingHttpServletResponse response) { final String cookieName = getGetLookupKey(formName); final Cookie cookie = CookieUtil.getCo...
#fixed code @Override protected String getRawFormData(final String formName, final SlingHttpServletRequest request, final SlingHttpServletResponse response) { final String cookieName = getGetLookupKey(formName); final Cookie cookie = CookieUtil.getCookie(r...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object getValue(Object adaptable, String name, Type declaredType, AnnotatedElement element, DisposalCallbackRegistry callbackRegistry) { // sanity check if (!(adaptable instanceof Resource || adaptable instanceof SlingHt...
#fixed code @Override public Object getValue(Object adaptable, String name, Type declaredType, AnnotatedElement element, DisposalCallbackRegistry callbackRegistry) { // sanity check if (!(adaptable instanceof Resource || adaptable instanceof SlingHttpServ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private PageManager getPageManager(Object adaptable) { return getResourceResolver(adaptable).adaptTo(PageManager.class); } #location 2 #vulnerability type NULL_DEREFERENCE
#fixed code private PageManager getPageManager(Object adaptable) { ResourceResolver resolver = getResourceResolver(adaptable); if(resolver != null) { return resolver.adaptTo(PageManager.class); } return null; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String evaluate(Map<String, String> configIn, String key, String value) { if (!configIn.containsKey(FAMILY_TAG) || !configIn.containsKey(QUALIFIER_TAG) || !configIn.containsKey(TABLE_NAME_TAG) || !configIn.containsKey(ZOOKEEPER_QUORUM_TA...
#fixed code public String evaluate(Map<String, String> configIn, String key, String value) { checkConfig(configIn); try { HTable table = getHTable(configIn.get(TABLE_NAME_TAG), configIn.get(ZOOKEEPER_QUORUM_TAG)); Put thePut = new Put(key.getBytes()); thePut.add(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public String evaluate(Map<String, String> configIn, String key, String value) { if (!configIn.containsKey(FAMILY_TAG) || !configIn.containsKey(QUALIFIER_TAG) || !configIn.containsKey(TABLE_NAME_TAG) || !configIn.containsKey(ZOOKEEPER_QUORUM_TA...
#fixed code public String evaluate(Map<String, String> configIn, String key, String value) { checkConfig(configIn); try { HTable table = getHTable(configIn.get(TABLE_NAME_TAG), configIn.get(ZOOKEEPER_QUORUM_TAG)); Put thePut = new Put(key.getBytes()); thePut.add(...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCreateRuntime_Injection() { BQTestRuntime runtime = testFactory.app("-x").autoLoadModules().createRuntime(); assertArrayEquals(new String[]{"-x"}, runtime.getRuntime().getArgs()); } #location 4 ...
#fixed code @Test public void testCreateRuntime_Injection() { BQRuntime runtime = testFactory.app("-x").autoLoadModules().createRuntime(); assertArrayEquals(new String[]{"-x"}, runtime.getArgs()); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testCreateRuntime_Streams_NoTrace() { TestIO io = TestIO.noTrace(); BQTestRuntime runtime = testFactory.app("-x") .autoLoadModules() .module(b -> BQCoreModule.extend(b).addCommand(XCommand.class)) ...
#fixed code @Test public void testCreateRuntime_Streams_NoTrace() { TestIO io = TestIO.noTrace(); CommandOutcome result = testFactory.app("-x") .autoLoadModules() .module(b -> BQCoreModule.extend(b).addCommand(XCommand.class)) ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void render(PebbleTemplateImpl self, Writer writer, EvaluationContext context) throws PebbleException, IOException { Object iterableEvaluation = iterableExpression.evaluate(self, context); Iterable<?> iterable = null; ...
#fixed code @Override public void render(PebbleTemplateImpl self, Writer writer, EvaluationContext context) throws PebbleException, IOException { Object iterableEvaluation = iterableExpression.evaluate(self, context); Iterable<?> iterable = null; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object evaluate(PebbleTemplateImpl self, EvaluationContext context) throws PebbleException { Object object = node.evaluate(self, context); Object result = null; Object[] argumentValues = null; if (object != null &&...
#fixed code @Override public Object evaluate(PebbleTemplateImpl self, EvaluationContext context) throws PebbleException { Object object = node.evaluate(self, context); Object result = null; Object[] argumentValues = null; Member member = obj...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void evaluateBlock(String blockName, Writer writer, Map<String, Object> map, Locale locale) throws PebbleException, IOException { EvaluationContext context = this.initContext(locale); context.getScopeChain().pushScope(map); final Writer n...
#fixed code public void evaluateBlock(String blockName, Writer writer, Map<String, Object> map, Locale locale) throws PebbleException, IOException { EvaluationContext context = this.initContext(locale); context.getScopeChain().pushScope(map); this.evaluate(new No...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object evaluate(PebbleTemplateImpl self, EvaluationContext context) throws PebbleException { Object object = node.evaluate(self, context); Object result = null; Object[] argumentValues = null; Member member = objec...
#fixed code @Override public Object evaluate(PebbleTemplateImpl self, EvaluationContext context) throws PebbleException { Object object = node.evaluate(self, context); Object result = null; Object[] argumentValues = null; Member member = object == n...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static GaugeRollup buildFromGaugeRollups(Points<GaugeRollup> input) throws IOException { // return the one with the latest timestamp. int numSamples = 0; Points.Point<GaugeRollup> latest = null; for (Points.Point<GaugeRollup> point...
#fixed code public static GaugeRollup buildFromGaugeRollups(Points<GaugeRollup> input) throws IOException { GaugeRollup rollup = new GaugeRollup(); rollup.computeFromRollups(BasicRollup.recast(input, IBasicRollup.class)); Points.Point<SimpleNumbe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected MetricData getRollupByGranularity( String tenantId, String metricName, long from, long to, Granularity g) { final Timer.Context ctx = metricsFetchTimer.time(); final Locator locator =...
#fixed code protected MetricData getRollupByGranularity( String tenantId, String metricName, long from, long to, Granularity g) { final Timer.Context ctx = metricsFetchTimer.time(); final Locator locator = Locat...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { if (args.length != 5){ System.err.println("Usage: java " + AFLRedundancyDriver.class + " TEST_CLASS TEST_METHOD TEST_INPUT_FILE AFL_TO_JAVA_PIPE JAVA_TO_AFL_PIPE"); System.exit(1); } ...
#fixed code public static void main(String[] args) { if (args.length != 5){ System.err.println("Usage: java " + AFLRedundancyDriver.class + " TEST_CLASS TEST_METHOD TEST_INPUT_FILE AFL_TO_JAVA_PIPE JAVA_TO_AFL_PIPE"); System.exit(1); } St...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { if (args.length != 5){ System.err.println("Usage: java " + AFLDriver.class + " TEST_CLASS TEST_METHOD TEST_INPUT_FILE AFL_TO_JAVA_PIPE JAVA_TO_AFL_PIPE"); System.exit(1); } String...
#fixed code public static void main(String[] args) { if (args.length != 5){ System.err.println("Usage: java " + AFLDriver.class + " TEST_CLASS TEST_METHOD TEST_INPUT_FILE AFL_TO_JAVA_PIPE JAVA_TO_AFL_PIPE"); System.exit(1); } String testC...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { if (args.length != 5){ System.err.println("Usage: java " + AFLRedundancyDriver.class + " TEST_CLASS TEST_METHOD TEST_INPUT_FILE AFL_TO_JAVA_PIPE JAVA_TO_AFL_PIPE"); System.exit(1); } ...
#fixed code public static void main(String[] args) { if (args.length != 5){ System.err.println("Usage: java " + AFLRedundancyDriver.class + " TEST_CLASS TEST_METHOD TEST_INPUT_FILE AFL_TO_JAVA_PIPE JAVA_TO_AFL_PIPE"); System.exit(1); } St...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void execute() throws MojoExecutionException, MojoFailureException { ClassLoader loader; ZestGuidance guidance; Log log = getLog(); PrintStream out = System.out; // TODO: Re-route to logger from super.getLog() ...
#fixed code @Override public void execute() throws MojoExecutionException, MojoFailureException { ClassLoader loader; ZestGuidance guidance; Log log = getLog(); PrintStream out = System.out; // TODO: Re-route to logger from super.getLog() Resul...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void evaluate() throws Throwable { // Construct generators for each parameter List<Generator<?>> generators = Arrays.stream(method.getMethod().getParameters()) .map(this::createParameterTypeContext) .m...
#fixed code @Override public void evaluate() throws Throwable { // Construct generators for each parameter List<Generator<?>> generators = Arrays.stream(method.getMethod().getParameters()) .map(this::createParameterTypeContext) .map(thi...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void prepareOutputDirectory() throws IOException { // Create the output directory if it does not exist if (!outputDirectory.exists()) { if (!outputDirectory.mkdirs()) { throw new IOException("Could not create output d...
#fixed code private void prepareOutputDirectory() throws IOException { // Create the output directory if it does not exist if (!outputDirectory.exists()) { if (!outputDirectory.mkdirs()) { throw new IOException("Could not create output directo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Guidance getCurrentGuidance() { if (guidance == null) { System.err.println(String.format("Warning: No guidance set. " + " Falling back to default %d trials with no feedback", DEFAULT_MAX_TRIALS)); setGuid...
#fixed code public static Guidance getCurrentGuidance() { return guidance; }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private File[] readSeedFiles() { if (this.inputDirectory == null) { return new File[0]; } ArrayList<File> seedFilesArray = new ArrayList<>(); File[] allFiles = this.inputDirectory.listFiles(); for (int i = 0; i < allF...
#fixed code private File[] readSeedFiles() { if (this.inputDirectory == null) { return new File[0]; } ArrayList<File> seedFilesArray = new ArrayList<>(); File[] allFiles = this.inputDirectory.listFiles(); if (allFiles == null) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { if (args.length != 5){ System.err.println("Usage: java " + AFLRedundancyDriver.class + " TEST_CLASS TEST_METHOD TEST_INPUT_FILE AFL_TO_JAVA_PIPE JAVA_TO_AFL_PIPE"); System.exit(1); } ...
#fixed code public static void main(String[] args) { if (args.length != 5){ System.err.println("Usage: java " + AFLRedundancyDriver.class + " TEST_CLASS TEST_METHOD TEST_INPUT_FILE AFL_TO_JAVA_PIPE JAVA_TO_AFL_PIPE"); System.exit(1); } St...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void prepareOutputDirectory() throws IOException { // Create the output directory if it does not exist if (!outputDirectory.exists()) { if (!outputDirectory.mkdirs()) { throw new IOException("Could not create output d...
#fixed code private void prepareOutputDirectory() throws IOException { // Create the output directory if it does not exist if (!outputDirectory.exists()) { if (!outputDirectory.mkdirs()) { throw new IOException("Could not create output directo...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main(String[] args) { if (args.length != 5){ System.err.println("Usage: java " + AFLRedundancyDriver.class + " TEST_CLASS TEST_METHOD TEST_INPUT_FILE AFL_TO_JAVA_PIPE JAVA_TO_AFL_PIPE"); System.exit(1); } ...
#fixed code public static void main(String[] args) { if (args.length != 5){ System.err.println("Usage: java " + AFLRedundancyDriver.class + " TEST_CLASS TEST_METHOD TEST_INPUT_FILE AFL_TO_JAVA_PIPE JAVA_TO_AFL_PIPE"); System.exit(1); } St...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Future<?> apply(final ClientRequest jerseyRequest, final AsyncConnectorCallback jerseyCallback) { final CompletableFuture<Object> settableFuture = new CompletableFuture<>(); final URI requestUri = jerseyRequest.getUri(); St...
#fixed code @Override public Future<?> apply(final ClientRequest jerseyRequest, final AsyncConnectorCallback jerseyCallback) { return execute(jerseyRequest).whenCompleteAsync((r, th) -> { if (th == null) jerseyCallback.response(r); else jer...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void writeTo(final Object object, final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputS...
#fixed code @Override public void writeTo(final Object object, final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, ...
#fixed code @Override public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, In...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void channelRead(final ChannelHandlerContext ctx, Object msg) { if (msg instanceof HttpRequest) { final HttpRequest req = (HttpRequest) msg; if (HttpUtil.is100ContinueExpected(req)) { ctx.write(new D...
#fixed code @Override public void channelRead(final ChannelHandlerContext ctx, Object msg) { if (msg instanceof HttpRequest) { final HttpRequest req = (HttpRequest) msg; if (HttpUtil.is100ContinueExpected(req)) { ctx.write(new Default...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Object readFrom(final Class<Object> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, String> httpHeaders, ...
#fixed code @Override public Object readFrom(final Class<Object> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, String> httpHeaders, ...
Below is the vulnerable code, please generate the patch based on the following information.