instruction
stringclasses
1 value
input
stringlengths
56
241k
output
int64
0
1
__index_level_0__
int64
0
175k
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: nfsd4_encode_layoutreturn(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_layoutreturn *lrp) { struct xdr_stream *xdr = &resp->xdr; __be32 *p; if (nfserr) return nfserr; p = xdr_reserve_space(xdr, 4); if (!p) return nfserr_resource; *p++ = cpu_to_be32(lrp->lrs_present); if (lrp->lrs_present) return nfsd4_encode_stateid(xdr, &lrp->lr_sid); return nfs_ok; } Commit Message: Merge tag 'nfsd-4.12' of git://linux-nfs.org/~bfields/linux Pull nfsd updates from Bruce Fields: "Another RDMA update from Chuck Lever, and a bunch of miscellaneous bugfixes" * tag 'nfsd-4.12' of git://linux-nfs.org/~bfields/linux: (26 commits) nfsd: Fix up the "supattr_exclcreat" attributes nfsd: encoders mustn't use unitialized values in error cases nfsd: fix undefined behavior in nfsd4_layout_verify lockd: fix lockd shutdown race NFSv4: Fix callback server shutdown SUNRPC: Refactor svc_set_num_threads() NFSv4.x/callback: Create the callback service through svc_create_pooled lockd: remove redundant check on block svcrdma: Clean out old XDR encoders svcrdma: Remove the req_map cache svcrdma: Remove unused RDMA Write completion handler svcrdma: Reduce size of sge array in struct svc_rdma_op_ctxt svcrdma: Clean up RPC-over-RDMA backchannel reply processing svcrdma: Report Write/Reply chunk overruns svcrdma: Clean up RDMA_ERROR path svcrdma: Use rdma_rw API in RPC reply path svcrdma: Introduce local rdma_rw API helpers svcrdma: Clean up svc_rdma_get_inv_rkey() svcrdma: Add helper to save pages under I/O svcrdma: Eliminate RPCRDMA_SQ_DEPTH_MULT ... CWE ID: CWE-404
0
65,810
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int SocketStream::DoResolveProxy() { DCHECK(context_); DCHECK(!pac_request_); next_state_ = STATE_RESOLVE_PROXY_COMPLETE; if (!proxy_url_.is_valid()) { next_state_ = STATE_CLOSE; return ERR_INVALID_ARGUMENT; } return context_->proxy_service()->ResolveProxy( proxy_url_, &proxy_info_, io_callback_, &pac_request_, net_log_); } Commit Message: Revert a workaround commit for a Use-After-Free crash. Revert a workaround commit r20158 for a Use-After-Free issue (http://crbug.com/244746) because a cleaner CL r207218 is landed. URLRequestContext does not inherit SupportsWeakPtr now. R=mmenke BUG=244746 Review URL: https://chromiumcodereview.appspot.com/16870008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207811 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
112,683
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color) { _gdImageFilledVRectangle(im, x1, y1, x2, y2, color); } Commit Message: Fix #72696: imagefilltoborder stackoverflow on truecolor images We must not allow negative color values be passed to gdImageFillToBorder(), because that can lead to infinite recursion since the recursion termination condition will not necessarily be met. CWE ID: CWE-119
0
72,474
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static ssize_t k90_show_macro_mode(struct device *dev, struct device_attribute *attr, char *buf) { int ret; struct usb_interface *usbif = to_usb_interface(dev->parent); struct usb_device *usbdev = interface_to_usbdev(usbif); const char *macro_mode; char data[8]; ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), K90_REQUEST_GET_MODE, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0, 0, data, 2, USB_CTRL_SET_TIMEOUT); if (ret < 0) { dev_warn(dev, "Failed to get K90 initial mode (error %d).\n", ret); return -EIO; } switch (data[0]) { case K90_MACRO_MODE_HW: macro_mode = "HW"; break; case K90_MACRO_MODE_SW: macro_mode = "SW"; break; default: dev_warn(dev, "K90 in unknown mode: %02hhx.\n", data[0]); return -EIO; } return snprintf(buf, PAGE_SIZE, "%s\n", macro_mode); } Commit Message: HID: corsair: fix DMA buffers on stack Not all platforms support DMA to the stack, and specifically since v4.9 this is no longer supported on x86 with VMAP_STACK either. Note that the macro-mode buffer was larger than necessary. Fixes: 6f78193ee9ea ("HID: corsair: Add Corsair Vengeance K90 driver") Cc: stable <stable@vger.kernel.org> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz> CWE ID: CWE-119
1
168,395
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void dev_unicast_unsync(struct net_device *to, struct net_device *from) { if (to->addr_len != from->addr_len) return; netif_addr_lock_bh(from); netif_addr_lock(to); __hw_addr_unsync(&to->uc, &from->uc, to->addr_len); __dev_set_rx_mode(to); netif_addr_unlock(to); netif_addr_unlock_bh(from); } Commit Message: veth: Dont kfree_skb() after dev_forward_skb() In case of congestion, netif_rx() frees the skb, so we must assume dev_forward_skb() also consume skb. Bug introduced by commit 445409602c092 (veth: move loopback logic to common location) We must change dev_forward_skb() to always consume skb, and veth to not double free it. Bug report : http://marc.info/?l=linux-netdev&m=127310770900442&w=3 Reported-by: Martín Ferrari <martin.ferrari@gmail.com> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-399
0
32,153
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: WebGLRenderingContextBase::CreateWebGraphicsContext3DProvider( CanvasRenderingContextHost* host, const CanvasContextCreationAttributesCore& attributes, unsigned webgl_version, bool* using_gpu_compositing) { if (host->IsWebGLBlocked()) { host->SetContextCreationWasBlocked(); host->HostDispatchEvent(WebGLContextEvent::Create( EventTypeNames::webglcontextcreationerror, "Web page caused context loss and was blocked")); return nullptr; } if ((webgl_version == 1 && !host->IsWebGL1Enabled()) || (webgl_version == 2 && !host->IsWebGL2Enabled())) { host->HostDispatchEvent(WebGLContextEvent::Create( EventTypeNames::webglcontextcreationerror, "disabled by enterprise policy or commandline switch")); return nullptr; } return CreateContextProviderInternal(host, attributes, webgl_version, using_gpu_compositing); } Commit Message: Validate all incoming WebGLObjects. A few entry points were missing the correct validation. Tested with improved conformance tests in https://github.com/KhronosGroup/WebGL/pull/2654 . Bug: 848914 Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel Change-Id: Ib98a61cc5bf378d1b3338b04acd7e1bc4c2fe008 Reviewed-on: https://chromium-review.googlesource.com/1086718 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Antoine Labour <piman@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org> Cr-Commit-Position: refs/heads/master@{#565016} CWE ID: CWE-119
0
153,604
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int get_filter(void __user *arg, struct sock_filter **p) { struct sock_fprog uprog; struct sock_filter *code = NULL; int len; if (copy_from_user(&uprog, arg, sizeof(uprog))) return -EFAULT; if (!uprog.len) { *p = NULL; return 0; } len = uprog.len * sizeof(struct sock_filter); code = memdup_user(uprog.filter, len); if (IS_ERR(code)) return PTR_ERR(code); *p = code; return uprog.len; } Commit Message: ppp: take reference on channels netns Let channels hold a reference on their network namespace. Some channel types, like ppp_async and ppp_synctty, can have their userspace controller running in a different namespace. Therefore they can't rely on them to preclude their netns from being removed from under them. ================================================================== BUG: KASAN: use-after-free in ppp_unregister_channel+0x372/0x3a0 at addr ffff880064e217e0 Read of size 8 by task syz-executor/11581 ============================================================================= BUG net_namespace (Not tainted): kasan: bad access detected ----------------------------------------------------------------------------- Disabling lock debugging due to kernel taint INFO: Allocated in copy_net_ns+0x6b/0x1a0 age=92569 cpu=3 pid=6906 [< none >] ___slab_alloc+0x4c7/0x500 kernel/mm/slub.c:2440 [< none >] __slab_alloc+0x4c/0x90 kernel/mm/slub.c:2469 [< inline >] slab_alloc_node kernel/mm/slub.c:2532 [< inline >] slab_alloc kernel/mm/slub.c:2574 [< none >] kmem_cache_alloc+0x23a/0x2b0 kernel/mm/slub.c:2579 [< inline >] kmem_cache_zalloc kernel/include/linux/slab.h:597 [< inline >] net_alloc kernel/net/core/net_namespace.c:325 [< none >] copy_net_ns+0x6b/0x1a0 kernel/net/core/net_namespace.c:360 [< none >] create_new_namespaces+0x2f6/0x610 kernel/kernel/nsproxy.c:95 [< none >] copy_namespaces+0x297/0x320 kernel/kernel/nsproxy.c:150 [< none >] copy_process.part.35+0x1bf4/0x5760 kernel/kernel/fork.c:1451 [< inline >] copy_process kernel/kernel/fork.c:1274 [< none >] _do_fork+0x1bc/0xcb0 kernel/kernel/fork.c:1723 [< inline >] SYSC_clone kernel/kernel/fork.c:1832 [< none >] SyS_clone+0x37/0x50 kernel/kernel/fork.c:1826 [< none >] entry_SYSCALL_64_fastpath+0x16/0x7a kernel/arch/x86/entry/entry_64.S:185 INFO: Freed in net_drop_ns+0x67/0x80 age=575 cpu=2 pid=2631 [< none >] __slab_free+0x1fc/0x320 kernel/mm/slub.c:2650 [< inline >] slab_free kernel/mm/slub.c:2805 [< none >] kmem_cache_free+0x2a0/0x330 kernel/mm/slub.c:2814 [< inline >] net_free kernel/net/core/net_namespace.c:341 [< none >] net_drop_ns+0x67/0x80 kernel/net/core/net_namespace.c:348 [< none >] cleanup_net+0x4e5/0x600 kernel/net/core/net_namespace.c:448 [< none >] process_one_work+0x794/0x1440 kernel/kernel/workqueue.c:2036 [< none >] worker_thread+0xdb/0xfc0 kernel/kernel/workqueue.c:2170 [< none >] kthread+0x23f/0x2d0 kernel/drivers/block/aoe/aoecmd.c:1303 [< none >] ret_from_fork+0x3f/0x70 kernel/arch/x86/entry/entry_64.S:468 INFO: Slab 0xffffea0001938800 objects=3 used=0 fp=0xffff880064e20000 flags=0x5fffc0000004080 INFO: Object 0xffff880064e20000 @offset=0 fp=0xffff880064e24200 CPU: 1 PID: 11581 Comm: syz-executor Tainted: G B 4.4.0+ Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.8.2-0-g33fbe13 by qemu-project.org 04/01/2014 00000000ffffffff ffff8800662c7790 ffffffff8292049d ffff88003e36a300 ffff880064e20000 ffff880064e20000 ffff8800662c77c0 ffffffff816f2054 ffff88003e36a300 ffffea0001938800 ffff880064e20000 0000000000000000 Call Trace: [< inline >] __dump_stack kernel/lib/dump_stack.c:15 [<ffffffff8292049d>] dump_stack+0x6f/0xa2 kernel/lib/dump_stack.c:50 [<ffffffff816f2054>] print_trailer+0xf4/0x150 kernel/mm/slub.c:654 [<ffffffff816f875f>] object_err+0x2f/0x40 kernel/mm/slub.c:661 [< inline >] print_address_description kernel/mm/kasan/report.c:138 [<ffffffff816fb0c5>] kasan_report_error+0x215/0x530 kernel/mm/kasan/report.c:236 [< inline >] kasan_report kernel/mm/kasan/report.c:259 [<ffffffff816fb4de>] __asan_report_load8_noabort+0x3e/0x40 kernel/mm/kasan/report.c:280 [< inline >] ? ppp_pernet kernel/include/linux/compiler.h:218 [<ffffffff83ad71b2>] ? ppp_unregister_channel+0x372/0x3a0 kernel/drivers/net/ppp/ppp_generic.c:2392 [< inline >] ppp_pernet kernel/include/linux/compiler.h:218 [<ffffffff83ad71b2>] ppp_unregister_channel+0x372/0x3a0 kernel/drivers/net/ppp/ppp_generic.c:2392 [< inline >] ? ppp_pernet kernel/drivers/net/ppp/ppp_generic.c:293 [<ffffffff83ad6f26>] ? ppp_unregister_channel+0xe6/0x3a0 kernel/drivers/net/ppp/ppp_generic.c:2392 [<ffffffff83ae18f3>] ppp_asynctty_close+0xa3/0x130 kernel/drivers/net/ppp/ppp_async.c:241 [<ffffffff83ae1850>] ? async_lcp_peek+0x5b0/0x5b0 kernel/drivers/net/ppp/ppp_async.c:1000 [<ffffffff82c33239>] tty_ldisc_close.isra.1+0x99/0xe0 kernel/drivers/tty/tty_ldisc.c:478 [<ffffffff82c332c0>] tty_ldisc_kill+0x40/0x170 kernel/drivers/tty/tty_ldisc.c:744 [<ffffffff82c34943>] tty_ldisc_release+0x1b3/0x260 kernel/drivers/tty/tty_ldisc.c:772 [<ffffffff82c1ef21>] tty_release+0xac1/0x13e0 kernel/drivers/tty/tty_io.c:1901 [<ffffffff82c1e460>] ? release_tty+0x320/0x320 kernel/drivers/tty/tty_io.c:1688 [<ffffffff8174de36>] __fput+0x236/0x780 kernel/fs/file_table.c:208 [<ffffffff8174e405>] ____fput+0x15/0x20 kernel/fs/file_table.c:244 [<ffffffff813595ab>] task_work_run+0x16b/0x200 kernel/kernel/task_work.c:115 [< inline >] exit_task_work kernel/include/linux/task_work.h:21 [<ffffffff81307105>] do_exit+0x8b5/0x2c60 kernel/kernel/exit.c:750 [<ffffffff813fdd20>] ? debug_check_no_locks_freed+0x290/0x290 kernel/kernel/locking/lockdep.c:4123 [<ffffffff81306850>] ? mm_update_next_owner+0x6f0/0x6f0 kernel/kernel/exit.c:357 [<ffffffff813215e6>] ? __dequeue_signal+0x136/0x470 kernel/kernel/signal.c:550 [<ffffffff8132067b>] ? recalc_sigpending_tsk+0x13b/0x180 kernel/kernel/signal.c:145 [<ffffffff81309628>] do_group_exit+0x108/0x330 kernel/kernel/exit.c:880 [<ffffffff8132b9d4>] get_signal+0x5e4/0x14f0 kernel/kernel/signal.c:2307 [< inline >] ? kretprobe_table_lock kernel/kernel/kprobes.c:1113 [<ffffffff8151d355>] ? kprobe_flush_task+0xb5/0x450 kernel/kernel/kprobes.c:1158 [<ffffffff8115f7d3>] do_signal+0x83/0x1c90 kernel/arch/x86/kernel/signal.c:712 [<ffffffff8151d2a0>] ? recycle_rp_inst+0x310/0x310 kernel/include/linux/list.h:655 [<ffffffff8115f750>] ? setup_sigcontext+0x780/0x780 kernel/arch/x86/kernel/signal.c:165 [<ffffffff81380864>] ? finish_task_switch+0x424/0x5f0 kernel/kernel/sched/core.c:2692 [< inline >] ? finish_lock_switch kernel/kernel/sched/sched.h:1099 [<ffffffff81380560>] ? finish_task_switch+0x120/0x5f0 kernel/kernel/sched/core.c:2678 [< inline >] ? context_switch kernel/kernel/sched/core.c:2807 [<ffffffff85d794e9>] ? __schedule+0x919/0x1bd0 kernel/kernel/sched/core.c:3283 [<ffffffff81003901>] exit_to_usermode_loop+0xf1/0x1a0 kernel/arch/x86/entry/common.c:247 [< inline >] prepare_exit_to_usermode kernel/arch/x86/entry/common.c:282 [<ffffffff810062ef>] syscall_return_slowpath+0x19f/0x210 kernel/arch/x86/entry/common.c:344 [<ffffffff85d88022>] int_ret_from_sys_call+0x25/0x9f kernel/arch/x86/entry/entry_64.S:281 Memory state around the buggy address: ffff880064e21680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff880064e21700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff880064e21780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff880064e21800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff880064e21880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== Fixes: 273ec51dd7ce ("net: ppp_generic - introduce net-namespace functionality v2") Reported-by: Baozeng Ding <sploving1@gmail.com> Signed-off-by: Guillaume Nault <g.nault@alphalink.fr> Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-416
0
52,608
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: fbStore_x4b4g4r4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) { int i; CARD16 *pixel = ((CARD16 *) bits) + x; for (i = 0; i < width; ++i) { Split(READ(values + i)); WRITE(pixel++, ((b << 4) & 0x0f00) | ((g ) & 0x00f0) | ((r >> 4) )); } } Commit Message: CWE ID: CWE-189
0
11,492
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void WebContentsImpl::ReplaceMisspelling(const base::string16& word) { RenderFrameHost* focused_frame = GetFocusedFrame(); if (!focused_frame) return; focused_frame->GetFrameInputHandler()->ReplaceMisspelling(word); } Commit Message: If JavaScript shows a dialog, cause the page to lose fullscreen. BUG=670135, 550017, 726761, 728276 Review-Url: https://codereview.chromium.org/2906133004 Cr-Commit-Position: refs/heads/master@{#478884} CWE ID: CWE-20
0
135,861
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static bool checkIfCover(const GifImageDesc& target, const GifImageDesc& covered) { return target.Left <= covered.Left && covered.Left + covered.Width <= target.Left + target.Width && target.Top <= covered.Top && covered.Top + covered.Height <= target.Top + target.Height; } Commit Message: Skip composition of frames lacking a color map Bug:68399117 Change-Id: I32f1d6856221b8a60130633edb69da2d2986c27c (cherry picked from commit 0dc887f70eeea8d707cb426b96c6756edd1c607d) CWE ID: CWE-20
0
163,281
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: unsigned char *lpReplaceInteger(unsigned char *lp, unsigned char **pos, int64_t value) { char buf[LONG_STR_SIZE]; int slen = ll2string(buf,sizeof(buf),value); return lpInsert(lp, (unsigned char*)buf, slen, *pos, LP_REPLACE, pos); } Commit Message: Abort in XGROUP if the key is not a stream CWE ID: CWE-704
0
81,783
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset, ssize_t len) { handle_t *handle; ext4_lblk_t block; unsigned int max_blocks; int ret = 0; int ret2 = 0; struct buffer_head map_bh; unsigned int credits, blkbits = inode->i_blkbits; block = offset >> blkbits; /* * We can't just convert len to max_blocks because * If blocksize = 4096 offset = 3072 and len = 2048 */ max_blocks = (EXT4_BLOCK_ALIGN(len + offset, blkbits) >> blkbits) - block; /* * credits to insert 1 extent into extent tree */ credits = ext4_chunk_trans_blocks(inode, max_blocks); while (ret >= 0 && ret < max_blocks) { block = block + ret; max_blocks = max_blocks - ret; handle = ext4_journal_start(inode, credits); if (IS_ERR(handle)) { ret = PTR_ERR(handle); break; } map_bh.b_state = 0; ret = ext4_get_blocks(handle, inode, block, max_blocks, &map_bh, EXT4_GET_BLOCKS_IO_CONVERT_EXT); if (ret <= 0) { WARN_ON(ret <= 0); printk(KERN_ERR "%s: ext4_ext_get_blocks " "returned error inode#%lu, block=%u, " "max_blocks=%u", __func__, inode->i_ino, block, max_blocks); } ext4_mark_inode_dirty(handle, inode); ret2 = ext4_journal_stop(handle); if (ret <= 0 || ret2 ) break; } return ret > 0 ? ret2 : ret; } Commit Message: ext4: use ext4_get_block_write in buffer write Allocate uninitialized extent before ext4 buffer write and convert the extent to initialized after io completes. The purpose is to make sure an extent can only be marked initialized after it has been written with new data so we can safely drop the i_mutex lock in ext4 DIO read without exposing stale data. This helps to improve multi-thread DIO read performance on high-speed disks. Skip the nobh and data=journal mount cases to make things simple for now. Signed-off-by: Jiaying Zhang <jiayingz@google.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> CWE ID:
0
57,430
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder) { FLAC__ASSERT(0 != decoder); FLAC__ASSERT(0 != decoder->protected_); return decoder->protected_->state; } Commit Message: Avoid free-before-initialize vulnerability in heap Bug: 27211885 Change-Id: Ib9c93bd9ffdde2a5f8d31a86f06e267dc9c152db CWE ID: CWE-119
0
161,192
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int sctp_listen_start(struct sock *sk, int backlog) { struct sctp_sock *sp = sctp_sk(sk); struct sctp_endpoint *ep = sp->ep; struct crypto_shash *tfm = NULL; char alg[32]; /* Allocate HMAC for generating cookie. */ if (!sp->hmac && sp->sctp_hmac_alg) { sprintf(alg, "hmac(%s)", sp->sctp_hmac_alg); tfm = crypto_alloc_shash(alg, 0, 0); if (IS_ERR(tfm)) { net_info_ratelimited("failed to load transform for %s: %ld\n", sp->sctp_hmac_alg, PTR_ERR(tfm)); return -ENOSYS; } sctp_sk(sk)->hmac = tfm; } /* * If a bind() or sctp_bindx() is not called prior to a listen() * call that allows new associations to be accepted, the system * picks an ephemeral port and will choose an address set equivalent * to binding with a wildcard address. * * This is not currently spelled out in the SCTP sockets * extensions draft, but follows the practice as seen in TCP * sockets. * */ sk->sk_state = SCTP_SS_LISTENING; if (!ep->base.bind_addr.port) { if (sctp_autobind(sk)) return -EAGAIN; } else { if (sctp_get_port(sk, inet_sk(sk)->inet_num)) { sk->sk_state = SCTP_SS_CLOSED; return -EADDRINUSE; } } sk->sk_max_ack_backlog = backlog; sctp_hash_endpoint(ep); return 0; } Commit Message: sctp: do not peel off an assoc from one netns to another one Now when peeling off an association to the sock in another netns, all transports in this assoc are not to be rehashed and keep use the old key in hashtable. As a transport uses sk->net as the hash key to insert into hashtable, it would miss removing these transports from hashtable due to the new netns when closing the sock and all transports are being freeed, then later an use-after-free issue could be caused when looking up an asoc and dereferencing those transports. This is a very old issue since very beginning, ChunYu found it with syzkaller fuzz testing with this series: socket$inet6_sctp() bind$inet6() sendto$inet6() unshare(0x40000000) getsockopt$inet_sctp6_SCTP_GET_ASSOC_ID_LIST() getsockopt$inet_sctp6_SCTP_SOCKOPT_PEELOFF() This patch is to block this call when peeling one assoc off from one netns to another one, so that the netns of all transport would not go out-sync with the key in hashtable. Note that this patch didn't fix it by rehashing transports, as it's difficult to handle the situation when the tuple is already in use in the new netns. Besides, no one would like to peel off one assoc to another netns, considering ipaddrs, ifaces, etc. are usually different. Reported-by: ChunYu Wang <chunwang@redhat.com> Signed-off-by: Xin Long <lucien.xin@gmail.com> Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-416
0
60,682
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void srpt_release_cmd(struct se_cmd *se_cmd) { struct srpt_send_ioctx *ioctx = container_of(se_cmd, struct srpt_send_ioctx, cmd); struct srpt_rdma_ch *ch = ioctx->ch; unsigned long flags; WARN_ON(ioctx->state != SRPT_STATE_DONE); WARN_ON(ioctx->mapped_sg_count != 0); if (ioctx->n_rbuf > 1) { kfree(ioctx->rbufs); ioctx->rbufs = NULL; ioctx->n_rbuf = 0; } spin_lock_irqsave(&ch->spinlock, flags); list_add(&ioctx->free_list, &ch->free_list); spin_unlock_irqrestore(&ch->spinlock, flags); } Commit Message: IB/srpt: Simplify srpt_handle_tsk_mgmt() Let the target core check task existence instead of the SRP target driver. Additionally, let the target core check the validity of the task management request instead of the ib_srpt driver. This patch fixes the following kernel crash: BUG: unable to handle kernel NULL pointer dereference at 0000000000000001 IP: [<ffffffffa0565f37>] srpt_handle_new_iu+0x6d7/0x790 [ib_srpt] Oops: 0002 [#1] SMP Call Trace: [<ffffffffa05660ce>] srpt_process_completion+0xde/0x570 [ib_srpt] [<ffffffffa056669f>] srpt_compl_thread+0x13f/0x160 [ib_srpt] [<ffffffff8109726f>] kthread+0xcf/0xe0 [<ffffffff81613cfc>] ret_from_fork+0x7c/0xb0 Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Fixes: 3e4f574857ee ("ib_srpt: Convert TMR path to target_submit_tmr") Tested-by: Alex Estrin <alex.estrin@intel.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Nicholas Bellinger <nab@linux-iscsi.org> Cc: Sagi Grimberg <sagig@mellanox.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Doug Ledford <dledford@redhat.com> CWE ID: CWE-476
0
50,694
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ZEND_API const char *get_active_function_name(void) /* {{{ */ { zend_function *func; if (!zend_is_executing()) { return NULL; } func = EG(current_execute_data)->func; switch (func->type) { case ZEND_USER_FUNCTION: { zend_string *function_name = func->common.function_name; if (function_name) { return ZSTR_VAL(function_name); } else { return "main"; } } break; case ZEND_INTERNAL_FUNCTION: return ZSTR_VAL(func->common.function_name); break; default: return NULL; } } /* }}} */ Commit Message: Use format string CWE ID: CWE-134
0
57,310
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: const char* CustomButton::GetClassName() const { return kViewClassName; } Commit Message: Custom buttons should only handle accelerators when focused. BUG=541415 Review URL: https://codereview.chromium.org/1437523005 Cr-Commit-Position: refs/heads/master@{#360130} CWE ID: CWE-254
0
132,331
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool RenderBox::canAutoscroll() const { if (node() && node()->isDocumentNode()) return view()->frameView()->isScrollable(); return canBeScrolledAndHasScrollableArea(); } Commit Message: Separate repaint and layout requirements of StyleDifference (Step 1) Previously StyleDifference was an enum that proximately bigger values imply smaller values (e.g. StyleDifferenceLayout implies StyleDifferenceRepaint). This causes unnecessary repaints in some cases on layout change. Convert StyleDifference to a structure containing relatively independent flags. This change doesn't directly improve the result, but can make further repaint optimizations possible. Step 1 doesn't change any functionality. RenderStyle still generate the legacy StyleDifference enum when comparing styles and convert the result to the new StyleDifference. Implicit requirements are not handled during the conversion. Converted call sites to use the new StyleDifference according to the following conversion rules: - diff == StyleDifferenceEqual (&& !context) => diff.hasNoChange() - diff == StyleDifferenceRepaint => diff.needsRepaintObjectOnly() - diff == StyleDifferenceRepaintLayer => diff.needsRepaintLayer() - diff == StyleDifferenceRepaint || diff == StyleDifferenceRepaintLayer => diff.needsRepaintLayer() - diff >= StyleDifferenceRepaint => diff.needsRepaint() || diff.needsLayout() - diff >= StyleDifferenceRepaintLayer => diff.needsRepaintLayer() || diff.needsLayout() - diff > StyleDifferenceRepaintLayer => diff.needsLayout() - diff == StyleDifferencePositionedMovementLayoutOnly => diff.needsPositionedMovementLayoutOnly() - diff == StyleDifferenceLayout => diff.needsFullLayout() BUG=358460 TEST=All existing layout tests. R=eseidel@chromium.org, esprehn@chromium.org, jchaffraix@chromium.org Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=171983 Review URL: https://codereview.chromium.org/236203020 git-svn-id: svn://svn.chromium.org/blink/trunk@172331 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-119
0
116,465
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: Browser* Browser::CreateForType(Type type, Profile* profile) { Browser* browser = new Browser(type, profile); browser->CreateBrowserWindow(); return browser; } Commit Message: Rename the TabContentWrapper pieces to be "TabHelper"s. (Except for the PasswordManager... for now.) Also, just pre-create them up-front. It saves us effort, as they're all going to be eventually created anyway, so being lazy saves us nothing and creates headaches since the rules about what can be lazy differ from feature to feature. BUG=71097 TEST=zero visible change Review URL: http://codereview.chromium.org/6480117 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75170 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
102,006
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void mpol_rebind_policy(struct mempolicy *pol, const nodemask_t *newmask, enum mpol_rebind_step step) { if (!pol) return; if (!mpol_store_user_nodemask(pol) && step == 0 && nodes_equal(pol->w.cpuset_mems_allowed, *newmask)) return; if (step == MPOL_REBIND_STEP1 && (pol->flags & MPOL_F_REBINDING)) return; if (step == MPOL_REBIND_STEP2 && !(pol->flags & MPOL_F_REBINDING)) BUG(); if (step == MPOL_REBIND_STEP1) pol->flags |= MPOL_F_REBINDING; else if (step == MPOL_REBIND_STEP2) pol->flags &= ~MPOL_F_REBINDING; else if (step >= MPOL_REBIND_NSTEP) BUG(); mpol_ops[pol->mode].rebind(pol, newmask, step); } Commit Message: mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode commit 1a5a9906d4e8d1976b701f889d8f35d54b928f25 upstream. In some cases it may happen that pmd_none_or_clear_bad() is called with the mmap_sem hold in read mode. In those cases the huge page faults can allocate hugepmds under pmd_none_or_clear_bad() and that can trigger a false positive from pmd_bad() that will not like to see a pmd materializing as trans huge. It's not khugepaged causing the problem, khugepaged holds the mmap_sem in write mode (and all those sites must hold the mmap_sem in read mode to prevent pagetables to go away from under them, during code review it seems vm86 mode on 32bit kernels requires that too unless it's restricted to 1 thread per process or UP builds). The race is only with the huge pagefaults that can convert a pmd_none() into a pmd_trans_huge(). Effectively all these pmd_none_or_clear_bad() sites running with mmap_sem in read mode are somewhat speculative with the page faults, and the result is always undefined when they run simultaneously. This is probably why it wasn't common to run into this. For example if the madvise(MADV_DONTNEED) runs zap_page_range() shortly before the page fault, the hugepage will not be zapped, if the page fault runs first it will be zapped. Altering pmd_bad() not to error out if it finds hugepmds won't be enough to fix this, because zap_pmd_range would then proceed to call zap_pte_range (which would be incorrect if the pmd become a pmd_trans_huge()). The simplest way to fix this is to read the pmd in the local stack (regardless of what we read, no need of actual CPU barriers, only compiler barrier needed), and be sure it is not changing under the code that computes its value. Even if the real pmd is changing under the value we hold on the stack, we don't care. If we actually end up in zap_pte_range it means the pmd was not none already and it was not huge, and it can't become huge from under us (khugepaged locking explained above). All we need is to enforce that there is no way anymore that in a code path like below, pmd_trans_huge can be false, but pmd_none_or_clear_bad can run into a hugepmd. The overhead of a barrier() is just a compiler tweak and should not be measurable (I only added it for THP builds). I don't exclude different compiler versions may have prevented the race too by caching the value of *pmd on the stack (that hasn't been verified, but it wouldn't be impossible considering pmd_none_or_clear_bad, pmd_bad, pmd_trans_huge, pmd_none are all inlines and there's no external function called in between pmd_trans_huge and pmd_none_or_clear_bad). if (pmd_trans_huge(*pmd)) { if (next-addr != HPAGE_PMD_SIZE) { VM_BUG_ON(!rwsem_is_locked(&tlb->mm->mmap_sem)); split_huge_page_pmd(vma->vm_mm, pmd); } else if (zap_huge_pmd(tlb, vma, pmd, addr)) continue; /* fall through */ } if (pmd_none_or_clear_bad(pmd)) Because this race condition could be exercised without special privileges this was reported in CVE-2012-1179. The race was identified and fully explained by Ulrich who debugged it. I'm quoting his accurate explanation below, for reference. ====== start quote ======= mapcount 0 page_mapcount 1 kernel BUG at mm/huge_memory.c:1384! At some point prior to the panic, a "bad pmd ..." message similar to the following is logged on the console: mm/memory.c:145: bad pmd ffff8800376e1f98(80000000314000e7). The "bad pmd ..." message is logged by pmd_clear_bad() before it clears the page's PMD table entry. 143 void pmd_clear_bad(pmd_t *pmd) 144 { -> 145 pmd_ERROR(*pmd); 146 pmd_clear(pmd); 147 } After the PMD table entry has been cleared, there is an inconsistency between the actual number of PMD table entries that are mapping the page and the page's map count (_mapcount field in struct page). When the page is subsequently reclaimed, __split_huge_page() detects this inconsistency. 1381 if (mapcount != page_mapcount(page)) 1382 printk(KERN_ERR "mapcount %d page_mapcount %d\n", 1383 mapcount, page_mapcount(page)); -> 1384 BUG_ON(mapcount != page_mapcount(page)); The root cause of the problem is a race of two threads in a multithreaded process. Thread B incurs a page fault on a virtual address that has never been accessed (PMD entry is zero) while Thread A is executing an madvise() system call on a virtual address within the same 2 MB (huge page) range. virtual address space .---------------------. | | | | .-|---------------------| | | | | | |<-- B(fault) | | | 2 MB | |/////////////////////|-. huge < |/////////////////////| > A(range) page | |/////////////////////|-' | | | | | | '-|---------------------| | | | | '---------------------' - Thread A is executing an madvise(..., MADV_DONTNEED) system call on the virtual address range "A(range)" shown in the picture. sys_madvise // Acquire the semaphore in shared mode. down_read(&current->mm->mmap_sem) ... madvise_vma switch (behavior) case MADV_DONTNEED: madvise_dontneed zap_page_range unmap_vmas unmap_page_range zap_pud_range zap_pmd_range // // Assume that this huge page has never been accessed. // I.e. content of the PMD entry is zero (not mapped). // if (pmd_trans_huge(*pmd)) { // We don't get here due to the above assumption. } // // Assume that Thread B incurred a page fault and .---------> // sneaks in here as shown below. | // | if (pmd_none_or_clear_bad(pmd)) | { | if (unlikely(pmd_bad(*pmd))) | pmd_clear_bad | { | pmd_ERROR | // Log "bad pmd ..." message here. | pmd_clear | // Clear the page's PMD entry. | // Thread B incremented the map count | // in page_add_new_anon_rmap(), but | // now the page is no longer mapped | // by a PMD entry (-> inconsistency). | } | } | v - Thread B is handling a page fault on virtual address "B(fault)" shown in the picture. ... do_page_fault __do_page_fault // Acquire the semaphore in shared mode. down_read_trylock(&mm->mmap_sem) ... handle_mm_fault if (pmd_none(*pmd) && transparent_hugepage_enabled(vma)) // We get here due to the above assumption (PMD entry is zero). do_huge_pmd_anonymous_page alloc_hugepage_vma // Allocate a new transparent huge page here. ... __do_huge_pmd_anonymous_page ... spin_lock(&mm->page_table_lock) ... page_add_new_anon_rmap // Here we increment the page's map count (starts at -1). atomic_set(&page->_mapcount, 0) set_pmd_at // Here we set the page's PMD entry which will be cleared // when Thread A calls pmd_clear_bad(). ... spin_unlock(&mm->page_table_lock) The mmap_sem does not prevent the race because both threads are acquiring it in shared mode (down_read). Thread B holds the page_table_lock while the page's map count and PMD table entry are updated. However, Thread A does not synchronize on that lock. ====== end quote ======= [akpm@linux-foundation.org: checkpatch fixes] Reported-by: Ulrich Obergfell <uobergfe@redhat.com> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Mel Gorman <mgorman@suse.de> Cc: Hugh Dickins <hughd@google.com> Cc: Dave Jones <davej@redhat.com> Acked-by: Larry Woodman <lwoodman@redhat.com> Acked-by: Rik van Riel <riel@redhat.com> Cc: Mark Salter <msalter@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> CWE ID: CWE-264
0
21,331
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride) { uint8_t halfH[88]; wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11); wmv2_mspel8_v_lowpass(dst, halfH+8, stride, 8, 8); } Commit Message: avcodec/dsputil: fix signedness in sizeof() comparissions Signed-off-by: Michael Niedermayer <michaelni@gmx.at> CWE ID: CWE-189
0
28,161
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Browser::ExecuteCommandWithDisposition( int id, WindowOpenDisposition disposition) { if (!GetSelectedTabContentsWrapper()) return; DCHECK(command_updater_.IsCommandEnabled(id)) << "Invalid/disabled command " << id; if (block_command_execution_) { DCHECK_EQ(last_blocked_command_id_, -1); last_blocked_command_id_ = id; last_blocked_command_disposition_ = disposition; return; } switch (id) { case IDC_BACK: GoBack(disposition); break; case IDC_FORWARD: GoForward(disposition); break; case IDC_RELOAD: Reload(disposition); break; case IDC_RELOAD_IGNORING_CACHE: ReloadIgnoringCache(disposition); break; case IDC_HOME: Home(disposition); break; case IDC_OPEN_CURRENT_URL: OpenCurrentURL(); break; case IDC_STOP: Stop(); break; case IDC_NEW_WINDOW: NewWindow(); break; case IDC_NEW_INCOGNITO_WINDOW: NewIncognitoWindow(); break; case IDC_CLOSE_WINDOW: CloseWindow(); break; case IDC_NEW_TAB: NewTab(); break; case IDC_CLOSE_TAB: CloseTab(); break; case IDC_SELECT_NEXT_TAB: SelectNextTab(); break; case IDC_SELECT_PREVIOUS_TAB: SelectPreviousTab(); break; case IDC_TABPOSE: OpenTabpose(); break; case IDC_MOVE_TAB_NEXT: MoveTabNext(); break; case IDC_MOVE_TAB_PREVIOUS: MoveTabPrevious(); break; case IDC_SELECT_TAB_0: case IDC_SELECT_TAB_1: case IDC_SELECT_TAB_2: case IDC_SELECT_TAB_3: case IDC_SELECT_TAB_4: case IDC_SELECT_TAB_5: case IDC_SELECT_TAB_6: case IDC_SELECT_TAB_7: SelectNumberedTab(id - IDC_SELECT_TAB_0); break; case IDC_SELECT_LAST_TAB: SelectLastTab(); break; case IDC_DUPLICATE_TAB: DuplicateTab(); break; case IDC_RESTORE_TAB: RestoreTab(); break; case IDC_COPY_URL: WriteCurrentURLToClipboard(); break; case IDC_SHOW_AS_TAB: ConvertPopupToTabbedBrowser(); break; case IDC_FULLSCREEN: ToggleFullscreenMode(); break; case IDC_EXIT: Exit(); break; case IDC_TOGGLE_VERTICAL_TABS: ToggleUseVerticalTabs(); break; #if defined(OS_CHROMEOS) case IDC_SEARCH: Search(); break; case IDC_SHOW_KEYBOARD_OVERLAY: ShowKeyboardOverlay(); break; #endif case IDC_SAVE_PAGE: SavePage(); break; case IDC_BOOKMARK_PAGE: BookmarkCurrentPage(); break; case IDC_BOOKMARK_ALL_TABS: BookmarkAllTabs(); break; case IDC_VIEW_SOURCE: ViewSelectedSource(); break; case IDC_EMAIL_PAGE_LOCATION: EmailPageLocation(); break; case IDC_PRINT: Print(); break; case IDC_ENCODING_AUTO_DETECT: ToggleEncodingAutoDetect(); break; case IDC_ENCODING_UTF8: case IDC_ENCODING_UTF16LE: case IDC_ENCODING_ISO88591: case IDC_ENCODING_WINDOWS1252: case IDC_ENCODING_GBK: case IDC_ENCODING_GB18030: case IDC_ENCODING_BIG5HKSCS: case IDC_ENCODING_BIG5: case IDC_ENCODING_KOREAN: case IDC_ENCODING_SHIFTJIS: case IDC_ENCODING_ISO2022JP: case IDC_ENCODING_EUCJP: case IDC_ENCODING_THAI: case IDC_ENCODING_ISO885915: case IDC_ENCODING_MACINTOSH: case IDC_ENCODING_ISO88592: case IDC_ENCODING_WINDOWS1250: case IDC_ENCODING_ISO88595: case IDC_ENCODING_WINDOWS1251: case IDC_ENCODING_KOI8R: case IDC_ENCODING_KOI8U: case IDC_ENCODING_ISO88597: case IDC_ENCODING_WINDOWS1253: case IDC_ENCODING_ISO88594: case IDC_ENCODING_ISO885913: case IDC_ENCODING_WINDOWS1257: case IDC_ENCODING_ISO88593: case IDC_ENCODING_ISO885910: case IDC_ENCODING_ISO885914: case IDC_ENCODING_ISO885916: case IDC_ENCODING_WINDOWS1254: case IDC_ENCODING_ISO88596: case IDC_ENCODING_WINDOWS1256: case IDC_ENCODING_ISO88598: case IDC_ENCODING_ISO88598I: case IDC_ENCODING_WINDOWS1255: case IDC_ENCODING_WINDOWS1258: OverrideEncoding(id); break; case IDC_CUT: Cut(); break; case IDC_COPY: Copy(); break; case IDC_PASTE: Paste(); break; case IDC_FIND: Find(); break; case IDC_FIND_NEXT: FindNext(); break; case IDC_FIND_PREVIOUS: FindPrevious(); break; case IDC_ZOOM_PLUS: Zoom(PageZoom::ZOOM_IN); break; case IDC_ZOOM_NORMAL: Zoom(PageZoom::RESET); break; case IDC_ZOOM_MINUS: Zoom(PageZoom::ZOOM_OUT); break; case IDC_FOCUS_TOOLBAR: FocusToolbar(); break; case IDC_FOCUS_LOCATION: FocusLocationBar(); break; case IDC_FOCUS_SEARCH: FocusSearch(); break; case IDC_FOCUS_MENU_BAR: FocusAppMenu(); break; case IDC_FOCUS_BOOKMARKS: FocusBookmarksToolbar(); break; case IDC_FOCUS_CHROMEOS_STATUS: FocusChromeOSStatus(); break; case IDC_FOCUS_NEXT_PANE: FocusNextPane(); break; case IDC_FOCUS_PREVIOUS_PANE: FocusPreviousPane(); break; case IDC_OPEN_FILE: OpenFile(); break; case IDC_CREATE_SHORTCUTS: OpenCreateShortcutsDialog(); break; case IDC_DEV_TOOLS: ToggleDevToolsWindow( DEVTOOLS_TOGGLE_ACTION_NONE); break; case IDC_DEV_TOOLS_CONSOLE: ToggleDevToolsWindow( DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE); break; case IDC_DEV_TOOLS_INSPECT: ToggleDevToolsWindow( DEVTOOLS_TOGGLE_ACTION_INSPECT); break; case IDC_TASK_MANAGER: OpenTaskManager(false); break; case IDC_VIEW_BACKGROUND_PAGES: OpenTaskManager(true); break; case IDC_FEEDBACK: OpenBugReportDialog(); break; case IDC_SHOW_BOOKMARK_BAR: ToggleBookmarkBar(); break; case IDC_PROFILING_ENABLED: Profiling::Toggle(); break; case IDC_SHOW_BOOKMARK_MANAGER: OpenBookmarkManager(); break; case IDC_SHOW_APP_MENU: ShowAppMenu(); break; case IDC_SHOW_HISTORY: ShowHistoryTab(); break; case IDC_SHOW_DOWNLOADS: ShowDownloadsTab(); break; case IDC_MANAGE_EXTENSIONS: ShowExtensionsTab(); break; case IDC_SYNC_BOOKMARKS: OpenSyncMyBookmarksDialog(); break; case IDC_OPTIONS: OpenOptionsDialog(); break; case IDC_EDIT_SEARCH_ENGINES: OpenKeywordEditor(); break; case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break; case IDC_CLEAR_BROWSING_DATA: OpenClearBrowsingDataDialog(); break; case IDC_IMPORT_SETTINGS: OpenImportSettingsDialog(); break; case IDC_ABOUT: OpenAboutChromeDialog(); break; case IDC_UPGRADE_DIALOG: OpenUpdateChromeDialog(); break; case IDC_VIEW_INCOMPATIBILITIES: ShowAboutConflictsTab(); break; case IDC_HELP_PAGE: OpenHelpTab(); break; #if defined(OS_CHROMEOS) case IDC_SYSTEM_OPTIONS: OpenSystemOptionsDialog(); break; case IDC_INTERNET_OPTIONS: OpenInternetOptionsDialog(); break; case IDC_LANGUAGE_OPTIONS: OpenLanguageOptionsDialog(); break; #endif default: LOG(WARNING) << "Received Unimplemented Command: " << id; break; } } Commit Message: Rename the TabContentWrapper pieces to be "TabHelper"s. (Except for the PasswordManager... for now.) Also, just pre-create them up-front. It saves us effort, as they're all going to be eventually created anyway, so being lazy saves us nothing and creates headaches since the rules about what can be lazy differ from feature to feature. BUG=71097 TEST=zero visible change Review URL: http://codereview.chromium.org/6480117 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75170 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
102,011
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: Document& SelectionController::GetDocument() const { DCHECK(frame_->GetDocument()); return *frame_->GetDocument(); } Commit Message: Move SelectionTemplate::is_handle_visible_ to FrameSelection This patch moves |is_handle_visible_| to |FrameSelection| from |SelectionTemplate| since handle visibility is used only for setting |FrameSelection|, hence it is a redundant member variable of |SelectionTemplate|. Bug: 742093 Change-Id: I3add4da3844fb40be34dcb4d4b46b5fa6fed1d7e Reviewed-on: https://chromium-review.googlesource.com/595389 Commit-Queue: Yoshifumi Inoue <yosin@chromium.org> Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Kent Tamura <tkent@chromium.org> Cr-Commit-Position: refs/heads/master@{#491660} CWE ID: CWE-119
0
124,913
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: rend_service_load_all_keys(const smartlist_t *service_list) { /* Use service_list for unit tests */ const smartlist_t *s_list = rend_get_service_list(service_list); if (BUG(!s_list)) { return -1; } SMARTLIST_FOREACH_BEGIN(s_list, rend_service_t *, s) { if (s->private_key) continue; log_info(LD_REND, "Loading hidden-service keys from %s", rend_service_escaped_dir(s)); if (rend_service_load_keys(s) < 0) return -1; } SMARTLIST_FOREACH_END(s); return 0; } Commit Message: Fix log-uninitialized-stack bug in rend_service_intro_established. Fixes bug 23490; bugfix on 0.2.7.2-alpha. TROVE-2017-008 CVE-2017-0380 CWE ID: CWE-532
0
69,622
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void tracing_iter_reset(struct trace_iterator *iter, int cpu) { struct ring_buffer_event *event; struct ring_buffer_iter *buf_iter; unsigned long entries = 0; u64 ts; per_cpu_ptr(iter->trace_buffer->data, cpu)->skipped_entries = 0; buf_iter = trace_buffer_iter(iter, cpu); if (!buf_iter) return; ring_buffer_iter_reset(buf_iter); /* * We could have the case with the max latency tracers * that a reset never took place on a cpu. This is evident * by the timestamp being before the start of the buffer. */ while ((event = ring_buffer_iter_peek(buf_iter, &ts))) { if (ts >= iter->trace_buffer->time_start) break; entries++; ring_buffer_read(buf_iter, NULL); } per_cpu_ptr(iter->trace_buffer->data, cpu)->skipped_entries = entries; } Commit Message: Merge tag 'trace-v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace Pull tracing fixes from Steven Rostedt: "This contains a few fixes and a clean up. - a bad merge caused an "endif" to go in the wrong place in scripts/Makefile.build - softirq tracing fix for tracing that corrupts lockdep and causes a false splat - histogram documentation typo fixes - fix a bad memory reference when passing in no filter to the filter code - simplify code by using the swap macro instead of open coding the swap" * tag 'trace-v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Fix SKIP_STACK_VALIDATION=1 build due to bad merge with -mrecord-mcount tracing: Fix some errors in histogram documentation tracing: Use swap macro in update_max_tr softirq: Reorder trace_softirqs_on to prevent lockdep splat tracing: Check for no filter when processing event filters CWE ID: CWE-787
0
81,478
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int fld1(struct sh_fpu_soft_struct *fregs, int n) { FRn = (_FP_EXPBIAS_S << (_FP_FRACBITS_S - 1)); return 0; } Commit Message: perf: Remove the nmi parameter from the swevent and overflow interface The nmi parameter indicated if we could do wakeups from the current context, if not, we would set some state and self-IPI and let the resulting interrupt do the wakeup. For the various event classes: - hardware: nmi=0; PMI is in fact an NMI or we run irq_work_run from the PMI-tail (ARM etc.) - tracepoint: nmi=0; since tracepoint could be from NMI context. - software: nmi=[0,1]; some, like the schedule thing cannot perform wakeups, and hence need 0. As one can see, there is very little nmi=1 usage, and the down-side of not using it is that on some platforms some software events can have a jiffy delay in wakeup (when arch_irq_work_raise isn't implemented). The up-side however is that we can remove the nmi parameter and save a bunch of conditionals in fast paths. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Michael Cree <mcree@orcon.net.nz> Cc: Will Deacon <will.deacon@arm.com> Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com> Cc: Anton Blanchard <anton@samba.org> Cc: Eric B Munson <emunson@mgebm.net> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Paul Mundt <lethal@linux-sh.org> Cc: David S. Miller <davem@davemloft.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jason Wessel <jason.wessel@windriver.com> Cc: Don Zickus <dzickus@redhat.com> Link: http://lkml.kernel.org/n/tip-agjev8eu666tvknpb3iaj0fg@git.kernel.org Signed-off-by: Ingo Molnar <mingo@elte.hu> CWE ID: CWE-399
0
25,596
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: parse_primitive( const char **pcur, uint *primitive ) { uint i; for (i = 0; i < PIPE_PRIM_MAX; i++) { const char *cur = *pcur; if (str_match_nocase_whole( &cur, tgsi_primitive_names[i])) { *primitive = i; *pcur = cur; return TRUE; } } return FALSE; } Commit Message: CWE ID: CWE-119
0
9,734
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void __ablkcipher_walk_complete(struct ablkcipher_walk *walk) { struct ablkcipher_buffer *p, *tmp; list_for_each_entry_safe(p, tmp, &walk->buffers, entry) { ablkcipher_buffer_write(p); list_del(&p->entry); kfree(p); } } Commit Message: crypto: user - fix info leaks in report API Three errors resulting in kernel memory disclosure: 1/ The structures used for the netlink based crypto algorithm report API are located on the stack. As snprintf() does not fill the remainder of the buffer with null bytes, those stack bytes will be disclosed to users of the API. Switch to strncpy() to fix this. 2/ crypto_report_one() does not initialize all field of struct crypto_user_alg. Fix this to fix the heap info leak. 3/ For the module name we should copy only as many bytes as module_name() returns -- not as much as the destination buffer could hold. But the current code does not and therefore copies random data from behind the end of the module name, as the module name is always shorter than CRYPTO_MAX_ALG_NAME. Also switch to use strncpy() to copy the algorithm's name and driver_name. They are strings, after all. Signed-off-by: Mathias Krause <minipli@googlemail.com> Cc: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> CWE ID: CWE-310
0
31,177
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq) { return &vq->guest_notifier; } Commit Message: CWE ID: CWE-20
0
9,217
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static unsigned int find_best_mtu(const struct t3c_data *d, unsigned short mtu) { int i = 0; while (i < d->nmtus - 1 && d->mtus[i + 1] <= mtu) ++i; return i; } Commit Message: iw_cxgb3: Fix incorrectly returning error on success The cxgb3_*_send() functions return NET_XMIT_ values, which are positive integers values. So don't treat positive return values as an error. Signed-off-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com> Signed-off-by: Doug Ledford <dledford@redhat.com> CWE ID:
0
56,863
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void OnNotifyStreamError(int stream_id) { WasNotifiedOfError(stream_id); } Commit Message: Switching AudioOutputAuthorizationHandler from using AudioManager interface to AudioSystem one. BUG=672468 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Review-Url: https://codereview.chromium.org/2692203003 Cr-Commit-Position: refs/heads/master@{#450939} CWE ID:
0
128,207
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void TabStripModel::NotifyIfActiveOrSelectionChanged( TabContents* old_contents, NotifyTypes notify_types, const TabStripSelectionModel& old_model) { NotifyIfActiveTabChanged(old_contents, notify_types); if (!selection_model().Equals(old_model)) { FOR_EACH_OBSERVER(TabStripModelObserver, observers_, TabSelectionChanged(this, old_model)); } } Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt. BUG=107201 TEST=no visible change Review URL: https://chromiumcodereview.appspot.com/11293205 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
118,230
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static struct ucounts *inc_mnt_namespaces(struct user_namespace *ns) { return inc_ucount(ns, current_euid(), UCOUNT_MNT_NAMESPACES); } Commit Message: mnt: Add a per mount namespace limit on the number of mounts CAI Qian <caiqian@redhat.com> pointed out that the semantics of shared subtrees make it possible to create an exponentially increasing number of mounts in a mount namespace. mkdir /tmp/1 /tmp/2 mount --make-rshared / for i in $(seq 1 20) ; do mount --bind /tmp/1 /tmp/2 ; done Will create create 2^20 or 1048576 mounts, which is a practical problem as some people have managed to hit this by accident. As such CVE-2016-6213 was assigned. Ian Kent <raven@themaw.net> described the situation for autofs users as follows: > The number of mounts for direct mount maps is usually not very large because of > the way they are implemented, large direct mount maps can have performance > problems. There can be anywhere from a few (likely case a few hundred) to less > than 10000, plus mounts that have been triggered and not yet expired. > > Indirect mounts have one autofs mount at the root plus the number of mounts that > have been triggered and not yet expired. > > The number of autofs indirect map entries can range from a few to the common > case of several thousand and in rare cases up to between 30000 and 50000. I've > not heard of people with maps larger than 50000 entries. > > The larger the number of map entries the greater the possibility for a large > number of active mounts so it's not hard to expect cases of a 1000 or somewhat > more active mounts. So I am setting the default number of mounts allowed per mount namespace at 100,000. This is more than enough for any use case I know of, but small enough to quickly stop an exponential increase in mounts. Which should be perfect to catch misconfigurations and malfunctioning programs. For anyone who needs a higher limit this can be changed by writing to the new /proc/sys/fs/mount-max sysctl. Tested-by: CAI Qian <caiqian@redhat.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> CWE ID: CWE-400
0
50,948
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void nfs_retry_commit(struct list_head *page_list, struct pnfs_layout_segment *lseg, struct nfs_commit_info *cinfo) { struct nfs_page *req; while (!list_empty(page_list)) { req = nfs_list_entry(page_list->next); nfs_list_remove_request(req); nfs_mark_request_commit(req, lseg, cinfo); if (!cinfo->dreq) { dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); dec_bdi_stat(page_file_mapping(req->wb_page)->backing_dev_info, BDI_RECLAIMABLE); } nfs_unlock_and_release_request(req); } } Commit Message: nfs: always make sure page is up-to-date before extending a write to cover the entire page We should always make sure the cached page is up-to-date when we're determining whether we can extend a write to cover the full page -- even if we've received a write delegation from the server. Commit c7559663 added logic to skip this check if we have a write delegation, which can lead to data corruption such as the following scenario if client B receives a write delegation from the NFS server: Client A: # echo 123456789 > /mnt/file Client B: # echo abcdefghi >> /mnt/file # cat /mnt/file 0�D0�abcdefghi Just because we hold a write delegation doesn't mean that we've read in the entire page contents. Cc: <stable@vger.kernel.org> # v3.11+ Signed-off-by: Scott Mayhew <smayhew@redhat.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> CWE ID: CWE-20
0
39,191
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: pdf_load_xobject(fz_context *ctx, pdf_document *doc, pdf_obj *dict) { pdf_xobject *form; if ((form = pdf_find_item(ctx, pdf_drop_xobject_imp, dict)) != NULL) return form; form->iteration = 0; /* Store item immediately, to avoid possible recursion if objects refer back to this one */ pdf_store_item(ctx, dict, form, pdf_xobject_size(form)); form->obj = pdf_keep_obj(ctx, dict); return form; } Commit Message: CWE ID: CWE-20
1
164,582
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void CL_Vid_Restart_f( void ) { vmCvar_t musicCvar; Cvar_Set( "com_expectedhunkusage", "-1" ); if( CL_VideoRecording( ) ) { CL_CloseAVI( ); } if(clc.demorecording) CL_StopRecord_f(); S_StopAllSounds(); if(!FS_ConditionalRestart(clc.checksumFeed, qtrue)) { if(com_sv_running->integer) { Hunk_ClearToMark(); } else { Hunk_Clear(); } CL_ShutdownUI(); CL_ShutdownCGame(); CL_ShutdownRef(); CL_ResetPureClientAtServer(); FS_ClearPakReferences( FS_UI_REF | FS_CGAME_REF ); cls.rendererStarted = qfalse; cls.uiStarted = qfalse; cls.cgameStarted = qfalse; cls.soundRegistered = qfalse; Cvar_Set( "cl_paused", "0" ); CL_InitRef(); CL_StartHunkUsers(qfalse); if(clc.state > CA_CONNECTED && clc.state != CA_CINEMATIC) { cls.cgameStarted = qtrue; CL_InitCGame(); CL_SendPureChecksums(); } Cvar_Register( &musicCvar, "s_currentMusic", "", CVAR_ROM ); if ( strlen( musicCvar.string ) ) { S_StartBackgroundTrack( musicCvar.string, musicCvar.string ); } } } Commit Message: All: Don't load .pk3s as .dlls, and don't load user config files from .pk3s CWE ID: CWE-269
0
95,894
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: AuthenticatorInternalUnrecognizedErrorSheetModel::GetStepIllustration( ImageColorScheme color_scheme) const { return color_scheme == ImageColorScheme::kDark ? kWebauthnErrorDarkIcon : kWebauthnErrorIcon; } Commit Message: chrome/browser/ui/webauthn: long domains may cause a line break. As requested by UX in [1], allow long host names to split a title into two lines. This allows us to show more of the name before eliding, although sufficiently long names will still trigger elision. Screenshot at https://drive.google.com/open?id=1_V6t2CeZDAVazy3Px-OET2LnB__aEW1r. [1] https://docs.google.com/presentation/d/1TtxkPUchyVZulqgdMcfui-68B0W-DWaFFVJEffGIbLA/edit#slide=id.g5913c4105f_1_12 Change-Id: I70f6541e0db3e9942239304de43b487a7561ca34 Bug: 870892 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1601812 Auto-Submit: Adam Langley <agl@chromium.org> Commit-Queue: Nina Satragno <nsatragno@chromium.org> Reviewed-by: Nina Satragno <nsatragno@chromium.org> Cr-Commit-Position: refs/heads/master@{#658114} CWE ID: CWE-119
0
142,899
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void __vsock_release(struct sock *sk) { if (sk) { struct sk_buff *skb; struct sock *pending; struct vsock_sock *vsk; vsk = vsock_sk(sk); pending = NULL; /* Compiler warning. */ if (vsock_in_bound_table(vsk)) vsock_remove_bound(vsk); if (vsock_in_connected_table(vsk)) vsock_remove_connected(vsk); transport->release(vsk); lock_sock(sk); sock_orphan(sk); sk->sk_shutdown = SHUTDOWN_MASK; while ((skb = skb_dequeue(&sk->sk_receive_queue))) kfree_skb(skb); /* Clean up any sockets that never were accepted. */ while ((pending = vsock_dequeue_accept(sk)) != NULL) { __vsock_release(pending); sock_put(pending); } release_sock(sk); sock_put(sk); } } Commit Message: VSOCK: Fix missing msg_namelen update in vsock_stream_recvmsg() The code misses to update the msg_namelen member to 0 and therefore makes net/socket.c leak the local, uninitialized sockaddr_storage variable to userland -- 128 bytes of kernel stack memory. Cc: Andy King <acking@vmware.com> Cc: Dmitry Torokhov <dtor@vmware.com> Cc: George Zhang <georgezhang@vmware.com> Signed-off-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-200
0
30,320
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: GF_OperatingPointsInformation *gf_isom_oinf_new_entry() { GF_OperatingPointsInformation* ptr; GF_SAFEALLOC(ptr, GF_OperatingPointsInformation); if (ptr) { ptr->profile_tier_levels = gf_list_new(); ptr->operating_points = gf_list_new(); ptr->dependency_layers = gf_list_new(); } return ptr; } Commit Message: fix some exploitable overflows (#994, #997) CWE ID: CWE-119
0
84,024
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void TestTransactionConsumer::DidFinish(int result) { state_ = DONE; error_ = result; if (--quit_counter_ == 0) base::MessageLoop::current()->QuitWhenIdle(); } Commit Message: Replace fixed string uses of AddHeaderFromString Uses of AddHeaderFromString() with a static string may as well be replaced with SetHeader(). Do so. BUG=None Review-Url: https://codereview.chromium.org/2236933005 Cr-Commit-Position: refs/heads/master@{#418161} CWE ID: CWE-119
0
119,316
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: hook_command_run_exec (struct t_gui_buffer *buffer, const char *command) { struct t_hook *ptr_hook, *next_hook; int rc, hook_matching, length; char *command2; const char *ptr_command; ptr_command = command; command2 = NULL; if (command[0] != '/') { length = strlen (command) + 1; command2 = malloc (length); if (command2) { snprintf (command2, length, "/%s", command + 1); ptr_command = command2; } } ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND_RUN]; while (ptr_hook) { next_hook = ptr_hook->next_hook; if (!ptr_hook->deleted && !ptr_hook->running && HOOK_COMMAND_RUN(ptr_hook, command)) { hook_matching = string_match (ptr_command, HOOK_COMMAND_RUN(ptr_hook, command), 0); if (!hook_matching && !strchr (HOOK_COMMAND_RUN(ptr_hook, command), ' ')) { hook_matching = (string_strncasecmp (ptr_command, HOOK_COMMAND_RUN(ptr_hook, command), utf8_strlen (HOOK_COMMAND_RUN(ptr_hook, command))) == 0); } if (hook_matching) { ptr_hook->running = 1; rc = (HOOK_COMMAND_RUN(ptr_hook, callback)) (ptr_hook->callback_data, buffer, ptr_command); ptr_hook->running = 0; if (rc == WEECHAT_RC_OK_EAT) { if (command2) free (command2); return rc; } } } ptr_hook = next_hook; } if (command2) free (command2); return WEECHAT_RC_OK; } Commit Message: CWE ID: CWE-20
0
3,400
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: struct sctp_chunk *sctp_make_abort(const struct sctp_association *asoc, const struct sctp_chunk *chunk, const size_t hint) { struct sctp_chunk *retval; __u8 flags = 0; /* Set the T-bit if we have no association and 'chunk' is not * an INIT (vtag will be reflected). */ if (!asoc) { if (chunk && chunk->chunk_hdr && chunk->chunk_hdr->type == SCTP_CID_INIT) flags = 0; else flags = SCTP_CHUNK_FLAG_T; } retval = sctp_make_control(asoc, SCTP_CID_ABORT, flags, hint); /* RFC 2960 6.4 Multi-homed SCTP Endpoints * * An endpoint SHOULD transmit reply chunks (e.g., SACK, * HEARTBEAT ACK, * etc.) to the same destination transport * address from which it * received the DATA or control chunk * to which it is replying. * * [ABORT back to where the offender came from.] */ if (retval && chunk) retval->transport = chunk->transport; return retval; } Commit Message: net: sctp: fix NULL pointer dereference in af->from_addr_param on malformed packet An SCTP server doing ASCONF will panic on malformed INIT ping-of-death in the form of: ------------ INIT[PARAM: SET_PRIMARY_IP] ------------> While the INIT chunk parameter verification dissects through many things in order to detect malformed input, it misses to actually check parameters inside of parameters. E.g. RFC5061, section 4.2.4 proposes a 'set primary IP address' parameter in ASCONF, which has as a subparameter an address parameter. So an attacker may send a parameter type other than SCTP_PARAM_IPV4_ADDRESS or SCTP_PARAM_IPV6_ADDRESS, param_type2af() will subsequently return 0 and thus sctp_get_af_specific() returns NULL, too, which we then happily dereference unconditionally through af->from_addr_param(). The trace for the log: BUG: unable to handle kernel NULL pointer dereference at 0000000000000078 IP: [<ffffffffa01e9c62>] sctp_process_init+0x492/0x990 [sctp] PGD 0 Oops: 0000 [#1] SMP [...] Pid: 0, comm: swapper Not tainted 2.6.32-504.el6.x86_64 #1 Bochs Bochs RIP: 0010:[<ffffffffa01e9c62>] [<ffffffffa01e9c62>] sctp_process_init+0x492/0x990 [sctp] [...] Call Trace: <IRQ> [<ffffffffa01f2add>] ? sctp_bind_addr_copy+0x5d/0xe0 [sctp] [<ffffffffa01e1fcb>] sctp_sf_do_5_1B_init+0x21b/0x340 [sctp] [<ffffffffa01e3751>] sctp_do_sm+0x71/0x1210 [sctp] [<ffffffffa01e5c09>] ? sctp_endpoint_lookup_assoc+0xc9/0xf0 [sctp] [<ffffffffa01e61f6>] sctp_endpoint_bh_rcv+0x116/0x230 [sctp] [<ffffffffa01ee986>] sctp_inq_push+0x56/0x80 [sctp] [<ffffffffa01fcc42>] sctp_rcv+0x982/0xa10 [sctp] [<ffffffffa01d5123>] ? ipt_local_in_hook+0x23/0x28 [iptable_filter] [<ffffffff8148bdc9>] ? nf_iterate+0x69/0xb0 [<ffffffff81496d10>] ? ip_local_deliver_finish+0x0/0x2d0 [<ffffffff8148bf86>] ? nf_hook_slow+0x76/0x120 [<ffffffff81496d10>] ? ip_local_deliver_finish+0x0/0x2d0 [...] A minimal way to address this is to check for NULL as we do on all other such occasions where we know sctp_get_af_specific() could possibly return with NULL. Fixes: d6de3097592b ("[SCTP]: Add the handling of "Set Primary IP Address" parameter to INIT") Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Cc: Vlad Yasevich <vyasevich@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-399
0
35,850
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int iscsi_truncate(BlockDriverState *bs, int64_t offset) { IscsiLun *iscsilun = bs->opaque; Error *local_err = NULL; if (iscsilun->type != TYPE_DISK) { return -ENOTSUP; } iscsi_readcapacity_sync(iscsilun, &local_err); if (local_err != NULL) { error_free(local_err); return -EIO; } if (offset > iscsi_getlength(bs)) { return -EINVAL; } if (iscsilun->allocationmap != NULL) { g_free(iscsilun->allocationmap); iscsilun->allocationmap = iscsi_allocationmap_init(iscsilun); } return 0; } Commit Message: CWE ID: CWE-119
0
10,530
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: WORD32 ih264d_get_frame_dimensions(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op) { ih264d_ctl_get_frame_dimensions_ip_t *ps_ip; ih264d_ctl_get_frame_dimensions_op_t *ps_op; dec_struct_t *ps_dec = dec_hdl->pv_codec_handle; UWORD32 disp_wd, disp_ht, buffer_wd, buffer_ht, x_offset, y_offset; ps_ip = (ih264d_ctl_get_frame_dimensions_ip_t *)pv_api_ip; ps_op = (ih264d_ctl_get_frame_dimensions_op_t *)pv_api_op; UNUSED(ps_ip); if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid))) { disp_wd = ps_dec->u2_disp_width; disp_ht = ps_dec->u2_disp_height; if(0 == ps_dec->u4_share_disp_buf) { buffer_wd = disp_wd; buffer_ht = disp_ht; } else { buffer_wd = ps_dec->u2_frm_wd_y; buffer_ht = ps_dec->u2_frm_ht_y; } } else { disp_wd = 0; disp_ht = 0; if(0 == ps_dec->u4_share_disp_buf) { buffer_wd = disp_wd; buffer_ht = disp_ht; } else { buffer_wd = ALIGN16(disp_wd) + (PAD_LEN_Y_H << 1); buffer_ht = ALIGN16(disp_ht) + (PAD_LEN_Y_V << 2); } } if(ps_dec->u4_app_disp_width > buffer_wd) buffer_wd = ps_dec->u4_app_disp_width; if(0 == ps_dec->u4_share_disp_buf) { x_offset = 0; y_offset = 0; } else { y_offset = (PAD_LEN_Y_V << 1); x_offset = PAD_LEN_Y_H; if((NULL != ps_dec->ps_sps) && (1 == (ps_dec->ps_sps->u1_is_valid)) && (0 != ps_dec->u2_crop_offset_y)) { y_offset += ps_dec->u2_crop_offset_y / ps_dec->u2_frm_wd_y; x_offset += ps_dec->u2_crop_offset_y % ps_dec->u2_frm_wd_y; } } ps_op->u4_disp_wd[0] = disp_wd; ps_op->u4_disp_ht[0] = disp_ht; ps_op->u4_buffer_wd[0] = buffer_wd; ps_op->u4_buffer_ht[0] = buffer_ht; ps_op->u4_x_offset[0] = x_offset; ps_op->u4_y_offset[0] = y_offset; ps_op->u4_disp_wd[1] = ps_op->u4_disp_wd[2] = ((ps_op->u4_disp_wd[0] + 1) >> 1); ps_op->u4_disp_ht[1] = ps_op->u4_disp_ht[2] = ((ps_op->u4_disp_ht[0] + 1) >> 1); ps_op->u4_buffer_wd[1] = ps_op->u4_buffer_wd[2] = (ps_op->u4_buffer_wd[0] >> 1); ps_op->u4_buffer_ht[1] = ps_op->u4_buffer_ht[2] = (ps_op->u4_buffer_ht[0] >> 1); ps_op->u4_x_offset[1] = ps_op->u4_x_offset[2] = (ps_op->u4_x_offset[0] >> 1); ps_op->u4_y_offset[1] = ps_op->u4_y_offset[2] = (ps_op->u4_y_offset[0] >> 1); if((ps_dec->u1_chroma_format == IV_YUV_420SP_UV) || (ps_dec->u1_chroma_format == IV_YUV_420SP_VU)) { ps_op->u4_disp_wd[2] = 0; ps_op->u4_disp_ht[2] = 0; ps_op->u4_buffer_wd[2] = 0; ps_op->u4_buffer_ht[2] = 0; ps_op->u4_x_offset[2] = 0; ps_op->u4_y_offset[2] = 0; ps_op->u4_disp_wd[1] <<= 1; ps_op->u4_buffer_wd[1] <<= 1; ps_op->u4_x_offset[1] <<= 1; } return IV_SUCCESS; } Commit Message: Fixed error concealment when no MBs are decoded in the current pic Bug: 29493002 Change-Id: I3fae547ddb0616b4e6579580985232bd3d65881e CWE ID: CWE-284
0
158,315
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: AXObject* AXObjectCacheImpl::firstAccessibleObjectFromNode(const Node* node) { if (!node) return 0; AXObject* accessibleObject = getOrCreate(node->layoutObject()); while (accessibleObject && accessibleObject->accessibilityIsIgnored()) { node = NodeTraversal::next(*node); while (node && !node->layoutObject()) node = NodeTraversal::nextSkippingChildren(*node); if (!node) return 0; accessibleObject = getOrCreate(node->layoutObject()); } return accessibleObject; } Commit Message: Switch to equalIgnoringASCIICase throughout modules/accessibility BUG=627682 Review-Url: https://codereview.chromium.org/2793913007 Cr-Commit-Position: refs/heads/master@{#461858} CWE ID: CWE-254
0
127,330
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int hsr_register_frame_out(struct hsr_port *port, struct hsr_node *node, u16 sequence_nr) { if (seq_nr_before_or_eq(sequence_nr, node->seq_out[port->type])) return 1; node->seq_out[port->type] = sequence_nr; return 0; } Commit Message: net: hsr: fix memory leak in hsr_dev_finalize() If hsr_add_port(hsr, hsr_dev, HSR_PT_MASTER) failed to add port, it directly returns res and forgets to free the node that allocated in hsr_create_self_node(), and forgets to delete the node->mac_list linked in hsr->self_node_db. BUG: memory leak unreferenced object 0xffff8881cfa0c780 (size 64): comm "syz-executor.0", pid 2077, jiffies 4294717969 (age 2415.377s) hex dump (first 32 bytes): e0 c7 a0 cf 81 88 ff ff 00 02 00 00 00 00 ad de ................ 00 e6 49 cd 81 88 ff ff c0 9b 87 d0 81 88 ff ff ..I............. backtrace: [<00000000e2ff5070>] hsr_dev_finalize+0x736/0x960 [hsr] [<000000003ed2e597>] hsr_newlink+0x2b2/0x3e0 [hsr] [<000000003fa8c6b6>] __rtnl_newlink+0xf1f/0x1600 net/core/rtnetlink.c:3182 [<000000001247a7ad>] rtnl_newlink+0x66/0x90 net/core/rtnetlink.c:3240 [<00000000e7d1b61d>] rtnetlink_rcv_msg+0x54e/0xb90 net/core/rtnetlink.c:5130 [<000000005556bd3a>] netlink_rcv_skb+0x129/0x340 net/netlink/af_netlink.c:2477 [<00000000741d5ee6>] netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline] [<00000000741d5ee6>] netlink_unicast+0x49a/0x650 net/netlink/af_netlink.c:1336 [<000000009d56f9b7>] netlink_sendmsg+0x88b/0xdf0 net/netlink/af_netlink.c:1917 [<0000000046b35c59>] sock_sendmsg_nosec net/socket.c:621 [inline] [<0000000046b35c59>] sock_sendmsg+0xc3/0x100 net/socket.c:631 [<00000000d208adc9>] __sys_sendto+0x33e/0x560 net/socket.c:1786 [<00000000b582837a>] __do_sys_sendto net/socket.c:1798 [inline] [<00000000b582837a>] __se_sys_sendto net/socket.c:1794 [inline] [<00000000b582837a>] __x64_sys_sendto+0xdd/0x1b0 net/socket.c:1794 [<00000000c866801d>] do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290 [<00000000fea382d9>] entry_SYSCALL_64_after_hwframe+0x49/0xbe [<00000000e01dacb3>] 0xffffffffffffffff Fixes: c5a759117210 ("net/hsr: Use list_head (and rcu) instead of array for slave devices.") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Mao Wenan <maowenan@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-772
0
87,685
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void vmxnet3_ack_events(VMXNET3State *s, uint32_t val) { uint32_t events; VMW_CBPRN("Clearing events: 0x%x", val); events = VMXNET3_READ_DRV_SHARED32(s->drv_shmem, ecr) & ~val; VMXNET3_WRITE_DRV_SHARED32(s->drv_shmem, ecr, events); } Commit Message: CWE ID: CWE-20
0
15,576
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool readWebCoreString(String* string) { uint32_t length; if (!doReadUint32(&length)) return false; if (m_position + length > m_length) return false; *string = String::fromUTF8(reinterpret_cast<const char*>(m_buffer + m_position), length); m_position += length; return true; } Commit Message: Replace further questionable HashMap::add usages in bindings BUG=390928 R=dcarney@chromium.org Review URL: https://codereview.chromium.org/411273002 git-svn-id: svn://svn.chromium.org/blink/trunk@178823 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID:
0
120,523
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool HasDataAndName(const history::DownloadRow& row) { return row.received_bytes > 0 && !row.target_path.empty(); } Commit Message: When turning a download into a navigation, navigate the right frame Code changes from Nate Chapin <japhet@chromium.org> Bug: 926105 Change-Id: I098599394e6ebe7d2fce5af838014297a337d294 Reviewed-on: https://chromium-review.googlesource.com/c/1454962 Reviewed-by: Camille Lamy <clamy@chromium.org> Commit-Queue: Jochen Eisinger <jochen@chromium.org> Cr-Commit-Position: refs/heads/master@{#629547} CWE ID: CWE-284
0
151,928
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: i915_gem_execbuffer_wait_for_flips(struct intel_ring_buffer *ring, u32 flips) { u32 plane, flip_mask; int ret; /* Check for any pending flips. As we only maintain a flip queue depth * of 1, we can simply insert a WAIT for the next display flip prior * to executing the batch and avoid stalling the CPU. */ for (plane = 0; flips >> plane; plane++) { if (((flips >> plane) & 1) == 0) continue; if (plane) flip_mask = MI_WAIT_FOR_PLANE_B_FLIP; else flip_mask = MI_WAIT_FOR_PLANE_A_FLIP; ret = intel_ring_begin(ring, 2); if (ret) return ret; intel_ring_emit(ring, MI_WAIT_FOR_EVENT | flip_mask); intel_ring_emit(ring, MI_NOOP); intel_ring_advance(ring); } return 0; } Commit Message: drm/i915: fix integer overflow in i915_gem_do_execbuffer() On 32-bit systems, a large args->num_cliprects from userspace via ioctl may overflow the allocation size, leading to out-of-bounds access. This vulnerability was introduced in commit 432e58ed ("drm/i915: Avoid allocation for execbuffer object list"). Signed-off-by: Xi Wang <xi.wang@gmail.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: stable@vger.kernel.org Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> CWE ID: CWE-189
0
19,793
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void PushMessagingServiceImpl::OnMessagesDeleted(const std::string& app_id) { } Commit Message: Remove some senseless indirection from the Push API code Four files to call one Java function. Let's just call it directly. BUG= Change-Id: I6e988e9a000051dd7e3dd2b517a33a09afc2fff6 Reviewed-on: https://chromium-review.googlesource.com/749147 Reviewed-by: Anita Woodruff <awdf@chromium.org> Commit-Queue: Peter Beverloo <peter@chromium.org> Cr-Commit-Position: refs/heads/master@{#513464} CWE ID: CWE-119
0
150,698
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: do_note_freebsd_version(struct magic_set *ms, int swap, void *v) { uint32_t desc; (void)memcpy(&desc, v, sizeof(desc)); desc = elf_getu32(swap, desc); if (file_printf(ms, ", for FreeBSD") == -1) return; /* * Contents is __FreeBSD_version, whose relation to OS * versions is defined by a huge table in the Porter's * Handbook. This is the general scheme: * * Releases: * Mmp000 (before 4.10) * Mmi0p0 (before 5.0) * Mmm0p0 * * Development branches: * Mmpxxx (before 4.6) * Mmp1xx (before 4.10) * Mmi1xx (before 5.0) * M000xx (pre-M.0) * Mmm1xx * * M = major version * m = minor version * i = minor version increment (491000 -> 4.10) * p = patchlevel * x = revision * * The first release of FreeBSD to use ELF by default * was version 3.0. */ if (desc == 460002) { if (file_printf(ms, " 4.6.2") == -1) return; } else if (desc < 460100) { if (file_printf(ms, " %d.%d", desc / 100000, desc / 10000 % 10) == -1) return; if (desc / 1000 % 10 > 0) if (file_printf(ms, ".%d", desc / 1000 % 10) == -1) return; if ((desc % 1000 > 0) || (desc % 100000 == 0)) if (file_printf(ms, " (%d)", desc) == -1) return; } else if (desc < 500000) { if (file_printf(ms, " %d.%d", desc / 100000, desc / 10000 % 10 + desc / 1000 % 10) == -1) return; if (desc / 100 % 10 > 0) { if (file_printf(ms, " (%d)", desc) == -1) return; } else if (desc / 10 % 10 > 0) { if (file_printf(ms, ".%d", desc / 10 % 10) == -1) return; } } else { if (file_printf(ms, " %d.%d", desc / 100000, desc / 1000 % 100) == -1) return; if ((desc / 100 % 10 > 0) || (desc % 100000 / 100 == 0)) { if (file_printf(ms, " (%d)", desc) == -1) return; } else if (desc / 10 % 10 > 0) { if (file_printf(ms, ".%d", desc / 10 % 10) == -1) return; } } } Commit Message: - Add a limit to the number of ELF notes processed (Suggested by Alexander Cherepanov) - Restructure ELF note printing so that we don't print the same message multiple times on repeated notes of the same kind. CWE ID: CWE-399
0
45,987
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int mdiobus_read_nested(struct mii_bus *bus, int addr, u32 regnum) { int retval; BUG_ON(in_interrupt()); mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED); retval = __mdiobus_read(bus, addr, regnum); mutex_unlock(&bus->mdio_lock); return retval; } Commit Message: mdio_bus: Fix use-after-free on device_register fails KASAN has found use-after-free in fixed_mdio_bus_init, commit 0c692d07842a ("drivers/net/phy/mdio_bus.c: call put_device on device_register() failure") call put_device() while device_register() fails,give up the last reference to the device and allow mdiobus_release to be executed ,kfreeing the bus. However in most drives, mdiobus_free be called to free the bus while mdiobus_register fails. use-after-free occurs when access bus again, this patch revert it to let mdiobus_free free the bus. KASAN report details as below: BUG: KASAN: use-after-free in mdiobus_free+0x85/0x90 drivers/net/phy/mdio_bus.c:482 Read of size 4 at addr ffff8881dc824d78 by task syz-executor.0/3524 CPU: 1 PID: 3524 Comm: syz-executor.0 Not tainted 5.0.0-rc7+ #45 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xfa/0x1ce lib/dump_stack.c:113 print_address_description+0x65/0x270 mm/kasan/report.c:187 kasan_report+0x149/0x18d mm/kasan/report.c:317 mdiobus_free+0x85/0x90 drivers/net/phy/mdio_bus.c:482 fixed_mdio_bus_init+0x283/0x1000 [fixed_phy] ? 0xffffffffc0e40000 ? 0xffffffffc0e40000 ? 0xffffffffc0e40000 do_one_initcall+0xfa/0x5ca init/main.c:887 do_init_module+0x204/0x5f6 kernel/module.c:3460 load_module+0x66b2/0x8570 kernel/module.c:3808 __do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902 do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x462e99 Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f6215c19c58 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 RAX: ffffffffffffffda RBX: 000000000073bf00 RCX: 0000000000462e99 RDX: 0000000000000000 RSI: 0000000020000080 RDI: 0000000000000003 RBP: 00007f6215c19c70 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f6215c1a6bc R13: 00000000004bcefb R14: 00000000006f7030 R15: 0000000000000004 Allocated by task 3524: set_track mm/kasan/common.c:85 [inline] __kasan_kmalloc.constprop.3+0xa0/0xd0 mm/kasan/common.c:496 kmalloc include/linux/slab.h:545 [inline] kzalloc include/linux/slab.h:740 [inline] mdiobus_alloc_size+0x54/0x1b0 drivers/net/phy/mdio_bus.c:143 fixed_mdio_bus_init+0x163/0x1000 [fixed_phy] do_one_initcall+0xfa/0x5ca init/main.c:887 do_init_module+0x204/0x5f6 kernel/module.c:3460 load_module+0x66b2/0x8570 kernel/module.c:3808 __do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902 do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 3524: set_track mm/kasan/common.c:85 [inline] __kasan_slab_free+0x130/0x180 mm/kasan/common.c:458 slab_free_hook mm/slub.c:1409 [inline] slab_free_freelist_hook mm/slub.c:1436 [inline] slab_free mm/slub.c:2986 [inline] kfree+0xe1/0x270 mm/slub.c:3938 device_release+0x78/0x200 drivers/base/core.c:919 kobject_cleanup lib/kobject.c:662 [inline] kobject_release lib/kobject.c:691 [inline] kref_put include/linux/kref.h:67 [inline] kobject_put+0x146/0x240 lib/kobject.c:708 put_device+0x1c/0x30 drivers/base/core.c:2060 __mdiobus_register+0x483/0x560 drivers/net/phy/mdio_bus.c:382 fixed_mdio_bus_init+0x26b/0x1000 [fixed_phy] do_one_initcall+0xfa/0x5ca init/main.c:887 do_init_module+0x204/0x5f6 kernel/module.c:3460 load_module+0x66b2/0x8570 kernel/module.c:3808 __do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902 do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff8881dc824c80 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 248 bytes inside of 2048-byte region [ffff8881dc824c80, ffff8881dc825480) The buggy address belongs to the page: page:ffffea0007720800 count:1 mapcount:0 mapping:ffff8881f6c02800 index:0x0 compound_mapcount: 0 flags: 0x2fffc0000010200(slab|head) raw: 02fffc0000010200 0000000000000000 0000000500000001 ffff8881f6c02800 raw: 0000000000000000 00000000800f000f 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8881dc824c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff8881dc824c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8881dc824d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881dc824d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881dc824e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb Fixes: 0c692d07842a ("drivers/net/phy/mdio_bus.c: call put_device on device_register() failure") Signed-off-by: YueHaibing <yuehaibing@huawei.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-416
0
89,647
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void hns_rcb_start(struct hnae_queue *q, u32 val) { hns_rcb_ring_enable_hw(q, val); } Commit Message: net: hns: fix ethtool_get_strings overflow in hns driver hns_get_sset_count() returns HNS_NET_STATS_CNT and the data space allocated is not enough for ethtool_get_strings(), which will cause random memory corruption. When SLAB and DEBUG_SLAB are both enabled, memory corruptions like the the following can be observed without this patch: [ 43.115200] Slab corruption (Not tainted): Acpi-ParseExt start=ffff801fb0b69030, len=80 [ 43.115206] Redzone: 0x9f911029d006462/0x5f78745f31657070. [ 43.115208] Last user: [<5f7272655f746b70>](0x5f7272655f746b70) [ 43.115214] 010: 70 70 65 31 5f 74 78 5f 70 6b 74 00 6b 6b 6b 6b ppe1_tx_pkt.kkkk [ 43.115217] 030: 70 70 65 31 5f 74 78 5f 70 6b 74 5f 6f 6b 00 6b ppe1_tx_pkt_ok.k [ 43.115218] Next obj: start=ffff801fb0b69098, len=80 [ 43.115220] Redzone: 0x706d655f6f666966/0x9f911029d74e35b. [ 43.115229] Last user: [<ffff0000084b11b0>](acpi_os_release_object+0x28/0x38) [ 43.115231] 000: 74 79 00 6b 6b 6b 6b 6b 70 70 65 31 5f 74 78 5f ty.kkkkkppe1_tx_ [ 43.115232] 010: 70 6b 74 5f 65 72 72 5f 63 73 75 6d 5f 66 61 69 pkt_err_csum_fai Signed-off-by: Timmy Li <lixiaoping3@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-119
0
85,622
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int hns_rcb_get_ring_sset_count(int stringset) { if (stringset == ETH_SS_STATS) return HNS_RING_STATIC_REG_NUM; return 0; } Commit Message: net: hns: fix ethtool_get_strings overflow in hns driver hns_get_sset_count() returns HNS_NET_STATS_CNT and the data space allocated is not enough for ethtool_get_strings(), which will cause random memory corruption. When SLAB and DEBUG_SLAB are both enabled, memory corruptions like the the following can be observed without this patch: [ 43.115200] Slab corruption (Not tainted): Acpi-ParseExt start=ffff801fb0b69030, len=80 [ 43.115206] Redzone: 0x9f911029d006462/0x5f78745f31657070. [ 43.115208] Last user: [<5f7272655f746b70>](0x5f7272655f746b70) [ 43.115214] 010: 70 70 65 31 5f 74 78 5f 70 6b 74 00 6b 6b 6b 6b ppe1_tx_pkt.kkkk [ 43.115217] 030: 70 70 65 31 5f 74 78 5f 70 6b 74 5f 6f 6b 00 6b ppe1_tx_pkt_ok.k [ 43.115218] Next obj: start=ffff801fb0b69098, len=80 [ 43.115220] Redzone: 0x706d655f6f666966/0x9f911029d74e35b. [ 43.115229] Last user: [<ffff0000084b11b0>](acpi_os_release_object+0x28/0x38) [ 43.115231] 000: 74 79 00 6b 6b 6b 6b 6b 70 70 65 31 5f 74 78 5f ty.kkkkkppe1_tx_ [ 43.115232] 010: 70 6b 74 5f 65 72 72 5f 63 73 75 6d 5f 66 61 69 pkt_err_csum_fai Signed-off-by: Timmy Li <lixiaoping3@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-119
1
169,400
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void TopSitesImpl::StartQueryForMostVisited() { DCHECK(loaded_); timer_.Stop(); if (!history_service_) return; provider_->ProvideTopSites( num_results_to_request_from_history(), base::Bind(&TopSitesImpl::OnTopSitesAvailableFromHistory, base::Unretained(this)), &cancelable_task_tracker_); } Commit Message: TopSites: Clear thumbnails from the cache when their URLs get removed We already cleared the thumbnails from persistent storage, but they remained in the in-memory cache, so they remained accessible (until the next Chrome restart) even after all browsing data was cleared. Bug: 758169 Change-Id: Id916d22358430a82e6d5043ac04fa463a32f824f Reviewed-on: https://chromium-review.googlesource.com/758640 Commit-Queue: Marc Treib <treib@chromium.org> Reviewed-by: Sylvain Defresne <sdefresne@chromium.org> Cr-Commit-Position: refs/heads/master@{#514861} CWE ID: CWE-200
0
147,094
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: struct h2_stream *h2_session_push(h2_session *session, h2_stream *is, h2_push *push) { apr_status_t status; h2_stream *stream; h2_ngheader *ngh; int nid; ngh = h2_util_ngheader_make_req(is->pool, push->req); nid = nghttp2_submit_push_promise(session->ngh2, 0, is->id, ngh->nv, ngh->nvlen, NULL); if (nid <= 0) { ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03075) "h2_stream(%ld-%d): submitting push promise fail: %s", session->id, is->id, nghttp2_strerror(nid)); return NULL; } ++session->pushes_promised; ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03076) "h2_stream(%ld-%d): SERVER_PUSH %d for %s %s on %d", session->id, is->id, nid, push->req->method, push->req->path, is->id); stream = h2_session_open_stream(session, nid, is->id, push->req); if (stream) { h2_session_set_prio(session, stream, push->priority); status = stream_schedule(session, stream, 1); if (status != APR_SUCCESS) { ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c, "h2_stream(%ld-%d): scheduling push stream", session->id, stream->id); stream = NULL; } ++session->unsent_promises; } else { ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03077) "h2_stream(%ld-%d): failed to create stream obj %d", session->id, is->id, nid); } if (!stream) { /* try to tell the client that it should not wait. */ nghttp2_submit_rst_stream(session->ngh2, NGHTTP2_FLAG_NONE, nid, NGHTTP2_INTERNAL_ERROR); } return stream; } Commit Message: SECURITY: CVE-2016-8740 mod_http2: properly crafted, endless HTTP/2 CONTINUATION frames could be used to exhaust all server's memory. Reported by: Naveen Tiwari <naveen.tiwari@asu.edu> and CDF/SEFCOM at Arizona State University git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1772576 13f79535-47bb-0310-9956-ffa450edef68 CWE ID: CWE-20
0
48,656
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: do_cmd(conn c) { dispatch_cmd(c); fill_extra_data(c); } Commit Message: Discard job body bytes if the job is too big. Previously, a malicious user could craft a job payload and inject beanstalk commands without the client application knowing. (An extra-careful client library could check the size of the job body before sending the put command, but most libraries do not do this, nor should they have to.) Reported by Graham Barr. CWE ID:
0
18,130
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void WebMediaPlayerMS::OnPictureInPictureControlClicked( const std::string& control_id) { NOTIMPLEMENTED(); } Commit Message: Simplify "WouldTaintOrigin" concept in media/blink Currently WebMediaPlayer has three predicates: - DidGetOpaqueResponseFromServiceWorker - HasSingleSecurityOrigin - DidPassCORSAccessCheck . These are used to determine whether the response body is available for scripts. They are known to be confusing, and actually MediaElementAudioSourceHandler::WouldTaintOrigin misuses them. This CL merges the three predicates to one, WouldTaintOrigin, to remove the confusion. Now the "response type" concept is available and we don't need a custom CORS check, so this CL removes BaseAudioContext::WouldTaintOrigin. This CL also renames URLData::has_opaque_data_ and its (direct and indirect) data accessors to match the spec. Bug: 849942, 875153 Change-Id: I6acf50169d7445c4ff614e80ac606f79ee577d2a Reviewed-on: https://chromium-review.googlesource.com/c/1238098 Reviewed-by: Fredrik Hubinette <hubbe@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Raymond Toy <rtoy@chromium.org> Commit-Queue: Yutaka Hirano <yhirano@chromium.org> Cr-Commit-Position: refs/heads/master@{#598258} CWE ID: CWE-732
0
144,167
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void AXObject::detach() { clearChildren(); m_axObjectCache = nullptr; } Commit Message: Switch to equalIgnoringASCIICase throughout modules/accessibility BUG=627682 Review-Url: https://codereview.chromium.org/2793913007 Cr-Commit-Position: refs/heads/master@{#461858} CWE ID: CWE-254
0
127,249
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool WebPagePrivate::handleMouseEvent(PlatformMouseEvent& mouseEvent) { EventHandler* eventHandler = m_mainFrame->eventHandler(); if (mouseEvent.type() == WebCore::PlatformEvent::MouseMoved) return eventHandler->mouseMoved(mouseEvent); if (mouseEvent.type() == WebCore::PlatformEvent::MouseScroll) return true; Node* node = 0; if (mouseEvent.inputMethod() == TouchScreen) { const FatFingersResult lastFatFingersResult = m_touchEventHandler->lastFatFingersResult(); node = lastFatFingersResult.node(FatFingersResult::ShadowContentNotAllowed); } if (!node) { HitTestResult result = eventHandler->hitTestResultAtPoint(mapFromViewportToContents(mouseEvent.position()), false /*allowShadowContent*/); node = result.innerNode(); } if (mouseEvent.type() == WebCore::PlatformEvent::MousePressed) { m_inputHandler->setInputModeEnabled(); if (m_inputHandler->willOpenPopupForNode(node)) { ASSERT(node->isElementNode()); if (node->isElementNode()) { Element* element = static_cast<Element*>(node); element->focus(); } } else eventHandler->handleMousePressEvent(mouseEvent); } else if (mouseEvent.type() == WebCore::PlatformEvent::MouseReleased) { if (!m_inputHandler->didNodeOpenPopup(node)) eventHandler->handleMouseReleaseEvent(mouseEvent); } return true; } Commit Message: [BlackBerry] Adapt to new BlackBerry::Platform::TouchPoint API https://bugs.webkit.org/show_bug.cgi?id=105143 RIM PR 171941 Reviewed by Rob Buis. Internally reviewed by George Staikos. Source/WebCore: TouchPoint instances now provide document coordinates for the viewport and content position of the touch event. The pixel coordinates stored in the TouchPoint should no longer be needed in WebKit. Also adapt to new method names and encapsulation of TouchPoint data members. No change in behavior, no new tests. * platform/blackberry/PlatformTouchPointBlackBerry.cpp: (WebCore::PlatformTouchPoint::PlatformTouchPoint): Source/WebKit/blackberry: TouchPoint instances now provide document coordinates for the viewport and content position of the touch event. The pixel coordinates stored in the TouchPoint should no longer be needed in WebKit. One exception is when passing events to a full screen plugin. Also adapt to new method names and encapsulation of TouchPoint data members. * Api/WebPage.cpp: (BlackBerry::WebKit::WebPage::touchEvent): (BlackBerry::WebKit::WebPage::touchPointAsMouseEvent): (BlackBerry::WebKit::WebPagePrivate::dispatchTouchEventToFullScreenPlugin): (BlackBerry::WebKit::WebPagePrivate::dispatchTouchPointAsMouseEventToFullScreenPlugin): * WebKitSupport/InputHandler.cpp: (BlackBerry::WebKit::InputHandler::shouldRequestSpellCheckingOptionsForPoint): * WebKitSupport/InputHandler.h: (InputHandler): * WebKitSupport/TouchEventHandler.cpp: (BlackBerry::WebKit::TouchEventHandler::doFatFingers): (BlackBerry::WebKit::TouchEventHandler::handleTouchPoint): * WebKitSupport/TouchEventHandler.h: (TouchEventHandler): Tools: Adapt to new method names and encapsulation of TouchPoint data members. * DumpRenderTree/blackberry/EventSender.cpp: (addTouchPointCallback): (updateTouchPointCallback): (touchEndCallback): (releaseTouchPointCallback): (sendTouchEvent): git-svn-id: svn://svn.chromium.org/blink/trunk@137880 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID:
0
104,223
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void rds_conn_message_info(struct socket *sock, unsigned int len, struct rds_info_iterator *iter, struct rds_info_lengths *lens, int want_send) { struct hlist_head *head; struct list_head *list; struct rds_connection *conn; struct rds_message *rm; unsigned int total = 0; unsigned long flags; size_t i; len /= sizeof(struct rds_info_message); rcu_read_lock(); for (i = 0, head = rds_conn_hash; i < ARRAY_SIZE(rds_conn_hash); i++, head++) { hlist_for_each_entry_rcu(conn, head, c_hash_node) { if (want_send) list = &conn->c_send_queue; else list = &conn->c_retrans; spin_lock_irqsave(&conn->c_lock, flags); /* XXX too lazy to maintain counts.. */ list_for_each_entry(rm, list, m_conn_item) { total++; if (total <= len) rds_inc_info_copy(&rm->m_inc, iter, conn->c_laddr, conn->c_faddr, 0); } spin_unlock_irqrestore(&conn->c_lock, flags); } } rcu_read_unlock(); lens->nr = total; lens->each = sizeof(struct rds_info_message); } Commit Message: RDS: fix race condition when sending a message on unbound socket Sasha's found a NULL pointer dereference in the RDS connection code when sending a message to an apparently unbound socket. The problem is caused by the code checking if the socket is bound in rds_sendmsg(), which checks the rs_bound_addr field without taking a lock on the socket. This opens a race where rs_bound_addr is temporarily set but where the transport is not in rds_bind(), leading to a NULL pointer dereference when trying to dereference 'trans' in __rds_conn_create(). Vegard wrote a reproducer for this issue, so kindly ask him to share if you're interested. I cannot reproduce the NULL pointer dereference using Vegard's reproducer with this patch, whereas I could without. Complete earlier incomplete fix to CVE-2015-6937: 74e98eb08588 ("RDS: verify the underlying transport exists before creating a connection") Cc: David S. Miller <davem@davemloft.net> Cc: stable@vger.kernel.org Reviewed-by: Vegard Nossum <vegard.nossum@oracle.com> Reviewed-by: Sasha Levin <sasha.levin@oracle.com> Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com> Signed-off-by: Quentin Casasnovas <quentin.casasnovas@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-362
0
41,937
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static struct pmcraid_cmd *pmcraid_get_free_cmd( struct pmcraid_instance *pinstance ) { struct pmcraid_cmd *cmd = NULL; unsigned long lock_flags; /* free cmd block list is protected by free_pool_lock */ spin_lock_irqsave(&pinstance->free_pool_lock, lock_flags); if (!list_empty(&pinstance->free_cmd_pool)) { cmd = list_entry(pinstance->free_cmd_pool.next, struct pmcraid_cmd, free_list); list_del(&cmd->free_list); } spin_unlock_irqrestore(&pinstance->free_pool_lock, lock_flags); /* Initialize the command block before giving it the caller */ if (cmd != NULL) pmcraid_reinit_cmdblk(cmd); return cmd; } Commit Message: [SCSI] pmcraid: reject negative request size There's a code path in pmcraid that can be reached via device ioctl that causes all sorts of ugliness, including heap corruption or triggering the OOM killer due to consecutive allocation of large numbers of pages. First, the user can call pmcraid_chr_ioctl(), with a type PMCRAID_PASSTHROUGH_IOCTL. This calls through to pmcraid_ioctl_passthrough(). Next, a pmcraid_passthrough_ioctl_buffer is copied in, and the request_size variable is set to buffer->ioarcb.data_transfer_length, which is an arbitrary 32-bit signed value provided by the user. If a negative value is provided here, bad things can happen. For example, pmcraid_build_passthrough_ioadls() is called with this request_size, which immediately calls pmcraid_alloc_sglist() with a negative size. The resulting math on allocating a scatter list can result in an overflow in the kzalloc() call (if num_elem is 0, the sglist will be smaller than expected), or if num_elem is unexpectedly large the subsequent loop will call alloc_pages() repeatedly, a high number of pages will be allocated and the OOM killer might be invoked. It looks like preventing this value from being negative in pmcraid_ioctl_passthrough() would be sufficient. Signed-off-by: Dan Rosenberg <drosenberg@vsecurity.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: James Bottomley <JBottomley@Parallels.com> CWE ID: CWE-189
0
26,447
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: content::ColorChooser* Browser::OpenColorChooser(WebContents* web_contents, int color_chooser_id, SkColor color) { #if defined(OS_WIN) if (!color_chooser_.get()) color_chooser_.reset(content::ColorChooser::Create(color_chooser_id, web_contents, color)); #else if (color_chooser_.get()) color_chooser_->End(); color_chooser_.reset(content::ColorChooser::Create(color_chooser_id, web_contents, color)); #endif return color_chooser_.get(); } Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt. BUG=107201 TEST=no visible change Review URL: https://chromiumcodereview.appspot.com/11293205 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
117,799
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: std::string MakeHtml(const std::string &txt) { std::string sRet = txt; stdreplace(sRet, "&", "&amp;"); stdreplace(sRet, "\"", "&quot;"); stdreplace(sRet, "'", "&apos;"); stdreplace(sRet, "<", "&lt;"); stdreplace(sRet, ">", "&gt;"); stdreplace(sRet, "\r\n", "<br/>"); return sRet; } Commit Message: Do not allow enters/returns in arguments (thanks to Fabio Carretto) CWE ID: CWE-93
0
90,924
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool InputDispatcher::InputState::isHovering(int32_t deviceId, uint32_t source, int32_t displayId) const { for (size_t i = 0; i < mMotionMementos.size(); i++) { const MotionMemento& memento = mMotionMementos.itemAt(i); if (memento.deviceId == deviceId && memento.source == source && memento.displayId == displayId && memento.hovering) { return true; } } return false; } Commit Message: Add new MotionEvent flag for partially obscured windows. Due to more complex window layouts resulting in lots of overlapping windows, the policy around FLAG_WINDOW_IS_OBSCURED has changed to only be set when the point at which the window was touched is obscured. Unfortunately, this doesn't prevent tapjacking attacks that overlay the dialog's text, making a potentially dangerous operation seem innocuous. To avoid this on particularly sensitive dialogs, introduce a new flag that really does tell you when your window is being even partially overlapped. We aren't exposing this as API since we plan on making the original flag more robust. This is really a workaround for system dialogs since we generally know their layout and screen position, and that they're unlikely to be overlapped by other applications. Bug: 26677796 Change-Id: I9e336afe90f262ba22015876769a9c510048fd47 CWE ID: CWE-264
0
163,786
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ContentEncoding::GetCompressionByIndex(unsigned long idx) const { const ptrdiff_t count = compression_entries_end_ - compression_entries_; assert(count >= 0); if (idx >= static_cast<unsigned long>(count)) return NULL; return compression_entries_[idx]; } Commit Message: libwebm: Pull from upstream Rolling mkvparser from upstream. Primarily for fixing a bug on parsing failures with certain Opus WebM files. Upstream commit hash of this pull: 574045edd4ecbeb802ee3f1d214b5510269852ae The diff is so huge because there were some style clean ups upstream. But it was ensured that there were no breaking changes when the style clean ups was done upstream. Change-Id: Ib6e907175484b4b0ae1b55ab39522ea3188ad039 CWE ID: CWE-119
0
164,330
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void limitedWithMissingDefaultAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) { TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); TestObjectPythonV8Internal::limitedWithMissingDefaultAttributeAttributeGetter(info); TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); } Commit Message: document.location bindings fix BUG=352374 R=jochen@chromium.org Review URL: https://codereview.chromium.org/196343011 git-svn-id: svn://svn.chromium.org/blink/trunk@169176 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-399
0
122,363
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int hwsim_fops_ps_write(void *dat, u64 val) { struct mac80211_hwsim_data *data = dat; enum ps_mode old_ps; if (val != PS_DISABLED && val != PS_ENABLED && val != PS_AUTO_POLL && val != PS_MANUAL_POLL) return -EINVAL; if (val == PS_MANUAL_POLL) { if (data->ps != PS_ENABLED) return -EINVAL; local_bh_disable(); ieee80211_iterate_active_interfaces_atomic( data->hw, IEEE80211_IFACE_ITER_NORMAL, hwsim_send_ps_poll, data); local_bh_enable(); return 0; } old_ps = data->ps; data->ps = val; local_bh_disable(); if (old_ps == PS_DISABLED && val != PS_DISABLED) { ieee80211_iterate_active_interfaces_atomic( data->hw, IEEE80211_IFACE_ITER_NORMAL, hwsim_send_nullfunc_ps, data); } else if (old_ps != PS_DISABLED && val == PS_DISABLED) { ieee80211_iterate_active_interfaces_atomic( data->hw, IEEE80211_IFACE_ITER_NORMAL, hwsim_send_nullfunc_no_ps, data); } local_bh_enable(); return 0; } Commit Message: mac80211_hwsim: fix possible memory leak in hwsim_new_radio_nl() 'hwname' is malloced in hwsim_new_radio_nl() and should be freed before leaving from the error handling cases, otherwise it will cause memory leak. Fixes: ff4dd73dd2b4 ("mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length") Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: Johannes Berg <johannes.berg@intel.com> CWE ID: CWE-772
0
83,796
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Browser::ToggleFullscreenModeWithExtension(const GURL& extension_url) { fullscreen_controller_->ToggleFullscreenModeWithExtension(extension_url); } Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt. BUG=107201 TEST=no visible change Review URL: https://chromiumcodereview.appspot.com/11293205 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
117,836
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video, libvpx_test::Encoder *encoder) { if (video->frame() == 1) { encoder->Control(VP9E_SET_TILE_COLUMNS, n_tiles_); } } Commit Message: Merge Conflict Fix CL to lmp-mr1-release for ag/849478 DO NOT MERGE - libvpx: Pull from upstream Current HEAD: 7105df53d7dc13d5e575bc8df714ec8d1da36b06 BUG=23452792 Change-Id: Ic78176fc369e0bacc71d423e0e2e6075d004aaec CWE ID: CWE-119
0
164,520
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: get_cond(const char *l, const char **t) { static const struct cond_tbl_s { char name[8]; size_t len; int cond; } cond_tbl[] = { { "if", 2, COND_IF }, { "elif", 4, COND_ELIF }, { "else", 4, COND_ELSE }, { "", 0, COND_NONE }, }; const struct cond_tbl_s *p; for (p = cond_tbl; p->len; p++) { if (strncmp(l, p->name, p->len) == 0 && isspace((unsigned char)l[p->len])) { if (t) *t = l + p->len; break; } } return p->cond; } Commit Message: CWE ID: CWE-17
0
7,392
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void SyncTest::AddOptionalTypesToCommandLine(CommandLine* cl) { if (!cl->HasSwitch(switches::kEnableSyncTabs)) cl->AppendSwitch(switches::kEnableSyncTabs); } Commit Message: [Sync] Cleanup all tab sync enabling logic now that its on by default. BUG=none TEST= Review URL: https://chromiumcodereview.appspot.com/10443046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139462 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-362
1
170,789
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl) { int status; status = nlmclnt_call(nfs_file_cred(fl->fl_file), req, NLMPROC_TEST); if (status < 0) goto out; switch (req->a_res.status) { case nlm_granted: fl->fl_type = F_UNLCK; break; case nlm_lck_denied: /* * Report the conflicting lock back to the application. */ fl->fl_start = req->a_res.lock.fl.fl_start; fl->fl_end = req->a_res.lock.fl.fl_end; fl->fl_type = req->a_res.lock.fl.fl_type; fl->fl_pid = 0; break; default: status = nlm_stat_to_errno(req->a_res.status); } out: nlmclnt_release_call(req); return status; } Commit Message: NLM: Don't hang forever on NLM unlock requests If the NLM daemon is killed on the NFS server, we can currently end up hanging forever on an 'unlock' request, instead of aborting. Basically, if the rpcbind request fails, or the server keeps returning garbage, we really want to quit instead of retrying. Tested-by: Vasily Averin <vvs@sw.ru> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Cc: stable@kernel.org CWE ID: CWE-399
0
34,876
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int kvm_set_tsc_khz(struct kvm_vcpu *vcpu, u32 this_tsc_khz) { u32 thresh_lo, thresh_hi; int use_scaling = 0; /* tsc_khz can be zero if TSC calibration fails */ if (this_tsc_khz == 0) { /* set tsc_scaling_ratio to a safe value */ vcpu->arch.tsc_scaling_ratio = kvm_default_tsc_scaling_ratio; return -1; } /* Compute a scale to convert nanoseconds in TSC cycles */ kvm_get_time_scale(this_tsc_khz, NSEC_PER_SEC / 1000, &vcpu->arch.virtual_tsc_shift, &vcpu->arch.virtual_tsc_mult); vcpu->arch.virtual_tsc_khz = this_tsc_khz; /* * Compute the variation in TSC rate which is acceptable * within the range of tolerance and decide if the * rate being applied is within that bounds of the hardware * rate. If so, no scaling or compensation need be done. */ thresh_lo = adjust_tsc_khz(tsc_khz, -tsc_tolerance_ppm); thresh_hi = adjust_tsc_khz(tsc_khz, tsc_tolerance_ppm); if (this_tsc_khz < thresh_lo || this_tsc_khz > thresh_hi) { pr_debug("kvm: requested TSC rate %u falls outside tolerance [%u,%u]\n", this_tsc_khz, thresh_lo, thresh_hi); use_scaling = 1; } return set_tsc_khz(vcpu, this_tsc_khz, use_scaling); } Commit Message: KVM: x86: Reload pit counters for all channels when restoring state Currently if userspace restores the pit counters with a count of 0 on channels 1 or 2 and the guest attempts to read the count on those channels, then KVM will perform a mod of 0 and crash. This will ensure that 0 values are converted to 65536 as per the spec. This is CVE-2015-7513. Signed-off-by: Andy Honig <ahonig@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> CWE ID:
0
57,757
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void nfs4_proc_rename_rpc_prepare(struct rpc_task *task, struct nfs_renamedata *data) { if (nfs4_setup_sequence(NFS_SERVER(data->old_dir), &data->args.seq_args, &data->res.seq_res, task)) return; rpc_call_start(task); } Commit Message: Fix length of buffer copied in __nfs4_get_acl_uncached _copy_from_pages() used to copy data from the temporary buffer to the user passed buffer is passed the wrong size parameter when copying data. res.acl_len contains both the bitmap and acl lenghts while acl_len contains the acl length after adjusting for the bitmap size. Signed-off-by: Sachin Prabhu <sprabhu@redhat.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> CWE ID: CWE-189
0
19,989
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int fuse_copy_ioctl_iovec(struct iovec *dst, void *src, size_t transferred, unsigned count, bool is_compat) { #ifdef CONFIG_COMPAT if (count * sizeof(struct compat_iovec) == transferred) { struct compat_iovec *ciov = src; unsigned i; /* * With this interface a 32bit server cannot support * non-compat (i.e. ones coming from 64bit apps) ioctl * requests */ if (!is_compat) return -EINVAL; for (i = 0; i < count; i++) { dst[i].iov_base = compat_ptr(ciov[i].iov_base); dst[i].iov_len = ciov[i].iov_len; } return 0; } #endif if (count * sizeof(struct iovec) != transferred) return -EIO; memcpy(dst, src, transferred); return 0; } Commit Message: fuse: verify ioctl retries Verify that the total length of the iovec returned in FUSE_IOCTL_RETRY doesn't overflow iov_length(). Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> CC: Tejun Heo <tj@kernel.org> CC: <stable@kernel.org> [2.6.31+] CWE ID: CWE-119
0
27,852
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: rs_filter_set_previous(RSFilter *filter, RSFilter *previous) { RS_DEBUG(FILTERS, "rs_filter_set_previous(%p, %p)", filter, previous); g_return_if_fail(RS_IS_FILTER(filter)); g_return_if_fail(RS_IS_FILTER(previous)); /* We will only set the previous filter if it differs from current previous filter */ if (filter->previous != previous) { if (filter->previous) { /* If we already got a previous filter, clean up */ filter->previous->next_filters = g_slist_remove(filter->previous->next_filters, filter); g_object_unref(filter->previous); } filter->previous = g_object_ref(previous); previous->next_filters = g_slist_append(previous->next_filters, filter); } } Commit Message: Fixes insecure use of temporary file (CVE-2014-4978). CWE ID: CWE-59
0
74,686
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int palm_os_4_probe(struct usb_serial *serial, const struct usb_device_id *id) { struct device *dev = &serial->dev->dev; struct palm_ext_connection_info *connection_info; unsigned char *transfer_buffer; int retval; transfer_buffer = kmalloc(sizeof(*connection_info), GFP_KERNEL); if (!transfer_buffer) return -ENOMEM; retval = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), PALM_GET_EXT_CONNECTION_INFORMATION, 0xc2, 0x0000, 0x0000, transfer_buffer, sizeof(*connection_info), 300); if (retval < 0) dev_err(dev, "%s - error %d getting connection info\n", __func__, retval); else usb_serial_debug_data(dev, __func__, retval, transfer_buffer); kfree(transfer_buffer); return 0; } Commit Message: USB: visor: fix null-deref at probe Fix null-pointer dereference at probe should a (malicious) Treo device lack the expected endpoints. Specifically, the Treo port-setup hack was dereferencing the bulk-in and interrupt-in urbs without first making sure they had been allocated by core. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable <stable@vger.kernel.org> Signed-off-by: Johan Hovold <johan@kernel.org> CWE ID:
0
54,565
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, u64 dir, const char *name, u16 name_len, int mod) { int ret; struct btrfs_key key; int ins_len = mod < 0 ? -1 : 0; int cow = mod != 0; key.objectid = dir; key.type = BTRFS_XATTR_ITEM_KEY; key.offset = btrfs_name_hash(name, name_len); ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); if (ret < 0) return ERR_PTR(ret); if (ret > 0) return NULL; return btrfs_match_dir_item_name(root, path, name, name_len); } Commit Message: Btrfs: make xattr replace operations atomic Replacing a xattr consists of doing a lookup for its existing value, delete the current value from the respective leaf, release the search path and then finally insert the new value. This leaves a time window where readers (getxattr, listxattrs) won't see any value for the xattr. Xattrs are used to store ACLs, so this has security implications. This change also fixes 2 other existing issues which were: *) Deleting the old xattr value without verifying first if the new xattr will fit in the existing leaf item (in case multiple xattrs are packed in the same item due to name hash collision); *) Returning -EEXIST when the flag XATTR_CREATE is given and the xattr doesn't exist but we have have an existing item that packs muliple xattrs with the same name hash as the input xattr. In this case we should return ENOSPC. A test case for xfstests follows soon. Thanks to Alexandre Oliva for reporting the non-atomicity of the xattr replace implementation. Reported-by: Alexandre Oliva <oliva@gnu.org> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Chris Mason <clm@fb.com> CWE ID: CWE-362
0
45,387
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool AuthenticatorTimeoutErrorModel::IsBackButtonVisible() const { return false; } Commit Message: chrome/browser/ui/webauthn: long domains may cause a line break. As requested by UX in [1], allow long host names to split a title into two lines. This allows us to show more of the name before eliding, although sufficiently long names will still trigger elision. Screenshot at https://drive.google.com/open?id=1_V6t2CeZDAVazy3Px-OET2LnB__aEW1r. [1] https://docs.google.com/presentation/d/1TtxkPUchyVZulqgdMcfui-68B0W-DWaFFVJEffGIbLA/edit#slide=id.g5913c4105f_1_12 Change-Id: I70f6541e0db3e9942239304de43b487a7561ca34 Bug: 870892 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1601812 Auto-Submit: Adam Langley <agl@chromium.org> Commit-Queue: Nina Satragno <nsatragno@chromium.org> Reviewed-by: Nina Satragno <nsatragno@chromium.org> Cr-Commit-Position: refs/heads/master@{#658114} CWE ID: CWE-119
0
142,968
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void UsbSetConfigurationFunction::OnComplete(bool success) { if (success) { Respond(NoArguments()); } else { Respond(Error(kErrorCannotSetConfiguration)); } } Commit Message: Remove fallback when requesting a single USB interface. This reverts commit 2d475d0ed37bf8f19385537ad31e361f1b21624b. The permission broker now supports opening devices that are partially claimed through the OpenPath method and RequestPathAccess will always fail for these devices so the fallback path from RequestPathAccess to OpenPath is always taken. BUG=500057 Review URL: https://codereview.chromium.org/1227313003 Cr-Commit-Position: refs/heads/master@{#338354} CWE ID: CWE-399
0
123,383
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int BluetoothSocketListenUsingL2capFunction::socket_id() const { return params_->socket_id; } Commit Message: chrome.bluetoothSocket: Fix regression in send() In https://crrev.com/c/997098, params_ was changed to a local variable, but it needs to last longer than that since net::WrappedIOBuffer may use the data after the local variable goes out of scope. This CL changed it back to be an instance variable. Bug: 851799 Change-Id: I392f8acaef4c6473d6ea4fbee7209445aa09112e Reviewed-on: https://chromium-review.googlesource.com/1103676 Reviewed-by: Toni Barzic <tbarzic@chromium.org> Commit-Queue: Sonny Sasaka <sonnysasaka@chromium.org> Cr-Commit-Position: refs/heads/master@{#568137} CWE ID: CWE-416
0
154,092
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: server_away_find_message (server *serv, char *nick) { struct away_msg *away; GSList *list = away_list; while (list) { away = (struct away_msg *) list->data; if (away->server == serv && !serv->p_cmp (nick, away->nick)) return away; list = list->next; } return NULL; } Commit Message: ssl: Validate hostnames Closes #524 CWE ID: CWE-310
0
58,440
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void init_vmcb(struct vcpu_svm *svm) { struct vmcb_control_area *control = &svm->vmcb->control; struct vmcb_save_area *save = &svm->vmcb->save; svm->vcpu.fpu_active = 1; svm->vcpu.arch.hflags = 0; set_cr_intercept(svm, INTERCEPT_CR0_READ); set_cr_intercept(svm, INTERCEPT_CR3_READ); set_cr_intercept(svm, INTERCEPT_CR4_READ); set_cr_intercept(svm, INTERCEPT_CR0_WRITE); set_cr_intercept(svm, INTERCEPT_CR3_WRITE); set_cr_intercept(svm, INTERCEPT_CR4_WRITE); set_cr_intercept(svm, INTERCEPT_CR8_WRITE); set_dr_intercepts(svm); set_exception_intercept(svm, PF_VECTOR); set_exception_intercept(svm, UD_VECTOR); set_exception_intercept(svm, MC_VECTOR); set_intercept(svm, INTERCEPT_INTR); set_intercept(svm, INTERCEPT_NMI); set_intercept(svm, INTERCEPT_SMI); set_intercept(svm, INTERCEPT_SELECTIVE_CR0); set_intercept(svm, INTERCEPT_RDPMC); set_intercept(svm, INTERCEPT_CPUID); set_intercept(svm, INTERCEPT_INVD); set_intercept(svm, INTERCEPT_HLT); set_intercept(svm, INTERCEPT_INVLPG); set_intercept(svm, INTERCEPT_INVLPGA); set_intercept(svm, INTERCEPT_IOIO_PROT); set_intercept(svm, INTERCEPT_MSR_PROT); set_intercept(svm, INTERCEPT_TASK_SWITCH); set_intercept(svm, INTERCEPT_SHUTDOWN); set_intercept(svm, INTERCEPT_VMRUN); set_intercept(svm, INTERCEPT_VMMCALL); set_intercept(svm, INTERCEPT_VMLOAD); set_intercept(svm, INTERCEPT_VMSAVE); set_intercept(svm, INTERCEPT_STGI); set_intercept(svm, INTERCEPT_CLGI); set_intercept(svm, INTERCEPT_SKINIT); set_intercept(svm, INTERCEPT_WBINVD); set_intercept(svm, INTERCEPT_MONITOR); set_intercept(svm, INTERCEPT_MWAIT); set_intercept(svm, INTERCEPT_XSETBV); control->iopm_base_pa = iopm_base; control->msrpm_base_pa = __pa(svm->msrpm); control->int_ctl = V_INTR_MASKING_MASK; init_seg(&save->es); init_seg(&save->ss); init_seg(&save->ds); init_seg(&save->fs); init_seg(&save->gs); save->cs.selector = 0xf000; save->cs.base = 0xffff0000; /* Executable/Readable Code Segment */ save->cs.attrib = SVM_SELECTOR_READ_MASK | SVM_SELECTOR_P_MASK | SVM_SELECTOR_S_MASK | SVM_SELECTOR_CODE_MASK; save->cs.limit = 0xffff; save->gdtr.limit = 0xffff; save->idtr.limit = 0xffff; init_sys_seg(&save->ldtr, SEG_TYPE_LDT); init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16); svm_set_efer(&svm->vcpu, 0); save->dr6 = 0xffff0ff0; kvm_set_rflags(&svm->vcpu, 2); save->rip = 0x0000fff0; svm->vcpu.arch.regs[VCPU_REGS_RIP] = save->rip; /* * svm_set_cr0() sets PG and WP and clears NW and CD on save->cr0. * It also updates the guest-visible cr0 value. */ svm_set_cr0(&svm->vcpu, X86_CR0_NW | X86_CR0_CD | X86_CR0_ET); kvm_mmu_reset_context(&svm->vcpu); save->cr4 = X86_CR4_PAE; /* rdx = ?? */ if (npt_enabled) { /* Setup VMCB for Nested Paging */ control->nested_ctl = 1; clr_intercept(svm, INTERCEPT_INVLPG); clr_exception_intercept(svm, PF_VECTOR); clr_cr_intercept(svm, INTERCEPT_CR3_READ); clr_cr_intercept(svm, INTERCEPT_CR3_WRITE); save->g_pat = svm->vcpu.arch.pat; save->cr3 = 0; save->cr4 = 0; } svm->asid_generation = 0; svm->nested.vmcb = 0; svm->vcpu.arch.hflags = 0; if (boot_cpu_has(X86_FEATURE_PAUSEFILTER)) { control->pause_filter_count = 3000; set_intercept(svm, INTERCEPT_PAUSE); } mark_all_dirty(svm->vmcb); enable_gif(svm); } Commit Message: KVM: x86: work around infinite loop in microcode when #AC is delivered It was found that a guest can DoS a host by triggering an infinite stream of "alignment check" (#AC) exceptions. This causes the microcode to enter an infinite loop where the core never receives another interrupt. The host kernel panics pretty quickly due to the effects (CVE-2015-5307). Signed-off-by: Eric Northup <digitaleric@google.com> Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> CWE ID: CWE-399
1
166,598
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int usb_find_common_endpoints(struct usb_host_interface *alt, struct usb_endpoint_descriptor **bulk_in, struct usb_endpoint_descriptor **bulk_out, struct usb_endpoint_descriptor **int_in, struct usb_endpoint_descriptor **int_out) { struct usb_endpoint_descriptor *epd; int i; if (bulk_in) *bulk_in = NULL; if (bulk_out) *bulk_out = NULL; if (int_in) *int_in = NULL; if (int_out) *int_out = NULL; for (i = 0; i < alt->desc.bNumEndpoints; ++i) { epd = &alt->endpoint[i].desc; if (match_endpoint(epd, bulk_in, bulk_out, int_in, int_out)) return 0; } return -ENXIO; } Commit Message: USB: check usb_get_extra_descriptor for proper size When reading an extra descriptor, we need to properly check the minimum and maximum size allowed, to prevent from invalid data being sent by a device. Reported-by: Hui Peng <benquike@gmail.com> Reported-by: Mathias Payer <mathias.payer@nebelwelt.net> Co-developed-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Hui Peng <benquike@gmail.com> Signed-off-by: Mathias Payer <mathias.payer@nebelwelt.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> CWE ID: CWE-400
0
75,556
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Document::addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> consoleMessage) { if (!isContextThread()) { m_taskRunner->postTask(FROM_HERE, AddConsoleMessageTask::create(consoleMessage->source(), consoleMessage->level(), consoleMessage->message())); return; } if (!m_frame) return; if (!consoleMessage->scriptState() && consoleMessage->url().isNull() && !consoleMessage->lineNumber()) { consoleMessage->setURL(url().string()); if (!isInDocumentWrite() && scriptableDocumentParser()) { ScriptableDocumentParser* parser = scriptableDocumentParser(); if (parser->isParsingAtLineNumber()) consoleMessage->setLineNumber(parser->lineNumber().oneBasedInt()); } } m_frame->console().addMessage(consoleMessage); } Commit Message: Don't change Document load progress in any page dismissal events. This can confuse the logic for blocking modal dialogs. BUG=536652 Review URL: https://codereview.chromium.org/1373113002 Cr-Commit-Position: refs/heads/master@{#351419} CWE ID: CWE-20
0
125,271
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int UnpackWPG2Raster(Image *image,int bpp) { int XorMe = 0; int RunCount; size_t x, y; ssize_t i, ldblk; unsigned int SampleSize=1; unsigned char bbuf, *BImgBuff, SampleBuffer[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; x=0; y=0; ldblk=(ssize_t) ((bpp*image->columns+7)/8); BImgBuff=(unsigned char *) AcquireQuantumMemory((size_t) ldblk, sizeof(*BImgBuff)); if(BImgBuff==NULL) return(-2); while( y< image->rows) { bbuf=ReadBlobByte(image); switch(bbuf) { case 0x7D: SampleSize=ReadBlobByte(image); /* DSZ */ if(SampleSize>8) { BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); return(-2); } if(SampleSize<1) { BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); return(-2); } break; case 0x7E: (void) FormatLocaleFile(stderr, "\nUnsupported WPG token XOR, please report!"); XorMe=!XorMe; break; case 0x7F: RunCount=ReadBlobByte(image); /* BLK */ if (RunCount < 0) break; for(i=0; i < SampleSize*(RunCount+1); i++) { InsertByte6(0); } break; case 0xFD: RunCount=ReadBlobByte(image); /* EXT */ if (RunCount < 0) break; for(i=0; i<= RunCount;i++) for(bbuf=0; bbuf < SampleSize; bbuf++) InsertByte6(SampleBuffer[bbuf]); break; case 0xFE: RunCount=ReadBlobByte(image); /* RST */ if (RunCount < 0) break; if(x!=0) { (void) FormatLocaleFile(stderr, "\nUnsupported WPG2 unaligned token RST x=%.20g, please report!\n" ,(double) x); BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); return(-3); } { /* duplicate the previous row RunCount x */ for(i=0;i<=RunCount;i++) { if (InsertRow(BImgBuff,(ssize_t) (image->rows >= y ? y : image->rows-1), image,bpp) != MagickFalse) y++; } } break; case 0xFF: RunCount=ReadBlobByte(image); /* WHT */ if (RunCount < 0) break; for (i=0; i < SampleSize*(RunCount+1); i++) { InsertByte6(0xFF); } break; default: RunCount=bbuf & 0x7F; if(bbuf & 0x80) /* REP */ { for(i=0; i < SampleSize; i++) SampleBuffer[i]=ReadBlobByte(image); for(i=0;i<=RunCount;i++) for(bbuf=0;bbuf<SampleSize;bbuf++) InsertByte6(SampleBuffer[bbuf]); } else { /* NRP */ for(i=0; i< SampleSize*(RunCount+1);i++) { bbuf=ReadBlobByte(image); InsertByte6(bbuf); } } } if (EOFBlob(image) != MagickFalse) break; } BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); return(0); } Commit Message: https://github.com/ImageMagick/ImageMagick/issues/851 CWE ID: CWE-119
0
95,077
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, uint16_t *refcount_table, int refcount_table_size, int64_t l2_offset, int flags) { BDRVQcowState *s = bs->opaque; uint64_t *l2_table, l2_entry; uint64_t next_contiguous_offset = 0; int i, l2_size, nb_csectors; /* Read L2 table from disk */ l2_size = s->l2_size * sizeof(uint64_t); l2_table = g_malloc(l2_size); if (bdrv_pread(bs->file, l2_offset, l2_table, l2_size) != l2_size) goto fail; /* Do the actual checks */ for(i = 0; i < s->l2_size; i++) { l2_entry = be64_to_cpu(l2_table[i]); switch (qcow2_get_cluster_type(l2_entry)) { case QCOW2_CLUSTER_COMPRESSED: /* Compressed clusters don't have QCOW_OFLAG_COPIED */ if (l2_entry & QCOW_OFLAG_COPIED) { fprintf(stderr, "ERROR: cluster %" PRId64 ": " "copied flag must never be set for compressed " "clusters\n", l2_entry >> s->cluster_bits); l2_entry &= ~QCOW_OFLAG_COPIED; res->corruptions++; } /* Mark cluster as used */ nb_csectors = ((l2_entry >> s->csize_shift) & s->csize_mask) + 1; l2_entry &= s->cluster_offset_mask; inc_refcounts(bs, res, refcount_table, refcount_table_size, l2_entry & ~511, nb_csectors * 512); if (flags & CHECK_FRAG_INFO) { res->bfi.allocated_clusters++; res->bfi.compressed_clusters++; /* Compressed clusters are fragmented by nature. Since they * take up sub-sector space but we only have sector granularity * I/O we need to re-read the same sectors even for adjacent * compressed clusters. */ res->bfi.fragmented_clusters++; } break; case QCOW2_CLUSTER_ZERO: if ((l2_entry & L2E_OFFSET_MASK) == 0) { break; } /* fall through */ case QCOW2_CLUSTER_NORMAL: { uint64_t offset = l2_entry & L2E_OFFSET_MASK; if (flags & CHECK_FRAG_INFO) { res->bfi.allocated_clusters++; if (next_contiguous_offset && offset != next_contiguous_offset) { res->bfi.fragmented_clusters++; } next_contiguous_offset = offset + s->cluster_size; } /* Mark cluster as used */ inc_refcounts(bs, res, refcount_table,refcount_table_size, offset, s->cluster_size); /* Correct offsets are cluster aligned */ if (offset_into_cluster(s, offset)) { fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not " "properly aligned; L2 entry corrupted.\n", offset); res->corruptions++; } break; } case QCOW2_CLUSTER_UNALLOCATED: break; default: abort(); } } g_free(l2_table); return 0; fail: fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n"); g_free(l2_table); return -EIO; } Commit Message: CWE ID: CWE-190
0
16,802
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void write_mmcr0(struct cpu_hw_events *cpuhw, unsigned long mmcr0) { unsigned long pmc5, pmc6; if (!cpuhw->n_limited) { mtspr(SPRN_MMCR0, mmcr0); return; } /* * Write MMCR0, then read PMC5 and PMC6 immediately. * To ensure we don't get a performance monitor interrupt * between writing MMCR0 and freezing/thawing the limited * events, we first write MMCR0 with the event overflow * interrupt enable bits turned off. */ asm volatile("mtspr %3,%2; mfspr %0,%4; mfspr %1,%5" : "=&r" (pmc5), "=&r" (pmc6) : "r" (mmcr0 & ~(MMCR0_PMC1CE | MMCR0_PMCjCE)), "i" (SPRN_MMCR0), "i" (SPRN_PMC5), "i" (SPRN_PMC6)); if (mmcr0 & MMCR0_FC) freeze_limited_counters(cpuhw, pmc5, pmc6); else thaw_limited_counters(cpuhw, pmc5, pmc6); /* * Write the full MMCR0 including the event overflow interrupt * enable bits, if necessary. */ if (mmcr0 & (MMCR0_PMC1CE | MMCR0_PMCjCE)) mtspr(SPRN_MMCR0, mmcr0); } Commit Message: perf, powerpc: Handle events that raise an exception without overflowing Events on POWER7 can roll back if a speculative event doesn't eventually complete. Unfortunately in some rare cases they will raise a performance monitor exception. We need to catch this to ensure we reset the PMC. In all cases the PMC will be 256 or less cycles from overflow. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: <stable@kernel.org> # as far back as it applies cleanly LKML-Reference: <20110309143842.6c22845e@kryten> Signed-off-by: Ingo Molnar <mingo@elte.hu> CWE ID: CWE-189
0
22,709
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: BOOL security_encrypt(BYTE* data, int length, rdpRdp* rdp) { if (rdp->encrypt_use_count >= 4096) { security_key_update(rdp->encrypt_key, rdp->encrypt_update_key, rdp->rc4_key_len); crypto_rc4_free(rdp->rc4_encrypt_key); rdp->rc4_encrypt_key = crypto_rc4_init(rdp->encrypt_key, rdp->rc4_key_len); rdp->encrypt_use_count = 0; } crypto_rc4(rdp->rc4_encrypt_key, length, data, data); rdp->encrypt_use_count++; rdp->encrypt_checksum_use_count++; return TRUE; } Commit Message: security: add a NULL pointer check to fix a server crash. CWE ID: CWE-476
0
58,656
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: IOThread::Globals::Globals() : system_request_context_leak_checker(this), ignore_certificate_errors(false), http_pipelining_enabled(false), testing_fixed_http_port(0), testing_fixed_https_port(0), enable_user_alternate_protocol_ports(false) { } Commit Message: Added daily UMA for non-data-reduction-proxy data usage when the proxy is enabled. BUG=325325 Review URL: https://codereview.chromium.org/106113002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239897 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-416
0
113,512
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void nfs4_schedule_state_recovery(struct nfs_client *clp) { if (!clp) return; if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) set_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state); nfs4_schedule_state_manager(clp); } Commit Message: NFSv4: Convert the open and close ops to use fmode Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> CWE ID:
0
22,956
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void perf_event_enable_on_exec(int ctxn) { struct perf_event_context *ctx, *clone_ctx = NULL; enum event_type_t event_type = 0; struct perf_cpu_context *cpuctx; struct perf_event *event; unsigned long flags; int enabled = 0; local_irq_save(flags); ctx = current->perf_event_ctxp[ctxn]; if (!ctx || !ctx->nr_events) goto out; cpuctx = __get_cpu_context(ctx); perf_ctx_lock(cpuctx, ctx); ctx_sched_out(ctx, cpuctx, EVENT_TIME); list_for_each_entry(event, &ctx->event_list, event_entry) { enabled |= event_enable_on_exec(event, ctx); event_type |= get_event_type(event); } /* * Unclone and reschedule this context if we enabled any event. */ if (enabled) { clone_ctx = unclone_ctx(ctx); ctx_resched(cpuctx, ctx, event_type); } else { ctx_sched_in(ctx, cpuctx, EVENT_TIME, current); } perf_ctx_unlock(cpuctx, ctx); out: local_irq_restore(flags); if (clone_ctx) put_ctx(clone_ctx); } Commit Message: perf/core: Fix the perf_cpu_time_max_percent check Use "proc_dointvec_minmax" instead of "proc_dointvec" to check the input value from user-space. If not, we can set a big value and some vars will overflow like "sysctl_perf_event_sample_rate" which will cause a lot of unexpected problems. Signed-off-by: Tan Xiaojun <tanxiaojun@huawei.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: <acme@kernel.org> Cc: <alexander.shishkin@linux.intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Link: http://lkml.kernel.org/r/1487829879-56237-1-git-send-email-tanxiaojun@huawei.com Signed-off-by: Ingo Molnar <mingo@kernel.org> CWE ID: CWE-190
0
85,220
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void WebURLLoaderImpl::loadAsynchronously(const WebURLRequest& request, WebURLLoaderClient* client) { DCHECK(!context_->client()); context_->set_client(client); context_->Start(request, NULL, platform_); } Commit Message: Protect WebURLLoaderImpl::Context while receiving responses. A client's didReceiveResponse can cancel a request; by protecting the Context we avoid a use after free in this case. Interestingly, we really had very good warning about this problem, see https://codereview.chromium.org/11900002/ back in January. R=darin BUG=241139 Review URL: https://chromiumcodereview.appspot.com/15738007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202821 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-416
0
113,076
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void impeg2d_dec_seq_disp_ext(dec_state_t *ps_dec) { stream_t *ps_stream; ps_stream = &ps_dec->s_bit_stream; /* sequence_display_extension() { extension_start_code_identifier 4 video_format 3 colour_description 1 if (colour_description) { colour_primaries 8 transfer_characteristics 8 matrix_coefficients 8 } display_horizontal_size 14 marker_bit 1 display_vertical_size 14 next_start_code() } */ impeg2d_bit_stream_get(ps_stream,7); if (impeg2d_bit_stream_get_bit(ps_stream) == 1) { impeg2d_bit_stream_get(ps_stream,24); } /* display_horizontal_size and display_vertical_size */ ps_dec->u2_display_horizontal_size = impeg2d_bit_stream_get(ps_stream,14);; GET_MARKER_BIT(ps_dec,ps_stream); ps_dec->u2_display_vertical_size = impeg2d_bit_stream_get(ps_stream,14); impeg2d_next_start_code(ps_dec); } Commit Message: Fix for handling streams which resulted in negative num_mbs_left Bug: 26070014 Change-Id: Id9f063a2c72a802d991b92abaf00ec687db5bb0f CWE ID: CWE-119
0
161,599
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void cmdloop(void) { int c; int usinguid, havepartition, havenamespace, recursive; static struct buf tag, cmd, arg1, arg2, arg3; char *p, shut[MAX_MAILBOX_PATH+1], cmdname[100]; const char *err; const char * commandmintimer; double commandmintimerd = 0.0; struct sync_reserve_list *reserve_list = sync_reserve_list_create(SYNC_MESSAGE_LIST_HASH_SIZE); struct applepushserviceargs applepushserviceargs; prot_printf(imapd_out, "* OK [CAPABILITY "); capa_response(CAPA_PREAUTH); prot_printf(imapd_out, "]"); if (config_serverinfo) prot_printf(imapd_out, " %s", config_servername); if (config_serverinfo == IMAP_ENUM_SERVERINFO_ON) { prot_printf(imapd_out, " Cyrus IMAP %s", cyrus_version()); } prot_printf(imapd_out, " server ready\r\n"); /* clear cancelled flag if present before the next command */ cmd_cancelled(); motd_file(); /* Get command timer logging paramater. This string * is a time in seconds. Any command that takes >= * this time to execute is logged */ commandmintimer = config_getstring(IMAPOPT_COMMANDMINTIMER); cmdtime_settimer(commandmintimer ? 1 : 0); if (commandmintimer) { commandmintimerd = atof(commandmintimer); } for (;;) { /* Release any held index */ index_release(imapd_index); /* Flush any buffered output */ prot_flush(imapd_out); if (backend_current) prot_flush(backend_current->out); /* command no longer running */ proc_register(config_ident, imapd_clienthost, imapd_userid, index_mboxname(imapd_index), NULL); /* Check for shutdown file */ if ( !imapd_userisadmin && imapd_userid && (shutdown_file(shut, sizeof(shut)) || userdeny(imapd_userid, config_ident, shut, sizeof(shut)))) { for (p = shut; *p == '['; p++); /* can't have [ be first char */ prot_printf(imapd_out, "* BYE [ALERT] %s\r\n", p); telemetry_rusage(imapd_userid); shut_down(0); } signals_poll(); if (!proxy_check_input(protin, imapd_in, imapd_out, backend_current ? backend_current->in : NULL, NULL, 0)) { /* No input from client */ continue; } /* Parse tag */ c = getword(imapd_in, &tag); if (c == EOF) { if ((err = prot_error(imapd_in))!=NULL && strcmp(err, PROT_EOF_STRING)) { syslog(LOG_WARNING, "%s, closing connection", err); prot_printf(imapd_out, "* BYE %s\r\n", err); } goto done; } if (c != ' ' || !imparse_isatom(tag.s) || (tag.s[0] == '*' && !tag.s[1])) { prot_printf(imapd_out, "* BAD Invalid tag\r\n"); eatline(imapd_in, c); continue; } /* Parse command name */ c = getword(imapd_in, &cmd); if (!cmd.s[0]) { prot_printf(imapd_out, "%s BAD Null command\r\n", tag.s); eatline(imapd_in, c); continue; } lcase(cmd.s); xstrncpy(cmdname, cmd.s, 99); cmd.s[0] = toupper((unsigned char) cmd.s[0]); if (config_getswitch(IMAPOPT_CHATTY)) syslog(LOG_NOTICE, "command: %s %s", tag.s, cmd.s); proc_register(config_ident, imapd_clienthost, imapd_userid, index_mboxname(imapd_index), cmd.s); /* if we need to force a kick, do so */ if (referral_kick) { kick_mupdate(); referral_kick = 0; } if (plaintextloginalert) { prot_printf(imapd_out, "* OK [ALERT] %s\r\n", plaintextloginalert); plaintextloginalert = NULL; } /* Only Authenticate/Enable/Login/Logout/Noop/Capability/Id/Starttls allowed when not logged in */ if (!imapd_userid && !strchr("AELNCIS", cmd.s[0])) goto nologin; /* Start command timer */ cmdtime_starttimer(); /* note that about half the commands (the common ones that don't hit the mailboxes file) now close the mailboxes file just in case it was open. */ switch (cmd.s[0]) { case 'A': if (!strcmp(cmd.s, "Authenticate")) { int haveinitresp = 0; if (c != ' ') goto missingargs; c = getword(imapd_in, &arg1); if (!imparse_isatom(arg1.s)) { prot_printf(imapd_out, "%s BAD Invalid authenticate mechanism\r\n", tag.s); eatline(imapd_in, c); continue; } if (c == ' ') { haveinitresp = 1; c = getword(imapd_in, &arg2); if (c == EOF) goto missingargs; } if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; if (imapd_userid) { prot_printf(imapd_out, "%s BAD Already authenticated\r\n", tag.s); continue; } cmd_authenticate(tag.s, arg1.s, haveinitresp ? arg2.s : NULL); snmp_increment(AUTHENTICATE_COUNT, 1); } else if (!imapd_userid) goto nologin; else if (!strcmp(cmd.s, "Append")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; cmd_append(tag.s, arg1.s, NULL); snmp_increment(APPEND_COUNT, 1); } else goto badcmd; break; case 'C': if (!strcmp(cmd.s, "Capability")) { if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_capability(tag.s); snmp_increment(CAPABILITY_COUNT, 1); } else if (!imapd_userid) goto nologin; #ifdef HAVE_ZLIB else if (!strcmp(cmd.s, "Compress")) { if (c != ' ') goto missingargs; c = getword(imapd_in, &arg1); if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_compress(tag.s, arg1.s); snmp_increment(COMPRESS_COUNT, 1); } #endif /* HAVE_ZLIB */ else if (!strcmp(cmd.s, "Check")) { if (!imapd_index && !backend_current) goto nomailbox; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_noop(tag.s, cmd.s); snmp_increment(CHECK_COUNT, 1); } else if (!strcmp(cmd.s, "Copy")) { if (!imapd_index && !backend_current) goto nomailbox; usinguid = 0; if (c != ' ') goto missingargs; copy: c = getword(imapd_in, &arg1); if (c == '\r') goto missingargs; if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence; c = getastring(imapd_in, imapd_out, &arg2); if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_copy(tag.s, arg1.s, arg2.s, usinguid, /*ismove*/0); snmp_increment(COPY_COUNT, 1); } else if (!strcmp(cmd.s, "Create")) { struct dlist *extargs = NULL; if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto missingargs; if (c == ' ') { c = parsecreateargs(&extargs); if (c == EOF) goto badpartition; } if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_create(tag.s, arg1.s, extargs, 0); dlist_free(&extargs); snmp_increment(CREATE_COUNT, 1); } else if (!strcmp(cmd.s, "Close")) { if (!imapd_index && !backend_current) goto nomailbox; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_close(tag.s, cmd.s); snmp_increment(CLOSE_COUNT, 1); } else goto badcmd; break; case 'D': if (!strcmp(cmd.s, "Delete")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_delete(tag.s, arg1.s, 0, 0); snmp_increment(DELETE_COUNT, 1); } else if (!strcmp(cmd.s, "Deleteacl")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg2); if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_setacl(tag.s, arg1.s, arg2.s, NULL); snmp_increment(DELETEACL_COUNT, 1); } else if (!strcmp(cmd.s, "Dump")) { int uid_start = 0; if(c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if(c == ' ') { c = getastring(imapd_in, imapd_out, &arg2); if(!imparse_isnumber(arg2.s)) goto extraargs; uid_start = atoi(arg2.s); } if(c == '\r') c = prot_getc(imapd_in); if(c != '\n') goto extraargs; cmd_dump(tag.s, arg1.s, uid_start); /* snmp_increment(DUMP_COUNT, 1);*/ } else goto badcmd; break; case 'E': if (!imapd_userid) goto nologin; else if (!strcmp(cmd.s, "Enable")) { if (c != ' ') goto missingargs; cmd_enable(tag.s); } else if (!strcmp(cmd.s, "Expunge")) { if (!imapd_index && !backend_current) goto nomailbox; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_expunge(tag.s, 0); snmp_increment(EXPUNGE_COUNT, 1); } else if (!strcmp(cmd.s, "Examine")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto missingargs; prot_ungetc(c, imapd_in); cmd_select(tag.s, cmd.s, arg1.s); snmp_increment(EXAMINE_COUNT, 1); } else goto badcmd; break; case 'F': if (!strcmp(cmd.s, "Fetch")) { if (!imapd_index && !backend_current) goto nomailbox; usinguid = 0; if (c != ' ') goto missingargs; fetch: c = getword(imapd_in, &arg1); if (c == '\r') goto missingargs; if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence; cmd_fetch(tag.s, arg1.s, usinguid); snmp_increment(FETCH_COUNT, 1); } else goto badcmd; break; case 'G': if (!strcmp(cmd.s, "Getacl")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_getacl(tag.s, arg1.s); snmp_increment(GETACL_COUNT, 1); } else if (!strcmp(cmd.s, "Getannotation")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; cmd_getannotation(tag.s, arg1.s); snmp_increment(GETANNOTATION_COUNT, 1); } else if (!strcmp(cmd.s, "Getmetadata")) { if (c != ' ') goto missingargs; cmd_getmetadata(tag.s); snmp_increment(GETANNOTATION_COUNT, 1); } else if (!strcmp(cmd.s, "Getquota")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_getquota(tag.s, arg1.s); snmp_increment(GETQUOTA_COUNT, 1); } else if (!strcmp(cmd.s, "Getquotaroot")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_getquotaroot(tag.s, arg1.s); snmp_increment(GETQUOTAROOT_COUNT, 1); } #ifdef HAVE_SSL else if (!strcmp(cmd.s, "Genurlauth")) { if (c != ' ') goto missingargs; cmd_genurlauth(tag.s); /* snmp_increment(GENURLAUTH_COUNT, 1);*/ } #endif else goto badcmd; break; case 'I': if (!strcmp(cmd.s, "Id")) { if (c != ' ') goto missingargs; cmd_id(tag.s); snmp_increment(ID_COUNT, 1); } else if (!imapd_userid) goto nologin; else if (!strcmp(cmd.s, "Idle") && idle_enabled()) { if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_idle(tag.s); snmp_increment(IDLE_COUNT, 1); } else goto badcmd; break; case 'L': if (!strcmp(cmd.s, "Login")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if(c != ' ') goto missingargs; cmd_login(tag.s, arg1.s); snmp_increment(LOGIN_COUNT, 1); } else if (!strcmp(cmd.s, "Logout")) { if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; snmp_increment(LOGOUT_COUNT, 1); /* force any responses from our selected backend */ if (backend_current) imapd_check(NULL, 0); prot_printf(imapd_out, "* BYE %s\r\n", error_message(IMAP_BYE_LOGOUT)); prot_printf(imapd_out, "%s OK %s\r\n", tag.s, error_message(IMAP_OK_COMPLETED)); if (imapd_userid && *imapd_userid) { telemetry_rusage(imapd_userid); } goto done; } else if (!imapd_userid) goto nologin; else if (!strcmp(cmd.s, "List")) { struct listargs listargs; if (c != ' ') goto missingargs; memset(&listargs, 0, sizeof(struct listargs)); listargs.ret = LIST_RET_CHILDREN; getlistargs(tag.s, &listargs); if (listargs.pat.count) cmd_list(tag.s, &listargs); snmp_increment(LIST_COUNT, 1); } else if (!strcmp(cmd.s, "Lsub")) { struct listargs listargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg2); if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; memset(&listargs, 0, sizeof(struct listargs)); listargs.cmd = LIST_CMD_LSUB; listargs.sel = LIST_SEL_SUBSCRIBED; if (!strcasecmpsafe(imapd_magicplus, "+dav")) listargs.sel |= LIST_SEL_DAV; listargs.ref = arg1.s; strarray_append(&listargs.pat, arg2.s); cmd_list(tag.s, &listargs); snmp_increment(LSUB_COUNT, 1); } else if (!strcmp(cmd.s, "Listrights")) { c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg2); if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_listrights(tag.s, arg1.s, arg2.s); snmp_increment(LISTRIGHTS_COUNT, 1); } else if (!strcmp(cmd.s, "Localappend")) { /* create a local-only mailbox */ if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg2); if (c != ' ') goto missingargs; cmd_append(tag.s, arg1.s, *arg2.s ? arg2.s : NULL); snmp_increment(APPEND_COUNT, 1); } else if (!strcmp(cmd.s, "Localcreate")) { /* create a local-only mailbox */ struct dlist *extargs = NULL; if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto missingargs; if (c == ' ') { c = parsecreateargs(&extargs); if (c == EOF) goto badpartition; } if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_create(tag.s, arg1.s, extargs, 1); dlist_free(&extargs); /* xxxx snmp_increment(CREATE_COUNT, 1); */ } else if (!strcmp(cmd.s, "Localdelete")) { /* delete a mailbox locally only */ if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_delete(tag.s, arg1.s, 1, 1); /* xxxx snmp_increment(DELETE_COUNT, 1); */ } else goto badcmd; break; case 'M': if (!strcmp(cmd.s, "Myrights")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_myrights(tag.s, arg1.s); /* xxxx snmp_increment(MYRIGHTS_COUNT, 1); */ } else if (!strcmp(cmd.s, "Mupdatepush")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if(c == EOF) goto missingargs; if(c == '\r') c = prot_getc(imapd_in); if(c != '\n') goto extraargs; cmd_mupdatepush(tag.s, arg1.s); /* xxxx snmp_increment(MUPDATEPUSH_COUNT, 1); */ } else if (!strcmp(cmd.s, "Move")) { if (!imapd_index && !backend_current) goto nomailbox; usinguid = 0; if (c != ' ') goto missingargs; move: c = getword(imapd_in, &arg1); if (c == '\r') goto missingargs; if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence; c = getastring(imapd_in, imapd_out, &arg2); if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_copy(tag.s, arg1.s, arg2.s, usinguid, /*ismove*/1); snmp_increment(COPY_COUNT, 1); } else goto badcmd; break; case 'N': if (!strcmp(cmd.s, "Noop")) { if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_noop(tag.s, cmd.s); /* xxxx snmp_increment(NOOP_COUNT, 1); */ } else if (!imapd_userid) goto nologin; else if (!strcmp(cmd.s, "Namespace")) { if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_namespace(tag.s); /* xxxx snmp_increment(NAMESPACE_COUNT, 1); */ } else goto badcmd; break; case 'R': if (!strcmp(cmd.s, "Rename")) { havepartition = 0; if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg2); if (c == EOF) goto missingargs; if (c == ' ') { havepartition = 1; c = getword(imapd_in, &arg3); if (!imparse_isatom(arg3.s)) goto badpartition; } if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_rename(tag.s, arg1.s, arg2.s, havepartition ? arg3.s : 0); /* xxxx snmp_increment(RENAME_COUNT, 1); */ } else if(!strcmp(cmd.s, "Reconstruct")) { recursive = 0; if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if(c == ' ') { /* Optional RECURSEIVE argument */ c = getword(imapd_in, &arg2); if(!imparse_isatom(arg2.s)) goto extraargs; else if(!strcasecmp(arg2.s, "RECURSIVE")) recursive = 1; else goto extraargs; } if(c == '\r') c = prot_getc(imapd_in); if(c != '\n') goto extraargs; cmd_reconstruct(tag.s, arg1.s, recursive); /* snmp_increment(RECONSTRUCT_COUNT, 1); */ } else if (!strcmp(cmd.s, "Rlist")) { struct listargs listargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg2); if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; memset(&listargs, 0, sizeof(struct listargs)); listargs.sel = LIST_SEL_REMOTE; listargs.ret = LIST_RET_CHILDREN; listargs.ref = arg1.s; strarray_append(&listargs.pat, arg2.s); cmd_list(tag.s, &listargs); /* snmp_increment(LIST_COUNT, 1); */ } else if (!strcmp(cmd.s, "Rlsub")) { struct listargs listargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg2); if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; memset(&listargs, 0, sizeof(struct listargs)); listargs.cmd = LIST_CMD_LSUB; listargs.sel = LIST_SEL_REMOTE | LIST_SEL_SUBSCRIBED; listargs.ref = arg1.s; strarray_append(&listargs.pat, arg2.s); cmd_list(tag.s, &listargs); /* snmp_increment(LSUB_COUNT, 1); */ } #ifdef HAVE_SSL else if (!strcmp(cmd.s, "Resetkey")) { int have_mbox = 0, have_mech = 0; if (c == ' ') { have_mbox = 1; c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto missingargs; if (c == ' ') { have_mech = 1; c = getword(imapd_in, &arg2); } } if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_resetkey(tag.s, have_mbox ? arg1.s : 0, have_mech ? arg2.s : 0); /* snmp_increment(RESETKEY_COUNT, 1);*/ } #endif else goto badcmd; break; case 'S': if (!strcmp(cmd.s, "Starttls")) { if (!tls_enabled()) { /* we don't support starttls */ goto badcmd; } if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; /* XXX discard any input pipelined after STARTTLS */ prot_flush(imapd_in); /* if we've already done SASL fail */ if (imapd_userid != NULL) { prot_printf(imapd_out, "%s BAD Can't Starttls after authentication\r\n", tag.s); continue; } /* if we've already done COMPRESS fail */ if (imapd_compress_done == 1) { prot_printf(imapd_out, "%s BAD Can't Starttls after Compress\r\n", tag.s); continue; } /* check if already did a successful tls */ if (imapd_starttls_done == 1) { prot_printf(imapd_out, "%s BAD Already did a successful Starttls\r\n", tag.s); continue; } cmd_starttls(tag.s, 0); snmp_increment(STARTTLS_COUNT, 1); continue; } if (!imapd_userid) { goto nologin; } else if (!strcmp(cmd.s, "Store")) { if (!imapd_index && !backend_current) goto nomailbox; usinguid = 0; if (c != ' ') goto missingargs; store: c = getword(imapd_in, &arg1); if (c != ' ' || !imparse_issequence(arg1.s)) goto badsequence; cmd_store(tag.s, arg1.s, usinguid); snmp_increment(STORE_COUNT, 1); } else if (!strcmp(cmd.s, "Select")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto missingargs; prot_ungetc(c, imapd_in); cmd_select(tag.s, cmd.s, arg1.s); snmp_increment(SELECT_COUNT, 1); } else if (!strcmp(cmd.s, "Search")) { if (!imapd_index && !backend_current) goto nomailbox; usinguid = 0; if (c != ' ') goto missingargs; search: cmd_search(tag.s, usinguid); snmp_increment(SEARCH_COUNT, 1); } else if (!strcmp(cmd.s, "Subscribe")) { if (c != ' ') goto missingargs; havenamespace = 0; c = getastring(imapd_in, imapd_out, &arg1); if (c == ' ') { havenamespace = 1; c = getastring(imapd_in, imapd_out, &arg2); } if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; if (havenamespace) { cmd_changesub(tag.s, arg1.s, arg2.s, 1); } else { cmd_changesub(tag.s, (char *)0, arg1.s, 1); } snmp_increment(SUBSCRIBE_COUNT, 1); } else if (!strcmp(cmd.s, "Setacl")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg2); if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg3); if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_setacl(tag.s, arg1.s, arg2.s, arg3.s); snmp_increment(SETACL_COUNT, 1); } else if (!strcmp(cmd.s, "Setannotation")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; cmd_setannotation(tag.s, arg1.s); snmp_increment(SETANNOTATION_COUNT, 1); } else if (!strcmp(cmd.s, "Setmetadata")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; cmd_setmetadata(tag.s, arg1.s); snmp_increment(SETANNOTATION_COUNT, 1); } else if (!strcmp(cmd.s, "Setquota")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; cmd_setquota(tag.s, arg1.s); snmp_increment(SETQUOTA_COUNT, 1); } else if (!strcmp(cmd.s, "Sort")) { if (!imapd_index && !backend_current) goto nomailbox; usinguid = 0; if (c != ' ') goto missingargs; sort: cmd_sort(tag.s, usinguid); snmp_increment(SORT_COUNT, 1); } else if (!strcmp(cmd.s, "Status")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; cmd_status(tag.s, arg1.s); snmp_increment(STATUS_COUNT, 1); } else if (!strcmp(cmd.s, "Scan")) { struct listargs listargs; c = getastring(imapd_in, imapd_out, &arg1); if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg2); if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg3); if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; memset(&listargs, 0, sizeof(struct listargs)); listargs.ref = arg1.s; strarray_append(&listargs.pat, arg2.s); listargs.scan = arg3.s; cmd_list(tag.s, &listargs); snmp_increment(SCAN_COUNT, 1); } else if (!strcmp(cmd.s, "Syncapply")) { struct dlist *kl = sync_parseline(imapd_in); if (kl) { cmd_syncapply(tag.s, kl, reserve_list); dlist_free(&kl); } else goto extraargs; } else if (!strcmp(cmd.s, "Syncget")) { struct dlist *kl = sync_parseline(imapd_in); if (kl) { cmd_syncget(tag.s, kl); dlist_free(&kl); } else goto extraargs; } else if (!strcmp(cmd.s, "Syncrestart")) { if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; /* just clear the GUID cache */ cmd_syncrestart(tag.s, &reserve_list, 1); } else if (!strcmp(cmd.s, "Syncrestore")) { struct dlist *kl = sync_parseline(imapd_in); if (kl) { cmd_syncrestore(tag.s, kl, reserve_list); dlist_free(&kl); } else goto extraargs; } else goto badcmd; break; case 'T': if (!strcmp(cmd.s, "Thread")) { if (!imapd_index && !backend_current) goto nomailbox; usinguid = 0; if (c != ' ') goto missingargs; thread: cmd_thread(tag.s, usinguid); snmp_increment(THREAD_COUNT, 1); } else goto badcmd; break; case 'U': if (!strcmp(cmd.s, "Uid")) { if (!imapd_index && !backend_current) goto nomailbox; usinguid = 1; if (c != ' ') goto missingargs; c = getword(imapd_in, &arg1); if (c != ' ') goto missingargs; lcase(arg1.s); xstrncpy(cmdname, arg1.s, 99); if (!strcmp(arg1.s, "fetch")) { goto fetch; } else if (!strcmp(arg1.s, "store")) { goto store; } else if (!strcmp(arg1.s, "search")) { goto search; } else if (!strcmp(arg1.s, "sort")) { goto sort; } else if (!strcmp(arg1.s, "thread")) { goto thread; } else if (!strcmp(arg1.s, "copy")) { goto copy; } else if (!strcmp(arg1.s, "move")) { goto move; } else if (!strcmp(arg1.s, "xmove")) { goto move; } else if (!strcmp(arg1.s, "expunge")) { c = getword(imapd_in, &arg1); if (!imparse_issequence(arg1.s)) goto badsequence; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_expunge(tag.s, arg1.s); snmp_increment(EXPUNGE_COUNT, 1); } else if (!strcmp(arg1.s, "xrunannotator")) { goto xrunannotator; } else { prot_printf(imapd_out, "%s BAD Unrecognized UID subcommand\r\n", tag.s); eatline(imapd_in, c); } } else if (!strcmp(cmd.s, "Unsubscribe")) { if (c != ' ') goto missingargs; havenamespace = 0; c = getastring(imapd_in, imapd_out, &arg1); if (c == ' ') { havenamespace = 1; c = getastring(imapd_in, imapd_out, &arg2); } if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; if (havenamespace) { cmd_changesub(tag.s, arg1.s, arg2.s, 0); } else { cmd_changesub(tag.s, (char *)0, arg1.s, 0); } snmp_increment(UNSUBSCRIBE_COUNT, 1); } else if (!strcmp(cmd.s, "Unselect")) { if (!imapd_index && !backend_current) goto nomailbox; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_close(tag.s, cmd.s); snmp_increment(UNSELECT_COUNT, 1); } else if (!strcmp(cmd.s, "Undump")) { if(c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); /* we want to get a list at this point */ if(c != ' ') goto missingargs; cmd_undump(tag.s, arg1.s); /* snmp_increment(UNDUMP_COUNT, 1);*/ } #ifdef HAVE_SSL else if (!strcmp(cmd.s, "Urlfetch")) { if (c != ' ') goto missingargs; cmd_urlfetch(tag.s); /* snmp_increment(URLFETCH_COUNT, 1);*/ } #endif else goto badcmd; break; case 'X': if (!strcmp(cmd.s, "Xbackup")) { int havechannel = 0; if (!config_getswitch(IMAPOPT_XBACKUP_ENABLED)) goto badcmd; /* user */ if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); /* channel */ if (c == ' ') { havechannel = 1; c = getword(imapd_in, &arg2); if (c == EOF) goto missingargs; } if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_xbackup(tag.s, arg1.s, havechannel ? arg2.s : NULL); } else if (!strcmp(cmd.s, "Xconvfetch")) { cmd_xconvfetch(tag.s); } else if (!strcmp(cmd.s, "Xconvmultisort")) { if (c != ' ') goto missingargs; if (!imapd_index && !backend_current) goto nomailbox; cmd_xconvmultisort(tag.s); } else if (!strcmp(cmd.s, "Xconvsort")) { if (c != ' ') goto missingargs; if (!imapd_index && !backend_current) goto nomailbox; cmd_xconvsort(tag.s, 0); } else if (!strcmp(cmd.s, "Xconvupdates")) { if (c != ' ') goto missingargs; if (!imapd_index && !backend_current) goto nomailbox; cmd_xconvsort(tag.s, 1); } else if (!strcmp(cmd.s, "Xfer")) { int havepartition = 0; /* Mailbox */ if(c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); /* Dest Server */ if(c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg2); if(c == ' ') { /* Dest Partition */ c = getastring(imapd_in, imapd_out, &arg3); if (!imparse_isatom(arg3.s)) goto badpartition; havepartition = 1; } if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_xfer(tag.s, arg1.s, arg2.s, (havepartition ? arg3.s : NULL)); /* snmp_increment(XFER_COUNT, 1);*/ } else if (!strcmp(cmd.s, "Xconvmeta")) { cmd_xconvmeta(tag.s); } else if (!strcmp(cmd.s, "Xlist")) { struct listargs listargs; if (c != ' ') goto missingargs; memset(&listargs, 0, sizeof(struct listargs)); listargs.cmd = LIST_CMD_XLIST; listargs.ret = LIST_RET_CHILDREN | LIST_RET_SPECIALUSE; getlistargs(tag.s, &listargs); if (listargs.pat.count) cmd_list(tag.s, &listargs); snmp_increment(LIST_COUNT, 1); } else if (!strcmp(cmd.s, "Xmove")) { if (!imapd_index && !backend_current) goto nomailbox; usinguid = 0; if (c != ' ') goto missingargs; goto move; } else if (!strcmp(cmd.s, "Xrunannotator")) { if (!imapd_index && !backend_current) goto nomailbox; usinguid = 0; if (c != ' ') goto missingargs; xrunannotator: c = getword(imapd_in, &arg1); if (!arg1.len || !imparse_issequence(arg1.s)) goto badsequence; cmd_xrunannotator(tag.s, arg1.s, usinguid); } else if (!strcmp(cmd.s, "Xsnippets")) { if (c != ' ') goto missingargs; if (!imapd_index && !backend_current) goto nomailbox; cmd_xsnippets(tag.s); } else if (!strcmp(cmd.s, "Xstats")) { cmd_xstats(tag.s, c); } else if (!strcmp(cmd.s, "Xwarmup")) { /* XWARMUP doesn't need a mailbox to be selected */ if (c != ' ') goto missingargs; cmd_xwarmup(tag.s); } else if (!strcmp(cmd.s, "Xkillmy")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_xkillmy(tag.s, arg1.s); } else if (!strcmp(cmd.s, "Xforever")) { if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_xforever(tag.s); } else if (!strcmp(cmd.s, "Xmeid")) { if (c != ' ') goto missingargs; c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto missingargs; if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto extraargs; cmd_xmeid(tag.s, arg1.s); } else if (apns_enabled && !strcmp(cmd.s, "Xapplepushservice")) { if (c != ' ') goto missingargs; memset(&applepushserviceargs, 0, sizeof(struct applepushserviceargs)); do { c = getastring(imapd_in, imapd_out, &arg1); if (c == EOF) goto aps_missingargs; if (!strcmp(arg1.s, "mailboxes")) { c = prot_getc(imapd_in); if (c != '(') goto aps_missingargs; c = prot_getc(imapd_in); if (c != ')') { prot_ungetc(c, imapd_in); do { c = getastring(imapd_in, imapd_out, &arg2); if (c == EOF) break; strarray_push(&applepushserviceargs.mailboxes, arg2.s); } while (c == ' '); } if (c != ')') goto aps_missingargs; c = prot_getc(imapd_in); } else { c = getastring(imapd_in, imapd_out, &arg2); if (!strcmp(arg1.s, "aps-version")) { if (!imparse_isnumber(arg2.s)) goto aps_extraargs; applepushserviceargs.aps_version = atoi(arg2.s); } else if (!strcmp(arg1.s, "aps-account-id")) buf_copy(&applepushserviceargs.aps_account_id, &arg2); else if (!strcmp(arg1.s, "aps-device-token")) buf_copy(&applepushserviceargs.aps_device_token, &arg2); else if (!strcmp(arg1.s, "aps-subtopic")) buf_copy(&applepushserviceargs.aps_subtopic, &arg2); else goto aps_extraargs; } } while (c == ' '); if (c == '\r') c = prot_getc(imapd_in); if (c != '\n') goto aps_extraargs; cmd_xapplepushservice(tag.s, &applepushserviceargs); } else goto badcmd; break; default: badcmd: prot_printf(imapd_out, "%s BAD Unrecognized command\r\n", tag.s); eatline(imapd_in, c); } /* End command timer - don't log "idle" commands */ if (commandmintimer && strcmp("idle", cmdname)) { double cmdtime, nettime; const char *mboxname = index_mboxname(imapd_index); if (!mboxname) mboxname = "<none>"; cmdtime_endtimer(&cmdtime, &nettime); if (cmdtime >= commandmintimerd) { syslog(LOG_NOTICE, "cmdtimer: '%s' '%s' '%s' '%f' '%f' '%f'", imapd_userid ? imapd_userid : "<none>", cmdname, mboxname, cmdtime, nettime, cmdtime + nettime); } } continue; nologin: prot_printf(imapd_out, "%s BAD Please login first\r\n", tag.s); eatline(imapd_in, c); continue; nomailbox: prot_printf(imapd_out, "%s BAD Please select a mailbox first\r\n", tag.s); eatline(imapd_in, c); continue; aps_missingargs: buf_free(&applepushserviceargs.aps_account_id); buf_free(&applepushserviceargs.aps_device_token); buf_free(&applepushserviceargs.aps_subtopic); strarray_fini(&applepushserviceargs.mailboxes); missingargs: prot_printf(imapd_out, "%s BAD Missing required argument to %s\r\n", tag.s, cmd.s); eatline(imapd_in, c); continue; aps_extraargs: buf_free(&applepushserviceargs.aps_account_id); buf_free(&applepushserviceargs.aps_device_token); buf_free(&applepushserviceargs.aps_subtopic); strarray_fini(&applepushserviceargs.mailboxes); extraargs: prot_printf(imapd_out, "%s BAD Unexpected extra arguments to %s\r\n", tag.s, cmd.s); eatline(imapd_in, c); continue; badsequence: prot_printf(imapd_out, "%s BAD Invalid sequence in %s\r\n", tag.s, cmd.s); eatline(imapd_in, c); continue; badpartition: prot_printf(imapd_out, "%s BAD Invalid partition name in %s\r\n", tag.s, cmd.s); eatline(imapd_in, c); continue; } done: cmd_syncrestart(NULL, &reserve_list, 0); } Commit Message: imapd: check for isadmin BEFORE parsing sync lines CWE ID: CWE-20
1
170,036
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void Ins_AND( INS_ARG ) { (void)exc; if ( args[0] != 0 && args[1] != 0 ) args[0] = 1; else args[0] = 0; } Commit Message: CWE ID: CWE-125
0
5,365
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void NTPResourceCache::CreateNewTabGuestHTML() { base::DictionaryValue localized_strings; localized_strings.SetString("title", l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE)); const char* guest_tab_link = kLearnMoreGuestSessionUrl; int guest_tab_ids = IDR_GUEST_TAB_HTML; int guest_tab_description_ids = IDS_NEW_TAB_GUEST_SESSION_DESCRIPTION; int guest_tab_heading_ids = IDS_NEW_TAB_GUEST_SESSION_HEADING; int guest_tab_link_ids = IDS_NEW_TAB_GUEST_SESSION_LEARN_MORE_LINK; #if defined(OS_CHROMEOS) guest_tab_ids = IDR_GUEST_SESSION_TAB_HTML; guest_tab_link = kLearnMoreGuestSessionUrl; policy::BrowserPolicyConnectorChromeOS* connector = g_browser_process->platform_part()->browser_policy_connector_chromeos(); std::string enterprise_domain = connector->GetEnterpriseDomain(); if (!enterprise_domain.empty()) { localized_strings.SetString("enterpriseInfoVisible", "true"); base::string16 enterprise_info = l10n_util::GetStringFUTF16( IDS_DEVICE_OWNED_BY_NOTICE, base::UTF8ToUTF16(enterprise_domain)); localized_strings.SetString("enterpriseInfoMessage", enterprise_info); localized_strings.SetString("enterpriseLearnMore", l10n_util::GetStringUTF16(IDS_LEARN_MORE)); localized_strings.SetString("enterpriseInfoHintLink", GetUrlWithLang(GURL(chrome::kLearnMoreEnterpriseURL))); } else { localized_strings.SetString("enterpriseInfoVisible", "false"); } #endif localized_strings.SetString("guestTabDescription", l10n_util::GetStringUTF16(guest_tab_description_ids)); localized_strings.SetString("guestTabHeading", l10n_util::GetStringUTF16(guest_tab_heading_ids)); localized_strings.SetString("learnMore", l10n_util::GetStringUTF16(guest_tab_link_ids)); localized_strings.SetString("learnMoreLink", GetUrlWithLang(GURL(guest_tab_link))); webui::SetFontAndTextDirection(&localized_strings); static const base::StringPiece guest_tab_html( ResourceBundle::GetSharedInstance().GetRawDataResource(guest_tab_ids)); std::string full_html = webui::GetI18nTemplateHtml( guest_tab_html, &localized_strings); new_tab_guest_html_ = base::RefCountedString::TakeString(&full_html); } Commit Message: Remove --disable-app-shims. App shims have been enabled by default for 3 milestones (since r242711). BUG=350161 Review URL: https://codereview.chromium.org/298953002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272786 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
110,356
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: WebDevToolsAgentImpl* InspectorClientImpl::devToolsAgent() { return static_cast<WebDevToolsAgentImpl*>(m_inspectedWebView->devToolsAgent()); } Commit Message: [4/4] Process clearBrowserCahce/cookies commands in browser. BUG=366585 Review URL: https://codereview.chromium.org/251183005 git-svn-id: svn://svn.chromium.org/blink/trunk@172984 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID:
0
114,169