input
stringlengths
205
73.3k
output
stringlengths
64
73.2k
instruction
stringclasses
1 value
#vulnerable code public void clear() { while (previousMove()); history.clear(); } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code public void clear() { initialize(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void drawWoodenBoard(Graphics2D g) { if (uiConfig.getBoolean("fancy-board")) { // fancy version int shadowRadius = (int) (boardLength * MARGIN / 6); BufferedImage boardImage = theme.getBoard(); // Support s...
#fixed code private void drawWoodenBoard(Graphics2D g) { if (uiConfig.getBoolean("fancy-board")) { if (cachedBoardImage == null) { try { cachedBoardImage = ImageIO.read(getClass().getResourceAsStream("/assets/board.png")); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static boolean save(String filename) throws IOException { FileOutputStream fp = new FileOutputStream(filename); OutputStreamWriter writer = new OutputStreamWriter(fp); StringBuilder builder = new StringBuilder(String.format("(;KM[7.5]AP[Li...
#fixed code public static boolean save(String filename) throws IOException { FileOutputStream fp = new FileOutputStream(filename); OutputStreamWriter writer = new OutputStreamWriter(fp); try { // add SGF header StringBuilder builde...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void ponder() { isPondering = true; startPonderTime = System.currentTimeMillis(); if (Lizzie.board.isAvoding && Lizzie.board.isKeepingAvoid && !isKataGo) analyzeAvoid( "avoid", Lizzie.board.getHistory().isBlacksTurn() ? "w" : "...
#fixed code public void ponder() { isPondering = true; startPonderTime = System.currentTimeMillis(); if (Lizzie.board.isAvoding && Lizzie.board.isKeepingAvoid && !isKataGo) analyzeAvoid( "avoid b " + Lizzie.board.avoidCoords + " " ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void sendCommand(String command) { if (printCommunication) { System.out.printf("> %s\n", command); } if (command.startsWith("fixed_handicap")) isSettingHandicap = true; if (command.startsWith("genmove")) ...
#fixed code public void sendCommand(String command) { command = cmdNumber + " " + command; cmdNumber++; if (printCommunication) { System.out.printf("> %s\n", command); } if (command.startsWith("fixed_handicap")) isSettingHan...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static boolean parse(String value) { // Drop anything outside "(;...)" final Pattern SGF_PATTERN = Pattern.compile("(?s).*?(\\(\\s*;.*\\)).*?"); Matcher sgfMatcher = SGF_PATTERN.matcher(value); if (sgfMatcher.matches()) { value = sgfMatcher.g...
#fixed code private static boolean parse(String value) { // Drop anything outside "(;...)" final Pattern SGF_PATTERN = Pattern.compile("(?s).*?(\\(\\s*;{0,1}.*\\))(?s).*?"); Matcher sgfMatcher = SGF_PATTERN.matcher(value); if (sgfMatcher.matches()) { value = sgfMatche...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void updateWinrate() { Leelaz.WinrateStats stats = Lizzie.leelaz.getWinrateStats(); if (stats.maxWinrate >= 0 && stats.totalPlayouts > history.getData().playouts) { history.getData().winrate = stats.maxWinrate; history.getData().playouts = stats...
#fixed code public void updateWinrate() { Leelaz.WinrateStats stats = Lizzie.leelaz.getWinrateStats(); if (stats.maxWinrate >= 0 && stats.totalPlayouts > history.getData().getPlayouts()) { history.getData().winrate = stats.maxWinrate; // we won't set playouts here. but ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void updateWinrate() { Leelaz.WinrateStats stats = Lizzie.leelaz.getWinrateStats(); if (stats.maxWinrate >= 0 && stats.totalPlayouts > history.getData().getPlayouts()) { history.getData().winrate = stats.maxWinrate; // we won't set playouts here...
#fixed code public void updateWinrate() { Leelaz.WinrateStats stats = Lizzie.leelaz.getWinrateStats(); if (stats.maxWinrate >= 0 && stats.totalPlayouts > history.getData().getPlayouts()) { history.getData().winrate = stats.maxWinrate; // we won't set playouts here. but ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void reopen(int size) { size = (size == 13 || size == 9) ? size : 19; if (size != boardSize) { boardSize = size; initialize(); forceRefresh = true; } } #location 5 #vulnerabil...
#fixed code public void reopen(int size) { size = (size >= 2) ? size : 19; if (size != boardSize) { boardSize = size; Zobrist.init(); clear(); Lizzie.leelaz.sendCommand("boardsize " + boardSize); forceRefresh = true; } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void updateWinrate() { Leelaz.WinrateStats stats = Lizzie.leelaz.getWinrateStats(); if (stats.maxWinrate >= 0 && stats.totalPlayouts > history.getData().getPlayouts()) { history.getData().winrate = stats.maxWinrate; // we won't set playouts here...
#fixed code public void updateWinrate() { Leelaz.WinrateStats stats = Lizzie.leelaz.getWinrateStats(); if (stats.maxWinrate >= 0 && stats.totalPlayouts > history.getData().getPlayouts()) { history.getData().winrate = stats.maxWinrate; // we won't set playouts here. but ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int height) { if (width < 0 || height < 0) return; // we don't have enough space double lastWR; if (Lizzie.board.getData().moveNumber == 0) last...
#fixed code private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int height) { if (width < 0 || height < 0) return; // we don't have enough space double lastWR = 50; // winrate the previous move boolean validLastWinrate = f...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGetPropertyType() throws Exception { assertThat(TypeUtil.getPropertyType(A.class, "b.i").equals(Integer.class), equalTo(true)); assertThat(TypeUtil.getPropertyType(A.class, "s").equals(String.class), equalTo(true)); } ...
#fixed code @Test public void testGetPropertyType() throws Exception { assertThat(TypeUtil.getPropertyType(A.class, "b.i", "1").equals(Integer.class), equalTo(true)); assertThat(TypeUtil.getPropertyType(A.class, "s", "2").equals(String.class), equalTo(true)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testGetPropertyType() throws Exception { assertThat(TypeUtil.getPropertyType(A.class, "b.i").equals(Integer.class), equalTo(true)); assertThat(TypeUtil.getPropertyType(A.class, "s").equals(String.class), equalTo(true)); } ...
#fixed code @Test public void testGetPropertyType() throws Exception { assertThat(TypeUtil.getPropertyType(A.class, "b.i", "1").equals(Integer.class), equalTo(true)); assertThat(TypeUtil.getPropertyType(A.class, "s", "2").equals(String.class), equalTo(true)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void executeDDL(Object test, String[] sqls) { Connection connection = CONNECTION_TABLE.get(test); try { Statement statement = connection.createStatement(); for (int i = 0; i < sqls.length; i++) { statement.execute(sqls[i]); } connection.co...
#fixed code public static void executeDDL(Object test, String[] sqls) { try { executeSql(CONNECTION_TABLE.get(test), sqls); } catch (SQLException e) { throw new RuntimeException(e); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected Properties getProperties() { if (propertyFile!=null) { Properties properties = new Properties(); // TODO: should we "inherit" from the ant projects properties ? try { properties.load(new FileInputStream(propertyFile) ); return properties; } ...
#fixed code protected Properties getProperties() { if (propertyFile!=null) { Properties properties = new Properties(); // TODO: should we "inherit" from the ant projects properties ? FileInputStream is = null; try { is = new FileInputStream(propertyFile); properties.load...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void execute() { getLog().info("Starting " + this.getClass().getSimpleName() + "..."); RevengStrategy strategy = setupReverseEngineeringStrategy(); Properties properties = loadPropertiesFile(); MetadataDescriptor jdbcDescriptor = c...
#fixed code public void execute() { getLog().info("Starting " + this.getClass().getSimpleName() + "..."); RevengStrategy strategy = setupReverseEngineeringStrategy(); if (propertyFile.exists()) { executeExporter(createJdbcDescriptor(strategy, loadProperti...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void testPropertySet() throws FileNotFoundException, IOException { GenericExporter ge = new GenericExporter(); ge.setConfiguration(getCfg()); ge.setOutputDirectory(getOutputDir()); Properties p = new Properties(); p.setProperty("proptest", "A value"); p....
#fixed code public void testPropertySet() throws FileNotFoundException, IOException { GenericExporter ge = new GenericExporter(); ge.setConfiguration(getCfg()); ge.setOutputDirectory(getOutputDir()); Properties p = new Properties(); p.setProperty("proptest", "A value"); p.setPro...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public String getAllExecutors(String jobName, CuratorRepository.CuratorFrameworkOp curatorFrameworkOp) { String executorsNodePath = SaturnExecutorsNode.getExecutorsNodePath(); if (!curatorFrameworkOp.checkExists(executorsNodePath)) { return null; } St...
#fixed code @Override public String getAllExecutors(String jobName, CuratorRepository.CuratorFrameworkOp curatorFrameworkOp) { String executorsNodePath = SaturnExecutorsNode.getExecutorsNodePath(); if (!curatorFrameworkOp.checkExists(executorsNodePath)) { return null; } StringBu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void refreshTreeData() { Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values(); for (ZkCluster zkCluster : zkClusters) { InitRegistryCenterService.initTreeJson(REGISTRY_CENTER_CONFIGURATION_MAP.get(zkCluster.getZkAddr(...
#fixed code private void refreshTreeData() { Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values(); for (ZkCluster zkCluster : zkClusters) { InitRegistryCenterService.initTreeJson(zkCluster.getRegCenterConfList(), zkCluster.getZkAddr()); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public RegistryCenterConfiguration findConfigByNamespace(String namespace) { if(Strings.isNullOrEmpty(namespace)){ return null; } Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values(); for (ZkCluster zkCluster: ...
#fixed code @Override public RegistryCenterConfiguration findConfigByNamespace(String namespace) { if(Strings.isNullOrEmpty(namespace)){ return null; } Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values(); for (ZkCluster zkCluster: zkClus...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void zip(List<File> runtimeLibFiles, File saturnContainerDir, File zipFile) throws IOException { ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile)); for(File file : saturnContainerDir.listFiles()) { zip(file, "saturn", zos); } ...
#fixed code public static void zip(List<File> runtimeLibFiles, File saturnContainerDir, File zipFile) throws IOException { ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile)); /* for(File file : saturnContainerDir.listFiles()) { zip(file, "saturn", zos); }*/ ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void run() { while (!halted.get()) { try { synchronized (sigLock) { while (paused && !halted.get()) { try { sigLock.wait(1000L); } catch (InterruptedException ignore) { } } if (halted.get()) { break; ...
#fixed code @Override public void run() { while (!halted.get()) { try { synchronized (sigLock) { while (paused && !halted.get()) { try { sigLock.wait(1000L); } catch (InterruptedException ignore) { } } if (halted.get()) { break; }...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public RegistryCenterConfiguration findConfig(String nameAndNamespace) { if(Strings.isNullOrEmpty(nameAndNamespace)){ return null; } Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values(); for (ZkCluster zkCluste...
#fixed code @Override public RegistryCenterConfiguration findConfig(String nameAndNamespace) { if(Strings.isNullOrEmpty(nameAndNamespace)){ return null; } Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values(); for (ZkCluster zkCluster: zkC...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void handleResponse(CloseableHttpResponse httpResponse) throws IOException, SaturnJobException { int status = httpResponse.getStatusLine().getStatusCode(); if (status == 201) { logger.info("raise alarm successfully."); return; } if (status >= 400 &&...
#fixed code private void handleResponse(CloseableHttpResponse httpResponse) throws IOException, SaturnJobException { int status = httpResponse.getStatusLine().getStatusCode(); if (status == 201) { logger.info("raise alarm successfully."); return; } if (status >= 400 && statu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static String[] getItemsPaths(String executorName, String jobName) { String jobNamePath = String.format(EXECUTINGJOBPATH, executorName, jobName); File jobNameFile = new File(jobNamePath); if (!jobNameFile.exists() || jobNameFile.isFile()) { return new Stri...
#fixed code public static String[] getItemsPaths(String executorName, String jobName) { String jobNamePath = String.format(EXECUTINGJOBPATH, executorName, jobName); File jobNameFile = new File(jobNamePath); if (!jobNameFile.exists() || jobNameFile.isFile()) { return new String[0];...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void init() { if (zkConfig.isUseNestedZookeeper()) { NestedZookeeperServers.getInstance().startServerIfNotStarted(zkConfig.getNestedPort(), zkConfig.getNestedDataDir()); } log.info("msg=Saturn job: zookeeper registry ce...
#fixed code @Override public void init() { if (zkConfig.isUseNestedZookeeper()) { NestedZookeeperServers.getInstance().startServerIfNotStarted(zkConfig.getNestedPort(), zkConfig.getNestedDataDir()); } log.info("msg=Saturn job: zookeeper registry center i...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static List<Long> getPidsFromFile(String executorName, String jobName, String jobItem) { List<Long> pids = new ArrayList<Long>(); //兼容旧版PID目录 Long pid = _getPidFromFile(executorName, jobName, jobItem); if(pid > 0){ pids.add(pid); } String path = St...
#fixed code public static List<Long> getPidsFromFile(String executorName, String jobName, String jobItem) { List<Long> pids = new ArrayList<Long>(); //兼容旧版PID目录 Long pid = _getPidFromFile(executorName, jobName, jobItem); if(pid > 0){ pids.add(pid); } String path = String.f...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void startNamespaceShardingManagerList(int count) throws Exception { assertThat(nestedZkUtils.isStarted()); for (int i = 0; i < count; i++) { shardingRegCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration(-1, nestedZ...
#fixed code public static void startNamespaceShardingManagerList(int count) throws Exception { assertThat(nestedZkUtils.isStarted()); for (int i = 0; i < count; i++) { ZookeeperRegistryCenter shardingRegCenter = new ZookeeperRegistryCenter(new ZookeeperConfigu...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void refreshNamespaceShardingListenerManagerMap() { Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values(); for (ZkCluster zkCluster: zkClusters) { for(RegistryCenterConfiguration conf: REGISTRY_CENTER_CONFIGURATION_MAP...
#fixed code private void refreshNamespaceShardingListenerManagerMap() { Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values(); for (ZkCluster zkCluster: zkClusters) { for(RegistryCenterConfiguration conf: zkCluster.getRegCenterConfList()) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public <T> Cursor<T> queryForCursor(Query query, final Class<T> clazz) { return new DelegatingCursor<T>(queryParsers.getForClass(query.getClass()).constructSolrQuery(query)) { @Override protected org.springframework.data.solr.core.query.result.DelegatingCursor.Pa...
#fixed code public <T> Cursor<T> queryForCursor(Query query, final Class<T> clazz) { return new DelegatingCursor<T>(queryParsers.getForClass(query.getClass()).constructSolrQuery(query)) { @Override protected org.springframework.data.solr.core.query.result.DelegatingCursor.PartialR...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void deliver() { if (actor.lifeCycle.isResuming()) { if (isStowed()) { internalDeliver(this); } else { internalDeliver(actor.lifeCycle.environment.suspended.swapWith(this)); } actor.lifeCycle.nextResuming(); ...
#fixed code @Override public void deliver() { if (actor.lifeCycle.isResuming()) { if (isStowed()) { internalDeliver(this); } else { internalDeliver(actor.lifeCycle.environment.suspended.swapWith(this)); } actor.lifeCycle.nextResuming(); } e...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static <T> T createFor(final Class<T> protocol, final Actor actor, final Mailbox mailbox) { final T maybeCachedProxy = actor.lifeCycle.environment.lookUpProxy(protocol); if (maybeCachedProxy != null) { return maybeCachedProxy; } final String...
#fixed code public static <T> T createFor(final Class<T> protocol, final Actor actor, final Mailbox mailbox) { final T maybeCachedProxy = actor.lifeCycle.environment.lookUpProxy(protocol); if (maybeCachedProxy != null) { return maybeCachedProxy; } final String proxy...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void deliver() { if (actor.__internal__IsResumed()) { if (isStowed()) { internalDeliver(this); } else { internalDeliver(actor.__internal__Environment().suspended.swapWith(this)); } actor.__internal__NextResumi...
#fixed code @Override public void deliver() { if (actor.lifeCycle.isResuming()) { if (isStowed()) { internalDeliver(this); } else { internalDeliver(actor.lifeCycle.environment.suspended.swapWith(this)); } actor.lifeCycle.nextResuming(); } e...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void deliver() { if (actor.lifeCycle.isResuming()) { if (isStowed()) { internalDeliver(this); } else { internalDeliver(actor.lifeCycle.environment.suspended.swapWith(this)); } actor.lifeCycle.nextResuming(); ...
#fixed code @Override public void deliver() { if (actor.lifeCycle.isResuming()) { if (isStowed()) { internalDeliver(this); } else { internalDeliver(actor.lifeCycle.environment.suspended.swapWith(this)); } actor.lifeCycle.nextResuming(); } e...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void stop() { if (stopped.compareAndSet(false, true)) { stopChildren(); // suspended.reset(); // stowage.reset(); mailbox.close(); } } #location 3 #vulnerability type THREAD_SAFET...
#fixed code void addChild(final Actor child) { children.add(child); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code void addChild(final Actor child) { children = children.plus(child); } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code void addChild(final Actor child) { children.add(child); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void deliver() { if (actor.__internal__IsResumed()) { if (isStowed()) { internalDeliver(this); } else { internalDeliver(actor.__internal__Environment().suspended.swapWith(this)); } actor.__internal__NextResumi...
#fixed code @Override public void deliver() { if (actor.lifeCycle.isResuming()) { if (isStowed()) { internalDeliver(this); } else { internalDeliver(actor.lifeCycle.environment.suspended.swapWith(this)); } actor.lifeCycle.nextResuming(); } e...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ZMQ.Event make(SendEvent sender, int eventFilter) { Ctx ctx = new Ctx(); @SuppressWarnings("deprecation") SocketBase s = ctx.createSocket(ZMQ.PUB); @SuppressWarnings("deprecation") SocketBase m = ctx.createSocket(ZMQ.PA...
#fixed code public ZMQ.Event make(SendEvent sender, int eventFilter) { try (ZMQ.Context zctx = new ZMQ.Context(1); ZMQ.Socket s = zctx.socket(SocketType.PUB); ZMQ.Socket m = zctx.socket(SocketType.PAIR)) { s.monitor("inproc://TestEventResol...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testProxy() throws Exception { Context ctx = ZMQ.context(1); assert (ctx != null); Main mt = new Main(ctx); mt.start(); new Dealer(ctx, "AA").start(); new Dealer(ctx, "BB").start(); Thr...
#fixed code @Test public void testProxy() throws Exception { int frontendPort = Utils.findOpenPort(); int backendPort = Utils.findOpenPort(); Context ctx = ZMQ.context(1); assert (ctx != null); Main mt = new Main(ctx, frontendPort, backe...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected boolean xsend(Msg msg_) { // If this is the first part of the message it's the ID of the // peer to send the message to. if (!more_out) { assert (current_out == null); // If we have malforme...
#fixed code @Override protected boolean xsend(Msg msg_) { // If this is the first part of the message it's the ID of the // peer to send the message to. if (!more_out) { assert (current_out == null); // If we have malformed mess...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public int start () { int rc = 0; timers.addAll(newTimers); newTimers.clear(); // Recalculate all timers now for (STimer timer: timers) { timer.when = timer.delay + System.currentTimeMillis(); } ...
#fixed code public int start () { int rc = 0; timers.addAll(newTimers); newTimers.clear(); // Recalculate all timers now for (STimer timer: timers) { timer.when = timer.delay + System.currentTimeMillis(); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public Command recv (long timeout_) { Command cmd_ = null; // Try to get the command straight away. if (active) { cmd_ = cpipe.read (); if (cmd_ != null) { return cmd_; } ...
#fixed code public Command recv (long timeout_) { Command cmd_ = null; // Try to get the command straight away. if (active) { cmd_ = cpipe.read (); if (cmd_ != null) { return cmd_; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main (String[] args) throws Exception { // Prepare our context and sockets ZMQ.Context context = ZMQ.context(1); // Connect to task ventilator ZMQ.Socket receiver = context.socket(ZMQ.PULL); receiver.connect("...
#fixed code public static void main (String[] args) throws Exception { // Prepare our context and sockets ZMQ.Context context = ZMQ.context(1); // Connect to task ventilator ZMQ.Socket receiver = context.socket(ZMQ.PULL); receiver.connect("tcp://...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private boolean identify_peer(Pipe pipe_) { Blob identity; Msg msg = pipe_.read(); if (msg == null) return false; if (msg.size () == 0) { // Fall back on the auto-generation ByteBuffer buf = Byte...
#fixed code private boolean identify_peer(Pipe pipe_) { Blob identity; Msg msg = pipe_.read(); if (msg == null) return false; if (msg.size () == 0) { // Fall back on the auto-generation ByteBuffer buf = ByteBuffer...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main (String[] args) throws Exception { // Prepare our context and sockets ZMQ.Context context = ZMQ.context(1); // Connect to task ventilator ZMQ.Socket receiver = context.socket(ZMQ.PULL); receiver.connect("...
#fixed code public static void main (String[] args) throws Exception { // Prepare our context and sockets ZMQ.Context context = ZMQ.context(1); // Connect to task ventilator ZMQ.Socket receiver = context.socket(ZMQ.PULL); receiver.connect("tcp://...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void destroySocket(Socket s) { if (s == null) { return; } if (sockets.remove(s)) { s.setLinger(linger); s.close(); } } #location 8 ...
#fixed code public void destroySocket(Socket s) { if (s == null) { return; } s.setLinger(linger); s.close(); try { mutex.lock(); this.sockets.remove(s); } finally { mutex.unlock();...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testConnectResolve() { System.out.println("test_connect_resolve running...\n"); Ctx ctx = ZMQ.init(1); assertThat(ctx, notNullValue()); // Create pair of socket, each with high watermark of 2. Thus the total ...
#fixed code @Test public void testConnectResolve() throws IOException { int port = Utils.findOpenPort(); System.out.println("test_connect_resolve running...\n"); Ctx ctx = ZMQ.init(1); assertThat(ctx, notNullValue()); // Create pair of s...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public final boolean bind(final String addr) { lock(); try { if (ctxTerminated) { errno.set(ZError.ETERM); return false; } options.mechanism.check(options); // Proces...
#fixed code public final boolean bind(final String addr) { lock(); try { if (ctxTerminated) { errno.set(ZError.ETERM); return false; } options.mechanism.check(options); // Process pend...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ZMQ.Event make(SendEvent sender, int eventFilter) { Ctx ctx = new Ctx(); @SuppressWarnings("deprecation") SocketBase s = ctx.createSocket(ZMQ.PUB); @SuppressWarnings("deprecation") SocketBase m = ctx.createSocket(ZMQ.PA...
#fixed code public ZMQ.Event make(SendEvent sender, int eventFilter) { try (ZMQ.Context zctx = new ZMQ.Context(1); ZMQ.Socket s = zctx.socket(SocketType.PUB); ZMQ.Socket m = zctx.socket(SocketType.PAIR)) { s.monitor("inproc://TestEventResol...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void destroy() { for (Socket socket : sockets) { socket.setLinger(linger); socket.close(); } sockets.clear(); // Only terminate context if we are on the main thread if (isMain() && context != nu...
#fixed code public void destroy() { for (Socket socket : sockets) { destroySocket(socket); } sockets.clear(); // Only terminate context if we are on the main thread if (isMain() && context != null) { context.term(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test(timeout = 1000) public void testSocketDoubleClose() { Context ctx = ZMQ.context(1); Socket socket = ctx.socket(ZMQ.PUSH); socket.close(); socket.close(); } #location 5 ...
#fixed code @Test(timeout = 1000) public void testSocketDoubleClose() { Context ctx = ZMQ.context(1); Socket socket = ctx.socket(ZMQ.PUSH); socket.close(); socket.close(); ctx.term(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testIssue476() throws InterruptedException, IOException, ExecutionException { final int front = Utils.findOpenPort(); final int back = Utils.findOpenPort(); final int max = 10; ExecutorService service = Executo...
#fixed code @Test public void testIssue476() throws InterruptedException, IOException, ExecutionException { final int front = Utils.findOpenPort(); final int back = Utils.findOpenPort(); final int max = 20; ExecutorService service = Executors.new...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public byte[] receive(int flags) { final Msg msg = socketBase.recv(flags); return msg.data(); } #location 4 #vulnerability type NULL_DEREFERENCE
#fixed code public byte[] receive(int flags) { final Msg msg = socketBase.recv(flags); if (msg == null) { return null; } return msg.data(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void destroy() { for (Socket socket : sockets) { socket.setLinger(linger); socket.close(); } sockets.clear(); // Only terminate context if we are on the main thread if (isMain() && context != nu...
#fixed code public void destroy() { for (Socket socket : sockets) { destroySocket(socket); } sockets.clear(); // Only terminate context if we are on the main thread if (isMain() && context != null) { context.term(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static void main (String[] args) throws Exception { // Prepare our context and sockets ZMQ.Context context = ZMQ.context(1); // Connect to task ventilator ZMQ.Socket receiver = context.socket(ZMQ.PULL); receiver.connect("...
#fixed code public static void main (String[] args) throws Exception { // Prepare our context and sockets ZMQ.Context context = ZMQ.context(1); // Connect to task ventilator ZMQ.Socket receiver = context.socket(ZMQ.PULL); receiver.connect("tcp://...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code boolean wasPending (kvmsg msg) { Iterator<kvmsg> it = pending.iterator(); while (it.hasNext()) { if (msg.UUID().equals(it.next().UUID())) { it.remove(); return true; } } return ...
#fixed code boolean wasPending (kvmsg msg) { Iterator<kvmsg> it = pending.iterator(); while (it.hasNext()) { if(java.util.Arrays.equals(msg.UUID(), it.next().UUID())){ it.remove(); return true; } } ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testHeartbeatTimeout() throws IOException, InterruptedException { Ctx ctx = ZMQ.createContext(); assertThat(ctx, notNullValue()); SocketBase server = prepServerSocket(ctx, true, false); assertThat(server, notNul...
#fixed code @Test public void testHeartbeatTimeout() throws IOException, InterruptedException { testHeartbeatTimeout(false); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void destroy() { for (Socket socket : sockets) { socket.setLinger(linger); socket.close(); } sockets.clear(); // Only terminate context if we are on the main thread if (isMain() && context != nu...
#fixed code public void destroy() { for (Socket socket : sockets) { destroySocket(socket); } sockets.clear(); // Only terminate context if we are on the main thread if (isMain() && context != null) { context.term(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void testLastEndpoint() { // Create the infrastructure Ctx ctx = ZMQ.init(1); assertThat(ctx, notNullValue()); SocketBase sb = ZMQ.socket(ctx, ZMQ.ZMQ_ROUTER); assertThat(sb, notNullValue()); bindAn...
#fixed code @Test public void testLastEndpoint() { // Create the infrastructure Ctx ctx = ZMQ.init(1); assertThat(ctx, notNullValue()); SocketBase sb = ZMQ.socket(ctx, ZMQ.ZMQ_ROUTER); assertThat(sb, notNullValue()); bindAndVerif...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void destroy() { for (Socket socket : sockets) { destroySocket(socket); } sockets.clear(); // Only terminate context if we are on the main thread if (isMain() && context != null) { context.term()...
#fixed code public void destroy() { for (Socket socket : sockets) { destroySocket(socket); } sockets.clear(); // Only terminate context if we are on the main thread if (isMain()) { context.term(); } }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public ZMQ.Event make(SendEvent sender, int eventFilter) { Ctx ctx = new Ctx(); @SuppressWarnings("deprecation") SocketBase s = ctx.createSocket(ZMQ.PUB); @SuppressWarnings("deprecation") SocketBase m = ctx.createSocket(ZMQ.PA...
#fixed code public ZMQ.Event make(SendEvent sender, int eventFilter) { try (ZMQ.Context zctx = new ZMQ.Context(1); ZMQ.Socket s = zctx.socket(SocketType.PUB); ZMQ.Socket m = zctx.socket(SocketType.PAIR)) { s.monitor("inproc://TestEventResol...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public boolean send(Msg msg_, int flags_) { // Drop the message if required. If we are at the end of the message // switch back to non-dropping mode. if (dropping) { more = msg_.has_more(); dropping = more; ...
#fixed code public boolean send(Msg msg_, int flags_) { // Drop the message if required. If we are at the end of the message // switch back to non-dropping mode. if (dropping) { more = msg_.has_more(); dropping = more; msg_....
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void test_streaming_changes() throws IOException { HttpResponse httpResponse = ResponseOnFileStub.newInstance(200, "changes/changes_full.json"); StreamingChangesResult changes = new StreamingChangesResult(new ObjectMapper(), ...
#fixed code @Test public void test_streaming_changes() throws IOException { HttpResponse httpResponse = ResponseOnFileStub.newInstance(200, "changes/changes_full.json"); StreamingChangesResult changes = new StreamingChangesResult(new ObjectMapper(), ht...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected ReadResponse doRead(ServerIdentity identity, ReadRequest request) { LwM2mPath path = request.getPath(); // Manage Object case if (path.isObject()) { List<LwM2mObjectInstance> lwM2mObjectInstances = new ArrayLi...
#fixed code @Override protected ReadResponse doRead(ServerIdentity identity, ReadRequest request) { LwM2mPath path = request.getPath(); // Manage Object case if (path.isObject()) { List<LwM2mObjectInstance> lwM2mObjectInstances = new ArrayList<>()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void createRPKClient() { ObjectsInitializer initializer = new ObjectsInitializer(); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.rpk( "coaps://" + server.getSecureAddress().getHostString() + ...
#fixed code public void createRPKClient() { ObjectsInitializer initializer = new ObjectsInitializer(); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.rpk( "coaps://" + server.getSecuredAddress().getHostString() + ":" ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") private void loadFromFile() { try { File file = new File(filename); if (file.exists()) { try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(file))) { ...
#fixed code @SuppressWarnings("unchecked") private void loadFromFile() { try { File file = new File(filename); if (file.exists()) { try (InputStreamReader in = new InputStreamReader(new FileInputStream(file))) { Map<...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") private static <T extends LwM2mNode> T parseTlv(Tlv[] tlvs, LwM2mPath path, LwM2mModel model, Class<T> nodeClass) throws CodecException { LOG.trace("Parsing TLV content for path {}: {}", path, tlvs); // Obj...
#fixed code @SuppressWarnings("unchecked") private static <T extends LwM2mNode> T parseTlv(Tlv[] tlvs, LwM2mPath path, LwM2mModel model, Class<T> nodeClass) throws CodecException { LOG.trace("Parsing TLV content for path {}: {}", path, tlvs); // Object ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void visit(final UpdateRequest request) { coapRequest = Request.newPut(); buildRequestSettings(); coapRequest.getOptions().setUriPath(request.getRegistrationId()); Long lifetime = request.getLifeTimeInSec(); ...
#fixed code @Override public void visit(final UpdateRequest request) { coapRequest = Request.newPut(); buildRequestSettings(); coapRequest.getOptions().setUriPath(request.getRegistrationId()); Long lifetime = request.getLifeTimeInSec(); if (li...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void createPSKClient() { ObjectsInitializer initializer = new ObjectsInitializer(); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.psk( "coaps://" + server.getSecureAddress().getHostString() + ...
#fixed code public void createPSKClient() { ObjectsInitializer initializer = new ObjectsInitializer(); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.psk( "coaps://" + server.getSecuredAddress().getHostString() + ":" ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void fireResourcesChanged(int instanceid, int... resourceIds) { if (listener != null) { listener.resourceChanged(this, instanceid, resourceIds); } } #location 3 #vulnerab...
#fixed code protected void fireResourcesChanged(int instanceid, int... resourceIds) { transactionalListener.resourceChanged(this, instanceid, resourceIds); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") private static <T extends LwM2mNode> T parseTlv(Tlv[] tlvs, LwM2mPath path, LwM2mModel model, Class<T> nodeClass) throws CodecException { LOG.trace("Parsing TLV content for path {}: {}", path, tlvs); // Obj...
#fixed code @SuppressWarnings("unchecked") private static <T extends LwM2mNode> T parseTlv(Tlv[] tlvs, LwM2mPath path, LwM2mModel model, Class<T> nodeClass) throws CodecException { LOG.trace("Parsing TLV content for path {}: {}", path, tlvs); // Object ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void register_with_invalid_request() throws InterruptedException, IOException { // Check registration helper.assertClientNotRegisterered(); // create a register request without the list of supported object Request coapRe...
#fixed code @Test public void register_with_invalid_request() throws InterruptedException, IOException { // Check registration helper.assertClientNotRegisterered(); // create a register request without the list of supported object Request coapRequest ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void register_with_invalid_request() throws InterruptedException, IOException { // Check registration helper.assertClientNotRegisterered(); // create a register request without the list of supported object Request coapRe...
#fixed code @Test public void register_with_invalid_request() throws InterruptedException, IOException { // Check registration helper.assertClientNotRegisterered(); // create a register request without the list of supported object Request coapRequest ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void createX509CertClient(PrivateKey privatekey, Certificate[] trustedCertificates) { ObjectsInitializer initializer = new ObjectsInitializer(); // TODO security instance with certificate info initializer.setInstancesForObject(LwM2mId.SECU...
#fixed code public void createX509CertClient(PrivateKey privatekey, Certificate[] trustedCertificates) { ObjectsInitializer initializer = new ObjectsInitializer(); // TODO security instance with certificate info initializer.setInstancesForObject(LwM2mId.SECURITY, ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected BootstrapWriteResponse doWrite(ServerIdentity identity, BootstrapWriteRequest request) { LwM2mPath path = request.getPath(); // Manage Object case if (path.isObject()) { for (LwM2mObjectInstance instanceNode :...
#fixed code @Override protected BootstrapWriteResponse doWrite(ServerIdentity identity, BootstrapWriteRequest request) { LwM2mPath path = request.getPath(); // Manage Object case if (path.isObject()) { for (LwM2mObjectInstance instanceNode : ((LwM...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override protected ObserveResponse doObserve(final ServerIdentity identity, final ObserveRequest request) { final LwM2mPath path = request.getPath(); // Manage Object case if (path.isObject()) { List<LwM2mObjectInstance> lwM2mOb...
#fixed code @Override protected ObserveResponse doObserve(final ServerIdentity identity, final ObserveRequest request) { final LwM2mPath path = request.getPath(); // Manage Object case if (path.isObject()) { List<LwM2mObjectInstance> lwM2mObjectIn...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void remove(byte[] token) { try (Jedis j = pool.getResource()) { byte[] tokenKey = toKey(OBS_TKN, token); // fetch the observation by token byte[] serializedObs = j.get(tokenKey); if (serializ...
#fixed code @Override public void remove(byte[] token) { try (Jedis j = pool.getResource()) { byte[] tokenKey = toKey(OBS_TKN, token); // fetch the observation by token byte[] serializedObs = j.get(tokenKey); if (serializedObs ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void handleUpdate(CoapExchange exchange, Request request, String registrationId) { // Get identity Identity sender = extractIdentity(exchange); // Create LwM2m request from CoAP request Long lifetime = null; String smsNum...
#fixed code private void handleUpdate(CoapExchange exchange, Request request, String registrationId) { // Get identity Identity sender = extractIdentity(exchange); // Create LwM2m request from CoAP request Long lifetime = null; String smsNumber = ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void beginTransaction() { if (listener != null) { listener.beginTransaction(); } } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code protected void beginTransaction() { transactionalListener.beginTransaction(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void createRPKClient() { ObjectsInitializer initializer = new ObjectsInitializer(); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.rpk( "coaps://" + server.getSecuredAddress().getHostString() +...
#fixed code public void createRPKClient() { createRPKClient(false); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void createClient() { // Create Security Object (with bootstrap server only) String bsUrl = "coap://" + bootstrapServer.getNonSecureAddress().getHostString() + ":" + bootstrapServer.getNonSecureAddress().getPort(); ...
#fixed code @Override public void createClient() { // Create Security Object (with bootstrap server only) String bsUrl = "coap://" + bootstrapServer.getUnsecuredAddress().getHostString() + ":" + bootstrapServer.getUnsecuredAddress().getPort(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void fireInstancesAdded(int... instanceIds) { if (listener != null) { listener.objectInstancesAdded(this, instanceIds); } } #location 3 #vulnerability type THREAD_SAFETY_...
#fixed code protected void fireInstancesAdded(int... instanceIds) { transactionalListener.objectInstancesAdded(this, instanceIds); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static Registration deserialize(JsonObject jObj) { Registration.Builder b = new Registration.Builder(jObj.getString("regId", null), jObj.getString("ep", null), new InetSocketAddress(jObj.getString("address", null), jObj.getInt("port", 0))....
#fixed code public static Registration deserialize(JsonObject jObj) { Registration.Builder b = new Registration.Builder(jObj.getString("regId", null), jObj.getString("ep", null), IdentitySerDes.deserialize(jObj.get("identity").asObject()), new Inet...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void sendNotification(byte[] payload, Response firstCoapResponse, int contentFormat) { // encode and send it try (DatagramSocket clientSocket = new DatagramSocket()) { // create observe response Response response = new R...
#fixed code private void sendNotification(byte[] payload, Response firstCoapResponse, int contentFormat) { // encode and send it try (DatagramSocket clientSocket = new DatagramSocket()) { // create observe response Response response = new Respons...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void fireInstancesRemoved(int... instanceIds) { if (listener != null) { listener.objectInstancesRemoved(this, instanceIds); } } #location 3 #vulnerability type THREAD_SAF...
#fixed code protected void fireInstancesRemoved(int... instanceIds) { transactionalListener.objectInstancesRemoved(this, instanceIds); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void createPSKClient() { ObjectsInitializer initializer = new ObjectsInitializer(); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.psk( "coaps://" + server.getSecuredAddress().getHostString() +...
#fixed code public void createPSKClient() { createPSKClient(false); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Test public void can_observe_timestamped_resource() throws InterruptedException { TestObservationListener listener = new TestObservationListener(); helper.server.getObservationService().addListener(listener); // observe device timezone ...
#fixed code @Test public void can_observe_timestamped_resource() throws InterruptedException { TestObservationListener listener = new TestObservationListener(); helper.server.getObservationService().addListener(listener); // observe device timezone Ob...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @SuppressWarnings("unchecked") private static <T extends LwM2mNode> T parseTlv(Tlv[] tlvs, LwM2mPath path, LwM2mModel model, Class<T> nodeClass) throws CodecException { LOG.trace("Parsing TLV content for path {}: {}", path, tlvs); // Obj...
#fixed code @SuppressWarnings("unchecked") private static <T extends LwM2mNode> T parseTlv(Tlv[] tlvs, LwM2mPath path, LwM2mModel model, Class<T> nodeClass) throws CodecException { LOG.trace("Parsing TLV content for path {}: {}", path, tlvs); // Object ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void createPSKClient(String pskIdentity, byte[] pskKey) { // Create Security Object (with bootstrap server only) String bsUrl = "coaps://" + bootstrapServer.getSecureAddress().getHostString() + ":" + bootstrapServer.getSecureAddre...
#fixed code public void createPSKClient(String pskIdentity, byte[] pskKey) { // Create Security Object (with bootstrap server only) String bsUrl = "coaps://" + bootstrapServer.getSecuredAddress().getHostString() + ":" + bootstrapServer.getSecuredAddress()...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void createClient() { // Create objects Enabler ObjectsInitializer initializer = new ObjectsInitializer(new LwM2mModel(createObjectModels())); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.noSec( "coap://" + ...
#fixed code public void createClient() { // Create objects Enabler ObjectsInitializer initializer = new ObjectsInitializer(new LwM2mModel(createObjectModels())); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.noSec( "coap://" + server...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private static boolean checkRpkIdentity(String endpoint, Identity clientIdentity, SecurityInfo securityInfo) { // Manage RPK authentication // ---------------------------------------------------- PublicKey publicKey = clientIdentity.getRawPublicK...
#fixed code private static boolean checkRpkIdentity(String endpoint, Identity clientIdentity, SecurityInfo securityInfo) { // Manage RPK authentication // ---------------------------------------------------- PublicKey publicKey = clientIdentity.getRawPublicKey(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public void createClient() { // Create Security Object (with bootstrap server only) String bsUrl = "coap://" + bootstrapServer.getUnsecuredAddress().getHostString() + ":" + bootstrapServer.getUnsecuredAddress().getPort(); ...
#fixed code @Override public void createClient() { createClient(withoutSecurity(), null); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static byte[] encodeInteger(Number number) { ByteBuffer iBuf = null; long longValue = number.longValue(); if (longValue == Long.MIN_VALUE) { throw new IllegalArgumentException( "Could not encode Long.MIN_VA...
#fixed code public static byte[] encodeInteger(Number number) { ByteBuffer iBuf = null; long lValue = number.longValue(); if (lValue >= Byte.MIN_VALUE && lValue <= Byte.MAX_VALUE) { iBuf = ByteBuffer.allocate(1); iBuf.put((byte) lValue); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code protected void endTransaction() { if (listener != null) { listener.endTransaction(); } } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code protected void endTransaction() { transactionalListener.endTransaction(); }
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private Object findInList(final Object current, final Method m, Node mapEq, String map) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (m.getParameterTypes().length != 1 && m.getParameterTypes()[0] != int.class) ...
#fixed code private Object findInList(final Object current, final Method m, Node mapEq, String map) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (m.getParameterTypes().length != 1 && m.getParameterTypes()[0] != int.class) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void initCsvTests(CsvDirectory csvDirectory) throws FileNotFoundException, IOException { File directory = getDirectory(csvDirectory.value()); testMethods = new ArrayList<Method>(); tests = new HashMap<String, List<List<String>>>(); for (...
#fixed code private void initCsvTests(CsvDirectory csvDirectory) throws FileNotFoundException, IOException { File testsRoot = getDirectory(csvDirectory.value()); String extension = csvDirectory.extension(); testMethods = new ArrayList<Method>(); tests = new HashM...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public void close () { super.close(); // Select one last time to complete closing the socket. synchronized (updateLock) { if (!isClosed) { isClosed = true; selector.wakeup(); try { selector.selectNow(); } catch (IOException ignored) { } ...
#fixed code public void close () { super.close(); synchronized (updateLock) { // Blocks to avoid a select while the selector is used to bind the server connection. } // Select one last time to complete closing the socket. if (!isClosed) { isClosed = true; selector.wakeup(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code private void loadSqlQueries() throws IOException { String queriesFile = config().getString(CONFIG_WIKIDB_SQL_QUERIES_RESOURCE_FILE); InputStream queriesInputStream; if (queriesFile != null) { queriesInputStream = new FileInputStream(queriesFile); } ...
#fixed code private void loadSqlQueries() throws IOException { String queriesFile = config().getString(CONFIG_WIKIDB_SQL_QUERIES_RESOURCE_FILE); InputStream queriesInputStream; if (queriesFile != null) { queriesInputStream = new FileInputStream(queriesFile); } else {...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code public static String toString(final InputStream stream) { StringBuilder out = new StringBuilder(); try { final char[] buffer = new char[0x10000]; Reader in = new InputStreamReader(stream, "UTF-8"); int read; do ...
#fixed code public static String toString(final InputStream stream) { StringBuilder out = new StringBuilder(); try { final char[] buffer = new char[0x10000]; Reader in = new InputStreamReader(stream, StandardCharsets.UTF_8); int read; ...
Below is the vulnerable code, please generate the patch based on the following information.
#vulnerable code @Override public Field<O> setLiteralInitializer(final String value) { String stub = "public class Stub { private String stub = " + value + " }"; JavaClass temp = (JavaClass) JavaParser.parse(stub); FieldDeclaration internal = (FieldDeclaration) te...
#fixed code @Override public Field<O> setLiteralInitializer(final String value) { String stub = "public class Stub { private String stub = " + value + " }"; JavaClass temp = (JavaClass) JavaParser.parse(stub); VariableDeclarationFragment tempFrag = (VariableDeclara...
Below is the vulnerable code, please generate the patch based on the following information.