output
stringlengths
64
73.2k
input
stringlengths
208
73.3k
instruction
stringclasses
1 value
#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...
#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 &&...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#vulnerable code @Override public void init() { if (zkConfig.isUseNestedZookeeper()) { NestedZookeeperServers.getInstance().startServerIfNotStarted(zkConfig.getNestedPort(), zkConfig.getNestedDataDir()); } log.info("msg=Saturn job: zookeeper registry ce...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private void refreshNamespaceShardingListenerManagerMap() { Collection<ZkCluster> zkClusters = RegistryCenterServiceImpl.ZKADDR_TO_ZKCLUSTER_MAP.values(); for (ZkCluster zkCluster: zkClusters) { for(RegistryCenterConfiguration conf: zkCluster.getRegCenterConfList()) { ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void addChild(final Actor child) { children.add(child); }
#vulnerable code void stop() { if (stopped.compareAndSet(false, true)) { stopChildren(); // suspended.reset(); // stowage.reset(); mailbox.close(); } } #location 3 #vulnerability type THREAD_SAFET...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code void addChild(final Actor child) { children.add(child); }
#vulnerable code void addChild(final Actor child) { children = children.plus(child); } #location 2 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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(); } ...
#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(); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#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_; } ...
#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_; } ...
Below is the vulnerable code, please generate the patch based on the following information.
#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://...
#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("...
Below is the vulnerable code, please generate the patch based on the following information.
#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();...
#vulnerable code public void destroySocket(Socket s) { if (s == null) { return; } if (sockets.remove(s)) { s.setLinger(linger); s.close(); } } #location 8 ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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(); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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(); }
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public byte[] receive(int flags) { final Msg msg = socketBase.recv(flags); if (msg == null) { return null; } return msg.data(); }
#vulnerable code public byte[] receive(int flags) { final Msg msg = socketBase.recv(flags); return msg.data(); } #location 4 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#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://...
#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("...
Below is the vulnerable code, please generate the patch based on the following information.
#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; } } ...
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testHeartbeatTimeout() throws IOException, InterruptedException { testHeartbeatTimeout(false); }
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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(); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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(); } }
#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()...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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_....
#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; ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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(), ...
Below is the vulnerable code, please generate the patch based on the following information.
#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<>()...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void createRPKClient() { ObjectsInitializer initializer = new ObjectsInitializer(); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.rpk( "coaps://" + server.getSecuredAddress().getHostString() + ":" ...
#vulnerable code public void createRPKClient() { ObjectsInitializer initializer = new ObjectsInitializer(); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.rpk( "coaps://" + server.getSecureAddress().getHostString() + ...
Below is the vulnerable code, please generate the patch based on the following information.
#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<...
#vulnerable code @SuppressWarnings("unchecked") private void loadFromFile() { try { File file = new File(filename); if (file.exists()) { try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(file))) { ...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public void visit(final UpdateRequest request) { coapRequest = Request.newPut(); buildRequestSettings(); coapRequest.getOptions().setUriPath(request.getRegistrationId()); Long lifetime = request.getLifeTimeInSec(); if (li...
#vulnerable code @Override public void visit(final UpdateRequest request) { coapRequest = Request.newPut(); buildRequestSettings(); coapRequest.getOptions().setUriPath(request.getRegistrationId()); Long lifetime = request.getLifeTimeInSec(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void createPSKClient() { ObjectsInitializer initializer = new ObjectsInitializer(); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.psk( "coaps://" + server.getSecuredAddress().getHostString() + ":" ...
#vulnerable code public void createPSKClient() { ObjectsInitializer initializer = new ObjectsInitializer(); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.psk( "coaps://" + server.getSecureAddress().getHostString() + ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void fireResourcesChanged(int instanceid, int... resourceIds) { transactionalListener.resourceChanged(this, instanceid, resourceIds); }
#vulnerable code protected void fireResourcesChanged(int instanceid, int... resourceIds) { if (listener != null) { listener.resourceChanged(this, instanceid, resourceIds); } } #location 3 #vulnerab...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void createX509CertClient(PrivateKey privatekey, Certificate[] trustedCertificates) { ObjectsInitializer initializer = new ObjectsInitializer(); // TODO security instance with certificate info initializer.setInstancesForObject(LwM2mId.SECURITY, ...
#vulnerable code public void createX509CertClient(PrivateKey privatekey, Certificate[] trustedCertificates) { ObjectsInitializer initializer = new ObjectsInitializer(); // TODO security instance with certificate info initializer.setInstancesForObject(LwM2mId.SECU...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override protected BootstrapWriteResponse doWrite(ServerIdentity identity, BootstrapWriteRequest request) { LwM2mPath path = request.getPath(); // Manage Object case if (path.isObject()) { for (LwM2mObjectInstance instanceNode : ((LwM...
#vulnerable code @Override protected BootstrapWriteResponse doWrite(ServerIdentity identity, BootstrapWriteRequest request) { LwM2mPath path = request.getPath(); // Manage Object case if (path.isObject()) { for (LwM2mObjectInstance instanceNode :...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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 = ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void beginTransaction() { transactionalListener.beginTransaction(); }
#vulnerable code protected void beginTransaction() { if (listener != null) { listener.beginTransaction(); } } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void createRPKClient() { createRPKClient(false); }
#vulnerable 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.
#fixed code @Override public void createClient() { // Create Security Object (with bootstrap server only) String bsUrl = "coap://" + bootstrapServer.getUnsecuredAddress().getHostString() + ":" + bootstrapServer.getUnsecuredAddress().getPort(); ...
#vulnerable code @Override public void createClient() { // Create Security Object (with bootstrap server only) String bsUrl = "coap://" + bootstrapServer.getNonSecureAddress().getHostString() + ":" + bootstrapServer.getNonSecureAddress().getPort(); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void fireInstancesAdded(int... instanceIds) { transactionalListener.objectInstancesAdded(this, instanceIds); }
#vulnerable code protected void fireInstancesAdded(int... instanceIds) { if (listener != null) { listener.objectInstancesAdded(this, instanceIds); } } #location 3 #vulnerability type THREAD_SAFETY_...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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))....
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void fireInstancesRemoved(int... instanceIds) { transactionalListener.objectInstancesRemoved(this, instanceIds); }
#vulnerable code protected void fireInstancesRemoved(int... instanceIds) { if (listener != null) { listener.objectInstancesRemoved(this, instanceIds); } } #location 3 #vulnerability type THREAD_SAF...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void createPSKClient() { createPSKClient(false); }
#vulnerable 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.
#fixed code @Test public void can_observe_timestamped_resource() throws InterruptedException { TestObservationListener listener = new TestObservationListener(); helper.server.getObservationService().addListener(listener); // observe device timezone Ob...
#vulnerable code @Test public void can_observe_timestamped_resource() throws InterruptedException { TestObservationListener listener = new TestObservationListener(); helper.server.getObservationService().addListener(listener); // observe device timezone ...
Below is the vulnerable code, please generate the patch based on the following information.
#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 ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void createPSKClient(String pskIdentity, byte[] pskKey) { // Create Security Object (with bootstrap server only) String bsUrl = "coaps://" + bootstrapServer.getSecuredAddress().getHostString() + ":" + bootstrapServer.getSecuredAddress()...
#vulnerable code public void createPSKClient(String pskIdentity, byte[] pskKey) { // Create Security Object (with bootstrap server only) String bsUrl = "coaps://" + bootstrapServer.getSecureAddress().getHostString() + ":" + bootstrapServer.getSecureAddre...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void createClient() { // Create objects Enabler ObjectsInitializer initializer = new ObjectsInitializer(new LwM2mModel(createObjectModels())); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.noSec( "coap://" + server...
#vulnerable code public void createClient() { // Create objects Enabler ObjectsInitializer initializer = new ObjectsInitializer(new LwM2mModel(createObjectModels())); initializer.setInstancesForObject(LwM2mId.SECURITY, Security.noSec( "coap://" + ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static boolean checkRpkIdentity(String endpoint, Identity clientIdentity, SecurityInfo securityInfo) { // Manage RPK authentication // ---------------------------------------------------- PublicKey publicKey = clientIdentity.getRawPublicKey(); ...
#vulnerable code private static boolean checkRpkIdentity(String endpoint, Identity clientIdentity, SecurityInfo securityInfo) { // Manage RPK authentication // ---------------------------------------------------- PublicKey publicKey = clientIdentity.getRawPublicK...
Below is the vulnerable code, please generate the patch based on the following information.
#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); ...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code protected void endTransaction() { transactionalListener.endTransaction(); }
#vulnerable code protected void endTransaction() { if (listener != null) { listener.endTransaction(); } } #location 3 #vulnerability type THREAD_SAFETY_VIOLATION
Below is the vulnerable code, please generate the patch based on the following information.
#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) { ...
#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) ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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 (...
Below is the vulnerable code, please generate the patch based on the following information.
#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(); ...
#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) { } ...
Below is the vulnerable code, please generate the patch based on the following information.
#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; ...
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#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...
#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...
Below is the vulnerable code, please generate the patch based on the following information.
#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; ...
#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 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public boolean isReturnTypeVoid() { return getReturnType() == null || getReturnType().isType(Void.TYPE); }
#vulnerable code @Override public boolean isReturnTypeVoid() { return getReturnType().isType(Void.TYPE); } #location 4 #vulnerability type NULL_DEREFERENCE
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) { Specification<T> combinedSpecs = null; for (Specification<T> spec : innerSpecs) { if (combinedSpecs == null) { combinedSpecs = Sp...
#vulnerable code @Override public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) { Specifications<T> combinedSpecs = null; for (Specification<T> spec : innerSpecs) { if (combinedSpecs == null) { combinedSpe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Bean(name = KAFKA_BEAN_NAME, destroyMethod = "stop") @DependsOn("zookeeper") public GenericContainer kafka( KafkaStatusCheck kafkaStatusCheck, KafkaConfigurationProperties kafkaProperties, @Value("${embedded.zookeeper.containerZook...
#vulnerable code @Bean(name = KAFKA_BEAN_NAME, destroyMethod = "stop") @DependsOn("zookeeper") public GenericContainer kafka( KafkaStatusCheck kafkaStatusCheck, KafkaConfigurationProperties kafkaProperties, @Value("${embedded.zookeeper.contain...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Bean(name = BEAN_NAME_EMBEDDED_SELENIUM, destroyMethod = "stop") @ConditionalOnMissingBean public BrowserWebDriverContainer selenium( ConfigurableEnvironment environment, SeleniumProperties properties, MutableCapabilities capabilit...
#vulnerable code @Bean(name = BEAN_NAME_EMBEDDED_SELENIUM, destroyMethod = "stop") @ConditionalOnMissingBean public BrowserWebDriverContainer selenium( ConfigurableEnvironment environment, SeleniumProperties properties, MutableCapabilities cap...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @SuppressWarnings("unchecked") protected void createBean(AbstractClassBean<?> bean, Set<AbstractBean<?, ?>> beans) { beans.add(bean); manager.getResolver().addInjectionPoints(bean.getInjectionPoints()); for (AnnotatedMethod<Object> producerMethod : bean...
#vulnerable code @SuppressWarnings("unchecked") protected void createBean(AbstractClassBean<?> bean, Set<AbstractBean<?, ?>> beans) { beans.add(bean); manager.getResolver().addInjectionPoints(bean.getInjectionPoints()); for (AnnotatedMethod<Object> producerMethod ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static void beginRequest(HttpServletRequest request) { }
#vulnerable code public static void beginRequest(HttpServletRequest request) { ManagerImpl manager = (ManagerImpl) JNDI.lookup("manager"); SessionContext sessionContext = (SessionContext) manager.getContext(SessionScoped.class); BeanMap sessionBeans = (BeanMap) request....
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String toString() { if (toString != null) { return toString; } toString = toDetailedString(); return toString; }
#vulnerable code @Override public String toString() { if (toString != null) { return toString; } toString = "Annotated parameter " + Names.type2String(getDelegate().getClass()); return toString; } #location 8 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append("Manager\n"); buffer.append("Enabled deployment types: " + getEnabledDeploymentTypes() + "\n"); buffer.append("Registered contexts: " + contextMap.keySet()...
#vulnerable code @Override public String toString() { StringBuilder buffer = new StringBuilder(); buffer.append(Strings.collectionToString("Enabled deployment types: ", getEnabledDeploymentTypes())); buffer.append(eventManager.toString() + "\n"); buffer.appe...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public final boolean isWebElementSufficientlyShown(WebElement webElement){ final WebView webView = viewFetcher.getFreshestView(viewFetcher.getCurrentViews(WebView.class)); final int[] xyWebView = new int[2]; if(webView != null && webElement != null){ webView.getLocatio...
#vulnerable code public final boolean isWebElementSufficientlyShown(WebElement webElement){ final WebView webView = viewFetcher.getFreshestView(viewFetcher.getCurrentViews(WebView.class)); final int[] xyWebView = new int[2]; if(webElement != null){ webView.getLocationOnScreen(xyW...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private View getViewOnListLine(AbsListView absListView, int lineIndex){ final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); View view = absListView.getChildAt(lineIndex); while(view == null){ final boolean timedOut = SystemClock.uptimeMillis() ...
#vulnerable code private View getViewOnListLine(AbsListView absListView, int lineIndex){ final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); View view = absListView.getChildAt(lineIndex); while(view == null){ final boolean timedOut = SystemClock.uptimeMil...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private boolean scrollScrollView(int direction, ArrayList<ScrollView> scrollViews){ ScrollView scroll = viewFetcher.getView(ScrollView.class, scrollViews, 0); if(scroll !=null){ int height = scroll.getHeight(); height--; int scrollTo = 0; if (direction == DOWN) ...
#vulnerable code private boolean scrollScrollView(int direction, ArrayList<ScrollView> scrollViews){ ScrollView scroll = viewFetcher.getView(ScrollView.class, scrollViews, 0); int height = scroll.getHeight(); height--; int scrollTo = 0; if (direction == DOWN) { scrollTo = (he...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private Bitmap getBitmapOfView(final View view){ view.destroyDrawingCache(); view.buildDrawingCache(false); Bitmap orig = view.getDrawingCache(); Bitmap.Config config = null; if(orig == null) { return null; } config = orig.getConfig(); if(config == null) { ...
#vulnerable code private Bitmap getBitmapOfView(final View view){ view.destroyDrawingCache(); view.buildDrawingCache(false); Bitmap orig = view.getDrawingCache(); Bitmap.Config config = null; if(orig != null) { config = orig.getConfig(); } if(config == null) { config ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private View getViewOnRecyclerItemIndex(ViewGroup recyclerView, int recyclerViewIndex, int itemIndex){ final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); View view = recyclerView.getChildAt(itemIndex); while(view == null){ final boolean timedO...
#vulnerable code private View getViewOnRecyclerItemIndex(ViewGroup recyclerView, int recyclerViewIndex, int itemIndex){ final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); View view = recyclerView.getChildAt(itemIndex); while(view == null){ final boolea...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void finishOpenedActivities(){ // Stops the activityStack listener activitySyncTimer.cancel(); ArrayList<Activity> activitiesOpened = getAllOpenedActivities(); // Finish all opened activities for (int i = activitiesOpened.size()-1; i >= 0; i--) { sleeper.slee...
#vulnerable code public void finishOpenedActivities(){ ArrayList<Activity> activitiesOpened = getAllOpenedActivities(); // Finish all opened activities for (int i = activitiesOpened.size()-1; i >= 0; i--) { sleeper.sleep(MINISLEEP); finishActivity(activitiesOpened.get(i)); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void colorize(InputFile i) { final File f = i.file(); LOGGER.info("Color the file: " + f.getPath()); highlighting.onFile(i); try (final BufferedReader br = new BufferedReader( new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8))) { String...
#vulnerable code public void colorize(InputFile i) { final File f = i.file(); LOGGER.info("Color the file: " + f.getPath()); highlighting.onFile(i); try { final BufferedReader br = new BufferedReader( new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8)); ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testExecution() { final CoverageSensor sensor = new CoverageSensor(); initFile(); sensor.execute(testerContext); Map<String, Map<Integer, Integer>> map = new HashMap<>(); map.put("myProjectKey:mathutil/mathutil.go", ImmutableMap.of(7, 1)); map.put...
#vulnerable code @Test public void testExecution() { final CoverageSensor sensor = new CoverageSensor(); try { BufferedReader reader = new BufferedReader( new FileReader(new File(CoverageSensor.class.getResource("/coverage/util/util.go").getFile()))); String sCur...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private static void init() { try { LOGGER.info("Load "+PATH_FILE); InputStream input=GoKeyRule.class.getResourceAsStream(PATH_FILE); if(input==null){ throw new FileNotFoundException(PATH_FILE); } prop.load(input); } catch (IOException e)...
#vulnerable code private static void init() { try { prop.load(new FileInputStream(new File(PATH_FILE))); } catch (FileNotFoundException e) { LOGGER.error("Unable to load the config file", e); } catch (IOException e) { LOGGER.error("Unable to load the config file", e); } }...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code private CharBuffer getFileAsBufferFromPath(Path p) { try (FileInputStream input = new FileInputStream(p.toString())) { FileChannel channel = input.getChannel(); ByteBuffer bbuf = channel.map(FileChannel.MapMode.READ_ONLY, 0, (int) channel.size()); return Chars...
#vulnerable code private CharBuffer getFileAsBufferFromPath(Path p) throws IOException { FileInputStream input = new FileInputStream(p.toString()); FileChannel channel = input.getChannel(); ByteBuffer bbuf = channel.map(FileChannel.MapMode.READ_ONLY, 0, (int) channel.size()); return...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public RulesProfile createProfile(ValidationMessages validation) { LOGGER.info("Golint Quality profile"); RulesProfile profile = RulesProfile.create("Golint Rules", GoLanguage.KEY); profile.setDefaultProfile(Boolean.TRUE); Properties prop=new Properties(...
#vulnerable code @Override public RulesProfile createProfile(ValidationMessages validation) { LOGGER.info("Golint Quality profile"); RulesProfile profile = RulesProfile.create("Golint Rules", GoLanguage.KEY); profile.setDefaultProfile(Boolean.TRUE); Properties prop=new Prope...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void check(GitlabMergeRequest gitlabMergeRequest) { if (_mergeRequestStatus == null) { _mergeRequestStatus = new GitlabMergeRequestStatus(); } if (_iid == null) { _iid = gitlabMergeRequest.getIid(); } i...
#vulnerable code public void check(GitlabMergeRequest gitlabMergeRequest) { if (_iid == null) { _iid = gitlabMergeRequest.getIid(); } if (_targetBranch == null) { _targetBranch = gitlabMergeRequest.getTargetBranch(); } if...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public void check(GitlabMergeRequest gitlabMergeRequest) { if (mergeRequestStatus == null) { mergeRequestStatus = new GitlabMergeRequestStatus(); } if (iid == null) { iid = gitlabMergeRequest.getIid(); } if (t...
#vulnerable code public void check(GitlabMergeRequest gitlabMergeRequest) { if (mergeRequestStatus == null) { mergeRequestStatus = new GitlabMergeRequestStatus(); } if (iid == null) { iid = gitlabMergeRequest.getIid(); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code public static Field getField(final Class<?> clazz, final String fieldName) throws Exception { Field field = clazz.getDeclaredField(fieldName); if (field != null) field.setAccessible(true); else if (clazz.getSuperclass() != null) field = getField(clazz.getSuperclass()...
#vulnerable code public static Field getField(final Class<?> clazz, final String fieldName) throws Exception { Field field = clazz.getDeclaredField(fieldName); if (field == null && clazz.getSuperclass() != null) { field = getField(clazz.getSuperclass(), fieldName); } field.setAc...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testShortArray_AsShorts() throws Exception { assertArrayEquals(new byte[]{1, 2, 3, 4}, BeginBin().Short((short)0x0102, (short)0x0304).End().toByteArray()); }
#vulnerable code @Test public void testShortArray_AsShorts() throws Exception { assertArrayEquals(new byte[]{1, 2, 3, 4}, binStart().Short((short)0x0102, (short)0x0304).end().toByteArray()); } #location 3 #vulnerability typ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testBitArrayAsBytes() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, BeginBin().Bit(new byte[]{(byte) 1, (byte) 3, (byte) 0, (byte) 2, (byte) 4, (byte) 1, (byte) 3, (byte) 7}).End().toByteArray()); assertArrayEquals(new byte[]{(byte) 0...
#vulnerable code @Test public void testBitArrayAsBytes() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, binStart().Bit(new byte[]{(byte) 1, (byte) 3, (byte) 0, (byte) 2, (byte) 4, (byte) 1, (byte) 3, (byte) 7}).end().toByteArray()); assertArrayEquals(new byte[]{(b...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Override public int read() throws IOException { final int result; if (this.bitsInBuffer == 0) { result = this.readByteFromStream(); if (result >= 0) { this.byteCounter++; } return result; } else { return this.readBits(JBB...
#vulnerable code @Override public int read() throws IOException { final int result; if (this.bitsInBuffer == 0) { result = this.readByteFromStream(); if (result < 0) { return result; } return result; } else { return this.readBits(JBB...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testByteArrayAsByteArray() throws Exception { assertArrayEquals(new byte[]{1, 3, 0, 2, 4, 1, 3, 7}, BeginBin().Byte(new byte[]{1, 3, 0, 2, 4, 1, 3, 7}).End().toByteArray()); }
#vulnerable code @Test public void testByteArrayAsByteArray() throws Exception { assertArrayEquals(new byte[]{1, 3, 0, 2, 4, 1, 3, 7}, binStart().Byte(new byte[]{1, 3, 0, 2, 4, 1, 3, 7}).end().toByteArray()); } #location 3 ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testBit_MSB0() throws Exception { assertArrayEquals(new byte[]{(byte) 0x80}, BeginBin(JBBPByteOrder.BIG_ENDIAN, JBBPBitOrder.MSB0).Bit(1).End().toByteArray()); }
#vulnerable code @Test public void testBit_MSB0() throws Exception { assertArrayEquals(new byte[]{(byte) 0x80}, binStart(JBBPByteOrder.BIG_ENDIAN, JBBPBitOrder.MSB0).Bit(1).end().toByteArray()); } #location 3 #vulnerability...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testByte() throws Exception { assertArrayEquals(new byte[]{-34}, BeginBin().Byte(-34).End().toByteArray()); }
#vulnerable code @Test public void testByte() throws Exception { assertArrayEquals(new byte[]{-34}, binStart().Byte(-34).end().toByteArray()); } #location 3 #vulnerability type RESOURCE_LEAK
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testBitArrayAsInts() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, BeginBin().Bit(1, 3, 0, 2, 4, 1, 3, 7).End().toByteArray()); assertArrayEquals(new byte[]{(byte) 0x0B}, BeginBin().Bit(1, 3, 0, 7).End().toByteArray()); }
#vulnerable code @Test public void testBitArrayAsInts() throws Exception { assertArrayEquals(new byte[]{(byte) 0xE3}, binStart().Bit(1, 3, 0, 2, 4, 1, 3, 7).end().toByteArray()); assertArrayEquals(new byte[]{(byte) 0x0B}, binStart().Bit(1, 3, 0, 7).end().toByteArray()); } ...
Below is the vulnerable code, please generate the patch based on the following information.
#fixed code @Test public void testFlush() throws Exception { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); final JBBPOut out = BeginBin(buffer); out.Bit(true); assertEquals(0, buffer.size()); out.Flush(); assertEquals(1, buffer.size()); }
#vulnerable code @Test public void testFlush() throws Exception { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); final JBBPOut out = binStart(buffer); out.Bit(true); assertEquals(0, buffer.size()); out.Flush(); assertEquals(1, buffer.size()); ...
Below is the vulnerable code, please generate the patch based on the following information.