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: static int ext4_commit_super(struct super_block *sb, int sync) { struct ext4_super_block *es = EXT4_SB(sb)->s_es; struct buffer_head *sbh = EXT4_SB(sb)->s_sbh; int error = 0; if (!sbh || block_device_ejected(sb)) return error; /* * If the file system is mounted read-only, don't update the * superblock write time. This avoids updating the superblock * write time when we are mounting the root file system * read/only but we need to replay the journal; at that point, * for people who are east of GMT and who make their clock * tick in localtime for Windows bug-for-bug compatibility, * the clock is set in the future, and this will cause e2fsck * to complain and force a full file system check. */ if (!(sb->s_flags & MS_RDONLY)) es->s_wtime = cpu_to_le32(get_seconds()); if (sb->s_bdev->bd_part) es->s_kbytes_written = cpu_to_le64(EXT4_SB(sb)->s_kbytes_written + ((part_stat_read(sb->s_bdev->bd_part, sectors[1]) - EXT4_SB(sb)->s_sectors_written_start) >> 1)); else es->s_kbytes_written = cpu_to_le64(EXT4_SB(sb)->s_kbytes_written); if (percpu_counter_initialized(&EXT4_SB(sb)->s_freeclusters_counter)) ext4_free_blocks_count_set(es, EXT4_C2B(EXT4_SB(sb), percpu_counter_sum_positive( &EXT4_SB(sb)->s_freeclusters_counter))); if (percpu_counter_initialized(&EXT4_SB(sb)->s_freeinodes_counter)) es->s_free_inodes_count = cpu_to_le32(percpu_counter_sum_positive( &EXT4_SB(sb)->s_freeinodes_counter)); BUFFER_TRACE(sbh, "marking dirty"); ext4_superblock_csum_set(sb); if (sync) lock_buffer(sbh); if (buffer_write_io_error(sbh)) { /* * Oh, dear. A previous attempt to write the * superblock failed. This could happen because the * USB device was yanked out. Or it could happen to * be a transient write error and maybe the block will * be remapped. Nothing we can do but to retry the * write and hope for the best. */ ext4_msg(sb, KERN_ERR, "previous I/O error to " "superblock detected"); clear_buffer_write_io_error(sbh); set_buffer_uptodate(sbh); } mark_buffer_dirty(sbh); if (sync) { unlock_buffer(sbh); error = __sync_dirty_buffer(sbh, test_opt(sb, BARRIER) ? WRITE_FUA : WRITE_SYNC); if (error) return error; error = buffer_write_io_error(sbh); if (error) { ext4_msg(sb, KERN_ERR, "I/O error while writing " "superblock"); clear_buffer_write_io_error(sbh); set_buffer_uptodate(sbh); } } return error; } Commit Message: ext4: validate s_first_meta_bg at mount time Ralf Spenneberg reported that he hit a kernel crash when mounting a modified ext4 image. And it turns out that kernel crashed when calculating fs overhead (ext4_calculate_overhead()), this is because the image has very large s_first_meta_bg (debug code shows it's 842150400), and ext4 overruns the memory in count_overhead() when setting bitmap buffer, which is PAGE_SIZE. ext4_calculate_overhead(): buf = get_zeroed_page(GFP_NOFS); <=== PAGE_SIZE buffer blks = count_overhead(sb, i, buf); count_overhead(): for (j = ext4_bg_num_gdb(sb, grp); j > 0; j--) { <=== j = 842150400 ext4_set_bit(EXT4_B2C(sbi, s++), buf); <=== buffer overrun count++; } This can be reproduced easily for me by this script: #!/bin/bash rm -f fs.img mkdir -p /mnt/ext4 fallocate -l 16M fs.img mke2fs -t ext4 -O bigalloc,meta_bg,^resize_inode -F fs.img debugfs -w -R "ssv first_meta_bg 842150400" fs.img mount -o loop fs.img /mnt/ext4 Fix it by validating s_first_meta_bg first at mount time, and refusing to mount if its value exceeds the largest possible meta_bg number. Reported-by: Ralf Spenneberg <ralf@os-t.de> Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Andreas Dilger <adilger@dilger.ca> CWE ID: CWE-125
0
70,525
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 inline int save_fsave_header(struct task_struct *tsk, void __user *buf) { if (use_fxsr()) { struct xregs_state *xsave = &tsk->thread.fpu.state.xsave; struct user_i387_ia32_struct env; struct _fpstate_32 __user *fp = buf; convert_from_fxsr(&env, tsk); if (__copy_to_user(buf, &env, sizeof(env)) || __put_user(xsave->i387.swd, &fp->status) || __put_user(X86_FXSR_MAGIC, &fp->magic)) return -1; } else { struct fregs_state __user *fp = buf; u32 swd; if (__get_user(swd, &fp->swd) || __put_user(swd, &fp->status)) return -1; } return 0; } Commit Message: x86/fpu: Don't let userspace set bogus xcomp_bv On x86, userspace can use the ptrace() or rt_sigreturn() system calls to set a task's extended state (xstate) or "FPU" registers. ptrace() can set them for another task using the PTRACE_SETREGSET request with NT_X86_XSTATE, while rt_sigreturn() can set them for the current task. In either case, registers can be set to any value, but the kernel assumes that the XSAVE area itself remains valid in the sense that the CPU can restore it. However, in the case where the kernel is using the uncompacted xstate format (which it does whenever the XSAVES instruction is unavailable), it was possible for userspace to set the xcomp_bv field in the xstate_header to an arbitrary value. However, all bits in that field are reserved in the uncompacted case, so when switching to a task with nonzero xcomp_bv, the XRSTOR instruction failed with a #GP fault. This caused the WARN_ON_FPU(err) in copy_kernel_to_xregs() to be hit. In addition, since the error is otherwise ignored, the FPU registers from the task previously executing on the CPU were leaked. Fix the bug by checking that the user-supplied value of xcomp_bv is 0 in the uncompacted case, and returning an error otherwise. The reason for validating xcomp_bv rather than simply overwriting it with 0 is that we want userspace to see an error if it (incorrectly) provides an XSAVE area in compacted format rather than in uncompacted format. Note that as before, in case of error we clear the task's FPU state. This is perhaps non-ideal, especially for PTRACE_SETREGSET; it might be better to return an error before changing anything. But it seems the "clear on error" behavior is fine for now, and it's a little tricky to do otherwise because it would mean we couldn't simply copy the full userspace state into kernel memory in one __copy_from_user(). This bug was found by syzkaller, which hit the above-mentioned WARN_ON_FPU(): WARNING: CPU: 1 PID: 0 at ./arch/x86/include/asm/fpu/internal.h:373 __switch_to+0x5b5/0x5d0 CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.13.0 #453 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 task: ffff9ba2bc8e42c0 task.stack: ffffa78cc036c000 RIP: 0010:__switch_to+0x5b5/0x5d0 RSP: 0000:ffffa78cc08bbb88 EFLAGS: 00010082 RAX: 00000000fffffffe RBX: ffff9ba2b8bf2180 RCX: 00000000c0000100 RDX: 00000000ffffffff RSI: 000000005cb10700 RDI: ffff9ba2b8bf36c0 RBP: ffffa78cc08bbbd0 R08: 00000000929fdf46 R09: 0000000000000001 R10: 0000000000000000 R11: 0000000000000000 R12: ffff9ba2bc8e42c0 R13: 0000000000000000 R14: ffff9ba2b8bf3680 R15: ffff9ba2bf5d7b40 FS: 00007f7e5cb10700(0000) GS:ffff9ba2bf400000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000004005cc CR3: 0000000079fd5000 CR4: 00000000001406e0 Call Trace: Code: 84 00 00 00 00 00 e9 11 fd ff ff 0f ff 66 0f 1f 84 00 00 00 00 00 e9 e7 fa ff ff 0f ff 66 0f 1f 84 00 00 00 00 00 e9 c2 fa ff ff <0f> ff 66 0f 1f 84 00 00 00 00 00 e9 d4 fc ff ff 66 66 2e 0f 1f Here is a C reproducer. The expected behavior is that the program spin forever with no output. However, on a buggy kernel running on a processor with the "xsave" feature but without the "xsaves" feature (e.g. Sandy Bridge through Broadwell for Intel), within a second or two the program reports that the xmm registers were corrupted, i.e. were not restored correctly. With CONFIG_X86_DEBUG_FPU=y it also hits the above kernel warning. #define _GNU_SOURCE #include <stdbool.h> #include <inttypes.h> #include <linux/elf.h> #include <stdio.h> #include <sys/ptrace.h> #include <sys/uio.h> #include <sys/wait.h> #include <unistd.h> int main(void) { int pid = fork(); uint64_t xstate[512]; struct iovec iov = { .iov_base = xstate, .iov_len = sizeof(xstate) }; if (pid == 0) { bool tracee = true; for (int i = 0; i < sysconf(_SC_NPROCESSORS_ONLN) && tracee; i++) tracee = (fork() != 0); uint32_t xmm0[4] = { [0 ... 3] = tracee ? 0x00000000 : 0xDEADBEEF }; asm volatile(" movdqu %0, %%xmm0\n" " mov %0, %%rbx\n" "1: movdqu %%xmm0, %0\n" " mov %0, %%rax\n" " cmp %%rax, %%rbx\n" " je 1b\n" : "+m" (xmm0) : : "rax", "rbx", "xmm0"); printf("BUG: xmm registers corrupted! tracee=%d, xmm0=%08X%08X%08X%08X\n", tracee, xmm0[0], xmm0[1], xmm0[2], xmm0[3]); } else { usleep(100000); ptrace(PTRACE_ATTACH, pid, 0, 0); wait(NULL); ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov); xstate[65] = -1; ptrace(PTRACE_SETREGSET, pid, NT_X86_XSTATE, &iov); ptrace(PTRACE_CONT, pid, 0, 0); wait(NULL); } return 1; } Note: the program only tests for the bug using the ptrace() system call. The bug can also be reproduced using the rt_sigreturn() system call, but only when called from a 32-bit program, since for 64-bit programs the kernel restores the FPU state from the signal frame by doing XRSTOR directly from userspace memory (with proper error checking). Reported-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Rik van Riel <riel@redhat.com> Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Cc: <stable@vger.kernel.org> [v3.17+] Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Eric Biggers <ebiggers3@gmail.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: Kevin Hao <haokexin@gmail.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Michael Halcrow <mhalcrow@google.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Wanpeng Li <wanpeng.li@hotmail.com> Cc: Yu-cheng Yu <yu-cheng.yu@intel.com> Cc: kernel-hardening@lists.openwall.com Fixes: 0b29643a5843 ("x86/xsaves: Change compacted format xsave area header") Link: http://lkml.kernel.org/r/20170922174156.16780-2-ebiggers3@gmail.com Link: http://lkml.kernel.org/r/20170923130016.21448-25-mingo@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org> CWE ID: CWE-200
0
60,455
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 TabStrip::UpdateContrastRatioValues() { if (!controller_) return; const SkColor inactive_bg = GetTabBackgroundColor(TAB_INACTIVE); const auto get_alpha = [inactive_bg](SkColor target, float contrast) { return color_utils::GetBlendValueWithMinimumContrast(inactive_bg, target, inactive_bg, contrast); }; const SkColor active_bg = GetTabBackgroundColor(TAB_ACTIVE); const auto get_hover_opacity = [active_bg, &get_alpha](float contrast) { return get_alpha(active_bg, contrast) / 255.0f; }; constexpr float kStandardWidthContrast = 1.11f; hover_opacity_min_ = get_hover_opacity(kStandardWidthContrast); constexpr float kMinWidthContrast = 1.19f; hover_opacity_max_ = get_hover_opacity(kMinWidthContrast); constexpr float kRadialGradientContrast = 1.13728f; radial_highlight_opacity_ = get_hover_opacity(kRadialGradientContrast); const SkColor inactive_fg = GetTabForegroundColor(TAB_INACTIVE, inactive_bg); constexpr float kTabSeparatorContrast = 2.5f; const SkAlpha separator_alpha = get_alpha(inactive_fg, kTabSeparatorContrast); separator_color_ = color_utils::AlphaBlend(inactive_fg, inactive_bg, separator_alpha); } Commit Message: Paint tab groups with the group color. * The background of TabGroupHeader now uses the group color. * The backgrounds of tabs in the group are tinted with the group color. This treatment, along with the colors chosen, are intended to be a placeholder. Bug: 905491 Change-Id: Ic808548f8eba23064606e7fb8c9bba281d0d117f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1610504 Commit-Queue: Bret Sepulveda <bsep@chromium.org> Reviewed-by: Taylor Bergquist <tbergquist@chromium.org> Cr-Commit-Position: refs/heads/master@{#660498} CWE ID: CWE-20
0
140,804
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 PaintLayerScrollableArea::IsScrollCornerVisible() const { return !ScrollCornerRect().IsEmpty(); } Commit Message: Always call UpdateCompositedScrollOffset, not just for the root layer Bug: 927560 Change-Id: I1d5522aae4f11dd3f5b8947bb089bac1bf19bdb4 Reviewed-on: https://chromium-review.googlesource.com/c/1452701 Reviewed-by: Chris Harrelson <chrishtr@chromium.org> Commit-Queue: Mason Freed <masonfreed@chromium.org> Cr-Commit-Position: refs/heads/master@{#628942} CWE ID: CWE-79
0
130,072
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 br_ip6_multicast_query(struct net_bridge *br, struct net_bridge_port *port, struct sk_buff *skb) { const struct ipv6hdr *ip6h = ipv6_hdr(skb); struct mld_msg *mld; struct net_bridge_mdb_entry *mp; struct mld2_query *mld2q; struct net_bridge_port_group *p; struct net_bridge_port_group __rcu **pp; unsigned long max_delay; unsigned long now = jiffies; const struct in6_addr *group = NULL; int err = 0; u16 vid = 0; spin_lock(&br->multicast_lock); if (!netif_running(br->dev) || (port && port->state == BR_STATE_DISABLED)) goto out; br_multicast_query_received(br, port, !ipv6_addr_any(&ip6h->saddr)); if (skb->len == sizeof(*mld)) { if (!pskb_may_pull(skb, sizeof(*mld))) { err = -EINVAL; goto out; } mld = (struct mld_msg *) icmp6_hdr(skb); max_delay = msecs_to_jiffies(ntohs(mld->mld_maxdelay)); if (max_delay) group = &mld->mld_mca; } else if (skb->len >= sizeof(*mld2q)) { if (!pskb_may_pull(skb, sizeof(*mld2q))) { err = -EINVAL; goto out; } mld2q = (struct mld2_query *)icmp6_hdr(skb); if (!mld2q->mld2q_nsrcs) group = &mld2q->mld2q_mca; max_delay = mld2q->mld2q_mrc ? MLDV2_MRC(ntohs(mld2q->mld2q_mrc)) : 1; } if (!group) goto out; br_vlan_get_tag(skb, &vid); mp = br_mdb_ip6_get(mlock_dereference(br->mdb, br), group, vid); if (!mp) goto out; setup_timer(&mp->timer, br_multicast_group_expired, (unsigned long)mp); mod_timer(&mp->timer, now + br->multicast_membership_interval); mp->timer_armed = true; max_delay *= br->multicast_last_member_count; if (mp->mglist && (timer_pending(&mp->timer) ? time_after(mp->timer.expires, now + max_delay) : try_to_del_timer_sync(&mp->timer) >= 0)) mod_timer(&mp->timer, now + max_delay); for (pp = &mp->ports; (p = mlock_dereference(*pp, br)) != NULL; pp = &p->next) { if (timer_pending(&p->timer) ? time_after(p->timer.expires, now + max_delay) : try_to_del_timer_sync(&p->timer) >= 0) mod_timer(&p->timer, now + max_delay); } out: spin_unlock(&br->multicast_lock); return err; } Commit Message: bridge: fix some kernel warning in multicast timer Several people reported the warning: "kernel BUG at kernel/timer.c:729!" and the stack trace is: #7 [ffff880214d25c10] mod_timer+501 at ffffffff8106d905 #8 [ffff880214d25c50] br_multicast_del_pg.isra.20+261 at ffffffffa0731d25 [bridge] #9 [ffff880214d25c80] br_multicast_disable_port+88 at ffffffffa0732948 [bridge] #10 [ffff880214d25cb0] br_stp_disable_port+154 at ffffffffa072bcca [bridge] #11 [ffff880214d25ce8] br_device_event+520 at ffffffffa072a4e8 [bridge] #12 [ffff880214d25d18] notifier_call_chain+76 at ffffffff8164aafc #13 [ffff880214d25d50] raw_notifier_call_chain+22 at ffffffff810858f6 #14 [ffff880214d25d60] call_netdevice_notifiers+45 at ffffffff81536aad #15 [ffff880214d25d80] dev_close_many+183 at ffffffff81536d17 #16 [ffff880214d25dc0] rollback_registered_many+168 at ffffffff81537f68 #17 [ffff880214d25de8] rollback_registered+49 at ffffffff81538101 #18 [ffff880214d25e10] unregister_netdevice_queue+72 at ffffffff815390d8 #19 [ffff880214d25e30] __tun_detach+272 at ffffffffa074c2f0 [tun] #20 [ffff880214d25e88] tun_chr_close+45 at ffffffffa074c4bd [tun] #21 [ffff880214d25ea8] __fput+225 at ffffffff8119b1f1 #22 [ffff880214d25ef0] ____fput+14 at ffffffff8119b3fe #23 [ffff880214d25f00] task_work_run+159 at ffffffff8107cf7f #24 [ffff880214d25f30] do_notify_resume+97 at ffffffff810139e1 #25 [ffff880214d25f50] int_signal+18 at ffffffff8164f292 this is due to I forgot to check if mp->timer is armed in br_multicast_del_pg(). This bug is introduced by commit 9f00b2e7cf241fa389733d41b6 (bridge: only expire the mdb entry when query is received). Same for __br_mdb_del(). Tested-by: poma <pomidorabelisima@gmail.com> Reported-by: LiYonghua <809674045@qq.com> Reported-by: Robert Hancock <hancockrwd@gmail.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Stephen Hemminger <stephen@networkplumber.org> Cc: "David S. Miller" <davem@davemloft.net> Signed-off-by: Cong Wang <amwang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-20
0
29,998
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: status_t MPEG4Extractor::parseDrmSINF( off64_t * /* offset */, off64_t data_offset) { uint8_t updateIdTag; if (mDataSource->readAt(data_offset, &updateIdTag, 1) < 1) { return ERROR_IO; } data_offset ++; if (0x01/*OBJECT_DESCRIPTOR_UPDATE_ID_TAG*/ != updateIdTag) { return ERROR_MALFORMED; } uint8_t numOfBytes; int32_t size = readSize(data_offset, mDataSource, &numOfBytes); if (size < 0) { return ERROR_IO; } data_offset += numOfBytes; while(size >= 11 ) { uint8_t descriptorTag; if (mDataSource->readAt(data_offset, &descriptorTag, 1) < 1) { return ERROR_IO; } data_offset ++; if (0x11/*OBJECT_DESCRIPTOR_ID_TAG*/ != descriptorTag) { return ERROR_MALFORMED; } uint8_t buffer[8]; if (mDataSource->readAt(data_offset, buffer, 2) < 2) { return ERROR_IO; } data_offset += 2; if ((buffer[1] >> 5) & 0x0001) { //url flag is set return ERROR_MALFORMED; } if (mDataSource->readAt(data_offset, buffer, 8) < 8) { return ERROR_IO; } data_offset += 8; if ((0x0F/*ES_ID_REF_TAG*/ != buffer[1]) || ( 0x0A/*IPMP_DESCRIPTOR_POINTER_ID_TAG*/ != buffer[5])) { return ERROR_MALFORMED; } SINF *sinf = new SINF; sinf->trackID = U16_AT(&buffer[3]); sinf->IPMPDescriptorID = buffer[7]; sinf->next = mFirstSINF; mFirstSINF = sinf; size -= (8 + 2 + 1); } if (size != 0) { return ERROR_MALFORMED; } if (mDataSource->readAt(data_offset, &updateIdTag, 1) < 1) { return ERROR_IO; } data_offset ++; if(0x05/*IPMP_DESCRIPTOR_UPDATE_ID_TAG*/ != updateIdTag) { return ERROR_MALFORMED; } size = readSize(data_offset, mDataSource, &numOfBytes); if (size < 0) { return ERROR_IO; } data_offset += numOfBytes; while (size > 0) { uint8_t tag; int32_t dataLen; if (mDataSource->readAt(data_offset, &tag, 1) < 1) { return ERROR_IO; } data_offset ++; if (0x0B/*IPMP_DESCRIPTOR_ID_TAG*/ == tag) { uint8_t id; dataLen = readSize(data_offset, mDataSource, &numOfBytes); if (dataLen < 0) { return ERROR_IO; } else if (dataLen < 4) { return ERROR_MALFORMED; } data_offset += numOfBytes; if (mDataSource->readAt(data_offset, &id, 1) < 1) { return ERROR_IO; } data_offset ++; SINF *sinf = mFirstSINF; while (sinf && (sinf->IPMPDescriptorID != id)) { sinf = sinf->next; } if (sinf == NULL) { return ERROR_MALFORMED; } sinf->len = dataLen - 3; sinf->IPMPData = new (std::nothrow) char[sinf->len]; if (sinf->IPMPData == NULL) { return ERROR_MALFORMED; } data_offset += 2; if (mDataSource->readAt(data_offset, sinf->IPMPData, sinf->len) < sinf->len) { return ERROR_IO; } data_offset += sinf->len; size -= (dataLen + numOfBytes + 1); } } if (size != 0) { return ERROR_MALFORMED; } return UNKNOWN_ERROR; // Return a dummy error. } Commit Message: Check malloc result to avoid NPD Bug: 28471206 Change-Id: Id5d055d76893d6f53a2e524ff5f282d1ddca3345 CWE ID: CWE-20
0
159,594
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 array_cleanup( char* arr[] , int arr_size) { int i=0; for( i=0; i< arr_size; i++ ){ if( arr[i*2] ){ efree( arr[i*2]); } } efree(arr); } Commit Message: Fix bug #72241: get_icu_value_internal out-of-bounds read CWE ID: CWE-125
1
167,200
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: upnp_event_process_notify(struct upnp_event_notify * obj) { int err; socklen_t len; switch(obj->state) { case EConnecting: /* now connected or failed to connect */ len = sizeof(err); if(getsockopt(obj->s, SOL_SOCKET, SO_ERROR, &err, &len) < 0) { syslog(LOG_ERR, "%s: getsockopt: %m", "upnp_event_process_notify"); obj->state = EError; break; } if(err != 0) { errno = err; syslog(LOG_WARNING, "%s: connect(%s%s): %m", "upnp_event_process_notify", obj->addrstr, obj->portstr); obj->state = EError; break; } upnp_event_prepare(obj); if(obj->state == ESending) upnp_event_send(obj); break; case ESending: upnp_event_send(obj); break; case EWaitingForResponse: upnp_event_recv(obj); break; case EFinished: close(obj->s); obj->s = -1; break; default: syslog(LOG_ERR, "%s: unknown state", "upnp_event_process_notify"); } } Commit Message: upnp_event_prepare(): check the return value of snprintf() CWE ID: CWE-200
0
89,884
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 check_no_speaker_on_headset(struct snd_kcontrol *kctl, struct snd_card *card) { const char *names_to_check[] = { "Headset", "headset", "Headphone", "headphone", NULL}; const char **s; bool found = false; if (strcmp("Speaker", kctl->id.name)) return; for (s = names_to_check; *s; s++) if (strstr(card->shortname, *s)) { found = true; break; } if (!found) return; strlcpy(kctl->id.name, "Headphone", sizeof(kctl->id.name)); } Commit Message: ALSA: usb-audio: Kill stray URB at exiting USB-audio driver may leave a stray URB for the mixer interrupt when it exits by some error during probe. This leads to a use-after-free error as spotted by syzkaller like: ================================================================== BUG: KASAN: use-after-free in snd_usb_mixer_interrupt+0x604/0x6f0 Call Trace: <IRQ> __dump_stack lib/dump_stack.c:16 dump_stack+0x292/0x395 lib/dump_stack.c:52 print_address_description+0x78/0x280 mm/kasan/report.c:252 kasan_report_error mm/kasan/report.c:351 kasan_report+0x23d/0x350 mm/kasan/report.c:409 __asan_report_load8_noabort+0x19/0x20 mm/kasan/report.c:430 snd_usb_mixer_interrupt+0x604/0x6f0 sound/usb/mixer.c:2490 __usb_hcd_giveback_urb+0x2e0/0x650 drivers/usb/core/hcd.c:1779 .... Allocated by task 1484: save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59 save_stack+0x43/0xd0 mm/kasan/kasan.c:447 set_track mm/kasan/kasan.c:459 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551 kmem_cache_alloc_trace+0x11e/0x2d0 mm/slub.c:2772 kmalloc ./include/linux/slab.h:493 kzalloc ./include/linux/slab.h:666 snd_usb_create_mixer+0x145/0x1010 sound/usb/mixer.c:2540 create_standard_mixer_quirk+0x58/0x80 sound/usb/quirks.c:516 snd_usb_create_quirk+0x92/0x100 sound/usb/quirks.c:560 create_composite_quirk+0x1c4/0x3e0 sound/usb/quirks.c:59 snd_usb_create_quirk+0x92/0x100 sound/usb/quirks.c:560 usb_audio_probe+0x1040/0x2c10 sound/usb/card.c:618 .... Freed by task 1484: save_stack_trace+0x1b/0x20 arch/x86/kernel/stacktrace.c:59 save_stack+0x43/0xd0 mm/kasan/kasan.c:447 set_track mm/kasan/kasan.c:459 kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:524 slab_free_hook mm/slub.c:1390 slab_free_freelist_hook mm/slub.c:1412 slab_free mm/slub.c:2988 kfree+0xf6/0x2f0 mm/slub.c:3919 snd_usb_mixer_free+0x11a/0x160 sound/usb/mixer.c:2244 snd_usb_mixer_dev_free+0x36/0x50 sound/usb/mixer.c:2250 __snd_device_free+0x1ff/0x380 sound/core/device.c:91 snd_device_free_all+0x8f/0xe0 sound/core/device.c:244 snd_card_do_free sound/core/init.c:461 release_card_device+0x47/0x170 sound/core/init.c:181 device_release+0x13f/0x210 drivers/base/core.c:814 .... Actually such a URB is killed properly at disconnection when the device gets probed successfully, and what we need is to apply it for the error-path, too. In this patch, we apply snd_usb_mixer_disconnect() at releasing. Also introduce a new flag, disconnected, to struct usb_mixer_interface for not performing the disconnection procedure twice. Reported-by: Andrey Konovalov <andreyknvl@google.com> Tested-by: Andrey Konovalov <andreyknvl@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> CWE ID: CWE-416
0
59,966
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: f2flac8_clip_array (const float *src, int32_t *dest, int count, int normalize) { float normfact, scaled_value ; normfact = normalize ? (8.0 * 0x10) : 1.0 ; while (--count >= 0) { scaled_value = src [count] * normfact ; if (CPU_CLIPS_POSITIVE == 0 && scaled_value >= (1.0 * 0x7F)) { dest [count] = 0x7F ; continue ; } ; if (CPU_CLIPS_NEGATIVE == 0 && scaled_value <= (-8.0 * 0x10)) { dest [count] = 0x80 ; continue ; } ; dest [count] = lrintf (scaled_value) ; } ; return ; } /* f2flac8_clip_array */ Commit Message: src/flac.c: Improve error handling Especially when dealing with corrupt or malicious files. CWE ID: CWE-119
0
67,105
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 rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len) { struct sockaddr_rc *sa = (struct sockaddr_rc *) addr; struct sock *sk = sock->sk; int err = 0; BT_DBG("sk %p %s", sk, batostr(&sa->rc_bdaddr)); if (!addr || addr->sa_family != AF_BLUETOOTH) return -EINVAL; lock_sock(sk); if (sk->sk_state != BT_OPEN) { err = -EBADFD; goto done; } if (sk->sk_type != SOCK_STREAM) { err = -EINVAL; goto done; } write_lock(&rfcomm_sk_list.lock); if (sa->rc_channel && __rfcomm_get_sock_by_addr(sa->rc_channel, &sa->rc_bdaddr)) { err = -EADDRINUSE; } else { /* Save source address */ bacpy(&bt_sk(sk)->src, &sa->rc_bdaddr); rfcomm_pi(sk)->channel = sa->rc_channel; sk->sk_state = BT_BOUND; } write_unlock(&rfcomm_sk_list.lock); done: release_sock(sk); return err; } Commit Message: Bluetooth: RFCOMM - Fix info leak via getsockname() The RFCOMM code fails to initialize the trailing padding byte of struct sockaddr_rc added for alignment. It that for leaks one byte kernel stack via the getsockname() syscall. Add an explicit memset(0) before filling the structure to avoid the info leak. Signed-off-by: Mathias Krause <minipli@googlemail.com> Cc: Marcel Holtmann <marcel@holtmann.org> Cc: Gustavo Padovan <gustavo@padovan.org> Cc: Johan Hedberg <johan.hedberg@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-200
0
34,114
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 __net_init inet6_net_init(struct net *net) { int err = 0; net->ipv6.sysctl.bindv6only = 0; net->ipv6.sysctl.icmpv6_time = 1*HZ; net->ipv6.sysctl.flowlabel_consistency = 1; net->ipv6.sysctl.auto_flowlabels = IP6_DEFAULT_AUTO_FLOW_LABELS; net->ipv6.sysctl.idgen_retries = 3; net->ipv6.sysctl.idgen_delay = 1 * HZ; net->ipv6.sysctl.flowlabel_state_ranges = 0; atomic_set(&net->ipv6.fib6_sernum, 1); err = ipv6_init_mibs(net); if (err) return err; #ifdef CONFIG_PROC_FS err = udp6_proc_init(net); if (err) goto out; err = tcp6_proc_init(net); if (err) goto proc_tcp6_fail; err = ac6_proc_init(net); if (err) goto proc_ac6_fail; #endif return err; #ifdef CONFIG_PROC_FS proc_ac6_fail: tcp6_proc_exit(net); proc_tcp6_fail: udp6_proc_exit(net); out: ipv6_cleanup_mibs(net); return err; #endif } Commit Message: net: add validation for the socket syscall protocol argument 郭永刚 reported that one could simply crash the kernel as root by using a simple program: int socket_fd; struct sockaddr_in addr; addr.sin_port = 0; addr.sin_addr.s_addr = INADDR_ANY; addr.sin_family = 10; socket_fd = socket(10,3,0x40000000); connect(socket_fd , &addr,16); AF_INET, AF_INET6 sockets actually only support 8-bit protocol identifiers. inet_sock's skc_protocol field thus is sized accordingly, thus larger protocol identifiers simply cut off the higher bits and store a zero in the protocol fields. This could lead to e.g. NULL function pointer because as a result of the cut off inet_num is zero and we call down to inet_autobind, which is NULL for raw sockets. kernel: Call Trace: kernel: [<ffffffff816db90e>] ? inet_autobind+0x2e/0x70 kernel: [<ffffffff816db9a4>] inet_dgram_connect+0x54/0x80 kernel: [<ffffffff81645069>] SYSC_connect+0xd9/0x110 kernel: [<ffffffff810ac51b>] ? ptrace_notify+0x5b/0x80 kernel: [<ffffffff810236d8>] ? syscall_trace_enter_phase2+0x108/0x200 kernel: [<ffffffff81645e0e>] SyS_connect+0xe/0x10 kernel: [<ffffffff81779515>] tracesys_phase2+0x84/0x89 I found no particular commit which introduced this problem. CVE: CVE-2015-8543 Cc: Cong Wang <cwang@twopensource.com> Reported-by: 郭永刚 <guoyonggang@360.cn> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID:
0
41,561
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 BluetoothDeviceChromeOS::OnPairError( const ConnectErrorCallback& error_callback, const std::string& error_name, const std::string& error_message) { if (--num_connecting_calls_ == 0) adapter_->NotifyDeviceChanged(this); DCHECK(num_connecting_calls_ >= 0); LOG(WARNING) << object_path_.value() << ": Failed to pair device: " << error_name << ": " << error_message; VLOG(1) << object_path_.value() << ": " << num_connecting_calls_ << " still in progress"; UnregisterAgent(); ConnectErrorCode error_code = ERROR_UNKNOWN; if (error_name == bluetooth_device::kErrorConnectionAttemptFailed) { error_code = ERROR_FAILED; } else if (error_name == bluetooth_device::kErrorFailed) { error_code = ERROR_FAILED; } else if (error_name == bluetooth_device::kErrorAuthenticationFailed) { error_code = ERROR_AUTH_FAILED; } else if (error_name == bluetooth_device::kErrorAuthenticationCanceled) { error_code = ERROR_AUTH_CANCELED; } else if (error_name == bluetooth_device::kErrorAuthenticationRejected) { error_code = ERROR_AUTH_REJECTED; } else if (error_name == bluetooth_device::kErrorAuthenticationTimeout) { error_code = ERROR_AUTH_TIMEOUT; } RecordPairingResult(error_code); error_callback.Run(error_code); } Commit Message: Refactor to support default Bluetooth pairing delegate In order to support a default pairing delegate we need to move the agent service provider delegate implementation from BluetoothDevice to BluetoothAdapter while retaining the existing API. BUG=338492 TEST=device_unittests, unit_tests, browser_tests Review URL: https://codereview.chromium.org/148293003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252216 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID:
1
171,228
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: lexer_parse_number (parser_context_t *context_p) /**< context */ { const uint8_t *source_p = context_p->source_p; const uint8_t *source_end_p = context_p->source_end_p; bool can_be_float = false; size_t length; context_p->token.type = LEXER_LITERAL; context_p->token.literal_is_reserved = false; context_p->token.extra_value = LEXER_NUMBER_DECIMAL; context_p->token.lit_location.char_p = source_p; context_p->token.lit_location.type = LEXER_NUMBER_LITERAL; context_p->token.lit_location.has_escape = false; if (source_p[0] == LIT_CHAR_0 && source_p + 1 < source_end_p) { if (LEXER_TO_ASCII_LOWERCASE (source_p[1]) == LIT_CHAR_LOWERCASE_X) { context_p->token.extra_value = LEXER_NUMBER_HEXADECIMAL; source_p += 2; if (source_p >= source_end_p || !lit_char_is_hex_digit (source_p[0])) { parser_raise_error (context_p, PARSER_ERR_INVALID_HEX_DIGIT); } do { source_p++; } while (source_p < source_end_p && lit_char_is_hex_digit (source_p[0])); } else if (source_p[1] >= LIT_CHAR_0 && source_p[1] <= LIT_CHAR_7) { context_p->token.extra_value = LEXER_NUMBER_OCTAL; if (context_p->status_flags & PARSER_IS_STRICT) { parser_raise_error (context_p, PARSER_ERR_OCTAL_NUMBER_NOT_ALLOWED); } do { source_p++; } while (source_p < source_end_p && source_p[0] >= LIT_CHAR_0 && source_p[0] <= LIT_CHAR_7); if (source_p < source_end_p && source_p[0] >= LIT_CHAR_8 && source_p[0] <= LIT_CHAR_9) { parser_raise_error (context_p, PARSER_ERR_INVALID_NUMBER); } } else if (source_p[1] >= LIT_CHAR_8 && source_p[1] <= LIT_CHAR_9) { parser_raise_error (context_p, PARSER_ERR_INVALID_NUMBER); } else { can_be_float = true; source_p++; } } else { do { source_p++; } while (source_p < source_end_p && source_p[0] >= LIT_CHAR_0 && source_p[0] <= LIT_CHAR_9); can_be_float = true; } if (can_be_float) { if (source_p < source_end_p && source_p[0] == LIT_CHAR_DOT) { source_p++; while (source_p < source_end_p && source_p[0] >= LIT_CHAR_0 && source_p[0] <= LIT_CHAR_9) { source_p++; } } if (source_p < source_end_p && LEXER_TO_ASCII_LOWERCASE (source_p[0]) == LIT_CHAR_LOWERCASE_E) { source_p++; if (source_p < source_end_p && (source_p[0] == LIT_CHAR_PLUS || source_p[0] == LIT_CHAR_MINUS)) { source_p++; } if (source_p >= source_end_p || source_p[0] < LIT_CHAR_0 || source_p[0] > LIT_CHAR_9) { parser_raise_error (context_p, PARSER_ERR_MISSING_EXPONENT); } do { source_p++; } while (source_p < source_end_p && source_p[0] >= LIT_CHAR_0 && source_p[0] <= LIT_CHAR_9); } } if (source_p < source_end_p && (lit_char_is_identifier_start (source_p) || source_p[0] == LIT_CHAR_BACKSLASH)) { parser_raise_error (context_p, PARSER_ERR_IDENTIFIER_AFTER_NUMBER); } length = (size_t) (source_p - context_p->source_p); if (length > PARSER_MAXIMUM_IDENT_LENGTH) { parser_raise_error (context_p, PARSER_ERR_NUMBER_TOO_LONG); } context_p->token.lit_location.length = (uint16_t) length; PARSER_PLUS_EQUAL_LC (context_p->column, length); context_p->source_p = source_p; } /* lexer_parse_number */ Commit Message: Do not allocate memory for zero length strings. Fixes #1821. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com CWE ID: CWE-476
0
64,618
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 SecurityHandler::AttachToRenderFrameHost() { DCHECK(host_); WebContents* web_contents = WebContents::FromRenderFrameHost(host_); WebContentsObserver::Observe(web_contents); DCHECK(enabled_); DidChangeVisibleSecurityState(); } Commit Message: DevTools: speculative fix for crash in NetworkHandler::Disable This keeps BrowserContext* and StoragePartition* instead of RenderProcessHost* in an attemp to resolve UAF of RenderProcessHost upon closure of DevTools front-end. Bug: 801117, 783067, 780694 Change-Id: I6c2cca60cc0c29f0949d189cf918769059f80c1b Reviewed-on: https://chromium-review.googlesource.com/876657 Commit-Queue: Andrey Kosyakov <caseq@chromium.org> Reviewed-by: Dmitry Gozman <dgozman@chromium.org> Cr-Commit-Position: refs/heads/master@{#531157} CWE ID: CWE-20
0
148,575
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: char comps_objrtree_paircmp(void *obj1, void *obj2) { if (strcmp(((COMPS_ObjRTreePair*)obj1)->key, ((COMPS_ObjRTreePair*)obj2)->key) != 0) return 0; return comps_object_cmp(((COMPS_ObjRTreePair*)obj1)->data, ((COMPS_ObjRTreePair*)obj2)->data); } Commit Message: Fix UAF in comps_objmrtree_unite function The added field is not used at all in many places and it is probably the left-over of some copy-paste. CWE ID: CWE-416
0
91,803
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: cmsSEQ* CMSEXPORT cmsDupProfileSequenceDescription(const cmsSEQ* pseq) { cmsSEQ *NewSeq; cmsUInt32Number i; if (pseq == NULL) return NULL; NewSeq = (cmsSEQ*) _cmsMalloc(pseq -> ContextID, sizeof(cmsSEQ)); if (NewSeq == NULL) return NULL; NewSeq -> seq = (cmsPSEQDESC*) _cmsCalloc(pseq ->ContextID, pseq ->n, sizeof(cmsPSEQDESC)); if (NewSeq ->seq == NULL) goto Error; NewSeq -> ContextID = pseq ->ContextID; NewSeq -> n = pseq ->n; for (i=0; i < pseq->n; i++) { memmove(&NewSeq ->seq[i].attributes, &pseq ->seq[i].attributes, sizeof(cmsUInt64Number)); NewSeq ->seq[i].deviceMfg = pseq ->seq[i].deviceMfg; NewSeq ->seq[i].deviceModel = pseq ->seq[i].deviceModel; memmove(&NewSeq ->seq[i].ProfileID, &pseq ->seq[i].ProfileID, sizeof(cmsProfileID)); NewSeq ->seq[i].technology = pseq ->seq[i].technology; NewSeq ->seq[i].Manufacturer = cmsMLUdup(pseq ->seq[i].Manufacturer); NewSeq ->seq[i].Model = cmsMLUdup(pseq ->seq[i].Model); NewSeq ->seq[i].Description = cmsMLUdup(pseq ->seq[i].Description); } return NewSeq; Error: cmsFreeProfileSequenceDescription(NewSeq); return NULL; } Commit Message: Non happy-path fixes CWE ID:
0
40,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: error::Error GLES2DecoderImpl::HandleDrawArrays(uint32_t immediate_data_size, const volatile void* cmd_data) { const volatile cmds::DrawArrays& c = *static_cast<const volatile cmds::DrawArrays*>(cmd_data); return DoDrawArrays("glDrawArrays", false, static_cast<GLenum>(c.mode), static_cast<GLint>(c.first), static_cast<GLsizei>(c.count), 1); } Commit Message: Implement immutable texture base/max level clamping It seems some drivers fail to handle that gracefully, so let's always clamp to be on the safe side. BUG=877874 TEST=test case in the bug, gpu_unittests R=kbr@chromium.org 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: I6d93cb9389ea70525df4604112223604577582a2 Reviewed-on: https://chromium-review.googlesource.com/1194994 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Zhenyao Mo <zmo@chromium.org> Cr-Commit-Position: refs/heads/master@{#587264} CWE ID: CWE-119
0
145,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: externalEntityInitProcessor(XML_Parser parser, const char *start, const char *end, const char **endPtr) { enum XML_Error result = initializeEncoding(parser); if (result != XML_ERROR_NONE) return result; parser->m_processor = externalEntityInitProcessor2; return externalEntityInitProcessor2(parser, start, end, endPtr); } Commit Message: xmlparse.c: Deny internal entities closing the doctype CWE ID: CWE-611
0
88,264
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 ion_buffer_put(struct ion_buffer *buffer) { return kref_put(&buffer->ref, _ion_buffer_destroy); } Commit Message: staging/android/ion : fix a race condition in the ion driver There is a use-after-free problem in the ion driver. This is caused by a race condition in the ion_ioctl() function. A handle has ref count of 1 and two tasks on different cpus calls ION_IOC_FREE simultaneously. cpu 0 cpu 1 ------------------------------------------------------- ion_handle_get_by_id() (ref == 2) ion_handle_get_by_id() (ref == 3) ion_free() (ref == 2) ion_handle_put() (ref == 1) ion_free() (ref == 0 so ion_handle_destroy() is called and the handle is freed.) ion_handle_put() is called and it decreases the slub's next free pointer The problem is detected as an unaligned access in the spin lock functions since it uses load exclusive instruction. In some cases it corrupts the slub's free pointer which causes a mis-aligned access to the next free pointer.(kmalloc returns a pointer like ffffc0745b4580aa). And it causes lots of other hard-to-debug problems. This symptom is caused since the first member in the ion_handle structure is the reference count and the ion driver decrements the reference after it has been freed. To fix this problem client->lock mutex is extended to protect all the codes that uses the handle. Signed-off-by: Eun Taik Lee <eun.taik.lee@samsung.com> Reviewed-by: Laura Abbott <labbott@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> CWE ID: CWE-416
0
48,529
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 RenderFrameHostImpl::CreateUsbDeviceManager( device::mojom::UsbDeviceManagerRequest request) { GetContentClient()->browser()->CreateUsbDeviceManager(this, std::move(request)); } Commit Message: If a page calls |window.focus()|, kick it out of fullscreen. BUG=776418, 800056 Change-Id: I1880fe600e4814c073f247c43b1c1ac80c8fc017 Reviewed-on: https://chromium-review.googlesource.com/852378 Reviewed-by: Nasko Oskov <nasko@chromium.org> Reviewed-by: Philip Jägenstedt <foolip@chromium.org> Commit-Queue: Avi Drissman <avi@chromium.org> Cr-Commit-Position: refs/heads/master@{#533790} CWE ID:
0
147,620
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 handle_new_msr(struct edgeport_port *edge_port, __u8 msr) { struct async_icount *icount; struct tty_struct *tty; dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, msr); if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { icount = &edge_port->port->icount; /* update input line counters */ if (msr & EDGEPORT_MSR_DELTA_CTS) icount->cts++; if (msr & EDGEPORT_MSR_DELTA_DSR) icount->dsr++; if (msr & EDGEPORT_MSR_DELTA_CD) icount->dcd++; if (msr & EDGEPORT_MSR_DELTA_RI) icount->rng++; wake_up_interruptible(&edge_port->port->port.delta_msr_wait); } /* Save the new modem status */ edge_port->shadow_msr = msr & 0xf0; tty = tty_port_tty_get(&edge_port->port->port); /* handle CTS flow control */ if (tty && C_CRTSCTS(tty)) { if (msr & EDGEPORT_MSR_CTS) tty_wakeup(tty); } tty_kref_put(tty); } Commit Message: USB: serial: io_ti: fix information leak in completion handler Add missing sanity check to the bulk-in completion handler to avoid an integer underflow that can be triggered by a malicious device. This avoids leaking 128 kB of memory content from after the URB transfer buffer to user space. Fixes: 8c209e6782ca ("USB: make actual_length in struct urb field u32") Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable <stable@vger.kernel.org> # 2.6.30 Signed-off-by: Johan Hovold <johan@kernel.org> CWE ID: CWE-191
0
66,099
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::didUpdateSecurityOrigin() { if (!m_frame) return; m_frame->script()->updateSecurityOrigin(); } Commit Message: Refactoring: Move m_mayDisplaySeamlesslyWithParent down to Document The member is used only in Document, thus no reason to stay in SecurityContext. TEST=none BUG=none R=haraken@chromium.org, abarth, haraken, hayato Review URL: https://codereview.chromium.org/27615003 git-svn-id: svn://svn.chromium.org/blink/trunk@159829 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-20
0
102,697
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: PluginServiceFilter* PluginServiceImpl::GetFilter() { return filter_; } Commit Message: Follow-on fixes and naming changes for https://codereview.chromium.org/12086077/ BUG=172573 Review URL: https://codereview.chromium.org/12177018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180600 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-287
0
116,775
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 vm_area_struct *vmacache_find(struct mm_struct *mm, unsigned long addr) { int idx = VMACACHE_HASH(addr); int i; count_vm_vmacache_event(VMACACHE_FIND_CALLS); if (!vmacache_valid(mm)) return NULL; for (i = 0; i < VMACACHE_SIZE; i++) { struct vm_area_struct *vma = current->vmacache.vmas[idx]; if (vma) { #ifdef CONFIG_DEBUG_VM_VMACACHE if (WARN_ON_ONCE(vma->vm_mm != mm)) break; #endif if (vma->vm_start <= addr && vma->vm_end > addr) { count_vm_vmacache_event(VMACACHE_FIND_HITS); return vma; } } if (++idx == VMACACHE_SIZE) idx = 0; } return NULL; } Commit Message: mm: get rid of vmacache_flush_all() entirely Jann Horn points out that the vmacache_flush_all() function is not only potentially expensive, it's buggy too. It also happens to be entirely unnecessary, because the sequence number overflow case can be avoided by simply making the sequence number be 64-bit. That doesn't even grow the data structures in question, because the other adjacent fields are already 64-bit. So simplify the whole thing by just making the sequence number overflow case go away entirely, which gets rid of all the complications and makes the code faster too. Win-win. [ Oleg Nesterov points out that the VMACACHE_FULL_FLUSHES statistics also just goes away entirely with this ] Reported-by: Jann Horn <jannh@google.com> Suggested-by: Will Deacon <will.deacon@arm.com> Acked-by: Davidlohr Bueso <dave@stgolabs.net> Cc: Oleg Nesterov <oleg@redhat.com> Cc: stable@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID: CWE-416
0
77,749
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 bin_main(RCore *r, int mode, int va) { RBinAddr *binmain = r_bin_get_sym (r->bin, R_BIN_SYM_MAIN); ut64 addr; if (!binmain) { return false; } addr = va ? r_bin_a2b (r->bin, binmain->vaddr) : binmain->paddr; if (IS_MODE_SET (mode)) { r_flag_space_set (r->flags, "symbols"); r_flag_set (r->flags, "main", addr, r->blocksize); } else if (IS_MODE_SIMPLE (mode)) { r_cons_printf ("%"PFMT64d, addr); } else if (IS_MODE_RAD (mode)) { r_cons_printf ("fs symbols\n"); r_cons_printf ("f main @ 0x%08"PFMT64x"\n", addr); } else if (IS_MODE_JSON (mode)) { r_cons_printf ("{\"vaddr\":%" PFMT64d ",\"paddr\":%" PFMT64d "}", addr, binmain->paddr); } else { r_cons_printf ("[Main]\n"); r_cons_printf ("vaddr=0x%08"PFMT64x" paddr=0x%08"PFMT64x"\n", addr, binmain->paddr); } return true; } Commit Message: Fix #9904 - crash in r2_hoobr_r_read_le32 (over 9000 entrypoints) and read_le oobread (#9923) CWE ID: CWE-125
0
82,960
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 inline void register_fair_sched_group(struct task_group *tg, int cpu) { } Commit Message: Sched: fix skip_clock_update optimization idle_balance() drops/retakes rq->lock, leaving the previous task vulnerable to set_tsk_need_resched(). Clear it after we return from balancing instead, and in setup_thread_stack() as well, so no successfully descheduled or never scheduled task has it set. Need resched confused the skip_clock_update logic, which assumes that the next call to update_rq_clock() will come nearly immediately after being set. Make the optimization robust against the waking a sleeper before it sucessfully deschedules case by checking that the current task has not been dequeued before setting the flag, since it is that useless clock update we're trying to save, and clear unconditionally in schedule() proper instead of conditionally in put_prev_task(). Signed-off-by: Mike Galbraith <efault@gmx.de> Reported-by: Bjoern B. Brandenburg <bbb.lst@gmail.com> Tested-by: Yong Zhang <yong.zhang0@gmail.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: stable@kernel.org LKML-Reference: <1291802742.1417.9.camel@marge.simson.net> Signed-off-by: Ingo Molnar <mingo@elte.hu> CWE ID:
0
22,514
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 hiddev_poll(struct file *file, poll_table *wait) { struct hiddev_list *list = file->private_data; poll_wait(file, &list->hiddev->wait, wait); if (list->head != list->tail) return POLLIN | POLLRDNORM; if (!list->hiddev->exist) return POLLERR | POLLHUP; return 0; } Commit Message: HID: hiddev: validate num_values for HIDIOCGUSAGES, HIDIOCSUSAGES commands This patch validates the num_values parameter from userland during the HIDIOCGUSAGES and HIDIOCSUSAGES commands. Previously, if the report id was set to HID_REPORT_ID_UNKNOWN, we would fail to validate the num_values parameter leading to a heap overflow. Cc: stable@vger.kernel.org Signed-off-by: Scott Bauer <sbauer@plzdonthack.me> Signed-off-by: Jiri Kosina <jkosina@suse.cz> CWE ID: CWE-119
0
51,239
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: AttachUnboundGPU(ScreenPtr pScreen, ScreenPtr new) { assert(new->isGPU); assert(!new->current_master); xorg_list_add(&new->unattached_head, &pScreen->unattached_list); new->current_master = pScreen; } Commit Message: CWE ID: CWE-369
0
14,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: void lodepng_decompress_settings_init(LodePNGDecompressSettings* settings) { settings->ignore_adler32 = 0; settings->custom_zlib = 0; settings->custom_inflate = 0; settings->custom_context = 0; } Commit Message: Fixed #5645: realloc return handling CWE ID: CWE-772
0
87,536
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 vfio_pci_set_irqs_ioctl(struct vfio_pci_device *vdev, uint32_t flags, unsigned index, unsigned start, unsigned count, void *data) { int (*func)(struct vfio_pci_device *vdev, unsigned index, unsigned start, unsigned count, uint32_t flags, void *data) = NULL; switch (index) { case VFIO_PCI_INTX_IRQ_INDEX: switch (flags & VFIO_IRQ_SET_ACTION_TYPE_MASK) { case VFIO_IRQ_SET_ACTION_MASK: func = vfio_pci_set_intx_mask; break; case VFIO_IRQ_SET_ACTION_UNMASK: func = vfio_pci_set_intx_unmask; break; case VFIO_IRQ_SET_ACTION_TRIGGER: func = vfio_pci_set_intx_trigger; break; } break; case VFIO_PCI_MSI_IRQ_INDEX: case VFIO_PCI_MSIX_IRQ_INDEX: switch (flags & VFIO_IRQ_SET_ACTION_TYPE_MASK) { case VFIO_IRQ_SET_ACTION_MASK: case VFIO_IRQ_SET_ACTION_UNMASK: /* XXX Need masking support exported */ break; case VFIO_IRQ_SET_ACTION_TRIGGER: func = vfio_pci_set_msi_trigger; break; } break; case VFIO_PCI_ERR_IRQ_INDEX: switch (flags & VFIO_IRQ_SET_ACTION_TYPE_MASK) { case VFIO_IRQ_SET_ACTION_TRIGGER: if (pci_is_pcie(vdev->pdev)) func = vfio_pci_set_err_trigger; break; } break; case VFIO_PCI_REQ_IRQ_INDEX: switch (flags & VFIO_IRQ_SET_ACTION_TYPE_MASK) { case VFIO_IRQ_SET_ACTION_TRIGGER: func = vfio_pci_set_req_trigger; break; } break; } if (!func) return -ENOTTY; return func(vdev, index, start, count, flags, data); } Commit Message: vfio/pci: Fix integer overflows, bitmask check The VFIO_DEVICE_SET_IRQS ioctl did not sufficiently sanitize user-supplied integers, potentially allowing memory corruption. This patch adds appropriate integer overflow checks, checks the range bounds for VFIO_IRQ_SET_DATA_NONE, and also verifies that only single element in the VFIO_IRQ_SET_DATA_TYPE_MASK bitmask is set. VFIO_IRQ_SET_ACTION_TYPE_MASK is already correctly checked later in vfio_pci_set_irqs_ioctl(). Furthermore, a kzalloc is changed to a kcalloc because the use of a kzalloc with an integer multiplication allowed an integer overflow condition to be reached without this patch. kcalloc checks for overflow and should prevent a similar occurrence. Signed-off-by: Vlad Tsyrklevich <vlad@tsyrklevich.net> Signed-off-by: Alex Williamson <alex.williamson@redhat.com> CWE ID: CWE-190
0
48,625
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: rpc_free_client(struct rpc_clnt *clnt) { dprintk("RPC: destroying %s client for %s\n", clnt->cl_protname, clnt->cl_server); if (!IS_ERR(clnt->cl_path.dentry)) { rpc_remove_client_dir(clnt->cl_path.dentry); rpc_put_mount(); } if (clnt->cl_parent != clnt) { rpc_release_client(clnt->cl_parent); goto out_free; } if (clnt->cl_server != clnt->cl_inline_name) kfree(clnt->cl_server); out_free: rpc_unregister_client(clnt); rpc_free_iostats(clnt->cl_metrics); kfree(clnt->cl_principal); clnt->cl_metrics = NULL; xprt_put(clnt->cl_xprt); rpciod_down(); kfree(clnt); } 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,904
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 NameForChoice(const Experiment& e, int index) { DCHECK_EQ(Experiment::MULTI_VALUE, e.type); DCHECK_LT(index, e.num_choices); return std::string(e.internal_name) + about_flags::testing::kMultiSeparator + base::IntToString(index); } 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
0
104,817
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 inline u64 virt_ticks(struct task_struct *p) { u64 utime, stime; task_cputime(p, &utime, &stime); return utime; } Commit Message: posix-timers: Sanitize overrun handling The posix timer overrun handling is broken because the forwarding functions can return a huge number of overruns which does not fit in an int. As a consequence timer_getoverrun(2) and siginfo::si_overrun can turn into random number generators. The k_clock::timer_forward() callbacks return a 64 bit value now. Make k_itimer::ti_overrun[_last] 64bit as well, so the kernel internal accounting is correct. 3Remove the temporary (int) casts. Add a helper function which clamps the overrun value returned to user space via timer_getoverrun(2) or siginfo::si_overrun limited to a positive value between 0 and INT_MAX. INT_MAX is an indicator for user space that the overrun value has been clamped. Reported-by: Team OWL337 <icytxw@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: John Stultz <john.stultz@linaro.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Michael Kerrisk <mtk.manpages@gmail.com> Link: https://lkml.kernel.org/r/20180626132705.018623573@linutronix.de CWE ID: CWE-190
0
81,136
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 user_space_stream_notifier_dtor(php_stream_notifier *notifier) { if (notifier && notifier->ptr) { zval_ptr_dtor((zval **)&(notifier->ptr)); notifier->ptr = NULL; } } Commit Message: CWE ID: CWE-254
0
15,291
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 iw_random_dither(struct iw_context *ctx, double fraction, int x, int y, int dithersubtype, int channel) { double threshold; threshold = ((double)iwpvt_prng_rand(ctx->prng)) / (double)0xffffffff; if(fraction>=threshold) return 1; return 0; } Commit Message: Fixed a bug that could cause invalid memory to be accessed The bug could happen when transparency is removed from an image. Also fixed a semi-related BMP error handling logic bug. Fixes issue #21 CWE ID: CWE-787
0
64,932
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: instance_handler(vector_t *strvec) { if (!strvec) return; if (!reload) { if (!global_data->instance_name) { global_data->instance_name = set_value(strvec); use_pid_dir = true; } else report_config_error(CONFIG_GENERAL_ERROR, "Duplicate instance definition %s - ignoring", FMT_STR_VSLOT(strvec, 1)); } } Commit Message: Add command line and configuration option to set umask Issue #1048 identified that files created by keepalived are created with mode 0666. This commit changes the default to 0644, and also allows the umask to be specified in the configuration or as a command line option. Signed-off-by: Quentin Armitage <quentin@armitage.org.uk> CWE ID: CWE-200
0
75,827
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: _dbus_marshal_header_test (void) { return TRUE; } Commit Message: CWE ID: CWE-20
0
2,759
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 ff_rtmp_packet_read(URLContext *h, RTMPPacket *p, int chunk_size, RTMPPacket **prev_pkt, int *nb_prev_pkt) { uint8_t hdr; if (ffurl_read(h, &hdr, 1) != 1) return AVERROR(EIO); return ff_rtmp_packet_read_internal(h, p, chunk_size, prev_pkt, nb_prev_pkt, hdr); } Commit Message: avformat/rtmppkt: Convert ff_amf_get_field_value() to bytestream2 Fixes: out of array accesses Found-by: JunDong Xie of Ant-financial Light-Year Security Lab Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> CWE ID: CWE-20
0
63,211
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 Cleanup(Vdbe *p){ sqlite3 *db = p->db; #ifdef SQLITE_DEBUG /* Execute assert() statements to ensure that the Vdbe.apCsr[] and ** Vdbe.aMem[] arrays have already been cleaned up. */ int i; if( p->apCsr ) for(i=0; i<p->nCursor; i++) assert( p->apCsr[i]==0 ); if( p->aMem ){ for(i=0; i<p->nMem; i++) assert( p->aMem[i].flags==MEM_Undefined ); } #endif sqlite3DbFree(db, p->zErrMsg); p->zErrMsg = 0; p->pResultSet = 0; } Commit Message: sqlite: safely move pointer values through SQL. This lands https://www.sqlite.org/src/timeline?c=d6a44b35 in third_party/sqlite/src/ and third_party/sqlite/patches/0013-Add-new-interfaces-sqlite3_bind_pointer-sqlite3_resu.patch and re-generates third_party/sqlite/amalgamation/* using the script at third_party/sqlite/google_generate_amalgamation.sh. The CL also adds a layout test that verifies the patch works as intended. BUG=742407 Change-Id: I2e1a457459cd2e975e6241b630e7b79c82545981 Reviewed-on: https://chromium-review.googlesource.com/572976 Reviewed-by: Chris Mumford <cmumford@chromium.org> Commit-Queue: Victor Costan <pwnall@chromium.org> Cr-Commit-Position: refs/heads/master@{#487275} CWE ID: CWE-119
0
136,258
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: load_face_in_embedded_rfork( FT_Library library, FT_Stream stream, FT_Long face_index, FT_Face *aface, const FT_Open_Args *args ) { #undef FT_COMPONENT #define FT_COMPONENT trace_raccess FT_Memory memory = library->memory; FT_Error error = FT_Err_Unknown_File_Format; int i; char * file_names[FT_RACCESS_N_RULES]; FT_Long offsets[FT_RACCESS_N_RULES]; FT_Error errors[FT_RACCESS_N_RULES]; FT_Open_Args args2; FT_Stream stream2 = 0; FT_Raccess_Guess( library, stream, args->pathname, file_names, offsets, errors ); for ( i = 0; i < FT_RACCESS_N_RULES; i++ ) { if ( errors[i] ) { FT_TRACE3(( "Error[%d] has occurred in rule %d\n", errors[i], i )); continue; } args2.flags = FT_OPEN_PATHNAME; args2.pathname = file_names[i] ? file_names[i] : args->pathname; FT_TRACE3(( "Try rule %d: %s (offset=%d) ...", i, args2.pathname, offsets[i] )); error = FT_Stream_New( library, &args2, &stream2 ); if ( error ) { FT_TRACE3(( "failed\n" )); continue; } error = IsMacResource( library, stream2, offsets[i], face_index, aface ); FT_Stream_Free( stream2, 0 ); FT_TRACE3(( "%s\n", error ? "failed": "successful" )); if ( !error ) break; } for (i = 0; i < FT_RACCESS_N_RULES; i++) { if ( file_names[i] ) FT_FREE( file_names[i] ); } /* Caller (load_mac_face) requires FT_Err_Unknown_File_Format. */ if ( error ) error = FT_Err_Unknown_File_Format; return error; #undef FT_COMPONENT #define FT_COMPONENT trace_objs } Commit Message: CWE ID: CWE-119
0
10,287
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_reqs_available(struct kioctx *ctx, unsigned nr) { struct kioctx_cpu *kcpu; unsigned long flags; local_irq_save(flags); kcpu = this_cpu_ptr(ctx->cpu); kcpu->reqs_available += nr; while (kcpu->reqs_available >= ctx->req_batch * 2) { kcpu->reqs_available -= ctx->req_batch; atomic_add(ctx->req_batch, &ctx->reqs_available); } local_irq_restore(flags); } Commit Message: aio: mark AIO pseudo-fs noexec This ensures that do_mmap() won't implicitly make AIO memory mappings executable if the READ_IMPLIES_EXEC personality flag is set. Such behavior is problematic because the security_mmap_file LSM hook doesn't catch this case, potentially permitting an attacker to bypass a W^X policy enforced by SELinux. I have tested the patch on my machine. To test the behavior, compile and run this: #define _GNU_SOURCE #include <unistd.h> #include <sys/personality.h> #include <linux/aio_abi.h> #include <err.h> #include <stdlib.h> #include <stdio.h> #include <sys/syscall.h> int main(void) { personality(READ_IMPLIES_EXEC); aio_context_t ctx = 0; if (syscall(__NR_io_setup, 1, &ctx)) err(1, "io_setup"); char cmd[1000]; sprintf(cmd, "cat /proc/%d/maps | grep -F '/[aio]'", (int)getpid()); system(cmd); return 0; } In the output, "rw-s" is good, "rwxs" is bad. Signed-off-by: Jann Horn <jann@thejh.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID: CWE-264
0
72,042
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: ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() : download_file_manager_(new DownloadFileManager(NULL)), save_file_manager_(new SaveFileManager()), request_id_(-1), is_shutdown_(false), max_outstanding_requests_cost_per_process_( kMaxOutstandingRequestsCostPerProcess), filter_(NULL), delegate_(NULL), allow_cross_origin_auth_prompt_(false) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!g_resource_dispatcher_host); g_resource_dispatcher_host = this; GetContentClient()->browser()->ResourceDispatcherHostCreated(); ANNOTATE_BENIGN_RACE( &last_user_gesture_time_, "We don't care about the precise value, see http://crbug.com/92889"); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&appcache::AppCacheInterceptor::EnsureRegistered)); update_load_states_timer_.reset( new base::RepeatingTimer<ResourceDispatcherHostImpl>()); } Commit Message: Make chrome.appWindow.create() provide access to the child window at a predictable time. When you first create a window with chrome.appWindow.create(), it won't have loaded any resources. So, at create time, you are guaranteed that: child_window.location.href == 'about:blank' child_window.document.documentElement.outerHTML == '<html><head></head><body></body></html>' This is in line with the behaviour of window.open(). BUG=131735 TEST=browser_tests:PlatformAppBrowserTest.WindowsApi Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=144072 Review URL: https://chromiumcodereview.appspot.com/10644006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144356 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
105,418
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 virtio_gpu_invalidate_display(void *opaque) { } Commit Message: CWE ID: CWE-772
0
6,252
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 iov_fault_in_pages_read(struct iovec *iov, unsigned long len) { while (!iov->iov_len) iov++; while (len > 0) { unsigned long this_len; this_len = min_t(unsigned long, len, iov->iov_len); fault_in_pages_readable(iov->iov_base, this_len); len -= this_len; iov++; } } Commit Message: new helper: copy_page_from_iter() parallel to copy_page_to_iter(). pipe_write() switched to it (and became ->write_iter()). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> CWE ID: CWE-17
1
166,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: ExtensionSettingsHandler::~ExtensionSettingsHandler() { if (load_extension_dialog_.get()) load_extension_dialog_->ListenerDestroyed(); registrar_.RemoveAll(); } Commit Message: [i18n-fixlet] Make strings branding specific in extension code. IDS_EXTENSIONS_UNINSTALL IDS_EXTENSIONS_INCOGNITO_WARNING IDS_EXTENSION_INSTALLED_HEADING IDS_EXTENSION_ALERT_ITEM_EXTERNAL And fix a $1 $1 bug. IDS_EXTENSION_INLINE_INSTALL_PROMPT_TITLE BUG=NONE TEST=NONE Review URL: http://codereview.chromium.org/9107061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118018 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-119
0
107,826
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: RenderFrameImpl* RenderFrameImpl::FromRoutingID(int routing_id) { DCHECK(RenderThread::IsMainThread()); auto iter = g_routing_id_frame_map.Get().find(routing_id); if (iter != g_routing_id_frame_map.Get().end()) return iter->second; return nullptr; } Commit Message: Convert FrameHostMsg_DidAddMessageToConsole to Mojo. Note: Since this required changing the test RenderViewImplTest.DispatchBeforeUnloadCanDetachFrame, I manually re-introduced https://crbug.com/666714 locally (the bug the test was added for), and reran the test to confirm that it still covers the bug. Bug: 786836 Change-Id: I110668fa6f0f261fd2ac36bb91a8d8b31c99f4f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1526270 Commit-Queue: Lowell Manners <lowell@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Camille Lamy <clamy@chromium.org> Cr-Commit-Position: refs/heads/master@{#653137} CWE ID: CWE-416
0
139,644
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 WebLocalFrameImpl::ExecuteCommand(const WebString& name) { DCHECK(GetFrame()); if (name.length() <= 2) return false; String command = name; command.replace(0, 1, command.Substring(0, 1).UpperASCII()); if (command[command.length() - 1] == UChar(':')) command = command.Substring(0, command.length() - 1); Node* plugin_lookup_context_node = nullptr; if (WebPluginContainerImpl::SupportsCommand(name)) plugin_lookup_context_node = ContextMenuNodeInner(); std::unique_ptr<UserGestureIndicator> gesture_indicator = Frame::NotifyUserActivation(GetFrame(), UserGestureToken::kNewGesture); WebPluginContainerImpl* plugin_container = GetFrame()->GetWebPluginContainer(plugin_lookup_context_node); if (plugin_container && plugin_container->ExecuteEditCommand(name)) return true; return GetFrame()->GetEditor().ExecuteCommand(command); } Commit Message: Do not forward resource timing to parent frame after back-forward navigation LocalFrame has |should_send_resource_timing_info_to_parent_| flag not to send timing info to parent except for the first navigation. This flag is cleared when the first timing is sent to parent, however this does not happen if iframe's first navigation was by back-forward navigation. For such iframes, we shouldn't send timings to parent at all. Bug: 876822 Change-Id: I128b51a82ef278c439548afc8283ae63abdef5c5 Reviewed-on: https://chromium-review.googlesource.com/1186215 Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Commit-Queue: Kunihiko Sakamoto <ksakamoto@chromium.org> Cr-Commit-Position: refs/heads/master@{#585736} CWE ID: CWE-200
0
145,721
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 __init des_generic_mod_init(void) { return crypto_register_algs(des_algs, ARRAY_SIZE(des_algs)); } Commit Message: crypto: prefix module autoloading with "crypto-" This prefixes all crypto module loading with "crypto-" so we never run the risk of exposing module auto-loading to userspace via a crypto API, as demonstrated by Mathias Krause: https://lkml.org/lkml/2013/3/4/70 Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> CWE ID: CWE-264
0
47,239
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::ShowHtmlDialog(HtmlDialogUIDelegate* delegate, gfx::NativeWindow parent_window) { window_->ShowHTMLDialog(delegate, parent_window); } Commit Message: chromeos: fix bug where "aw snap" page replaces first tab if it was a NTP when closing window with > 1 tab. BUG=chromium-os:12088 TEST=verify bug per bug report. Review URL: http://codereview.chromium.org/6882058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83031 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
98,324
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 _etc_hosts_lookup(const char *cszName, char *szIP, const int ciMaxIPLen) { #define EHL_LINE_LEN 260 int iSuccess = 0; size_t iLen; char szLine[EHL_LINE_LEN + 1]; /* one extra for the space character (*) */ char *pcStart, *pcEnd; FILE *fHosts; do { /* initialization */ fHosts = NULL; /* sanity checks */ if ((cszName == NULL) || (szIP == NULL) || (ciMaxIPLen <= 0)) break; szIP[0] = 0; /* open the hosts file */ #ifdef _WIN32 pcStart = getenv("WINDIR"); if (pcStart != NULL) { sprintf(szLine, "%s\\system32\\drivers\\etc\\hosts", pcStart); } else { strcpy(szLine, "C:\\WINDOWS\\system32\\drivers\\etc\\hosts"); } #else strcpy(szLine, "/etc/hosts"); #endif fHosts = fopen(szLine, "r"); if (fHosts == NULL) break; /* read line by line ... */ while (fgets(szLine, EHL_LINE_LEN, fHosts) != NULL) { /* remove comments */ pcStart = strchr (szLine, '#'); if (pcStart != NULL) *pcStart = 0; strcat(szLine, " "); /* append a space character for easier parsing (*) */ /* first to appear: IP address */ iLen = strspn(szLine, "1234567890."); if ((iLen < 7) || (iLen > 15)) /* superficial test for anything between x.x.x.x and xxx.xxx.xxx.xxx */ continue; pcEnd = szLine + iLen; *pcEnd = 0; pcEnd++; /* not beyond the end of the line yet (*) */ /* check strings separated by blanks, tabs or newlines */ pcStart = pcEnd + strspn(pcEnd, " \t\n"); while (*pcStart != 0) { pcEnd = pcStart + strcspn(pcStart, " \t\n"); *pcEnd = 0; pcEnd++; /* not beyond the end of the line yet (*) */ if (strcasecmp(pcStart, cszName) == 0) { strncpy(szIP, szLine, ciMaxIPLen - 1); szIP[ciMaxIPLen - 1] = '\0'; iSuccess = 1; break; } pcStart = pcEnd + strspn(pcEnd, " \t\n"); } if (iSuccess) break; } } while (0); if (fHosts != NULL) fclose(fHosts); return (iSuccess); } Commit Message: Fixed possibility of Unsolicited Dialback Attacks CWE ID: CWE-20
0
19,183
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 __exit wp512_mod_fini(void) { crypto_unregister_shashes(wp_algs, ARRAY_SIZE(wp_algs)); } Commit Message: crypto: prefix module autoloading with "crypto-" This prefixes all crypto module loading with "crypto-" so we never run the risk of exposing module auto-loading to userspace via a crypto API, as demonstrated by Mathias Krause: https://lkml.org/lkml/2013/3/4/70 Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> CWE ID: CWE-264
0
47,406
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 nfs4_client *alloc_client(struct xdr_netobj name) { struct nfs4_client *clp; int i; clp = kzalloc(sizeof(struct nfs4_client), GFP_KERNEL); if (clp == NULL) return NULL; clp->cl_name.data = kmemdup(name.data, name.len, GFP_KERNEL); if (clp->cl_name.data == NULL) goto err_no_name; clp->cl_ownerstr_hashtbl = kmalloc(sizeof(struct list_head) * OWNER_HASH_SIZE, GFP_KERNEL); if (!clp->cl_ownerstr_hashtbl) goto err_no_hashtbl; for (i = 0; i < OWNER_HASH_SIZE; i++) INIT_LIST_HEAD(&clp->cl_ownerstr_hashtbl[i]); clp->cl_name.len = name.len; INIT_LIST_HEAD(&clp->cl_sessions); idr_init(&clp->cl_stateids); atomic_set(&clp->cl_refcount, 0); clp->cl_cb_state = NFSD4_CB_UNKNOWN; INIT_LIST_HEAD(&clp->cl_idhash); INIT_LIST_HEAD(&clp->cl_openowners); INIT_LIST_HEAD(&clp->cl_delegations); INIT_LIST_HEAD(&clp->cl_lru); INIT_LIST_HEAD(&clp->cl_revoked); #ifdef CONFIG_NFSD_PNFS INIT_LIST_HEAD(&clp->cl_lo_states); #endif spin_lock_init(&clp->cl_lock); rpc_init_wait_queue(&clp->cl_cb_waitq, "Backchannel slot table"); return clp; err_no_hashtbl: kfree(clp->cl_name.data); err_no_name: kfree(clp); return NULL; } 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,403
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* AXNodeObject::menuButtonForMenu() const { Element* menuItem = menuItemElementForMenu(); if (menuItem) { AXObject* menuItemAX = axObjectCache().getOrCreate(menuItem); if (menuItemAX && menuItemAX->isMenuButton()) return menuItemAX; } return 0; } 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,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: int FlateStream::lookChar() { int c; if (pred) { return pred->lookChar(); } while (remain == 0) { if (endOfBlock && eof) return EOF; readSome(); } c = buf[index]; return c; } Commit Message: CWE ID: CWE-119
0
3,993
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 _snd_pcm_hw_param_first(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { int changed; if (hw_is_mask(var)) changed = snd_mask_refine_first(hw_param_mask(params, var)); else if (hw_is_interval(var)) changed = snd_interval_refine_first(hw_param_interval(params, var)); else return -EINVAL; if (changed) { params->cmask |= 1 << var; params->rmask |= 1 << var; } return changed; } Commit Message: ALSA: pcm : Call kill_fasync() in stream lock Currently kill_fasync() is called outside the stream lock in snd_pcm_period_elapsed(). This is potentially racy, since the stream may get released even during the irq handler is running. Although snd_pcm_release_substream() calls snd_pcm_drop(), this doesn't guarantee that the irq handler finishes, thus the kill_fasync() call outside the stream spin lock may be invoked after the substream is detached, as recently reported by KASAN. As a quick workaround, move kill_fasync() call inside the stream lock. The fasync is rarely used interface, so this shouldn't have a big impact from the performance POV. Ideally, we should implement some sync mechanism for the proper finish of stream and irq handler. But this oneliner should suffice for most cases, so far. Reported-by: Baozeng Ding <sploving1@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> CWE ID: CWE-416
0
47,778
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 ChromeContentBrowserClient::GetSchemesBypassingSecureContextCheckWhitelist( std::set<std::string>* schemes) { *schemes = secure_origin_whitelist::GetSchemesBypassingSecureContextCheck(); } Commit Message: Move IsDataSaverEnabledByUser to be a static method and use it This method now officially becomes the source of truth that everything in the code base eventually calls into to determine whether or not DataSaver is enabled. Bug: 934399 Change-Id: Iae837b710ace8cc3101188f79d02cbc2d4f0fd93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1537242 Reviewed-by: Joshua Pawlicki <waffles@chromium.org> Reviewed-by: Tarun Bansal <tbansal@chromium.org> Commit-Queue: Robert Ogden <robertogden@chromium.org> Cr-Commit-Position: refs/heads/master@{#643948} CWE ID: CWE-119
0
142,673
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 mk_vhost_fdt_worker_exit() { struct mk_list *head; struct mk_list *tmp; struct vhost_fdt_host *fdt; if (config->fdt == MK_FALSE) { return -1; } mk_list_foreach_safe(head, tmp, mk_vhost_fdt_key) { fdt = mk_list_entry(head, struct vhost_fdt_host, _head); mk_list_del(&fdt->_head); mk_mem_free(fdt); } mk_mem_free(mk_vhost_fdt_key); return 0; } Commit Message: Request: new request session flag to mark those files opened by FDT This patch aims to fix a potential DDoS problem that can be caused in the server quering repetitive non-existent resources. When serving a static file, the core use Vhost FDT mechanism, but if it sends a static error page it does a direct open(2). When closing the resources for the same request it was just calling mk_vhost_close() which did not clear properly the file descriptor. This patch adds a new field on the struct session_request called 'fd_is_fdt', which contains MK_TRUE or MK_FALSE depending of how fd_file was opened. Thanks to Matthew Daley <mattd@bugfuzz.com> for report and troubleshoot this problem. Signed-off-by: Eduardo Silva <eduardo@monkey.io> CWE ID: CWE-20
0
36,169
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 o2nm_depend_this_node(void) { int ret = 0; struct o2nm_node *local_node; local_node = o2nm_get_node_by_num(o2nm_this_node()); if (!local_node) { ret = -EINVAL; goto out; } ret = o2nm_depend_item(&local_node->nd_item); o2nm_node_put(local_node); out: return ret; } Commit Message: ocfs2: subsystem.su_mutex is required while accessing the item->ci_parent The subsystem.su_mutex is required while accessing the item->ci_parent, otherwise, NULL pointer dereference to the item->ci_parent will be triggered in the following situation: add node delete node sys_write vfs_write configfs_write_file o2nm_node_store o2nm_node_local_write do_rmdir vfs_rmdir configfs_rmdir mutex_lock(&subsys->su_mutex); unlink_obj item->ci_group = NULL; item->ci_parent = NULL; to_o2nm_cluster_from_node node->nd_item.ci_parent->ci_parent BUG since of NULL pointer dereference to nd_item.ci_parent Moreover, the o2nm_cluster also should be protected by the subsystem.su_mutex. [alex.chen@huawei.com: v2] Link: http://lkml.kernel.org/r/59EEAA69.9080703@huawei.com Link: http://lkml.kernel.org/r/59E9B36A.10700@huawei.com Signed-off-by: Alex Chen <alex.chen@huawei.com> Reviewed-by: Jun Piao <piaojun@huawei.com> Reviewed-by: Joseph Qi <jiangqi903@gmail.com> Cc: Mark Fasheh <mfasheh@versity.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID: CWE-476
0
85,753
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 MACH0_(is_pie)(struct MACH0_(obj_t)* bin) { return (bin && bin->hdr.filetype == MH_EXECUTE && bin->hdr.flags & MH_PIE); } Commit Message: Fix null deref and uaf in mach0 parser CWE ID: CWE-416
0
66,831
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 rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit) { int retval; struct tree *t1 = commit->tree; if (!t1) return 0; tree_difference = REV_TREE_SAME; DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES); retval = diff_tree_sha1(NULL, t1->object.oid.hash, "", &revs->pruning); return retval >= 0 && (tree_difference == REV_TREE_SAME); } Commit Message: list-objects: pass full pathname to callbacks When we find a blob at "a/b/c", we currently pass this to our show_object_fn callbacks as two components: "a/b/" and "c". Callbacks which want the full value then call path_name(), which concatenates the two. But this is an inefficient interface; the path is a strbuf, and we could simply append "c" to it temporarily, then roll back the length, without creating a new copy. So we could improve this by teaching the callsites of path_name() this trick (and there are only 3). But we can also notice that no callback actually cares about the broken-down representation, and simply pass each callback the full path "a/b/c" as a string. The callback code becomes even simpler, then, as we do not have to worry about freeing an allocated buffer, nor rolling back our modification to the strbuf. This is theoretically less efficient, as some callbacks would not bother to format the final path component. But in practice this is not measurable. Since we use the same strbuf over and over, our work to grow it is amortized, and we really only pay to memcpy a few bytes. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com> CWE ID: CWE-119
0
55,035
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: __printf(2, 3) void bpf_verifier_log_write(struct bpf_verifier_env *env, const char *fmt, ...) { va_list args; if (!bpf_verifier_log_needed(&env->log)) return; va_start(args, fmt); bpf_verifier_vlog(&env->log, fmt, args); va_end(args); } Commit Message: bpf: 32-bit RSH verification must truncate input before the ALU op When I wrote commit 468f6eafa6c4 ("bpf: fix 32-bit ALU op verification"), I assumed that, in order to emulate 64-bit arithmetic with 32-bit logic, it is sufficient to just truncate the output to 32 bits; and so I just moved the register size coercion that used to be at the start of the function to the end of the function. That assumption is true for almost every op, but not for 32-bit right shifts, because those can propagate information towards the least significant bit. Fix it by always truncating inputs for 32-bit ops to 32 bits. Also get rid of the coerce_reg_to_size() after the ALU op, since that has no effect. Fixes: 468f6eafa6c4 ("bpf: fix 32-bit ALU op verification") Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> CWE ID: CWE-125
0
76,361
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: GLvoid StubGLTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) { glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); } Commit Message: Add chromium_code: 1 to surface.gyp and gl.gyp to pick up -Werror. It looks like this was dropped accidentally in http://codereview.chromium.org/6718027 (surface.gyp) and http://codereview.chromium.org/6722026 (gl.gyp) Remove now-redudant code that's implied by chromium_code: 1. Fix the warnings that have crept in since chromium_code: 1 was removed. BUG=none TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=91598 Review URL: http://codereview.chromium.org/7227009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91813 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-189
0
99,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: channel_send_open(int id) { Channel *c = channel_lookup(id); if (c == NULL) { logit("channel_send_open: %d: bad id", id); return; } debug2("channel %d: send open", id); packet_start(SSH2_MSG_CHANNEL_OPEN); packet_put_cstring(c->ctype); packet_put_int(c->self); packet_put_int(c->local_window); packet_put_int(c->local_maxpacket); packet_send(); } Commit Message: CWE ID: CWE-264
0
2,260
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 HTMLTextAreaElement::setValueCommon(const String& newValue) { String normalizedValue = newValue.isNull() ? "" : newValue; normalizedValue.replace("\r\n", "\n"); normalizedValue.replace('\r', '\n'); if (normalizedValue == value()) return; m_value = normalizedValue; setInnerTextValue(m_value); setLastChangeWasNotUserEdit(); updatePlaceholderVisibility(false); setNeedsStyleRecalc(); setFormControlValueMatchesRenderer(true); if (document().focusedElement() == this) { unsigned endOfString = m_value.length(); setSelectionRange(endOfString, endOfString); } notifyFormStateChanged(); setTextAsOfLastFormControlChangeEvent(normalizedValue); } Commit Message: Add HTMLFormControlElement::supportsAutofocus to fix a FIXME comment. This virtual function should return true if the form control can hanlde 'autofocucs' attribute if it is specified. Note: HTMLInputElement::supportsAutofocus reuses InputType::isInteractiveContent because interactiveness is required for autofocus capability. BUG=none TEST=none; no behavior changes. Review URL: https://codereview.chromium.org/143343003 git-svn-id: svn://svn.chromium.org/blink/trunk@165432 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-119
0
114,105
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: lseg_lt(PG_FUNCTION_ARGS) { LSEG *l1 = PG_GETARG_LSEG_P(0); LSEG *l2 = PG_GETARG_LSEG_P(1); PG_RETURN_BOOL(FPlt(point_dt(&l1->p[0], &l1->p[1]), point_dt(&l2->p[0], &l2->p[1]))); } Commit Message: Predict integer overflow to avoid buffer overruns. Several functions, mostly type input functions, calculated an allocation size such that the calculation wrapped to a small positive value when arguments implied a sufficiently-large requirement. Writes past the end of the inadvertent small allocation followed shortly thereafter. Coverity identified the path_in() vulnerability; code inspection led to the rest. In passing, add check_stack_depth() to prevent stack overflow in related functions. Back-patch to 8.4 (all supported versions). The non-comment hstore changes touch code that did not exist in 8.4, so that part stops at 9.0. Noah Misch and Heikki Linnakangas, reviewed by Tom Lane. Security: CVE-2014-0064 CWE ID: CWE-189
0
38,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: static const EditorInternalCommand* InternalCommand( const String& command_name) { static const EditorInternalCommand kEditorCommands[] = { {WebEditingCommandType::kAlignJustified, ExecuteJustifyFull, SupportedFromMenuOrKeyBinding, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kAlignLeft, ExecuteJustifyLeft, SupportedFromMenuOrKeyBinding, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kAlignRight, ExecuteJustifyRight, SupportedFromMenuOrKeyBinding, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kBackColor, ExecuteBackColor, Supported, EnabledInRichlyEditableText, StateNone, ValueBackColor, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kBackwardDelete, ExecuteDeleteBackward, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kBold, ExecuteToggleBold, Supported, EnabledInRichlyEditableText, StateBold, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kCopy, ExecuteCopy, Supported, EnabledCopy, StateNone, ValueStateOrNull, kNotTextInsertion, kAllowExecutionWhenDisabled}, {WebEditingCommandType::kCreateLink, ExecuteCreateLink, Supported, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kCut, ExecuteCut, Supported, EnabledCut, StateNone, ValueStateOrNull, kNotTextInsertion, kAllowExecutionWhenDisabled}, {WebEditingCommandType::kDefaultParagraphSeparator, ExecuteDefaultParagraphSeparator, Supported, Enabled, StateNone, ValueDefaultParagraphSeparator, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kDelete, ExecuteDelete, Supported, EnabledDelete, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kDeleteBackward, ExecuteDeleteBackward, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kDeleteBackwardByDecomposingPreviousCharacter, ExecuteDeleteBackwardByDecomposingPreviousCharacter, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kDeleteForward, ExecuteDeleteForward, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kDeleteToBeginningOfLine, ExecuteDeleteToBeginningOfLine, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kDeleteToBeginningOfParagraph, ExecuteDeleteToBeginningOfParagraph, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kDeleteToEndOfLine, ExecuteDeleteToEndOfLine, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kDeleteToEndOfParagraph, ExecuteDeleteToEndOfParagraph, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kDeleteToMark, ExecuteDeleteToMark, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kDeleteWordBackward, ExecuteDeleteWordBackward, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kDeleteWordForward, ExecuteDeleteWordForward, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kFindString, ExecuteFindString, Supported, Enabled, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kFontName, ExecuteFontName, Supported, EnabledInRichlyEditableText, StateNone, ValueFontName, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kFontSize, ExecuteFontSize, Supported, EnabledInRichlyEditableText, StateNone, ValueFontSize, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kFontSizeDelta, ExecuteFontSizeDelta, Supported, EnabledInRichlyEditableText, StateNone, ValueFontSizeDelta, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kForeColor, ExecuteForeColor, Supported, EnabledInRichlyEditableText, StateNone, ValueForeColor, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kFormatBlock, ExecuteFormatBlock, Supported, EnabledInRichlyEditableText, StateNone, ValueFormatBlock, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kForwardDelete, ExecuteForwardDelete, Supported, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kHiliteColor, ExecuteBackColor, Supported, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kIgnoreSpelling, ExecuteIgnoreSpelling, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kIndent, ExecuteIndent, Supported, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kInsertBacktab, ExecuteInsertBacktab, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kIsTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kInsertHTML, ExecuteInsertHTML, Supported, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kInsertHorizontalRule, ExecuteInsertHorizontalRule, Supported, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kInsertImage, ExecuteInsertImage, Supported, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kInsertLineBreak, ExecuteInsertLineBreak, Supported, EnabledInEditableText, StateNone, ValueStateOrNull, kIsTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kInsertNewline, ExecuteInsertNewline, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kIsTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kInsertNewlineInQuotedContent, ExecuteInsertNewlineInQuotedContent, Supported, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kInsertOrderedList, ExecuteInsertOrderedList, Supported, EnabledInRichlyEditableText, StateOrderedList, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kInsertParagraph, ExecuteInsertParagraph, Supported, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kInsertTab, ExecuteInsertTab, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kIsTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kInsertText, ExecuteInsertText, Supported, EnabledInEditableText, StateNone, ValueStateOrNull, kIsTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kInsertUnorderedList, ExecuteInsertUnorderedList, Supported, EnabledInRichlyEditableText, StateUnorderedList, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kItalic, ExecuteToggleItalic, Supported, EnabledInRichlyEditableText, StateItalic, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kJustifyCenter, ExecuteJustifyCenter, Supported, EnabledInRichlyEditableText, StateJustifyCenter, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kJustifyFull, ExecuteJustifyFull, Supported, EnabledInRichlyEditableText, StateJustifyFull, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kJustifyLeft, ExecuteJustifyLeft, Supported, EnabledInRichlyEditableText, StateJustifyLeft, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kJustifyNone, ExecuteJustifyLeft, Supported, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kJustifyRight, ExecuteJustifyRight, Supported, EnabledInRichlyEditableText, StateJustifyRight, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMakeTextWritingDirectionLeftToRight, ExecuteMakeTextWritingDirectionLeftToRight, SupportedFromMenuOrKeyBinding, EnabledInRichlyEditableText, StateTextWritingDirectionLeftToRight, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMakeTextWritingDirectionNatural, ExecuteMakeTextWritingDirectionNatural, SupportedFromMenuOrKeyBinding, EnabledInRichlyEditableText, StateTextWritingDirectionNatural, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMakeTextWritingDirectionRightToLeft, ExecuteMakeTextWritingDirectionRightToLeft, SupportedFromMenuOrKeyBinding, EnabledInRichlyEditableText, StateTextWritingDirectionRightToLeft, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveBackward, ExecuteMoveBackward, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveBackwardAndModifySelection, ExecuteMoveBackwardAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveDown, ExecuteMoveDown, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveDownAndModifySelection, ExecuteMoveDownAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveForward, ExecuteMoveForward, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveForwardAndModifySelection, ExecuteMoveForwardAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveLeft, ExecuteMoveLeft, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveLeftAndModifySelection, ExecuteMoveLeftAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMovePageDown, ExecuteMovePageDown, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMovePageDownAndModifySelection, ExecuteMovePageDownAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMovePageUp, ExecuteMovePageUp, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMovePageUpAndModifySelection, ExecuteMovePageUpAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveParagraphBackward, ExecuteMoveParagraphBackward, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveParagraphBackwardAndModifySelection, ExecuteMoveParagraphBackwardAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveParagraphForward, ExecuteMoveParagraphForward, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveParagraphForwardAndModifySelection, ExecuteMoveParagraphForwardAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveRight, ExecuteMoveRight, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveRightAndModifySelection, ExecuteMoveRightAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToBeginningOfDocument, ExecuteMoveToBeginningOfDocument, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToBeginningOfDocumentAndModifySelection, ExecuteMoveToBeginningOfDocumentAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToBeginningOfLine, ExecuteMoveToBeginningOfLine, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToBeginningOfLineAndModifySelection, ExecuteMoveToBeginningOfLineAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToBeginningOfParagraph, ExecuteMoveToBeginningOfParagraph, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToBeginningOfParagraphAndModifySelection, ExecuteMoveToBeginningOfParagraphAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToBeginningOfSentence, ExecuteMoveToBeginningOfSentence, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToBeginningOfSentenceAndModifySelection, ExecuteMoveToBeginningOfSentenceAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToEndOfDocument, ExecuteMoveToEndOfDocument, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToEndOfDocumentAndModifySelection, ExecuteMoveToEndOfDocumentAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToEndOfLine, ExecuteMoveToEndOfLine, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToEndOfLineAndModifySelection, ExecuteMoveToEndOfLineAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToEndOfParagraph, ExecuteMoveToEndOfParagraph, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToEndOfParagraphAndModifySelection, ExecuteMoveToEndOfParagraphAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToEndOfSentence, ExecuteMoveToEndOfSentence, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToEndOfSentenceAndModifySelection, ExecuteMoveToEndOfSentenceAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToLeftEndOfLine, ExecuteMoveToLeftEndOfLine, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToLeftEndOfLineAndModifySelection, ExecuteMoveToLeftEndOfLineAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToRightEndOfLine, ExecuteMoveToRightEndOfLine, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveToRightEndOfLineAndModifySelection, ExecuteMoveToRightEndOfLineAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveUp, ExecuteMoveUp, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveUpAndModifySelection, ExecuteMoveUpAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveWordBackward, ExecuteMoveWordBackward, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveWordBackwardAndModifySelection, ExecuteMoveWordBackwardAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveWordForward, ExecuteMoveWordForward, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveWordForwardAndModifySelection, ExecuteMoveWordForwardAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveWordLeft, ExecuteMoveWordLeft, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveWordLeftAndModifySelection, ExecuteMoveWordLeftAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveWordRight, ExecuteMoveWordRight, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kMoveWordRightAndModifySelection, ExecuteMoveWordRightAndModifySelection, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kOutdent, ExecuteOutdent, Supported, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kOverWrite, ExecuteToggleOverwrite, SupportedFromMenuOrKeyBinding, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kPaste, ExecutePaste, Supported, EnabledPaste, StateNone, ValueStateOrNull, kNotTextInsertion, kAllowExecutionWhenDisabled}, {WebEditingCommandType::kPasteAndMatchStyle, ExecutePasteAndMatchStyle, Supported, EnabledPaste, StateNone, ValueStateOrNull, kNotTextInsertion, kAllowExecutionWhenDisabled}, {WebEditingCommandType::kPasteGlobalSelection, ExecutePasteGlobalSelection, SupportedFromMenuOrKeyBinding, EnabledPaste, StateNone, ValueStateOrNull, kNotTextInsertion, kAllowExecutionWhenDisabled}, {WebEditingCommandType::kPrint, ExecutePrint, Supported, Enabled, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kRedo, ExecuteRedo, Supported, EnabledRedo, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kRemoveFormat, ExecuteRemoveFormat, Supported, EnabledRangeInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kScrollPageBackward, ExecuteScrollPageBackward, SupportedFromMenuOrKeyBinding, Enabled, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kScrollPageForward, ExecuteScrollPageForward, SupportedFromMenuOrKeyBinding, Enabled, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kScrollLineUp, ExecuteScrollLineUp, SupportedFromMenuOrKeyBinding, Enabled, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kScrollLineDown, ExecuteScrollLineDown, SupportedFromMenuOrKeyBinding, Enabled, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kScrollToBeginningOfDocument, ExecuteScrollToBeginningOfDocument, SupportedFromMenuOrKeyBinding, Enabled, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kScrollToEndOfDocument, ExecuteScrollToEndOfDocument, SupportedFromMenuOrKeyBinding, Enabled, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kSelectAll, ExecuteSelectAll, Supported, EnabledSelectAll, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kSelectLine, ExecuteSelectLine, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kSelectParagraph, ExecuteSelectParagraph, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kSelectSentence, ExecuteSelectSentence, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kSelectToMark, ExecuteSelectToMark, SupportedFromMenuOrKeyBinding, EnabledVisibleSelectionAndMark, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kSelectWord, ExecuteSelectWord, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kSetMark, ExecuteSetMark, SupportedFromMenuOrKeyBinding, EnabledVisibleSelection, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kStrikethrough, ExecuteStrikethrough, Supported, EnabledInRichlyEditableText, StateStrikethrough, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kStyleWithCSS, ExecuteStyleWithCSS, Supported, Enabled, StateStyleWithCSS, ValueEmpty, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kSubscript, ExecuteSubscript, Supported, EnabledInRichlyEditableText, StateSubscript, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kSuperscript, ExecuteSuperscript, Supported, EnabledInRichlyEditableText, StateSuperscript, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kSwapWithMark, ExecuteSwapWithMark, SupportedFromMenuOrKeyBinding, EnabledVisibleSelectionAndMark, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kToggleBold, ExecuteToggleBold, SupportedFromMenuOrKeyBinding, EnabledInRichlyEditableText, StateBold, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kToggleItalic, ExecuteToggleItalic, SupportedFromMenuOrKeyBinding, EnabledInRichlyEditableText, StateItalic, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kToggleUnderline, ExecuteUnderline, SupportedFromMenuOrKeyBinding, EnabledInRichlyEditableText, StateUnderline, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kTranspose, ExecuteTranspose, Supported, EnableCaretInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kUnderline, ExecuteUnderline, Supported, EnabledInRichlyEditableText, StateUnderline, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kUndo, ExecuteUndo, Supported, EnabledUndo, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kUnlink, ExecuteUnlink, Supported, EnabledRangeInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kUnscript, ExecuteUnscript, SupportedFromMenuOrKeyBinding, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kUnselect, ExecuteUnselect, Supported, EnabledUnselect, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kUseCSS, ExecuteUseCSS, Supported, Enabled, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kYank, ExecuteYank, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kYankAndSelect, ExecuteYankAndSelect, SupportedFromMenuOrKeyBinding, EnabledInEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, {WebEditingCommandType::kAlignCenter, ExecuteJustifyCenter, SupportedFromMenuOrKeyBinding, EnabledInRichlyEditableText, StateNone, ValueStateOrNull, kNotTextInsertion, kDoNotAllowExecutionWhenDisabled}, }; static_assert( arraysize(kEditorCommands) + 1 == static_cast<size_t>(WebEditingCommandType::kNumberOfCommandTypes), "must handle all valid WebEditingCommandType"); WebEditingCommandType command_type = WebEditingCommandTypeFromCommandName(command_name); if (command_type == WebEditingCommandType::kInvalid) return nullptr; int command_index = static_cast<int>(command_type) - 1; DCHECK(command_index >= 0 && command_index < static_cast<int>(arraysize(kEditorCommands))); return &kEditorCommands[command_index]; } Commit Message: Move Editor::Transpose() out of Editor class This patch moves |Editor::Transpose()| out of |Editor| class as preparation of expanding it into |ExecutTranspose()| in "EditorCommand.cpp" to make |Editor| class simpler for improving code health. Following patch will expand |Transpose()| into |ExecutTranspose()|. Bug: 672405 Change-Id: Icde253623f31813d2b4517c4da7d4798bd5fadf6 Reviewed-on: https://chromium-review.googlesource.com/583880 Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org> Commit-Queue: Yoshifumi Inoue <yosin@chromium.org> Cr-Commit-Position: refs/heads/master@{#489518} CWE ID:
0
128,634
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 set_huge_ptep_writable(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) { pte_t entry; entry = pte_mkwrite(pte_mkdirty(huge_ptep_get(ptep))); if (huge_ptep_set_access_flags(vma, address, ptep, entry, 1)) update_mmu_cache(vma, address, ptep); } Commit Message: hugetlb: fix resv_map leak in error path When called for anonymous (non-shared) mappings, hugetlb_reserve_pages() does a resv_map_alloc(). It depends on code in hugetlbfs's vm_ops->close() to release that allocation. However, in the mmap() failure path, we do a plain unmap_region() without the remove_vma() which actually calls vm_ops->close(). This is a decent fix. This leak could get reintroduced if new code (say, after hugetlb_reserve_pages() in hugetlbfs_file_mmap()) decides to return an error. But, I think it would have to unroll the reservation anyway. Christoph's test case: http://marc.info/?l=linux-mm&m=133728900729735 This patch applies to 3.4 and later. A version for earlier kernels is at https://lkml.org/lkml/2012/5/22/418. Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com> Acked-by: Mel Gorman <mel@csn.ul.ie> Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Reported-by: Christoph Lameter <cl@linux.com> Tested-by: Christoph Lameter <cl@linux.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: <stable@vger.kernel.org> [2.6.32+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID: CWE-399
0
19,755
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 ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser) { WebViewClient* client = m_webView->client(); if (!client) return; WebFileChooserParams params; params.multiSelect = fileChooser->settings().allowsMultipleFiles; params.directory = fileChooser->settings().allowsDirectoryUpload; params.acceptTypes = fileChooser->settings().acceptTypes(); params.selectedFiles = fileChooser->settings().selectedFiles; if (params.selectedFiles.size() > 0) params.initialValue = params.selectedFiles[0]; #if ENABLE(MEDIA_CAPTURE) params.useMediaCapture = fileChooser->settings().useMediaCapture; #endif WebFileChooserCompletionImpl* chooserCompletion = new WebFileChooserCompletionImpl(fileChooser); if (client->runFileChooser(params, chooserCompletion)) return; chooserCompletion->didChooseFile(WebVector<WebString>()); } Commit Message: Delete apparently unused geolocation declarations and include. BUG=336263 Review URL: https://codereview.chromium.org/139743014 git-svn-id: svn://svn.chromium.org/blink/trunk@165601 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-399
0
118,646
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: _rpc_reconfig(slurm_msg_t *msg) { uid_t req_uid = g_slurm_auth_get_uid(msg->auth_cred, conf->auth_info); if (!_slurm_authorized_user(req_uid)) error("Security violation, reconfig RPC from uid %d", req_uid); else kill(conf->pid, SIGHUP); forward_wait(msg); /* Never return a message, slurmctld does not expect one */ } Commit Message: Fix security issue in _prolog_error(). Fix security issue caused by insecure file path handling triggered by the failure of a Prolog script. To exploit this a user needs to anticipate or cause the Prolog to fail for their job. (This commit is slightly different from the fix to the 15.08 branch.) CVE-2016-10030. CWE ID: CWE-284
0
72,125
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_release(struct inode *inode, struct file *file) { struct fuse_conn *fc = get_fuse_conn(inode); /* see fuse_vma_close() for !writeback_cache case */ if (fc->writeback_cache) write_inode_now(inode, 1); fuse_release_common(file, FUSE_RELEASE); /* return value is ignored by VFS */ return 0; } Commit Message: fuse: break infinite loop in fuse_fill_write_pages() I got a report about unkillable task eating CPU. Further investigation shows, that the problem is in the fuse_fill_write_pages() function. If iov's first segment has zero length, we get an infinite loop, because we never reach iov_iter_advance() call. Fix this by calling iov_iter_advance() before repeating an attempt to copy data from userspace. A similar problem is described in 124d3b7041f ("fix writev regression: pan hanging unkillable and un-straceable"). If zero-length segmend is followed by segment with invalid address, iov_iter_fault_in_readable() checks only first segment (zero-length), iov_iter_copy_from_user_atomic() skips it, fails at second and returns zero -> goto again without skipping zero-length segment. Patch calls iov_iter_advance() before goto again: we'll skip zero-length segment at second iteraction and iov_iter_fault_in_readable() will detect invalid address. Special thanks to Konstantin Khlebnikov, who helped a lot with the commit description. Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Maxim Patlasov <mpatlasov@parallels.com> Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Signed-off-by: Roman Gushchin <klamm@yandex-team.ru> Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Fixes: ea9b9907b82a ("fuse: implement perform_write") Cc: <stable@vger.kernel.org> CWE ID: CWE-399
0
56,962
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 HTMLStyleElement::DispatchPendingEvent( std::unique_ptr<IncrementLoadEventDelayCount> count) { if (loaded_sheet_) { if (GetDocument().HasListenerType( Document::kLoadListenerAtCapturePhaseOrAtStyleElement)) DispatchEvent(Event::Create(EventTypeNames::load)); } else { DispatchEvent(Event::Create(EventTypeNames::error)); } count->ClearAndCheckLoadEvent(); } Commit Message: Do not crash while reentrantly appending to style element. When a node is inserted into a container, it is notified via ::InsertedInto. However, a node may request a second notification via DidNotifySubtreeInsertionsToDocument, which occurs after all the children have been notified as well. *StyleElement is currently using this second notification. This causes a problem, because *ScriptElement is using the same mechanism, which in turn means that scripts can execute before the state of *StyleElements are properly updated. This patch avoids ::DidNotifySubtreeInsertionsToDocument, and instead processes the stylesheet in ::InsertedInto. The original reason for using ::DidNotifySubtreeInsertionsToDocument in the first place appears to be invalid now, as the test case is still passing. R=futhark@chromium.org, hayato@chromium.org Bug: 853709, 847570 Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel Change-Id: Ic0b5fa611044c78c5745cf26870a747f88920a14 Reviewed-on: https://chromium-review.googlesource.com/1104347 Commit-Queue: Anders Ruud <andruud@chromium.org> Reviewed-by: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/master@{#568368} CWE ID: CWE-416
0
154,347
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_count_objects(fz_context *ctx, pdf_document *doc) { return pdf_xref_len(ctx, doc); } Commit Message: CWE ID: CWE-119
0
16,696
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 vp7_update_dimensions(VP8Context *s, int width, int height) { return update_dimensions(s, width, height, IS_VP7); } Commit Message: avcodec/webp: Always set pix_fmt Fixes: out of array access Fixes: 1434/clusterfuzz-testcase-minimized-6314998085189632 Fixes: 1435/clusterfuzz-testcase-minimized-6483783723253760 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Reviewed-by: "Ronald S. Bultje" <rsbultje@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> CWE ID: CWE-119
0
64,000
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 inline void cast6_fpu_end(bool fpu_enabled) { glue_fpu_end(fpu_enabled); } Commit Message: crypto: prefix module autoloading with "crypto-" This prefixes all crypto module loading with "crypto-" so we never run the risk of exposing module auto-loading to userspace via a crypto API, as demonstrated by Mathias Krause: https://lkml.org/lkml/2013/3/4/70 Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> CWE ID: CWE-264
0
46,904
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 SQLITE_NOINLINE Vdbe *allocVdbe(Parse *pParse){ Vdbe *v = pParse->pVdbe = sqlite3VdbeCreate(pParse); if( v ) sqlite3VdbeAddOp2(v, OP_Init, 0, 1); if( pParse->pToplevel==0 && OptimizationEnabled(pParse->db,SQLITE_FactorOutConst) ){ pParse->okConstFactor = 1; } return v; } Commit Message: sqlite: safely move pointer values through SQL. This lands https://www.sqlite.org/src/timeline?c=d6a44b35 in third_party/sqlite/src/ and third_party/sqlite/patches/0013-Add-new-interfaces-sqlite3_bind_pointer-sqlite3_resu.patch and re-generates third_party/sqlite/amalgamation/* using the script at third_party/sqlite/google_generate_amalgamation.sh. The CL also adds a layout test that verifies the patch works as intended. BUG=742407 Change-Id: I2e1a457459cd2e975e6241b630e7b79c82545981 Reviewed-on: https://chromium-review.googlesource.com/572976 Reviewed-by: Chris Mumford <cmumford@chromium.org> Commit-Queue: Victor Costan <pwnall@chromium.org> Cr-Commit-Position: refs/heads/master@{#487275} CWE ID: CWE-119
0
136,289
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 perf_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) { struct perf_event *event = vma->vm_file->private_data; struct ring_buffer *rb; int ret = VM_FAULT_SIGBUS; if (vmf->flags & FAULT_FLAG_MKWRITE) { if (vmf->pgoff == 0) ret = 0; return ret; } rcu_read_lock(); rb = rcu_dereference(event->rb); if (!rb) goto unlock; if (vmf->pgoff && (vmf->flags & FAULT_FLAG_WRITE)) goto unlock; vmf->page = perf_mmap_to_page(rb, vmf->pgoff); if (!vmf->page) goto unlock; get_page(vmf->page); vmf->page->mapping = vma->vm_file->f_mapping; vmf->page->index = vmf->pgoff; ret = 0; unlock: rcu_read_unlock(); return ret; } 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
26,134
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 ext4_key_prefix(struct inode *inode, u8 **key) { *key = EXT4_SB(inode->i_sb)->key_prefix; return EXT4_SB(inode->i_sb)->key_prefix_size; } Commit Message: ext4: validate s_first_meta_bg at mount time Ralf Spenneberg reported that he hit a kernel crash when mounting a modified ext4 image. And it turns out that kernel crashed when calculating fs overhead (ext4_calculate_overhead()), this is because the image has very large s_first_meta_bg (debug code shows it's 842150400), and ext4 overruns the memory in count_overhead() when setting bitmap buffer, which is PAGE_SIZE. ext4_calculate_overhead(): buf = get_zeroed_page(GFP_NOFS); <=== PAGE_SIZE buffer blks = count_overhead(sb, i, buf); count_overhead(): for (j = ext4_bg_num_gdb(sb, grp); j > 0; j--) { <=== j = 842150400 ext4_set_bit(EXT4_B2C(sbi, s++), buf); <=== buffer overrun count++; } This can be reproduced easily for me by this script: #!/bin/bash rm -f fs.img mkdir -p /mnt/ext4 fallocate -l 16M fs.img mke2fs -t ext4 -O bigalloc,meta_bg,^resize_inode -F fs.img debugfs -w -R "ssv first_meta_bg 842150400" fs.img mount -o loop fs.img /mnt/ext4 Fix it by validating s_first_meta_bg first at mount time, and refusing to mount if its value exceeds the largest possible meta_bg number. Reported-by: Ralf Spenneberg <ralf@os-t.de> Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Andreas Dilger <adilger@dilger.ca> CWE ID: CWE-125
0
70,537
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: gfx::Size WebContentsImpl::GetAutoResizeSize() { return auto_resize_size_; } 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,701
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 SoftAVC::setDecodeArgs( ivd_video_decode_ip_t *ps_dec_ip, ivd_video_decode_op_t *ps_dec_op, OMX_BUFFERHEADERTYPE *inHeader, OMX_BUFFERHEADERTYPE *outHeader, size_t timeStampIx) { size_t sizeY = outputBufferWidth() * outputBufferHeight(); size_t sizeUV; uint8_t *pBuf; ps_dec_ip->u4_size = sizeof(ivd_video_decode_ip_t); ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t); ps_dec_ip->e_cmd = IVD_CMD_VIDEO_DECODE; /* When in flush and after EOS with zero byte input, * inHeader is set to zero. Hence check for non-null */ if (inHeader) { ps_dec_ip->u4_ts = timeStampIx; ps_dec_ip->pv_stream_buffer = inHeader->pBuffer + inHeader->nOffset; ps_dec_ip->u4_num_Bytes = inHeader->nFilledLen; } else { ps_dec_ip->u4_ts = 0; ps_dec_ip->pv_stream_buffer = NULL; ps_dec_ip->u4_num_Bytes = 0; } if (outHeader) { pBuf = outHeader->pBuffer; } else { pBuf = mFlushOutBuffer; } sizeUV = sizeY / 4; ps_dec_ip->s_out_buffer.u4_min_out_buf_size[0] = sizeY; ps_dec_ip->s_out_buffer.u4_min_out_buf_size[1] = sizeUV; ps_dec_ip->s_out_buffer.u4_min_out_buf_size[2] = sizeUV; ps_dec_ip->s_out_buffer.pu1_bufs[0] = pBuf; ps_dec_ip->s_out_buffer.pu1_bufs[1] = pBuf + sizeY; ps_dec_ip->s_out_buffer.pu1_bufs[2] = pBuf + sizeY + sizeUV; ps_dec_ip->s_out_buffer.u4_num_bufs = 3; return; } Commit Message: codecs: check OMX buffer size before use in (avc|hevc|mpeg2)dec Bug: 27833616 Change-Id: Ic4045a3f56f53b08d0b1264b2a91b8f43e91b738 (cherry picked from commit 87fdee0bc9e3ac4d2a88ef0a8e150cfdf08c161d) CWE ID: CWE-20
1
174,180
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: process_request_identities(SocketEntry *e, int version) { Idtab *tab = idtab_lookup(version); Identity *id; struct sshbuf *msg; int r; if ((msg = sshbuf_new()) == NULL) fatal("%s: sshbuf_new failed", __func__); if ((r = sshbuf_put_u8(msg, (version == 1) ? SSH_AGENT_RSA_IDENTITIES_ANSWER : SSH2_AGENT_IDENTITIES_ANSWER)) != 0 || (r = sshbuf_put_u32(msg, tab->nentries)) != 0) fatal("%s: buffer error: %s", __func__, ssh_err(r)); TAILQ_FOREACH(id, &tab->idlist, next) { if (id->key->type == KEY_RSA1) { #ifdef WITH_SSH1 if ((r = sshbuf_put_u32(msg, BN_num_bits(id->key->rsa->n))) != 0 || (r = sshbuf_put_bignum1(msg, id->key->rsa->e)) != 0 || (r = sshbuf_put_bignum1(msg, id->key->rsa->n)) != 0) fatal("%s: buffer error: %s", __func__, ssh_err(r)); #endif } else { u_char *blob; size_t blen; if ((r = sshkey_to_blob(id->key, &blob, &blen)) != 0) { error("%s: sshkey_to_blob: %s", __func__, ssh_err(r)); continue; } if ((r = sshbuf_put_string(msg, blob, blen)) != 0) fatal("%s: buffer error: %s", __func__, ssh_err(r)); free(blob); } if ((r = sshbuf_put_cstring(msg, id->comment)) != 0) fatal("%s: buffer error: %s", __func__, ssh_err(r)); } if ((r = sshbuf_put_stringb(e->output, msg)) != 0) fatal("%s: buffer error: %s", __func__, ssh_err(r)); sshbuf_free(msg); } Commit Message: add a whitelist of paths from which ssh-agent will load (via ssh-pkcs11-helper) a PKCS#11 module; ok markus@ CWE ID: CWE-426
0
72,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: static void __net_exit packet_net_exit(struct net *net) { remove_proc_entry("packet", net->proc_net); } Commit Message: net: rework recvmsg handler msg_name and msg_namelen logic This patch now always passes msg->msg_namelen as 0. recvmsg handlers must set msg_namelen to the proper size <= sizeof(struct sockaddr_storage) to return msg_name to the user. This prevents numerous uninitialized memory leaks we had in the recvmsg handlers and makes it harder for new code to accidentally leak uninitialized memory. Optimize for the case recvfrom is called with NULL as address. We don't need to copy the address at all, so set it to NULL before invoking the recvmsg handler. We can do so, because all the recvmsg handlers must cope with the case a plain read() is called on them. read() also sets msg_name to NULL. Also document these changes in include/linux/net.h as suggested by David Miller. Changes since RFC: Set msg->msg_name = NULL if user specified a NULL in msg_name but had a non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't affect sendto as it would bail out earlier while trying to copy-in the address. It also more naturally reflects the logic by the callers of verify_iovec. With this change in place I could remove " if (!uaddr || msg_sys->msg_namelen == 0) msg->msg_name = NULL ". This change does not alter the user visible error logic as we ignore msg_namelen as long as msg_name is NULL. Also remove two unnecessary curly brackets in ___sys_recvmsg and change comments to netdev style. Cc: David Miller <davem@davemloft.net> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-20
0
40,628
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 RenderThreadImpl::Init() { TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); base::debug::TraceLog::GetInstance()->SetThreadSortIndex( base::PlatformThread::CurrentId(), kTraceEventRendererMainThreadSortIndex); #if defined(OS_MACOSX) || defined(OS_ANDROID) blink::WebView::setUseExternalPopupMenus(true); #endif lazy_tls.Pointer()->Set(this); ChildProcess::current()->set_main_thread(this); suspend_webkit_shared_timer_ = true; notify_webkit_of_modal_loop_ = true; webkit_shared_timer_suspended_ = false; widget_count_ = 0; hidden_widget_count_ = 0; idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; idle_notifications_to_skip_ = 0; layout_test_mode_ = false; appcache_dispatcher_.reset( new AppCacheDispatcher(Get(), new AppCacheFrontendImpl())); dom_storage_dispatcher_.reset(new DomStorageDispatcher()); main_thread_indexed_db_dispatcher_.reset(new IndexedDBDispatcher( thread_safe_sender())); embedded_worker_dispatcher_.reset(new EmbeddedWorkerDispatcher()); media_stream_center_ = NULL; db_message_filter_ = new DBMessageFilter(); AddFilter(db_message_filter_.get()); vc_manager_.reset(new VideoCaptureImplManager()); AddFilter(vc_manager_->video_capture_message_filter()); #if defined(ENABLE_WEBRTC) peer_connection_tracker_.reset(new PeerConnectionTracker()); AddObserver(peer_connection_tracker_.get()); p2p_socket_dispatcher_ = new P2PSocketDispatcher(GetIOMessageLoopProxy().get()); AddFilter(p2p_socket_dispatcher_.get()); webrtc_identity_service_.reset(new WebRTCIdentityService()); aec_dump_message_filter_ = new AecDumpMessageFilter(GetIOMessageLoopProxy(), message_loop()->message_loop_proxy()); AddFilter(aec_dump_message_filter_.get()); peer_connection_factory_.reset(new PeerConnectionDependencyFactory( p2p_socket_dispatcher_.get())); #endif // defined(ENABLE_WEBRTC) audio_input_message_filter_ = new AudioInputMessageFilter(GetIOMessageLoopProxy()); AddFilter(audio_input_message_filter_.get()); audio_message_filter_ = new AudioMessageFilter(GetIOMessageLoopProxy()); AddFilter(audio_message_filter_.get()); midi_message_filter_ = new MidiMessageFilter(GetIOMessageLoopProxy()); AddFilter(midi_message_filter_.get()); AddFilter((new IndexedDBMessageFilter(thread_safe_sender()))->GetFilter()); AddFilter((new EmbeddedWorkerContextMessageFilter())->GetFilter()); GetContentClient()->renderer()->RenderThreadStarted(); InitSkiaEventTracer(); const CommandLine& command_line = *CommandLine::ForCurrentProcess(); if (command_line.HasSwitch(cc::switches::kEnableGpuBenchmarking)) RegisterExtension(GpuBenchmarkingExtension::Get()); is_impl_side_painting_enabled_ = command_line.HasSwitch(switches::kEnableImplSidePainting); WebLayerImpl::SetImplSidePaintingEnabled(is_impl_side_painting_enabled_); is_zero_copy_enabled_ = command_line.HasSwitch(switches::kEnableZeroCopy) && !command_line.HasSwitch(switches::kDisableZeroCopy); is_one_copy_enabled_ = command_line.HasSwitch(switches::kEnableOneCopy); if (command_line.HasSwitch(switches::kDisableLCDText)) { is_lcd_text_enabled_ = false; } else if (command_line.HasSwitch(switches::kEnableLCDText)) { is_lcd_text_enabled_ = true; } else { #if defined(OS_ANDROID) is_lcd_text_enabled_ = false; #else is_lcd_text_enabled_ = true; #endif } is_gpu_rasterization_enabled_ = command_line.HasSwitch(switches::kEnableGpuRasterization); is_gpu_rasterization_forced_ = command_line.HasSwitch(switches::kForceGpuRasterization); if (command_line.HasSwitch(switches::kDisableDistanceFieldText)) { is_distance_field_text_enabled_ = false; } else if (command_line.HasSwitch(switches::kEnableDistanceFieldText)) { is_distance_field_text_enabled_ = true; } else { is_distance_field_text_enabled_ = false; } is_low_res_tiling_enabled_ = true; if (command_line.HasSwitch(switches::kDisableLowResTiling) && !command_line.HasSwitch(switches::kEnableLowResTiling)) { is_low_res_tiling_enabled_ = false; } base::FilePath media_path; PathService::Get(DIR_MEDIA_LIBS, &media_path); if (!media_path.empty()) media::InitializeMediaLibrary(media_path); memory_pressure_listener_.reset(new base::MemoryPressureListener( base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); std::vector<base::DiscardableMemoryType> supported_types; base::DiscardableMemory::GetSupportedTypes(&supported_types); DCHECK(!supported_types.empty()); base::DiscardableMemoryType type = supported_types[0]; if (command_line.HasSwitch(switches::kUseDiscardableMemory)) { std::string requested_type_name = command_line.GetSwitchValueASCII( switches::kUseDiscardableMemory); base::DiscardableMemoryType requested_type = base::DiscardableMemory::GetNamedType(requested_type_name); if (std::find(supported_types.begin(), supported_types.end(), requested_type) != supported_types.end()) { type = requested_type; } else { LOG(ERROR) << "Requested discardable memory type is not supported."; } } base::DiscardableMemory::SetPreferredType(type); base::DiscardableMemory::RegisterMemoryPressureListeners(); allocate_gpu_memory_buffer_thread_checker_.DetachFromThread(); if (command_line.HasSwitch(switches::kNumRasterThreads)) { int num_raster_threads; std::string string_value = command_line.GetSwitchValueASCII(switches::kNumRasterThreads); if (base::StringToInt(string_value, &num_raster_threads) && num_raster_threads >= kMinRasterThreads && num_raster_threads <= kMaxRasterThreads) { cc::RasterWorkerPool::SetNumRasterThreads(num_raster_threads); } else { LOG(WARNING) << "Failed to parse switch " << switches::kNumRasterThreads << ": " << string_value; } } service_registry()->AddService<RenderFrameSetup>( base::Bind(CreateRenderFrameSetup)); TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); } Commit Message: Suspend shared timers while blockingly closing databases BUG=388771 R=michaeln@chromium.org Review URL: https://codereview.chromium.org/409863002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284785 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-362
0
111,148
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: aura::Window* CreatePanelWindow() { gfx::Rect rect(100, 100); aura::Window* window = CreateTestWindowInShellWithDelegateAndType( NULL, aura::client::WINDOW_TYPE_PANEL, 0, rect); shelf_view_test_->RunMessageLoopUntilAnimationsDone(); return window; } Commit Message: cros: Enable some tests in //ash/wm in ash_unittests --mash For the ones that fail, disable them via filter file instead of in the code, per our disablement policy. Bug: 698085, 695556, 698878, 698888, 698093, 698894 Test: ash_unittests --mash Change-Id: Ic145ab6a95508968d6884d14fac2a3ca08888d26 Reviewed-on: https://chromium-review.googlesource.com/752423 Commit-Queue: James Cook <jamescook@chromium.org> Reviewed-by: Steven Bennetts <stevenjb@chromium.org> Cr-Commit-Position: refs/heads/master@{#513836} CWE ID: CWE-119
0
133,309
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: start_monitoring_file_list (NautilusDirectory *directory) { DirectoryLoadState *state; if (!directory->details->file_list_monitored) { g_assert (!directory->details->directory_load_in_progress); directory->details->file_list_monitored = TRUE; nautilus_file_list_ref (directory->details->file_list); } if (directory->details->directory_loaded || directory->details->directory_load_in_progress != NULL) { return; } if (!async_job_start (directory, "file list")) { return; } mark_all_files_unconfirmed (directory); state = g_new0 (DirectoryLoadState, 1); state->directory = directory; state->cancellable = g_cancellable_new (); state->load_mime_list_hash = istr_set_new (); state->load_file_count = 0; g_assert (directory->details->location != NULL); state->load_directory_file = nautilus_directory_get_corresponding_file (directory); state->load_directory_file->details->loading_directory = TRUE; #ifdef DEBUG_LOAD_DIRECTORY g_message ("load_directory called to monitor file list of %p", directory->details->location); #endif directory->details->directory_load_in_progress = state; g_file_enumerate_children_async (directory->details->location, NAUTILUS_FILE_DEFAULT_ATTRIBUTES, 0, /* flags */ G_PRIORITY_DEFAULT, /* prio */ state->cancellable, enumerate_children_callback, state); } Commit Message: mime-actions: use file metadata for trusting desktop files Currently we only trust desktop files that have the executable bit set, and don't replace the displayed icon or the displayed name until it's trusted, which prevents for running random programs by a malicious desktop file. However, the executable permission is preserved if the desktop file comes from a compressed file. To prevent this, add a metadata::trusted metadata to the file once the user acknowledges the file as trusted. This adds metadata to the file, which cannot be added unless it has access to the computer. Also remove the SHEBANG "trusted" content we were putting inside the desktop file, since that doesn't add more security since it can come with the file itself. https://bugzilla.gnome.org/show_bug.cgi?id=777991 CWE ID: CWE-20
0
61,000
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 CheckAuthenticationBrokenState(TabContents* tab, int error, bool ran_insecure_content, bool interstitial) { NavigationEntry* entry = tab->controller().GetActiveEntry(); ASSERT_TRUE(entry); EXPECT_EQ(interstitial ? INTERSTITIAL_PAGE : NORMAL_PAGE, entry->page_type()); EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN, entry->ssl().security_style()); ASSERT_NE(net::CERT_STATUS_UNABLE_TO_CHECK_REVOCATION, error); EXPECT_EQ(error, entry->ssl().cert_status() & net::CERT_STATUS_ALL_ERRORS); EXPECT_FALSE(entry->ssl().displayed_insecure_content()); EXPECT_EQ(ran_insecure_content, entry->ssl().ran_insecure_content()); } Commit Message: Disable SSLUITest.TestCNInvalidStickiness, flakily hits an assertion. TBR=rsleevi BUG=68448, 49377 TEST=browser_tests Review URL: http://codereview.chromium.org/6178005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70876 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-362
0
97,936
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: ValidityMessage::ValidityMessage(const base::string16& text, bool sure) : text(text), sure(sure) {} Commit Message: Clear out some minor TODOs. BUG=none Review URL: https://codereview.chromium.org/1047063002 Cr-Commit-Position: refs/heads/master@{#322959} CWE ID: CWE-20
0
109,929
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 CompositorImpl::DidFailToInitializeLayerTreeFrameSink() { layer_tree_frame_sink_request_pending_ = false; base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::BindOnce(&CompositorImpl::RequestNewLayerTreeFrameSink, weak_factory_.GetWeakPtr())); } Commit Message: gpu/android : Add support for partial swap with surface control. Add support for PostSubBuffer to GLSurfaceEGLSurfaceControl. This should allow the display compositor to draw the minimum sub-rect necessary from the damage tracking in BufferQueue on the client-side, and also to pass this damage rect to the framework. R=piman@chromium.org Bug: 926020 Change-Id: I73d3320cab68250d4c6865bf21c5531682d8bf61 Reviewed-on: https://chromium-review.googlesource.com/c/1457467 Commit-Queue: Khushal <khushalsagar@chromium.org> Commit-Queue: Antoine Labour <piman@chromium.org> Reviewed-by: Antoine Labour <piman@chromium.org> Auto-Submit: Khushal <khushalsagar@chromium.org> Cr-Commit-Position: refs/heads/master@{#629852} CWE ID:
0
130,812
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 skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, int size, unsigned int truesize) { skb_fill_page_desc(skb, i, page, off, size); skb->len += size; skb->data_len += size; skb->truesize += truesize; } Commit Message: skbuff: skb_segment: orphan frags before copying skb_segment copies frags around, so we need to copy them carefully to avoid accessing user memory after reporting completion to userspace through a callback. skb_segment doesn't normally happen on datapath: TSO needs to be disabled - so disabling zero copy in this case does not look like a big deal. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-416
0
39,871
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 Textfield::CanDrop(const OSExchangeData& data) { int formats; std::set<ui::Clipboard::FormatType> format_types; GetDropFormats(&formats, &format_types); return enabled() && !read_only() && data.HasAnyFormat(formats, format_types); } Commit Message: MacViews: Enable secure text input for password Textfields. In Cocoa the NSTextInputContext automatically enables secure text input when activated and it's in the secure text entry mode. RenderWidgetHostViewMac did the similar thing for ages following the WebKit example. views::Textfield needs to do the same thing in a fashion that's sycnrhonized with RenderWidgetHostViewMac, otherwise the race conditions are possible when the Textfield gets focus, activates the secure text input mode and the RWHVM loses focus immediately afterwards and disables the secure text input instead of leaving it in the enabled state. BUG=818133,677220 Change-Id: I6db6c4b59e4a1a72cbb7f8c7056f71b04a3df08b Reviewed-on: https://chromium-review.googlesource.com/943064 Commit-Queue: Michail Pishchagin <mblsha@yandex-team.ru> Reviewed-by: Pavel Feldman <pfeldman@chromium.org> Reviewed-by: Avi Drissman <avi@chromium.org> Reviewed-by: Peter Kasting <pkasting@chromium.org> Cr-Commit-Position: refs/heads/master@{#542517} CWE ID:
0
126,289
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: iter_get_sequence (DBusMessageDataIter *iter) { _dbus_assert (iter->sequence_nos[iter->depth] >= 0); return iter->sequence_nos[iter->depth]; } Commit Message: CWE ID: CWE-399
0
7,497
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 HTMLFormElement::submitFromJavaScript() { submit(nullptr, nullptr); } Commit Message: Enforce form-action CSP even when form.target is present. BUG=630332 Review-Url: https://codereview.chromium.org/2464123004 Cr-Commit-Position: refs/heads/master@{#429922} CWE ID: CWE-19
0
142,557
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 GLES2DecoderImpl::HasMoreIdleWork() { return !pending_readpixel_fences_.empty() || async_pixel_transfer_manager_->NeedsProcessMorePendingTransfers(); } Commit Message: Framebuffer clear() needs to consider the situation some draw buffers are disabled. This is when we expose DrawBuffers extension. BUG=376951 TEST=the attached test case, webgl conformance R=kbr@chromium.org,bajones@chromium.org Review URL: https://codereview.chromium.org/315283002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275338 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-119
0
120,981
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: donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size, int clazz, int swap, size_t align, int *flags, uint16_t *notecount, int fd, off_t ph_off, int ph_num, off_t fsize) { Elf32_Nhdr nh32; Elf64_Nhdr nh64; size_t noff, doff; uint32_t namesz, descsz; unsigned char *nbuf = CAST(unsigned char *, vbuf); if (*notecount == 0) return 0; --*notecount; if (xnh_sizeof + offset > size) { /* * We're out of note headers. */ return xnh_sizeof + offset; } memcpy(xnh_addr, &nbuf[offset], xnh_sizeof); offset += xnh_sizeof; namesz = xnh_namesz; descsz = xnh_descsz; if ((namesz == 0) && (descsz == 0)) { /* * We're out of note headers. */ return (offset >= size) ? offset : size; } if (namesz & 0x80000000) { file_printf(ms, ", bad note name size %#lx", CAST(unsigned long, namesz)); return 0; } if (descsz & 0x80000000) { file_printf(ms, ", bad note description size %#lx", CAST(unsigned long, descsz)); return 0; } noff = offset; doff = ELF_ALIGN(offset + namesz); if (offset + namesz > size) { /* * We're past the end of the buffer. */ return doff; } offset = ELF_ALIGN(doff + descsz); if (doff + descsz > size) { /* * We're past the end of the buffer. */ return (offset >= size) ? offset : size; } if ((*flags & FLAGS_DID_OS_NOTE) == 0) { if (do_os_note(ms, nbuf, xnh_type, swap, namesz, descsz, noff, doff, flags)) return offset; } if ((*flags & FLAGS_DID_BUILD_ID) == 0) { if (do_bid_note(ms, nbuf, xnh_type, swap, namesz, descsz, noff, doff, flags)) return offset; } if ((*flags & FLAGS_DID_NETBSD_PAX) == 0) { if (do_pax_note(ms, nbuf, xnh_type, swap, namesz, descsz, noff, doff, flags)) return offset; } if ((*flags & FLAGS_DID_CORE) == 0) { if (do_core_note(ms, nbuf, xnh_type, swap, namesz, descsz, noff, doff, flags, size, clazz)) return offset; } if ((*flags & FLAGS_DID_AUXV) == 0) { if (do_auxv_note(ms, nbuf, xnh_type, swap, namesz, descsz, noff, doff, flags, size, clazz, fd, ph_off, ph_num, fsize)) return offset; } if (namesz == 7 && strcmp(CAST(char *, &nbuf[noff]), "NetBSD") == 0) { int descw, flag; const char *str, *tag; if (descsz > 100) descsz = 100; switch (xnh_type) { case NT_NETBSD_VERSION: return offset; case NT_NETBSD_MARCH: flag = FLAGS_DID_NETBSD_MARCH; tag = "compiled for"; break; case NT_NETBSD_CMODEL: flag = FLAGS_DID_NETBSD_CMODEL; tag = "compiler model"; break; case NT_NETBSD_EMULATION: flag = FLAGS_DID_NETBSD_EMULATION; tag = "emulation:"; break; default: if (*flags & FLAGS_DID_NETBSD_UNKNOWN) return offset; *flags |= FLAGS_DID_NETBSD_UNKNOWN; if (file_printf(ms, ", note=%u", xnh_type) == -1) return offset; return offset; } if (*flags & flag) return offset; str = CAST(const char *, &nbuf[doff]); descw = CAST(int, descsz); *flags |= flag; file_printf(ms, ", %s: %.*s", tag, descw, str); return offset; } return offset; } Commit Message: Avoid reading past the end of buffer (Rui Reis) CWE ID: CWE-125
0
83,124
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 Verify_FindMainResponseWithMultipleHits5() { EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_); EXPECT_EQ(kManifestUrl2, delegate()->found_manifest_url_); EXPECT_EQ(2, delegate()->found_cache_id_); EXPECT_EQ(2, delegate()->found_group_id_); EXPECT_FALSE(delegate()->found_entry_.has_response_id()); EXPECT_EQ(2 + kFallbackEntryIdOffset, delegate()->found_fallback_entry_.response_id()); EXPECT_TRUE(delegate()->found_fallback_entry_.IsFallback()); EXPECT_EQ(kEntryUrl2, delegate()->found_namespace_entry_url_); TestFinished(); } Commit Message: Reland "AppCache: Add padding to cross-origin responses." This is a reland of 85b389caa7d725cdd31f59e9a2b79ff54804b7b7 Initialized CacheRecord::padding_size to 0. Original change's description: > AppCache: Add padding to cross-origin responses. > > Bug: 918293 > Change-Id: I4f16640f06feac009d6bbbb624951da6d2669f6c > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1488059 > Commit-Queue: Staphany Park <staphany@chromium.org> > Reviewed-by: Victor Costan <pwnall@chromium.org> > Reviewed-by: Marijn Kruisselbrink <mek@chromium.org> > Cr-Commit-Position: refs/heads/master@{#644624} Bug: 918293 Change-Id: Ie1d3f99c7e8a854d33255a4d66243da2ce16441c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1539906 Reviewed-by: Victor Costan <pwnall@chromium.org> Commit-Queue: Staphany Park <staphany@chromium.org> Cr-Commit-Position: refs/heads/master@{#644719} CWE ID: CWE-200
0
151,391
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: tracing_buffers_splice_read(struct file *file, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags) { struct ftrace_buffer_info *info = file->private_data; struct trace_iterator *iter = &info->iter; struct partial_page partial_def[PIPE_DEF_BUFFERS]; struct page *pages_def[PIPE_DEF_BUFFERS]; struct splice_pipe_desc spd = { .pages = pages_def, .partial = partial_def, .nr_pages_max = PIPE_DEF_BUFFERS, .ops = &buffer_pipe_buf_ops, .spd_release = buffer_spd_release, }; struct buffer_ref *ref; int entries, i; ssize_t ret = 0; #ifdef CONFIG_TRACER_MAX_TRACE if (iter->snapshot && iter->tr->current_trace->use_max_tr) return -EBUSY; #endif if (*ppos & (PAGE_SIZE - 1)) return -EINVAL; if (len & (PAGE_SIZE - 1)) { if (len < PAGE_SIZE) return -EINVAL; len &= PAGE_MASK; } if (splice_grow_spd(pipe, &spd)) return -ENOMEM; again: trace_access_lock(iter->cpu_file); entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file); for (i = 0; i < spd.nr_pages_max && len && entries; i++, len -= PAGE_SIZE) { struct page *page; int r; ref = kzalloc(sizeof(*ref), GFP_KERNEL); if (!ref) { ret = -ENOMEM; break; } ref->ref = 1; ref->buffer = iter->trace_buffer->buffer; ref->page = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file); if (IS_ERR(ref->page)) { ret = PTR_ERR(ref->page); ref->page = NULL; kfree(ref); break; } ref->cpu = iter->cpu_file; r = ring_buffer_read_page(ref->buffer, &ref->page, len, iter->cpu_file, 1); if (r < 0) { ring_buffer_free_read_page(ref->buffer, ref->cpu, ref->page); kfree(ref); break; } page = virt_to_page(ref->page); spd.pages[i] = page; spd.partial[i].len = PAGE_SIZE; spd.partial[i].offset = 0; spd.partial[i].private = (unsigned long)ref; spd.nr_pages++; *ppos += PAGE_SIZE; entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file); } trace_access_unlock(iter->cpu_file); spd.nr_pages = i; /* did we read anything? */ if (!spd.nr_pages) { if (ret) goto out; ret = -EAGAIN; if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK)) goto out; ret = wait_on_pipe(iter, true); if (ret) goto out; goto again; } ret = splice_to_pipe(pipe, &spd); out: splice_shrink_spd(&spd); return ret; } 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,458
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: _asn1_delete_list (void) { list_type *listElement; while (firstElement) { listElement = firstElement; firstElement = firstElement->next; free (listElement); } } Commit Message: CWE ID: CWE-119
0
3,877
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 rpc_async_schedule(struct work_struct *work) { __rpc_execute(container_of(work, struct rpc_task, u.tk_work)); } 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,949
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: MessageRouter* ChildThread::GetRouter() { DCHECK(base::MessageLoop::current() == message_loop()); return &router_; } Commit Message: [FileAPI] Clean up WebFileSystemImpl before Blink shutdown WebFileSystemImpl should not outlive V8 instance, since it may have references to V8. This CL ensures it deleted before Blink shutdown. BUG=369525 Review URL: https://codereview.chromium.org/270633009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269345 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID:
0
121,301
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::ExitFullscreenMode(bool will_cause_resize) { RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); if (widget_view) { RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) ->ShutdownAndDestroyWidget(true); } #if defined(OS_ANDROID) ContentVideoView* video_view = ContentVideoView::GetInstance(); if (video_view != NULL) video_view->ExitFullscreen(); #endif if (delegate_) delegate_->ExitFullscreenModeForTab(this); if (!will_cause_resize) { if (RenderWidgetHostView* rwhv = GetRenderWidgetHostView()) { if (RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost()) render_widget_host->WasResized(); } } for (auto& observer : observers_) { observer.DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab(), will_cause_resize); } } 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,689