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: bool Textfield::Cut() { if (!read_only() && text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD && model_->Cut()) { if (controller_) controller_->OnAfterCutOrCopy(ui::CLIPBOARD_TYPE_COPY_PASTE); return true; } return false; } 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,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: menu_add_separator_image(WebKitWebView *page, GArray *argv, GString *result) { (void) page; (void) result; add_separator_to_menu(argv, WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE); } Commit Message: disable Uzbl javascript object because of security problem. CWE ID: CWE-264
0
18,374
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 WebUILoginView::AcceleratorPressed( const ui::Accelerator& accelerator) { AccelMap::const_iterator entry = accel_map_.find(accelerator); if (entry == accel_map_.end()) return false; if (!webui_login_) return true; content::WebUI* web_ui = GetWebUI(); if (web_ui) { base::StringValue accel_name(entry->second); web_ui->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", accel_name); } return true; } Commit Message: [cros] Allow media streaming for OOBE WebUI. BUG=122764 TEST=Manual with --enable-html5-camera Review URL: https://chromiumcodereview.appspot.com/10693027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144899 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
103,450
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 find_new_extents(struct btrfs_root *root, struct inode *inode, u64 newer_than, u64 *off, int thresh) { struct btrfs_path *path; struct btrfs_key min_key; struct btrfs_key max_key; struct extent_buffer *leaf; struct btrfs_file_extent_item *extent; int type; int ret; u64 ino = btrfs_ino(inode); path = btrfs_alloc_path(); if (!path) return -ENOMEM; min_key.objectid = ino; min_key.type = BTRFS_EXTENT_DATA_KEY; min_key.offset = *off; max_key.objectid = ino; max_key.type = (u8)-1; max_key.offset = (u64)-1; path->keep_locks = 1; while(1) { ret = btrfs_search_forward(root, &min_key, &max_key, path, 0, newer_than); if (ret != 0) goto none; if (min_key.objectid != ino) goto none; if (min_key.type != BTRFS_EXTENT_DATA_KEY) goto none; leaf = path->nodes[0]; extent = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_file_extent_item); type = btrfs_file_extent_type(leaf, extent); if (type == BTRFS_FILE_EXTENT_REG && btrfs_file_extent_num_bytes(leaf, extent) < thresh && check_defrag_in_cache(inode, min_key.offset, thresh)) { *off = min_key.offset; btrfs_free_path(path); return 0; } if (min_key.offset == (u64)-1) goto none; min_key.offset++; btrfs_release_path(path); } none: btrfs_free_path(path); return -ENOENT; } Commit Message: Btrfs: fix hash overflow handling The handling for directory crc hash overflows was fairly obscure, split_leaf returns EOVERFLOW when we try to extend the item and that is supposed to bubble up to userland. For a while it did so, but along the way we added better handling of errors and forced the FS readonly if we hit IO errors during the directory insertion. Along the way, we started testing only for EEXIST and the EOVERFLOW case was dropped. The end result is that we may force the FS readonly if we catch a directory hash bucket overflow. This fixes a few problem spots. First I add tests for EOVERFLOW in the places where we can safely just return the error up the chain. btrfs_rename is harder though, because it tries to insert the new directory item only after it has already unlinked anything the rename was going to overwrite. Rather than adding very complex logic, I added a helper to test for the hash overflow case early while it is still safe to bail out. Snapshot and subvolume creation had a similar problem, so they are using the new helper now too. Signed-off-by: Chris Mason <chris.mason@fusionio.com> Reported-by: Pascal Junod <pascal@junod.info> CWE ID: CWE-310
0
34,454
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: JBIG2PatternDict::JBIG2PatternDict(Guint segNumA, Guint sizeA): JBIG2Segment(segNumA) { size = sizeA; bitmaps = (JBIG2Bitmap **)gmallocn(size, sizeof(JBIG2Bitmap *)); } Commit Message: CWE ID: CWE-189
0
1,156
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: PanoramiXMaybeAddVisual(VisualPtr pVisual) { ScreenPtr pScreen; int j, k; Bool found = FALSE; FOR_NSCREENS_FORWARD_SKIP(j) { pScreen = screenInfo.screens[j]; found = FALSE; for (k = 0; k < pScreen->numVisuals; k++) { VisualPtr candidate = &pScreen->visuals[k]; if ((*XineramaVisualsEqualPtr) (pVisual, pScreen, candidate) #ifdef GLXPROXY && glxMatchVisual(screenInfo.screens[0], pVisual, pScreen) #endif ) { found = TRUE; break; } } if (!found) return; } /* found a matching visual on all screens, add it to the subset list */ j = PanoramiXNumVisuals; PanoramiXNumVisuals++; PanoramiXVisuals = reallocarray(PanoramiXVisuals, PanoramiXNumVisuals, sizeof(VisualRec)); memcpy(&PanoramiXVisuals[j], pVisual, sizeof(VisualRec)); for (k = 0; k < PanoramiXNumDepths; k++) { if (PanoramiXDepths[k].depth == pVisual->nplanes) { PanoramiXDepths[k].vids[PanoramiXDepths[k].numVids] = pVisual->vid; PanoramiXDepths[k].numVids++; break; } } } Commit Message: CWE ID: CWE-20
0
17,372
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 __le16 brcmf_get_mcs_map(u32 nchain, enum ieee80211_vht_mcs_support supp) { u16 mcs_map; int i; for (i = 0, mcs_map = 0xFFFF; i < nchain; i++) mcs_map = (mcs_map << 2) | supp; return cpu_to_le16(mcs_map); } Commit Message: brcmfmac: avoid potential stack overflow in brcmf_cfg80211_start_ap() User-space can choose to omit NL80211_ATTR_SSID and only provide raw IE TLV data. When doing so it can provide SSID IE with length exceeding the allowed size. The driver further processes this IE copying it into a local variable without checking the length. Hence stack can be corrupted and used as exploit. Cc: stable@vger.kernel.org # v4.7 Reported-by: Daxing Guo <freener.gdx@gmail.com> Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com> Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com> Reviewed-by: Franky Lin <franky.lin@broadcom.com> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> CWE ID: CWE-119
0
49,078
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 PrintWebViewHelper::CopyAndPrint(WebKit::WebFrame* web_frame) { WebPreferences prefs = render_view()->webkit_preferences(); prefs.javascript_enabled = false; prefs.java_enabled = false; print_web_view_ = WebView::create(this); prefs.Apply(print_web_view_); print_web_view_->initializeMainFrame(this); print_pages_params_->pages.clear(); // Print all pages of selection. std::string html = web_frame->selectionAsMarkup().utf8(); std::string url_str = "data:text/html;charset=utf-8,"; url_str.append(html); GURL url(url_str); print_web_view_->mainFrame()->loadRequest(WebURLRequest(url)); return true; } Commit Message: Fix print preview workflow to reflect settings of selected printer. BUG=95110 TEST=none Review URL: http://codereview.chromium.org/7831041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102242 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
97,512
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int network_config_set_security_level (oconfig_item_t *ci, /* {{{ */ int *retval) { char *str; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) { WARNING ("network plugin: The `SecurityLevel' config option needs exactly " "one string argument."); return (-1); } str = ci->values[0].value.string; if (strcasecmp ("Encrypt", str) == 0) *retval = SECURITY_LEVEL_ENCRYPT; else if (strcasecmp ("Sign", str) == 0) *retval = SECURITY_LEVEL_SIGN; else if (strcasecmp ("None", str) == 0) *retval = SECURITY_LEVEL_NONE; else { WARNING ("network plugin: Unknown security level: %s.", str); return (-1); } return (0); } /* }}} int network_config_set_security_level */ Commit Message: network plugin: Fix heap overflow in parse_packet(). Emilien Gaspar has identified a heap overflow in parse_packet(), the function used by the network plugin to parse incoming network packets. This is a vulnerability in collectd, though the scope is not clear at this point. At the very least specially crafted network packets can be used to crash the daemon. We can't rule out a potential remote code execution though. Fixes: CVE-2016-6254 CWE ID: CWE-119
0
50,742
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: parse_ENQUEUE(char *arg, struct ofpbuf *ofpacts, enum ofputil_protocol *usable_protocols OVS_UNUSED) { char *sp = NULL; char *port = strtok_r(arg, ":q,", &sp); char *queue = strtok_r(NULL, "", &sp); struct ofpact_enqueue *enqueue; if (port == NULL || queue == NULL) { return xstrdup("\"enqueue\" syntax is \"enqueue:PORT:QUEUE\" or " "\"enqueue(PORT,QUEUE)\""); } enqueue = ofpact_put_ENQUEUE(ofpacts); if (!ofputil_port_from_string(port, &enqueue->port)) { return xasprintf("%s: enqueue to unknown port", port); } return str_to_u32(queue, &enqueue->queue); } Commit Message: ofp-actions: Avoid buffer overread in BUNDLE action decoding. Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9052 Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org> CWE ID:
0
77,049
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 FrameLoader::StartLoad(FrameLoadRequest& frame_load_request, FrameLoadType type, NavigationPolicy navigation_policy, HistoryItem* history_item) { DCHECK(Client()->HasWebView()); ResourceRequest& resource_request = frame_load_request.GetResourceRequest(); NavigationType navigation_type = DetermineNavigationType( type, resource_request.HttpBody() || frame_load_request.Form(), frame_load_request.TriggeringEvent()); resource_request.SetRequestContext( DetermineRequestContextFromNavigationType(navigation_type)); resource_request.SetFrameType( frame_->IsMainFrame() ? network::mojom::RequestContextFrameType::kTopLevel : network::mojom::RequestContextFrameType::kNested); bool had_placeholder_client_document_loader = provisional_document_loader_ && !provisional_document_loader_->DidStart(); navigation_policy = CheckLoadCanStart(frame_load_request, type, navigation_policy, navigation_type); if (navigation_policy == kNavigationPolicyIgnore) { if (had_placeholder_client_document_loader && !resource_request.CheckForBrowserSideNavigation()) { DetachDocumentLoader(provisional_document_loader_); } return; } if (had_placeholder_client_document_loader) provisional_document_loader_->SetSentDidFinishLoad(); frame_->GetDocument()->CancelParsing(); if (!had_placeholder_client_document_loader && type == kFrameLoadTypeStandard && (navigation_policy == kNavigationPolicyCurrentTab || navigation_policy == kNavigationPolicyHandledByClient)) { frame_->GetDocument()->CheckCompleted(); } DetachDocumentLoader(provisional_document_loader_); if (!frame_->GetPage()) return; progress_tracker_->ProgressStarted(type); if (navigation_policy == kNavigationPolicyHandledByClientForInitialHistory) return; DCHECK(navigation_policy == kNavigationPolicyCurrentTab || navigation_policy == kNavigationPolicyHandledByClient); provisional_document_loader_ = CreateDocumentLoader( resource_request, frame_load_request, type, navigation_type); if (!had_placeholder_client_document_loader || navigation_policy == kNavigationPolicyHandledByClient) { frame_->GetNavigationScheduler().Cancel(); } if (frame_load_request.Form()) Client()->DispatchWillSubmitForm(frame_load_request.Form()); provisional_document_loader_->AppendRedirect( provisional_document_loader_->Url()); if (IsBackForwardLoadType(type)) { DCHECK(history_item); provisional_document_loader_->SetItemForHistoryNavigation(history_item); } DCHECK(!frame_load_request.GetResourceRequest().IsSameDocumentNavigation()); frame_->FrameScheduler()->DidStartProvisionalLoad(frame_->IsMainFrame()); Client()->DispatchDidStartProvisionalLoad(provisional_document_loader_, resource_request); DCHECK(provisional_document_loader_); if (navigation_policy == kNavigationPolicyCurrentTab) { provisional_document_loader_->StartLoading(); probe::frameClearedScheduledClientNavigation(frame_); } else { probe::frameScheduledClientNavigation(frame_); } TakeObjectSnapshot(); } Commit Message: Fix detach with open()ed document leaving parent loading indefinitely Change-Id: I26c2a054b9f1e5eb076acd677e1223058825f6d6 Bug: 803416 Test: fast/loader/document-open-iframe-then-detach.html Change-Id: I26c2a054b9f1e5eb076acd677e1223058825f6d6 Reviewed-on: https://chromium-review.googlesource.com/887298 Reviewed-by: Mike West <mkwst@chromium.org> Commit-Queue: Nate Chapin <japhet@chromium.org> Cr-Commit-Position: refs/heads/master@{#532967} CWE ID: CWE-362
0
125,825
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 do_tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen) { struct inet_connection_sock *icsk = inet_csk(sk); struct tcp_sock *tp = tcp_sk(sk); int val, len; if (get_user(len, optlen)) return -EFAULT; len = min_t(unsigned int, len, sizeof(int)); if (len < 0) return -EINVAL; switch (optname) { case TCP_MAXSEG: val = tp->mss_cache; if (!val && ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) val = tp->rx_opt.user_mss; break; case TCP_NODELAY: val = !!(tp->nonagle&TCP_NAGLE_OFF); break; case TCP_CORK: val = !!(tp->nonagle&TCP_NAGLE_CORK); break; case TCP_KEEPIDLE: val = keepalive_time_when(tp) / HZ; break; case TCP_KEEPINTVL: val = keepalive_intvl_when(tp) / HZ; break; case TCP_KEEPCNT: val = keepalive_probes(tp); break; case TCP_SYNCNT: val = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries; break; case TCP_LINGER2: val = tp->linger2; if (val >= 0) val = (val ? : sysctl_tcp_fin_timeout) / HZ; break; case TCP_DEFER_ACCEPT: val = retrans_to_secs(icsk->icsk_accept_queue.rskq_defer_accept, TCP_TIMEOUT_INIT / HZ, TCP_RTO_MAX / HZ); break; case TCP_WINDOW_CLAMP: val = tp->window_clamp; break; case TCP_INFO: { struct tcp_info info; if (get_user(len, optlen)) return -EFAULT; tcp_get_info(sk, &info); len = min_t(unsigned int, len, sizeof(info)); if (put_user(len, optlen)) return -EFAULT; if (copy_to_user(optval, &info, len)) return -EFAULT; return 0; } case TCP_QUICKACK: val = !icsk->icsk_ack.pingpong; break; case TCP_CONGESTION: if (get_user(len, optlen)) return -EFAULT; len = min_t(unsigned int, len, TCP_CA_NAME_MAX); if (put_user(len, optlen)) return -EFAULT; if (copy_to_user(optval, icsk->icsk_ca_ops->name, len)) return -EFAULT; return 0; case TCP_COOKIE_TRANSACTIONS: { struct tcp_cookie_transactions ctd; struct tcp_cookie_values *cvp = tp->cookie_values; if (get_user(len, optlen)) return -EFAULT; if (len < sizeof(ctd)) return -EINVAL; memset(&ctd, 0, sizeof(ctd)); ctd.tcpct_flags = (tp->rx_opt.cookie_in_always ? TCP_COOKIE_IN_ALWAYS : 0) | (tp->rx_opt.cookie_out_never ? TCP_COOKIE_OUT_NEVER : 0); if (cvp != NULL) { ctd.tcpct_flags |= (cvp->s_data_in ? TCP_S_DATA_IN : 0) | (cvp->s_data_out ? TCP_S_DATA_OUT : 0); ctd.tcpct_cookie_desired = cvp->cookie_desired; ctd.tcpct_s_data_desired = cvp->s_data_desired; memcpy(&ctd.tcpct_value[0], &cvp->cookie_pair[0], cvp->cookie_pair_size); ctd.tcpct_used = cvp->cookie_pair_size; } if (put_user(sizeof(ctd), optlen)) return -EFAULT; if (copy_to_user(optval, &ctd, sizeof(ctd))) return -EFAULT; return 0; } default: return -ENOPROTOOPT; } if (put_user(len, optlen)) return -EFAULT; if (copy_to_user(optval, &val, len)) return -EFAULT; return 0; } Commit Message: net: Fix oops from tcp_collapse() when using splice() tcp_read_sock() can have a eat skbs without immediately advancing copied_seq. This can cause a panic in tcp_collapse() if it is called as a result of the recv_actor dropping the socket lock. A userspace program that splices data from a socket to either another socket or to a file can trigger this bug. Signed-off-by: Steven J. Magnani <steve@digidescorp.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-119
0
31,856
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 ProfileSyncService::EncryptEverythingEnabled() const { DCHECK(backend_initialized_); return encrypt_everything_ || encryption_pending_; } 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,924
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void irda_destroy_socket(struct irda_sock *self) { pr_debug("%s(%p)\n", __func__, self); /* Unregister with IrLMP */ irlmp_unregister_client(self->ckey); irlmp_unregister_service(self->skey); /* Unregister with LM-IAS */ if (self->ias_obj) { irias_delete_object(self->ias_obj); self->ias_obj = NULL; } if (self->iriap) { iriap_close(self->iriap); self->iriap = NULL; } if (self->tsap) { irttp_disconnect_request(self->tsap, NULL, P_NORMAL); irttp_close_tsap(self->tsap); self->tsap = NULL; } #ifdef CONFIG_IRDA_ULTRA if (self->lsap) { irlmp_close_lsap(self->lsap); self->lsap = NULL; } #endif /* CONFIG_IRDA_ULTRA */ } 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,579
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: GDataDirectory* GDataDirectory::AsGDataDirectory() { return this; } Commit Message: gdata: Define the resource ID for the root directory Per the spec, the resource ID for the root directory is defined as "folder:root". Add the resource ID to the root directory in our file system representation so we can look up the root directory by the resource ID. BUG=127697 TEST=add unit tests Review URL: https://chromiumcodereview.appspot.com/10332253 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137928 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID:
0
104,674
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 SetFixedFontFamilyWrapper(WebSettings* settings, const base::string16& font, UScriptCode script) { settings->SetFixedFontFamily(WebString::FromUTF16(font), script); } Commit Message: Prevent renderer initiated back navigation to cancel a browser one. Renderer initiated back/forward navigations must not be able to cancel ongoing browser initiated navigation if they are not user initiated. Note: 'normal' renderer initiated navigation uses the FrameHost::BeginNavigation() path. A code similar to this patch is done in NavigatorImpl::OnBeginNavigation(). Test: ----- Added: NavigationBrowserTest. * HistoryBackInBeforeUnload * HistoryBackInBeforeUnloadAfterSetTimeout * HistoryBackCancelPendingNavigationNoUserGesture * HistoryBackCancelPendingNavigationUserGesture Fixed: * (WPT) .../the-history-interface/traverse_the_history_2.html * (WPT) .../the-history-interface/traverse_the_history_3.html * (WPT) .../the-history-interface/traverse_the_history_4.html * (WPT) .../the-history-interface/traverse_the_history_5.html Bug: 879965 Change-Id: I1a9bfaaea1ffc219e6c32f6e676b660e746c578c Reviewed-on: https://chromium-review.googlesource.com/1209744 Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Mustaq Ahmed <mustaq@chromium.org> Reviewed-by: Camille Lamy <clamy@chromium.org> Reviewed-by: Charlie Reis <creis@chromium.org> Cr-Commit-Position: refs/heads/master@{#592823} CWE ID: CWE-254
0
145,172
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 get_kernel_consoles(char ***ret) { _cleanup_strv_free_ char **l = NULL; _cleanup_free_ char *line = NULL; const char *p; int r; assert(ret); /* If /sys is mounted read-only this means we are running in some kind of container environment. In that * case /sys would reflect the host system, not us, hence ignore the data we can read from it. */ if (path_is_read_only_fs("/sys") > 0) goto fallback; r = read_one_line_file("/sys/class/tty/console/active", &line); if (r < 0) return r; p = line; for (;;) { _cleanup_free_ char *tty = NULL; char *path; r = extract_first_word(&p, &tty, NULL, 0); if (r < 0) return r; if (r == 0) break; if (streq(tty, "tty0")) { tty = mfree(tty); r = read_one_line_file("/sys/class/tty/tty0/active", &tty); if (r < 0) return r; } path = strappend("/dev/", tty); if (!path) return -ENOMEM; if (access(path, F_OK) < 0) { log_debug_errno(errno, "Console device %s is not accessible, skipping: %m", path); free(path); continue; } r = strv_consume(&l, path); if (r < 0) return r; } if (strv_isempty(l)) { log_debug("No devices found for system console"); goto fallback; } *ret = TAKE_PTR(l); return 0; fallback: r = strv_extend(&l, "/dev/console"); if (r < 0) return r; *ret = TAKE_PTR(l); return 0; } Commit Message: Merge pull request #12378 from rbalint/vt-kbd-reset-check VT kbd reset check CWE ID: CWE-255
0
92,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: prepare_incremental_sweep(mrb_state *mrb, mrb_gc *gc) { gc->state = MRB_GC_STATE_SWEEP; gc->sweeps = gc->heaps; gc->live_after_mark = gc->live; } Commit Message: Clear unused stack region that may refer freed objects; fix #3596 CWE ID: CWE-416
0
64,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 OnShowCreatedWindow(int pending_widget_routing_id, WindowOpenDisposition disposition, const gfx::Rect& initial_rect, bool user_gesture) { content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, base::BindOnce(&PendingWidgetMessageFilter::OnReceivedRoutingIDOnUI, this, pending_widget_routing_id)); } Commit Message: Use unique processes for data URLs on restore. Data URLs are usually put into the process that created them, but this info is not tracked after a tab restore. Ensure that they do not end up in the parent frame's process (or each other's process), in case they are malicious. BUG=863069 Change-Id: Ib391f90c7bdf28a0a9c057c5cc7918c10aed968b Reviewed-on: https://chromium-review.googlesource.com/1150767 Reviewed-by: Alex Moshchuk <alexmos@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Charlie Reis <creis@chromium.org> Cr-Commit-Position: refs/heads/master@{#581023} CWE ID: CWE-285
0
154,541
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: SavePackageNotificationObserver::~SavePackageNotificationObserver() {} Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt. BUG=107201 TEST=no visible change Review URL: https://chromiumcodereview.appspot.com/11293205 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
117,694
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: PassRefPtr<CustomElementConstructor> Document::registerElement(WebCore::ScriptState* state, const AtomicString& name, const Dictionary& options, ExceptionCode& ec) { if (!isHTMLDocument() && !isXHTMLDocument()) { ec = NOT_SUPPORTED_ERR; return 0; } if (!m_registry) m_registry = adoptRef(new CustomElementRegistry(this)); return m_registry->registerElement(state, name, options, ec); } Commit Message: Unreviewed, rolling out r147402. http://trac.webkit.org/changeset/147402 https://bugs.webkit.org/show_bug.cgi?id=112903 Source/WebCore: * dom/Document.cpp: (WebCore::Document::processHttpEquiv): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::responseReceived): LayoutTests: * http/tests/security/XFrameOptions/x-frame-options-deny-expected.txt: * http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-expected.txt: * http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body-expected.txt: * http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body.html: * http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny-expected.txt: * http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny.html: * http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag.html: * http/tests/security/XFrameOptions/x-frame-options-deny.html: * http/tests/security/XFrameOptions/x-frame-options-multiple-headers-sameorigin-deny-expected.txt: * http/tests/security/XFrameOptions/x-frame-options-multiple-headers-sameorigin-deny.html: * http/tests/security/XFrameOptions/x-frame-options-parent-same-origin-deny-expected.txt: * http/tests/security/XFrameOptions/x-frame-options-parent-same-origin-deny.html: * platform/chromium/http/tests/security/XFrameOptions/x-frame-options-deny-expected.txt: * platform/chromium/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-expected.txt: * platform/chromium/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body-expected.txt: * platform/chromium/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny-expected.txt: * platform/chromium/http/tests/security/XFrameOptions/x-frame-options-multiple-headers-sameorigin-deny-expected.txt: * platform/chromium/http/tests/security/XFrameOptions/x-frame-options-parent-same-origin-deny-expected.txt: git-svn-id: svn://svn.chromium.org/blink/trunk@147450 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-399
0
105,577
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 ssl3_get_cert_verify(SSL *s) { EVP_PKEY *pkey=NULL; unsigned char *p; int al,ok,ret=0; long n; int type=0,i,j; X509 *peer; const EVP_MD *md = NULL; EVP_MD_CTX mctx; EVP_MD_CTX_init(&mctx); n=s->method->ssl_get_message(s, SSL3_ST_SR_CERT_VRFY_A, SSL3_ST_SR_CERT_VRFY_B, -1, SSL3_RT_MAX_PLAIN_LENGTH, &ok); if (!ok) return((int)n); if (s->session->peer != NULL) { peer=s->session->peer; pkey=X509_get_pubkey(peer); type=X509_certificate_type(peer,pkey); } else { peer=NULL; pkey=NULL; } if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE_VERIFY) { s->s3->tmp.reuse_message=1; if ((peer != NULL) && (type & EVP_PKT_SIGN)) { al=SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_MISSING_VERIFY_MESSAGE); goto f_err; } ret=1; goto end; } if (peer == NULL) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_NO_CLIENT_CERT_RECEIVED); al=SSL_AD_UNEXPECTED_MESSAGE; goto f_err; } if (!(type & EVP_PKT_SIGN)) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE); al=SSL_AD_ILLEGAL_PARAMETER; goto f_err; } if (s->s3->change_cipher_spec) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_CCS_RECEIVED_EARLY); al=SSL_AD_UNEXPECTED_MESSAGE; goto f_err; } /* we now have a signature that we need to verify */ p=(unsigned char *)s->init_msg; /* Check for broken implementations of GOST ciphersuites */ /* If key is GOST and n is exactly 64, it is bare * signature without length field */ if (n==64 && (pkey->type==NID_id_GostR3410_94 || pkey->type == NID_id_GostR3410_2001) ) { i=64; } else { if (SSL_USE_SIGALGS(s)) { int rv = tls12_check_peer_sigalg(&md, s, p, pkey); if (rv == -1) { al = SSL_AD_INTERNAL_ERROR; goto f_err; } else if (rv == 0) { al = SSL_AD_DECODE_ERROR; goto f_err; } #ifdef SSL_DEBUG fprintf(stderr, "USING TLSv1.2 HASH %s\n", EVP_MD_name(md)); #endif p += 2; n -= 2; } n2s(p,i); n-=2; if (i > n) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_LENGTH_MISMATCH); al=SSL_AD_DECODE_ERROR; goto f_err; } } j=EVP_PKEY_size(pkey); if ((i > j) || (n > j) || (n <= 0)) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_WRONG_SIGNATURE_SIZE); al=SSL_AD_DECODE_ERROR; goto f_err; } if (SSL_USE_SIGALGS(s)) { long hdatalen = 0; void *hdata; hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata); if (hdatalen <= 0) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_INTERNAL_ERROR); al=SSL_AD_INTERNAL_ERROR; goto f_err; } #ifdef SSL_DEBUG fprintf(stderr, "Using TLS 1.2 with client verify alg %s\n", EVP_MD_name(md)); #endif if (!EVP_VerifyInit_ex(&mctx, md, NULL) || !EVP_VerifyUpdate(&mctx, hdata, hdatalen)) { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, ERR_R_EVP_LIB); al=SSL_AD_INTERNAL_ERROR; goto f_err; } if (EVP_VerifyFinal(&mctx, p , i, pkey) <= 0) { al=SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_SIGNATURE); goto f_err; } } else #ifndef OPENSSL_NO_RSA if (pkey->type == EVP_PKEY_RSA) { i=RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md, MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH, p, i, pkey->pkey.rsa); if (i < 0) { al=SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_DECRYPT); goto f_err; } if (i == 0) { al=SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_SIGNATURE); goto f_err; } } else #endif #ifndef OPENSSL_NO_DSA if (pkey->type == EVP_PKEY_DSA) { j=DSA_verify(pkey->save_type, &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), SHA_DIGEST_LENGTH,p,i,pkey->pkey.dsa); if (j <= 0) { /* bad signature */ al=SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_DSA_SIGNATURE); goto f_err; } } else #endif #ifndef OPENSSL_NO_ECDSA if (pkey->type == EVP_PKEY_EC) { j=ECDSA_verify(pkey->save_type, &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), SHA_DIGEST_LENGTH,p,i,pkey->pkey.ec); if (j <= 0) { /* bad signature */ al=SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_ECDSA_SIGNATURE); goto f_err; } } else #endif if (pkey->type == NID_id_GostR3410_94 || pkey->type == NID_id_GostR3410_2001) { unsigned char signature[64]; int idx; EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new(pkey,NULL); EVP_PKEY_verify_init(pctx); if (i!=64) { fprintf(stderr,"GOST signature length is %d",i); } for (idx=0;idx<64;idx++) { signature[63-idx]=p[idx]; } j=EVP_PKEY_verify(pctx,signature,64,s->s3->tmp.cert_verify_md,32); EVP_PKEY_CTX_free(pctx); if (j<=0) { al=SSL_AD_DECRYPT_ERROR; SSLerr(SSL_F_SSL3_GET_CERT_VERIFY, SSL_R_BAD_ECDSA_SIGNATURE); goto f_err; } } else { SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,ERR_R_INTERNAL_ERROR); al=SSL_AD_UNSUPPORTED_CERTIFICATE; goto f_err; } ret=1; if (0) { f_err: ssl3_send_alert(s,SSL3_AL_FATAL,al); } end: if (s->s3->handshake_buffer) { BIO_free(s->s3->handshake_buffer); s->s3->handshake_buffer = NULL; s->s3->flags &= ~TLS1_FLAGS_KEEP_HANDSHAKE; } EVP_MD_CTX_cleanup(&mctx); EVP_PKEY_free(pkey); return(ret); } Commit Message: Only allow ephemeral RSA keys in export ciphersuites. OpenSSL clients would tolerate temporary RSA keys in non-export ciphersuites. It also had an option SSL_OP_EPHEMERAL_RSA which enabled this server side. Remove both options as they are a protocol violation. Thanks to Karthikeyan Bhargavan for reporting this issue. (CVE-2015-0204) Reviewed-by: Matt Caswell <matt@openssl.org> CWE ID: CWE-310
0
45,202
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 *zrle_convert_fb(VncState *vs, int x, int y, int w, int h, int bpp) { Buffer tmp; buffer_reset(&vs->zrle.fb); buffer_reserve(&vs->zrle.fb, w * h * bpp + bpp); tmp = vs->output; vs->output = vs->zrle.fb; vnc_raw_send_framebuffer_update(vs, x, y, w, h); vs->zrle.fb = vs->output; vs->output = tmp; return vs->zrle.fb.buffer; } Commit Message: CWE ID: CWE-125
0
17,894
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: RemoveObservedFrame(RenderFrameHost* render_frame_host, int session_id) { DCHECK_CURRENTLY_ON(BrowserThread::UI); auto iters = observed_frames_.equal_range(render_frame_host); auto it = std::find_if(iters.first, iters.second, [render_frame_host, session_id]( std::pair<RenderFrameHost* const, int>& map_pair) { return map_pair.first == render_frame_host && map_pair.second == session_id; }); if (it == iters.second) return; observed_frames_.erase(it); if (!observed_frames_.size()) parent_observer_->contents_observers_.erase(web_contents()); } Commit Message: Make MediaStreamDispatcherHost per-request instead of per-frame. Instead of having RenderFrameHost own a single MSDH to handle all requests from a frame, MSDH objects will be owned by a strong binding. A consequence of this is that an additional requester ID is added to requests to MediaStreamManager, so that an MSDH is able to cancel only requests generated by it. In practice, MSDH will continue to be per frame in most cases since each frame normally makes a single request for an MSDH object. This fixes a lifetime issue caused by the IO thread executing tasks after the RenderFrameHost dies. Drive-by: Fix some minor lint issues. Bug: 912520 Change-Id: I52742ffc98b9fc57ce8e6f5093a61aed86d3e516 Reviewed-on: https://chromium-review.googlesource.com/c/1369799 Reviewed-by: Emircan Uysaler <emircan@chromium.org> Reviewed-by: Ken Buchanan <kenrb@chromium.org> Reviewed-by: Olga Sharonova <olka@chromium.org> Commit-Queue: Guido Urdaneta <guidou@chromium.org> Cr-Commit-Position: refs/heads/master@{#616347} CWE ID: CWE-189
0
153,314
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: _HB_GPOS_Free_SubTable( HB_GPOS_SubTable* st, HB_UShort lookup_type ) { switch ( lookup_type ) { case HB_GPOS_LOOKUP_SINGLE: Free_SinglePos ( st ); return; case HB_GPOS_LOOKUP_PAIR: Free_PairPos ( st ); return; case HB_GPOS_LOOKUP_CURSIVE: Free_CursivePos ( st ); return; case HB_GPOS_LOOKUP_MARKBASE: Free_MarkBasePos ( st ); return; case HB_GPOS_LOOKUP_MARKLIG: Free_MarkLigPos ( st ); return; case HB_GPOS_LOOKUP_MARKMARK: Free_MarkMarkPos ( st ); return; case HB_GPOS_LOOKUP_CONTEXT: Free_ContextPos ( st ); return; case HB_GPOS_LOOKUP_CHAIN: Free_ChainContextPos ( st ); return; /*case HB_GPOS_LOOKUP_EXTENSION: Free_ExtensionPos ( st ); return;*/ default: return; } } Commit Message: CWE ID: CWE-119
0
13,613
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: encode_getdeviceinfo(struct xdr_stream *xdr, const struct nfs4_getdeviceinfo_args *args, struct compound_hdr *hdr) { __be32 *p; p = reserve_space(xdr, 16 + NFS4_DEVICEID4_SIZE); *p++ = cpu_to_be32(OP_GETDEVICEINFO); p = xdr_encode_opaque_fixed(p, args->pdev->dev_id.data, NFS4_DEVICEID4_SIZE); *p++ = cpu_to_be32(args->pdev->layout_type); *p++ = cpu_to_be32(args->pdev->pglen); /* gdia_maxcount */ *p++ = cpu_to_be32(0); /* bitmap length 0 */ hdr->nops++; hdr->replen += decode_getdeviceinfo_maxsz; } Commit Message: NFSv4: include bitmap in nfsv4 get acl data The NFSv4 bitmap size is unbounded: a server can return an arbitrary sized bitmap in an FATTR4_WORD0_ACL request. Replace using the nfs4_fattr_bitmap_maxsz as a guess to the maximum bitmask returned by a server with the inclusion of the bitmap (xdr length plus bitmasks) and the acl data xdr length to the (cached) acl page data. This is a general solution to commit e5012d1f "NFSv4.1: update nfs4_fattr_bitmap_maxsz" and fixes hitting a BUG_ON in xdr_shrink_bufhead when getting ACLs. Fix a bug in decode_getacl that returned -EINVAL on ACLs > page when getxattr was called with a NULL buffer, preventing ACL > PAGE_SIZE from being retrieved. Cc: stable@kernel.org Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> CWE ID: CWE-189
0
23,360
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: v8::Local<v8::Value> PrivateScriptRunner::runDOMMethod(ScriptState* scriptState, ScriptState* scriptStateInUserScript, const char* className, const char* methodName, v8::Local<v8::Value> holder, int argc, v8::Local<v8::Value> argv[]) { v8::Local<v8::Object> classObject = classObjectOfPrivateScript(scriptState, className); v8::Local<v8::Value> method; if (!classObject->Get(scriptState->context(), v8String(scriptState->isolate(), methodName)).ToLocal(&method) || !method->IsFunction()) { fprintf(stderr, "Private script error: Target DOM method was not found. (Class name = %s, Method name = %s)\n", className, methodName); RELEASE_NOTREACHED(); } initializeHolderIfNeeded(scriptState, classObject, holder); v8::TryCatch block(scriptState->isolate()); v8::Local<v8::Value> result; if (!V8ScriptRunner::callFunction(v8::Local<v8::Function>::Cast(method), scriptState->getExecutionContext(), holder, argc, argv, scriptState->isolate()).ToLocal(&result)) { rethrowExceptionInPrivateScript(scriptState->isolate(), block, scriptStateInUserScript, ExceptionState::ExecutionContext, methodName, className); block.ReThrow(); return v8::Local<v8::Value>(); } return result; } Commit Message: Blink-in-JS should not run micro tasks If Blink-in-JS runs micro tasks, there's a risk of causing a UXSS bug (see 645211 for concrete steps). This CL makes Blink-in-JS use callInternalFunction (instead of callFunction) to avoid running micro tasks after Blink-in-JS' callbacks. BUG=645211 Review-Url: https://codereview.chromium.org/2330843002 Cr-Commit-Position: refs/heads/master@{#417874} CWE ID: CWE-79
1
172,077
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: GF_Err dvcC_Write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_DOVIConfigurationBox *ptr = (GF_DOVIConfigurationBox *) s; if (!s) return GF_BAD_PARAM; e = gf_isom_box_write_header(s, bs); if (e) return e; gf_bs_write_u8(bs, ptr->DOVIConfig.dv_version_major); gf_bs_write_u8(bs, ptr->DOVIConfig.dv_version_minor); gf_bs_write_int(bs, ptr->DOVIConfig.dv_profile, 7); gf_bs_write_int(bs, ptr->DOVIConfig.dv_level, 6); gf_bs_write_int(bs, ptr->DOVIConfig.rpu_present_flag, 1); gf_bs_write_int(bs, ptr->DOVIConfig.el_present_flag, 1); gf_bs_write_int(bs, ptr->DOVIConfig.bl_present_flag, 1); gf_bs_write_int(bs, 0, 5*32); return GF_OK; } Commit Message: prevent dref memleak on invalid input (#1183) CWE ID: CWE-400
0
91,863
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: LayerTreeHostTestCompositeImmediatelyStateTransitions() : current_state_(kInvalid), current_begin_frame_args_() {} Commit Message: (Reland) Discard compositor frames from unloaded web content This is a reland of https://codereview.chromium.org/2707243005/ with a small change to fix an uninitialized memory error that fails on MSAN bots. BUG=672847 TBR=danakj@chromium.org, creis@chromium.org CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_site_isolation Review-Url: https://codereview.chromium.org/2731283003 Cr-Commit-Position: refs/heads/master@{#454954} CWE ID: CWE-362
0
137,427
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 mem_read(jas_stream_obj_t *obj, char *buf, int cnt) { ssize_t n; assert(cnt >= 0); assert(buf); JAS_DBGLOG(100, ("mem_read(%p, %p, %d)\n", obj, buf, cnt)); jas_stream_memobj_t *m = (jas_stream_memobj_t *)obj; n = m->len_ - m->pos_; cnt = JAS_MIN(n, cnt); memcpy(buf, &m->buf_[m->pos_], cnt); m->pos_ += cnt; return cnt; } Commit Message: The generation of the configuration file jas_config.h has been completely reworked in order to avoid pollution of the global namespace. Some problematic types like uchar, ulong, and friends have been replaced with names with a jas_ prefix. An option max_samples has been added to the BMP and JPEG decoders to restrict the maximum size of image that they can decode. This change was made as a (possibly temporary) fix to address security concerns. A max_samples command-line option has also been added to imginfo. Whether an image component (for jas_image_t) is stored in memory or on disk is now based on the component size (rather than the image size). Some debug log message were added. Some new integer overflow checks were added. Some new safe integer add/multiply functions were added. More pre-C99 cruft was removed. JasPer has numerous "hacks" to handle pre-C99 compilers. JasPer now assumes C99 support. So, this pre-C99 cruft is unnecessary and can be removed. The regression jasper-doublefree-mem_close.jpg has been re-enabled. Theoretically, it should work more predictably now. CWE ID: CWE-190
0
72,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: bool CacheMemoryRegions() { std::string contents; if (!ReadProcMaps(&contents)) { LOG(ERROR) << "Failed to read /proc/self/maps"; return false; } if (!ParseProcMaps(contents, &regions_)) { LOG(ERROR) << "Failed to parse the contents of /proc/self/maps"; return false; } is_initialized_ = true; return true; } Commit Message: Convert ARRAYSIZE_UNSAFE -> arraysize in base/. R=thestig@chromium.org BUG=423134 Review URL: https://codereview.chromium.org/656033009 Cr-Commit-Position: refs/heads/master@{#299835} CWE ID: CWE-189
0
110,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: static int crypto_rfc4543_encrypt(struct aead_request *req) { struct crypto_aead *aead = crypto_aead_reqtfm(req); struct crypto_rfc4543_req_ctx *rctx = crypto_rfc4543_reqctx(req); struct aead_request *subreq; int err; if (req->src != req->dst) { err = crypto_rfc4543_copy_src_to_dst(req, true); if (err) return err; } subreq = crypto_rfc4543_crypt(req, true); err = crypto_aead_encrypt(subreq); if (err) return err; scatterwalk_map_and_copy(rctx->auth_tag, req->dst, req->cryptlen, crypto_aead_authsize(aead), 1); return 0; } Commit Message: crypto: include crypto- module prefix in template This adds the module loading prefix "crypto-" to the template lookup as well. For example, attempting to load 'vfat(blowfish)' via AF_ALG now correctly includes the "crypto-" prefix at every level, correctly rejecting "vfat": net-pf-38 algif-hash crypto-vfat(blowfish) crypto-vfat(blowfish)-all crypto-vfat Reported-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> CWE ID: CWE-264
0
45,760
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 S_AL_NewLoopMaster(src_t *rmSource, qboolean iskilled) { int index; src_t *curSource = NULL; alSfx_t *curSfx; curSfx = &knownSfx[rmSource->sfx]; if(rmSource->isPlaying) curSfx->loopActiveCnt--; if(iskilled) curSfx->loopCnt--; if(curSfx->loopCnt) { if(rmSource->priority == SRCPRI_ENTITY) { if(!iskilled && rmSource->isPlaying) { S_AL_SaveLoopPos(rmSource, rmSource->alSource); } } else if(rmSource == &srcList[curSfx->masterLoopSrc]) { int firstInactive = -1; if(iskilled || curSfx->loopActiveCnt) { for(index = 0; index < srcCount; index++) { curSource = &srcList[index]; if(curSource->sfx == rmSource->sfx && curSource != rmSource && curSource->isActive && curSource->isLooping && curSource->priority == SRCPRI_AMBIENT) { if(curSource->isPlaying) { curSfx->masterLoopSrc = index; break; } else if(firstInactive < 0) firstInactive = index; } } } if(!curSfx->loopActiveCnt) { if(firstInactive < 0) { if(iskilled) { curSfx->masterLoopSrc = -1; return; } else curSource = rmSource; } else curSource = &srcList[firstInactive]; if(rmSource->isPlaying) { S_AL_SaveLoopPos(curSource, rmSource->alSource); } else { curSource->lastTimePos = rmSource->lastTimePos; curSource->lastSampleTime = rmSource->lastSampleTime; } } } } else curSfx->masterLoopSrc = -1; } Commit Message: Don't open .pk3 files as OpenAL drivers. CWE ID: CWE-269
0
95,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: mojom::PageVisibilityState Document::GetPageVisibilityState() const { if (!frame_ || !frame_->GetPage()) return mojom::PageVisibilityState::kHidden; if (load_event_progress_ >= kUnloadVisibilityChangeInProgress) return mojom::PageVisibilityState::kHidden; return frame_->GetPage()->VisibilityState(); } Commit Message: Inherit CSP when self-navigating to local-scheme URL As the linked bug example shows, we should inherit CSP when we navigate to a local-scheme URL (even if we are in a main browsing context). Bug: 799747 Change-Id: I8413aa8e8049461ebcf0ffbf7b04c41d1340af02 Reviewed-on: https://chromium-review.googlesource.com/c/1234337 Reviewed-by: Mike West <mkwst@chromium.org> Commit-Queue: Andy Paicu <andypaicu@chromium.org> Cr-Commit-Position: refs/heads/master@{#597889} CWE ID:
0
143,990
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 FrameLoader::Load(const FrameLoadRequest& passed_request, FrameLoadType frame_load_type, HistoryItem* history_item, HistoryLoadType history_load_type) { DCHECK(frame_->GetDocument()); if (IsBackForwardLoadType(frame_load_type) && !frame_->IsNavigationAllowed()) return; if (in_stop_all_loaders_) return; FrameLoadRequest request(passed_request); request.GetResourceRequest().SetHasUserGesture( Frame::HasTransientUserActivation(frame_)); if (!PrepareRequestForThisFrame(request)) return; Frame* target_frame = request.Form() ? nullptr : frame_->FindFrameForNavigation( AtomicString(request.FrameName()), *frame_, request.GetResourceRequest().Url()); NavigationPolicy policy = NavigationPolicyForRequest(request); if (target_frame && target_frame != frame_ && ShouldNavigateTargetFrame(policy)) { if (target_frame->IsLocalFrame() && !ToLocalFrame(target_frame)->IsNavigationAllowed()) { return; } bool was_in_same_page = target_frame->GetPage() == frame_->GetPage(); request.SetFrameName("_self"); target_frame->Navigate(request); Page* page = target_frame->GetPage(); if (!was_in_same_page && page) page->GetChromeClient().Focus(); return; } SetReferrerForFrameRequest(request); if (!target_frame && !request.FrameName().IsEmpty()) { if (policy == kNavigationPolicyDownload) { Client()->DownloadURL(request.GetResourceRequest(), String()); return; // Navigation/download will be handled by the client. } else if (ShouldNavigateTargetFrame(policy)) { request.GetResourceRequest().SetFrameType( network::mojom::RequestContextFrameType::kAuxiliary); CreateWindowForRequest(request, *frame_, policy); return; // Navigation will be handled by the new frame/window. } } if (!frame_->IsNavigationAllowed()) return; const KURL& url = request.GetResourceRequest().Url(); FrameLoadType new_load_type = (frame_load_type == kFrameLoadTypeStandard) ? DetermineFrameLoadType(request) : frame_load_type; bool same_document_history_navigation = IsBackForwardLoadType(new_load_type) && history_load_type == kHistorySameDocumentLoad; bool same_document_navigation = policy == kNavigationPolicyCurrentTab && ShouldPerformFragmentNavigation(request.Form(), request.GetResourceRequest().HttpMethod(), new_load_type, url); if (same_document_history_navigation || same_document_navigation) { DCHECK(history_item || !same_document_history_navigation); scoped_refptr<SerializedScriptValue> state_object = same_document_history_navigation ? history_item->StateObject() : nullptr; if (!same_document_history_navigation) { document_loader_->SetNavigationType(DetermineNavigationType( new_load_type, false, request.TriggeringEvent())); if (ShouldTreatURLAsSameAsCurrent(url)) new_load_type = kFrameLoadTypeReplaceCurrentItem; } LoadInSameDocument(url, state_object, new_load_type, history_item, request.ClientRedirect(), request.OriginDocument()); return; } if (request.GetResourceRequest().IsSameDocumentNavigation()) return; StartLoad(request, new_load_type, policy, history_item); } Commit Message: Fix detach with open()ed document leaving parent loading indefinitely Change-Id: I26c2a054b9f1e5eb076acd677e1223058825f6d6 Bug: 803416 Test: fast/loader/document-open-iframe-then-detach.html Change-Id: I26c2a054b9f1e5eb076acd677e1223058825f6d6 Reviewed-on: https://chromium-review.googlesource.com/887298 Reviewed-by: Mike West <mkwst@chromium.org> Commit-Queue: Nate Chapin <japhet@chromium.org> Cr-Commit-Position: refs/heads/master@{#532967} CWE ID: CWE-362
0
125,800
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: MagickExport void SetQuantumQuantum(QuantumInfo *quantum_info, const size_t quantum) { assert(quantum_info != (QuantumInfo *) NULL); assert(quantum_info->signature == MagickCoreSignature); quantum_info->quantum=quantum; } Commit Message: https://github.com/ImageMagick/ImageMagick/issues/126 CWE ID: CWE-125
0
73,565
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int nfs4_xdr_dec_layoutcommit(struct rpc_rqst *rqstp, struct xdr_stream *xdr, struct nfs4_layoutcommit_res *res) { struct compound_hdr hdr; int status; status = decode_compound_hdr(xdr, &hdr); if (status) goto out; status = decode_sequence(xdr, &res->seq_res, rqstp); if (status) goto out; status = decode_putfh(xdr); if (status) goto out; status = decode_layoutcommit(xdr, rqstp, res); if (status) goto out; decode_getfattr(xdr, res->fattr, res->server, !RPC_IS_ASYNC(rqstp->rq_task)); out: return status; } Commit Message: NFSv4: include bitmap in nfsv4 get acl data The NFSv4 bitmap size is unbounded: a server can return an arbitrary sized bitmap in an FATTR4_WORD0_ACL request. Replace using the nfs4_fattr_bitmap_maxsz as a guess to the maximum bitmask returned by a server with the inclusion of the bitmap (xdr length plus bitmasks) and the acl data xdr length to the (cached) acl page data. This is a general solution to commit e5012d1f "NFSv4.1: update nfs4_fattr_bitmap_maxsz" and fixes hitting a BUG_ON in xdr_shrink_bufhead when getting ACLs. Fix a bug in decode_getacl that returned -EINVAL on ACLs > page when getxattr was called with a NULL buffer, preventing ACL > PAGE_SIZE from being retrieved. Cc: stable@kernel.org Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> CWE ID: CWE-189
0
23,419
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 OmniboxViewWin::OnAfterPossibleChange() { return OnAfterPossibleChangeInternal(false); } Commit Message: Change omnibox behavior when stripping javascript schema to navigate after stripping the schema on drag drop. BUG=109245 TEST=N/A Review URL: http://codereview.chromium.org/9116016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116692 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID:
0
107,471
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 salsa20_wordtobyte(u8 output[64], const u32 input[16]) { u32 x[16]; int i; memcpy(x, input, sizeof(x)); for (i = 20; i > 0; i -= 2) { x[ 4] ^= rol32((x[ 0] + x[12]), 7); x[ 8] ^= rol32((x[ 4] + x[ 0]), 9); x[12] ^= rol32((x[ 8] + x[ 4]), 13); x[ 0] ^= rol32((x[12] + x[ 8]), 18); x[ 9] ^= rol32((x[ 5] + x[ 1]), 7); x[13] ^= rol32((x[ 9] + x[ 5]), 9); x[ 1] ^= rol32((x[13] + x[ 9]), 13); x[ 5] ^= rol32((x[ 1] + x[13]), 18); x[14] ^= rol32((x[10] + x[ 6]), 7); x[ 2] ^= rol32((x[14] + x[10]), 9); x[ 6] ^= rol32((x[ 2] + x[14]), 13); x[10] ^= rol32((x[ 6] + x[ 2]), 18); x[ 3] ^= rol32((x[15] + x[11]), 7); x[ 7] ^= rol32((x[ 3] + x[15]), 9); x[11] ^= rol32((x[ 7] + x[ 3]), 13); x[15] ^= rol32((x[11] + x[ 7]), 18); x[ 1] ^= rol32((x[ 0] + x[ 3]), 7); x[ 2] ^= rol32((x[ 1] + x[ 0]), 9); x[ 3] ^= rol32((x[ 2] + x[ 1]), 13); x[ 0] ^= rol32((x[ 3] + x[ 2]), 18); x[ 6] ^= rol32((x[ 5] + x[ 4]), 7); x[ 7] ^= rol32((x[ 6] + x[ 5]), 9); x[ 4] ^= rol32((x[ 7] + x[ 6]), 13); x[ 5] ^= rol32((x[ 4] + x[ 7]), 18); x[11] ^= rol32((x[10] + x[ 9]), 7); x[ 8] ^= rol32((x[11] + x[10]), 9); x[ 9] ^= rol32((x[ 8] + x[11]), 13); x[10] ^= rol32((x[ 9] + x[ 8]), 18); x[12] ^= rol32((x[15] + x[14]), 7); x[13] ^= rol32((x[12] + x[15]), 9); x[14] ^= rol32((x[13] + x[12]), 13); x[15] ^= rol32((x[14] + x[13]), 18); } for (i = 0; i < 16; ++i) x[i] += input[i]; for (i = 0; i < 16; ++i) U32TO8_LITTLE(output + 4 * i,x[i]); } 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,331
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: NavigationURLLoaderImpl::NavigationURLLoaderImpl( ResourceContext* resource_context, StoragePartition* storage_partition, std::unique_ptr<NavigationRequestInfo> request_info, std::unique_ptr<NavigationUIData> navigation_ui_data, ServiceWorkerNavigationHandle* service_worker_navigation_handle, AppCacheNavigationHandle* appcache_handle, NavigationURLLoaderDelegate* delegate, std::vector<std::unique_ptr<NavigationLoaderInterceptor>> initial_interceptors) : delegate_(delegate), allow_download_(request_info->common_params.allow_download), weak_factory_(this) { DCHECK_CURRENTLY_ON(BrowserThread::UI); int frame_tree_node_id = request_info->frame_tree_node_id; TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( "navigation", "Navigation timeToResponseStarted", this, request_info->common_params.navigation_start, "FrameTreeNode id", frame_tree_node_id); ServiceWorkerNavigationHandleCore* service_worker_navigation_handle_core = service_worker_navigation_handle ? service_worker_navigation_handle->core() : nullptr; AppCacheNavigationHandleCore* appcache_handle_core = appcache_handle ? appcache_handle->core() : nullptr; std::unique_ptr<network::ResourceRequest> new_request = CreateResourceRequest( request_info.get(), frame_tree_node_id, allow_download_); new_request->transition_type = request_info->common_params.transition; if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) { DCHECK(!request_controller_); request_controller_ = std::make_unique<URLLoaderRequestController>( /* initial_interceptors = */ std::vector<std::unique_ptr<NavigationLoaderInterceptor>>(), std::move(new_request), resource_context, request_info->common_params.url, request_info->is_main_frame, /* proxied_url_loader_factory_request */ nullptr, /* proxied_url_loader_factory_info */ nullptr, std::set<std::string>(), /* bypass_redirect_checks */ false, weak_factory_.GetWeakPtr()); base::PostTaskWithTraits( FROM_HERE, {BrowserThread::IO}, base::BindOnce( &URLLoaderRequestController::StartWithoutNetworkService, base::Unretained(request_controller_.get()), base::RetainedRef(storage_partition->GetURLRequestContext()), base::Unretained(storage_partition->GetFileSystemContext()), base::Unretained(service_worker_navigation_handle_core), base::Unretained(appcache_handle_core), std::move(request_info), std::move(navigation_ui_data))); return; } FrameTreeNode* frame_tree_node = FrameTreeNode::GloballyFindByID(frame_tree_node_id); network::mojom::URLLoaderFactoryPtrInfo factory_for_webui; const auto& schemes = URLDataManagerBackend::GetWebUISchemes(); std::string scheme = new_request->url.scheme(); if (base::ContainsValue(schemes, scheme)) { factory_for_webui = CreateWebUIURLLoaderBinding( frame_tree_node->current_frame_host(), scheme) .PassInterface(); } network::mojom::URLLoaderFactoryPtrInfo proxied_factory_info; network::mojom::URLLoaderFactoryRequest proxied_factory_request; bool bypass_redirect_checks = false; auto* partition = static_cast<StoragePartitionImpl*>(storage_partition); if (frame_tree_node) { GetContentClient() ->browser() ->RegisterNonNetworkNavigationURLLoaderFactories( frame_tree_node_id, &non_network_url_loader_factories_); url::Origin navigation_request_initiator = url::Origin(); network::mojom::URLLoaderFactoryPtrInfo factory_info; auto factory_request = mojo::MakeRequest(&factory_info); bool use_proxy = GetContentClient()->browser()->WillCreateURLLoaderFactory( partition->browser_context(), frame_tree_node->current_frame_host(), true /* is_navigation */, navigation_request_initiator, &factory_request, &bypass_redirect_checks); if (RenderFrameDevToolsAgentHost::WillCreateURLLoaderFactory( frame_tree_node->current_frame_host(), true, false, &factory_request)) { use_proxy = true; } if (use_proxy) { proxied_factory_request = std::move(factory_request); proxied_factory_info = std::move(factory_info); } const std::string storage_domain; non_network_url_loader_factories_[url::kFileSystemScheme] = CreateFileSystemURLLoaderFactory(frame_tree_node->current_frame_host(), /*is_navigation=*/true, partition->GetFileSystemContext(), storage_domain); } non_network_url_loader_factories_[url::kFileScheme] = std::make_unique<FileURLLoaderFactory>( partition->browser_context()->GetPath(), base::CreateSequencedTaskRunnerWithTraits( {base::MayBlock(), base::TaskPriority::BEST_EFFORT, base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})); std::set<std::string> known_schemes; for (auto& iter : non_network_url_loader_factories_) known_schemes.insert(iter.first); DCHECK(!request_controller_); request_controller_ = std::make_unique<URLLoaderRequestController>( std::move(initial_interceptors), std::move(new_request), resource_context, request_info->common_params.url, request_info->is_main_frame, std::move(proxied_factory_request), std::move(proxied_factory_info), std::move(known_schemes), bypass_redirect_checks, weak_factory_.GetWeakPtr()); base::PostTaskWithTraits( FROM_HERE, {BrowserThread::IO}, base::BindOnce( &URLLoaderRequestController::Start, base::Unretained(request_controller_.get()), partition->url_loader_factory_getter()->GetNetworkFactoryInfo(), service_worker_navigation_handle_core, appcache_handle_core, std::move(request_info), std::move(navigation_ui_data), std::move(factory_for_webui), frame_tree_node_id, ServiceManagerConnection::GetForProcess()->GetConnector()->Clone())); } Commit Message: Abort navigations on 304 responses. A recent change (https://chromium-review.googlesource.com/1161479) accidentally resulted in treating 304 responses as downloads. This CL treats them as ERR_ABORTED instead. This doesn't exactly match old behavior, which passed them on to the renderer, which then aborted them. The new code results in correctly restoring the original URL in the omnibox, and has a shiny new test to prevent future regressions. Bug: 882270 Change-Id: Ic73dcce9e9596d43327b13acde03b4ed9bd0c82e Reviewed-on: https://chromium-review.googlesource.com/1252684 Commit-Queue: Matt Menke <mmenke@chromium.org> Reviewed-by: Camille Lamy <clamy@chromium.org> Cr-Commit-Position: refs/heads/master@{#595641} CWE ID: CWE-20
0
145,379
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( const scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) { TRACE_EVENT0("startup", "RenderThreadImpl::Init"); base::trace_event::TraceLog::GetInstance()->SetThreadSortIndex( base::PlatformThread::CurrentId(), kTraceEventRendererMainThreadSortIndex); #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) blink::WebView::SetUseExternalPopupMenus(true); #endif lazy_tls.Pointer()->Set(this); ChildProcess::current()->set_main_thread(this); metrics::InitializeSingleSampleMetricsFactory( base::BindRepeating(&CreateSingleSampleMetricsProvider, message_loop()->task_runner(), GetConnector())); gpu_ = ui::Gpu::Create( GetConnector(), IsRunningInMash() ? ui::mojom::kServiceName : mojom::kBrowserServiceName, GetIOTaskRunner()); viz::mojom::SharedBitmapAllocationNotifierPtr shared_bitmap_allocation_notifier_ptr; GetConnector()->BindInterface( mojom::kBrowserServiceName, mojo::MakeRequest(&shared_bitmap_allocation_notifier_ptr)); shared_bitmap_manager_ = std::make_unique<viz::ClientSharedBitmapManager>( viz::mojom::ThreadSafeSharedBitmapAllocationNotifierPtr::Create( shared_bitmap_allocation_notifier_ptr.PassInterface(), GetChannel()->ipc_task_runner_refptr())); notification_dispatcher_ = new NotificationDispatcher(thread_safe_sender()); AddFilter(notification_dispatcher_->GetFilter()); resource_dispatcher_.reset(new ResourceDispatcher( this, message_loop()->task_runner())); resource_message_filter_ = new ChildResourceMessageFilter(resource_dispatcher_.get()); AddFilter(resource_message_filter_.get()); quota_message_filter_ = new QuotaMessageFilter(thread_safe_sender()); quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender(), quota_message_filter_.get())); AddFilter(quota_message_filter_->GetFilter()); auto registry = std::make_unique<service_manager::BinderRegistry>(); BlinkInterfaceRegistryImpl interface_registry(registry->GetWeakPtr()); InitializeWebKit(resource_task_queue, &interface_registry); blink_initialized_time_ = base::TimeTicks::Now(); webkit_shared_timer_suspended_ = false; widget_count_ = 0; hidden_widget_count_ = 0; idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; idle_notifications_to_skip_ = 0; appcache_dispatcher_.reset( new AppCacheDispatcher(Get(), new AppCacheFrontendImpl())); dom_storage_dispatcher_.reset(new DomStorageDispatcher()); main_thread_indexed_db_dispatcher_.reset(new IndexedDBDispatcher()); main_thread_cache_storage_dispatcher_.reset( new CacheStorageDispatcher(thread_safe_sender())); file_system_dispatcher_.reset(new FileSystemDispatcher()); resource_dispatch_throttler_.reset(new ResourceDispatchThrottler( static_cast<RenderThread*>(this), renderer_scheduler_.get(), base::TimeDelta::FromSecondsD(kThrottledResourceRequestFlushPeriodS), kMaxResourceRequestsPerFlushWhenThrottled)); resource_dispatcher_->set_message_sender(resource_dispatch_throttler_.get()); blob_message_filter_ = new BlobMessageFilter(GetFileThreadTaskRunner()); AddFilter(blob_message_filter_.get()); vc_manager_.reset(new VideoCaptureImplManager()); browser_plugin_manager_.reset(new BrowserPluginManager()); AddObserver(browser_plugin_manager_.get()); #if BUILDFLAG(ENABLE_WEBRTC) peer_connection_tracker_.reset(new PeerConnectionTracker()); AddObserver(peer_connection_tracker_.get()); p2p_socket_dispatcher_ = new P2PSocketDispatcher(GetIOTaskRunner().get()); AddFilter(p2p_socket_dispatcher_.get()); peer_connection_factory_.reset( new PeerConnectionDependencyFactory(p2p_socket_dispatcher_.get())); aec_dump_message_filter_ = new AecDumpMessageFilter( GetIOTaskRunner(), message_loop()->task_runner()); AddFilter(aec_dump_message_filter_.get()); #endif // BUILDFLAG(ENABLE_WEBRTC) audio_input_message_filter_ = new AudioInputMessageFilter(GetIOTaskRunner()); AddFilter(audio_input_message_filter_.get()); scoped_refptr<AudioMessageFilter> audio_message_filter; if (!base::FeatureList::IsEnabled( features::kUseMojoAudioOutputStreamFactory)) { audio_message_filter = base::MakeRefCounted<AudioMessageFilter>(GetIOTaskRunner()); AddFilter(audio_message_filter.get()); } audio_ipc_factory_.emplace(std::move(audio_message_filter), GetIOTaskRunner()); midi_message_filter_ = new MidiMessageFilter(GetIOTaskRunner()); AddFilter(midi_message_filter_.get()); AddFilter((new CacheStorageMessageFilter(thread_safe_sender()))->GetFilter()); AddFilter((new ServiceWorkerContextMessageFilter())->GetFilter()); #if defined(USE_AURA) if (IsRunningInMash()) { CreateRenderWidgetWindowTreeClientFactory(GetServiceManagerConnection()); } #endif registry->AddInterface(base::Bind(&SharedWorkerFactoryImpl::Create), base::ThreadTaskRunnerHandle::Get()); GetServiceManagerConnection()->AddConnectionFilter( std::make_unique<SimpleConnectionFilter>(std::move(registry))); { auto registry_with_source_info = std::make_unique<service_manager::BinderRegistryWithArgs< const service_manager::BindSourceInfo&>>(); registry_with_source_info->AddInterface( base::Bind(&CreateFrameFactory), base::ThreadTaskRunnerHandle::Get()); GetServiceManagerConnection()->AddConnectionFilter( std::make_unique<SimpleConnectionFilterWithSourceInfo>( std::move(registry_with_source_info))); } GetContentClient()->renderer()->RenderThreadStarted(); StartServiceManagerConnection(); GetAssociatedInterfaceRegistry()->AddInterface( base::Bind(&RenderThreadImpl::OnRendererInterfaceRequest, base::Unretained(this))); InitSkiaEventTracer(); base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( skia::SkiaMemoryDumpProvider::GetInstance(), "Skia", nullptr); const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); #if defined(ENABLE_IPC_FUZZER) if (command_line.HasSwitch(switches::kIpcDumpDirectory)) { base::FilePath dump_directory = command_line.GetSwitchValuePath(switches::kIpcDumpDirectory); IPC::ChannelProxy::OutgoingMessageFilter* filter = LoadExternalIPCDumper(dump_directory); GetChannel()->set_outgoing_message_filter(filter); } #endif cc::SetClientNameForMetrics("Renderer"); is_threaded_animation_enabled_ = !command_line.HasSwitch(cc::switches::kDisableThreadedAnimation); is_zero_copy_enabled_ = command_line.HasSwitch(switches::kEnableZeroCopy); is_partial_raster_enabled_ = !command_line.HasSwitch(switches::kDisablePartialRaster); is_gpu_memory_buffer_compositor_resources_enabled_ = command_line.HasSwitch( switches::kEnableGpuMemoryBufferCompositorResources); #if defined(OS_MACOSX) is_elastic_overscroll_enabled_ = true; #else is_elastic_overscroll_enabled_ = false; #endif std::string image_texture_target_string = command_line.GetSwitchValueASCII(switches::kContentImageTextureTarget); buffer_to_texture_target_map_ = viz::StringToBufferToTextureTargetMap(image_texture_target_string); 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 } if (command_line.HasSwitch(switches::kDisableGpuCompositing)) is_gpu_compositing_disabled_ = true; is_gpu_rasterization_forced_ = command_line.HasSwitch(switches::kForceGpuRasterization); is_async_worker_context_enabled_ = command_line.HasSwitch(switches::kEnableGpuAsyncWorkerContext); if (command_line.HasSwitch(switches::kGpuRasterizationMSAASampleCount)) { std::string string_value = command_line.GetSwitchValueASCII( switches::kGpuRasterizationMSAASampleCount); bool parsed_msaa_sample_count = base::StringToInt(string_value, &gpu_rasterization_msaa_sample_count_); DCHECK(parsed_msaa_sample_count) << string_value; DCHECK_GE(gpu_rasterization_msaa_sample_count_, 0); } else { gpu_rasterization_msaa_sample_count_ = -1; } 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; } WebRuntimeFeatures::EnableCompositorImageAnimations( command_line.HasSwitch(switches::kEnableCompositorImageAnimations)); media::InitializeMediaLibrary(); #if defined(OS_ANDROID) if (!command_line.HasSwitch(switches::kDisableAcceleratedVideoDecode) && media::MediaCodecUtil::IsMediaCodecAvailable()) { media::EnablePlatformDecoderSupport(); } #endif memory_pressure_listener_.reset(new base::MemoryPressureListener( base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)), base::Bind(&RenderThreadImpl::OnSyncMemoryPressure, base::Unretained(this)))); if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { base::MemoryPressureListener::SetNotificationsSuppressed(true); mojom::MemoryCoordinatorHandlePtr parent_coordinator; GetConnector()->BindInterface(mojom::kBrowserServiceName, mojo::MakeRequest(&parent_coordinator)); memory_coordinator_ = CreateChildMemoryCoordinator( std::move(parent_coordinator), this); } int num_raster_threads = 0; std::string string_value = command_line.GetSwitchValueASCII(switches::kNumRasterThreads); bool parsed_num_raster_threads = base::StringToInt(string_value, &num_raster_threads); DCHECK(parsed_num_raster_threads) << string_value; DCHECK_GT(num_raster_threads, 0); categorized_worker_pool_->Start(num_raster_threads); discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; if (IsRunningInMash()) { #if defined(USE_AURA) GetServiceManagerConnection()->GetConnector()->BindInterface( ui::mojom::kServiceName, &manager_ptr); #else NOTREACHED(); #endif } else { ChildThread::Get()->GetConnector()->BindInterface( mojom::kBrowserServiceName, mojo::MakeRequest(&manager_ptr)); } discardable_shared_memory_manager_ = std::make_unique< discardable_memory::ClientDiscardableSharedMemoryManager>( std::move(manager_ptr), GetIOTaskRunner()); base::DiscardableMemoryAllocator::SetInstance( discardable_shared_memory_manager_.get()); GetConnector()->BindInterface(mojom::kBrowserServiceName, mojo::MakeRequest(&storage_partition_service_)); #if defined(OS_LINUX) ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY); ChildThreadImpl::current()->SetThreadPriority( categorized_worker_pool_->background_worker_thread_id(), base::ThreadPriority::BACKGROUND); #endif process_foregrounded_count_ = 0; needs_to_record_first_active_paint_ = false; was_backgrounded_time_ = base::TimeTicks::Min(); base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); if (!command_line.HasSwitch(switches::kSingleProcess)) base::SequencedWorkerPool::EnableForProcess(); EVP_set_buggy_rsa_parser( base::FeatureList::IsEnabled(features::kBuggyRSAParser)); GetConnector()->BindInterface(mojom::kBrowserServiceName, mojo::MakeRequest(&frame_sink_provider_)); if (!is_gpu_compositing_disabled_) { GetConnector()->BindInterface( mojom::kBrowserServiceName, mojo::MakeRequest(&compositing_mode_reporter_)); viz::mojom::CompositingModeWatcherPtr watcher_ptr; compositing_mode_watcher_binding_.Bind(mojo::MakeRequest(&watcher_ptr)); compositing_mode_reporter_->AddCompositingModeWatcher( std::move(watcher_ptr)); } } Commit Message: Roll src/third_party/boringssl/src 664e99a64..696c13bd6 https://boringssl.googlesource.com/boringssl/+log/664e99a6486c293728097c661332f92bf2d847c6..696c13bd6ab78011adfe7b775519c8b7cc82b604 BUG=778101 Change-Id: I8dda4f3db952597148e3c7937319584698d00e1c Reviewed-on: https://chromium-review.googlesource.com/747941 Reviewed-by: Avi Drissman <avi@chromium.org> Reviewed-by: David Benjamin <davidben@chromium.org> Commit-Queue: Steven Valdez <svaldez@chromium.org> Cr-Commit-Position: refs/heads/master@{#513774} CWE ID: CWE-310
1
172,934
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 HTMLSelectElement::remove(HTMLOptionElement* option) { if (option->ownerSelectElement() != this) return; option->remove(IGNORE_EXCEPTION); } Commit Message: SelectElement should remove an option when null is assigned by indexed setter Fix bug embedded in r151449 see http://src.chromium.org/viewvc/blink?revision=151449&view=revision R=haraken@chromium.org, tkent@chromium.org, eseidel@chromium.org BUG=262365 TEST=fast/forms/select/select-assign-null.html Review URL: https://chromiumcodereview.appspot.com/19947008 git-svn-id: svn://svn.chromium.org/blink/trunk@154743 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-125
0
103,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 GraphicsContext::setMiterLimit(float limit) { if (paintingDisabled()) return; platformContext()->setMiterLimit(limit); } Commit Message: [skia] not all convex paths are convex, so recompute convexity for the problematic ones https://bugs.webkit.org/show_bug.cgi?id=75960 Reviewed by Stephen White. No new tests. See related chrome issue http://code.google.com/p/chromium/issues/detail?id=108605 * platform/graphics/skia/GraphicsContextSkia.cpp: (WebCore::setPathFromConvexPoints): git-svn-id: svn://svn.chromium.org/blink/trunk@104609 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-19
0
107,602
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: const RECTANGLE_16* region16_rects(const REGION16* region, UINT32* nbRects) { REGION16_DATA* data; if (nbRects) *nbRects = 0; if (!region) return NULL; data = region->data; if (!data) return NULL; if (nbRects) *nbRects = data->nbRects; return (RECTANGLE_16*)(data + 1); } Commit Message: Fixed #5645: realloc return handling CWE ID: CWE-772
0
87,417
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 SocketStream::DidSendData(int result) { DCHECK_GT(result, 0); DCHECK(current_write_buf_.get()); net_log_.AddEvent(NetLog::TYPE_SOCKET_STREAM_SENT); int bytes_sent = result; metrics_->OnWrite(bytes_sent); current_write_buf_->DidConsume(result); if (current_write_buf_->BytesRemaining()) return; size_t bytes_freed = current_write_buf_->size(); current_write_buf_ = NULL; if (delegate_) delegate_->OnSentData(this, bytes_freed); } Commit Message: Revert a workaround commit for a Use-After-Free crash. Revert a workaround commit r20158 for a Use-After-Free issue (http://crbug.com/244746) because a cleaner CL r207218 is landed. URLRequestContext does not inherit SupportsWeakPtr now. R=mmenke BUG=244746 Review URL: https://chromiumcodereview.appspot.com/16870008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207811 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
112,671
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: spnego_gss_set_cred_option( OM_uint32 *minor_status, gss_cred_id_t *cred_handle, const gss_OID desired_object, const gss_buffer_t value) { OM_uint32 ret; OM_uint32 tmp_minor_status; spnego_gss_cred_id_t spcred = (spnego_gss_cred_id_t)*cred_handle; gss_cred_id_t mcred; mcred = (spcred == NULL) ? GSS_C_NO_CREDENTIAL : spcred->mcred; ret = gss_set_cred_option(minor_status, &mcred, desired_object, value); if (ret == GSS_S_COMPLETE && spcred == NULL) { /* * If the mechanism allocated a new credential handle, then * we need to wrap it up in an SPNEGO credential handle. */ ret = create_spnego_cred(minor_status, mcred, &spcred); if (ret != GSS_S_COMPLETE) { gss_release_cred(&tmp_minor_status, &mcred); return (ret); } *cred_handle = (gss_cred_id_t)spcred; } if (ret != GSS_S_COMPLETE) return (ret); /* Recognize KRB5_NO_CI_FLAGS_X_OID and avoid asking for integrity. */ if (g_OID_equal(desired_object, no_ci_flags_oid)) spcred->no_ask_integ = 1; return (GSS_S_COMPLETE); } Commit Message: Fix SPNEGO context aliasing bugs [CVE-2015-2695] The SPNEGO mechanism currently replaces its context handle with the mechanism context handle upon establishment, under the assumption that most GSS functions are only called after context establishment. This assumption is incorrect, and can lead to aliasing violations for some programs. Maintain the SPNEGO context structure after context establishment and refer to it in all GSS methods. Add initiate and opened flags to the SPNEGO context structure for use in gss_inquire_context() prior to context establishment. CVE-2015-2695: In MIT krb5 1.5 and later, applications which call gss_inquire_context() on a partially-established SPNEGO context can cause the GSS-API library to read from a pointer using the wrong type, generally causing a process crash. This bug may go unnoticed, because the most common SPNEGO authentication scenario establishes the context after just one call to gss_accept_sec_context(). Java server applications using the native JGSS provider are vulnerable to this bug. A carefully crafted SPNEGO packet might allow the gss_inquire_context() call to succeed with attacker-determined results, but applications should not make access control decisions based on gss_inquire_context() results prior to context establishment. CVSSv2 Vector: AV:N/AC:M/Au:N/C:N/I:N/A:C/E:POC/RL:OF/RC:C [ghudson@mit.edu: several bugfixes, style changes, and edge-case behavior changes; commit message and CVE description] ticket: 8244 target_version: 1.14 tags: pullup CWE ID: CWE-18
0
43,823
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 WebLocalFrameImpl::DispatchUnloadEvent() { if (!GetFrame()) return; SubframeLoadingDisabler disabler(GetFrame()->GetDocument()); IgnoreOpensDuringUnloadCountIncrementer ignore_opens_during_unload( GetFrame()->GetDocument()); GetFrame()->Loader().DispatchUnloadEvent(); } 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,719
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 bonding_exit(void) { unregister_netdevice_notifier(&bond_netdev_notifier); unregister_inetaddr_notifier(&bond_inetaddr_notifier); bond_destroy_sysfs(); bond_destroy_debugfs(); rtnl_link_unregister(&bond_link_ops); unregister_pernet_subsys(&bond_net_ops); #ifdef CONFIG_NET_POLL_CONTROLLER /* * Make sure we don't have an imbalance on our netpoll blocking */ WARN_ON(atomic_read(&netpoll_block_tx)); #endif } Commit Message: net: Audit drivers to identify those needing IFF_TX_SKB_SHARING cleared After the last patch, We are left in a state in which only drivers calling ether_setup have IFF_TX_SKB_SHARING set (we assume that drivers touching real hardware call ether_setup for their net_devices and don't hold any state in their skbs. There are a handful of drivers that violate this assumption of course, and need to be fixed up. This patch identifies those drivers, and marks them as not being able to support the safe transmission of skbs by clearning the IFF_TX_SKB_SHARING flag in priv_flags Signed-off-by: Neil Horman <nhorman@tuxdriver.com> CC: Karsten Keil <isdn@linux-pingi.de> CC: "David S. Miller" <davem@davemloft.net> CC: Jay Vosburgh <fubar@us.ibm.com> CC: Andy Gospodarek <andy@greyhouse.net> CC: Patrick McHardy <kaber@trash.net> CC: Krzysztof Halasa <khc@pm.waw.pl> CC: "John W. Linville" <linville@tuxdriver.com> CC: Greg Kroah-Hartman <gregkh@suse.de> CC: Marcel Holtmann <marcel@holtmann.org> CC: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-264
0
23,777
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: SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid, struct timespec __user *, interval) { struct task_struct *p; unsigned int time_slice; unsigned long flags; struct rq *rq; int retval; struct timespec t; if (pid < 0) return -EINVAL; retval = -ESRCH; rcu_read_lock(); p = find_process_by_pid(pid); if (!p) goto out_unlock; retval = security_task_getscheduler(p); if (retval) goto out_unlock; rq = task_rq_lock(p, &flags); time_slice = p->sched_class->get_rr_interval(rq, p); task_rq_unlock(rq, p, &flags); rcu_read_unlock(); jiffies_to_timespec(time_slice, &t); retval = copy_to_user(interval, &t, sizeof(t)) ? -EFAULT : 0; return retval; out_unlock: rcu_read_unlock(); return retval; } 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,242
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 SkiaOutputSurfaceImplTest::CopyRequestCallbackOnGpuThread( const SkColor output_color, const gfx::Rect& output_rect, const gfx::ColorSpace& color_space, std::unique_ptr<CopyOutputResult> result) { std::unique_ptr<SkBitmap> result_bitmap; result_bitmap = std::make_unique<SkBitmap>(result->AsSkBitmap()); EXPECT_EQ(result_bitmap->width(), output_rect.width()); EXPECT_EQ(result_bitmap->height(), output_rect.height()); std::vector<SkPMColor> expected_pixels( output_rect.width() * output_rect.height(), SkPreMultiplyColor(output_color)); SkBitmap expected; expected.installPixels( SkImageInfo::MakeN32Premul(output_rect.width(), output_rect.height(), color_space.ToSkColorSpace()), expected_pixels.data(), output_rect.width() * sizeof(SkColor)); ExpectEquals(*result_bitmap.get(), expected); UnblockMainThread(); } Commit Message: SkiaRenderer: Support changing color space SkiaOutputSurfaceImpl did not handle the color space changing after it was created previously. The SkSurfaceCharacterization color space was only set during the first time Reshape() ran when the charactization is returned from the GPU thread. If the color space was changed later the SkSurface and SkDDL color spaces no longer matched and draw failed. Bug: 1009452 Change-Id: Ib6d2083efc7e7eb6f94782342e92a809b69d6fdc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1841811 Reviewed-by: Peng Huang <penghuang@chromium.org> Commit-Queue: kylechar <kylechar@chromium.org> Cr-Commit-Position: refs/heads/master@{#702946} CWE ID: CWE-704
0
136,005
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 fsl_emb_pmu_enable(struct pmu *pmu) { struct cpu_hw_events *cpuhw; unsigned long flags; local_irq_save(flags); cpuhw = &__get_cpu_var(cpu_hw_events); if (!cpuhw->disabled) goto out; cpuhw->disabled = 0; ppc_set_pmu_inuse(cpuhw->n_events != 0); if (cpuhw->n_events > 0) { mtpmr(PMRN_PMGC0, PMGC0_PMIE | PMGC0_FCECE); isync(); } out: local_irq_restore(flags); } Commit Message: perf: Remove the nmi parameter from the swevent and overflow interface The nmi parameter indicated if we could do wakeups from the current context, if not, we would set some state and self-IPI and let the resulting interrupt do the wakeup. For the various event classes: - hardware: nmi=0; PMI is in fact an NMI or we run irq_work_run from the PMI-tail (ARM etc.) - tracepoint: nmi=0; since tracepoint could be from NMI context. - software: nmi=[0,1]; some, like the schedule thing cannot perform wakeups, and hence need 0. As one can see, there is very little nmi=1 usage, and the down-side of not using it is that on some platforms some software events can have a jiffy delay in wakeup (when arch_irq_work_raise isn't implemented). The up-side however is that we can remove the nmi parameter and save a bunch of conditionals in fast paths. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Michael Cree <mcree@orcon.net.nz> Cc: Will Deacon <will.deacon@arm.com> Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com> Cc: Anton Blanchard <anton@samba.org> Cc: Eric B Munson <emunson@mgebm.net> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Paul Mundt <lethal@linux-sh.org> Cc: David S. Miller <davem@davemloft.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jason Wessel <jason.wessel@windriver.com> Cc: Don Zickus <dzickus@redhat.com> Link: http://lkml.kernel.org/n/tip-agjev8eu666tvknpb3iaj0fg@git.kernel.org Signed-off-by: Ingo Molnar <mingo@elte.hu> CWE ID: CWE-399
0
25,457
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 RenderFrameImpl::OnSwapOut( int proxy_routing_id, bool is_loading, const FrameReplicationState& replicated_frame_state) { TRACE_EVENT1("navigation", "RenderFrameImpl::OnSwapOut", "id", routing_id_); RenderFrameProxy* proxy = NULL; bool swapped_out_forbidden = SiteIsolationPolicy::IsSwappedOutStateForbidden(); bool is_main_frame = !frame_->parent(); CHECK_IMPLIES(!is_main_frame, SiteIsolationPolicy::AreCrossProcessFramesPossible()); if (!is_swapped_out_) { render_view_->SendUpdateState(); if (proxy_routing_id != MSG_ROUTING_NONE) { proxy = RenderFrameProxy::CreateProxyToReplaceFrame( this, proxy_routing_id, replicated_frame_state.scope); } if (is_main_frame) frame_->dispatchUnloadEvent(); if (is_main_frame) render_view_->SetSwappedOut(true); is_swapped_out_ = true; if (proxy) set_render_frame_proxy(proxy); if (!swapped_out_forbidden) OnStop(); if (!is_main_frame && proxy) proxy->web_frame()->initializeFromFrame(frame_); if (!swapped_out_forbidden) NavigateToSwappedOutURL(); if (is_main_frame) { render_view_->webview()->setVisibilityState( blink::WebPageVisibilityStateHidden, false); } } if (is_main_frame) render_view_->suppress_dialogs_until_swap_out_ = false; Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); RenderViewImpl* render_view = render_view_.get(); if (proxy && swapped_out_forbidden) { frame_->swap(proxy->web_frame()); if (is_loading) proxy->OnDidStartLoading(); } if (proxy && swapped_out_forbidden) proxy->SetReplicatedState(replicated_frame_state); if (is_main_frame) { render_view->WasSwappedOut(); } } Commit Message: Connect WebUSB client interface to the devices app This provides a basic WebUSB client interface in content/renderer. Most of the interface is unimplemented, but this CL hooks up navigator.usb.getDevices() to the browser's Mojo devices app to enumerate available USB devices. BUG=492204 Review URL: https://codereview.chromium.org/1293253002 Cr-Commit-Position: refs/heads/master@{#344881} CWE ID: CWE-399
0
123,176
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 FrameView::updateWidgetPositions() { WillBeHeapVector<RefPtrWillBeMember<RenderWidget> > widgets; copyToVector(m_widgets, widgets); for (size_t i = 0; i < widgets.size() && renderView(); ++i) widgets[i]->updateWidgetPosition(); for (size_t i = 0; i < widgets.size() && renderView(); ++i) widgets[i]->widgetPositionsUpdated(); } Commit Message: Defer call to updateWidgetPositions() outside of RenderLayerScrollableArea. updateWidgetPositions() can destroy the render tree, so it should never be called from inside RenderLayerScrollableArea. Leaving it there allows for the potential of use-after-free bugs. BUG=402407 R=vollick@chromium.org Review URL: https://codereview.chromium.org/490473003 git-svn-id: svn://svn.chromium.org/blink/trunk@180681 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-416
0
119,954
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 __net_init int setup_net(struct net *net, struct user_namespace *user_ns) { /* Must be called with net_mutex held */ const struct pernet_operations *ops, *saved_ops; int error = 0; LIST_HEAD(net_exit_list); atomic_set(&net->count, 1); refcount_set(&net->passive, 1); net->dev_base_seq = 1; net->user_ns = user_ns; idr_init(&net->netns_ids); spin_lock_init(&net->nsid_lock); list_for_each_entry(ops, &pernet_list, list) { error = ops_init(ops, net); if (error < 0) goto out_undo; } out: return error; out_undo: /* Walk through the list backwards calling the exit functions * for the pernet modules whose init functions did not fail. */ list_add(&net->exit_list, &net_exit_list); saved_ops = ops; list_for_each_entry_continue_reverse(ops, &pernet_list, list) ops_exit_list(ops, &net_exit_list); ops = saved_ops; list_for_each_entry_continue_reverse(ops, &pernet_list, list) ops_free_list(ops, &net_exit_list); rcu_barrier(); goto out; } Commit Message: net: Fix double free and memory corruption in get_net_ns_by_id() (I can trivially verify that that idr_remove in cleanup_net happens after the network namespace count has dropped to zero --EWB) Function get_net_ns_by_id() does not check for net::count after it has found a peer in netns_ids idr. It may dereference a peer, after its count has already been finaly decremented. This leads to double free and memory corruption: put_net(peer) rtnl_lock() atomic_dec_and_test(&peer->count) [count=0] ... __put_net(peer) get_net_ns_by_id(net, id) spin_lock(&cleanup_list_lock) list_add(&net->cleanup_list, &cleanup_list) spin_unlock(&cleanup_list_lock) queue_work() peer = idr_find(&net->netns_ids, id) | get_net(peer) [count=1] | ... | (use after final put) v ... cleanup_net() ... spin_lock(&cleanup_list_lock) ... list_replace_init(&cleanup_list, ..) ... spin_unlock(&cleanup_list_lock) ... ... ... ... put_net(peer) ... atomic_dec_and_test(&peer->count) [count=0] ... spin_lock(&cleanup_list_lock) ... list_add(&net->cleanup_list, &cleanup_list) ... spin_unlock(&cleanup_list_lock) ... queue_work() ... rtnl_unlock() rtnl_lock() ... for_each_net(tmp) { ... id = __peernet2id(tmp, peer) ... spin_lock_irq(&tmp->nsid_lock) ... idr_remove(&tmp->netns_ids, id) ... ... ... net_drop_ns() ... net_free(peer) ... } ... | v cleanup_net() ... (Second free of peer) Also, put_net() on the right cpu may reorder with left's cpu list_replace_init(&cleanup_list, ..), and then cleanup_list will be corrupted. Since cleanup_net() is executed in worker thread, while put_net(peer) can happen everywhere, there should be enough time for concurrent get_net_ns_by_id() to pick the peer up, and the race does not seem to be unlikely. The patch fixes the problem in standard way. (Also, there is possible problem in peernet2id_alloc(), which requires check for net::count under nsid_lock and maybe_get_net(peer), but in current stable kernel it's used under rtnl_lock() and it has to be safe. Openswitch begun to use peernet2id_alloc(), and possibly it should be fixed too. While this is not in stable kernel yet, so I'll send a separate message to netdev@ later). Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Fixes: 0c7aecd4bde4 "netns: add rtnl cmd to add and get peer netns ids" Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-416
0
86,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: bool PageInfoUI::ContentSettingsTypeInPageInfo(ContentSettingsType type) { for (const PermissionsUIInfo& info : GetContentSettingsUIInfo()) { if (info.type == type) return true; } return false; } Commit Message: Revert "PageInfo: decouple safe browsing and TLS statii." This reverts commit ee95bc44021230127c7e6e9a8cf9d3820760f77c. Reason for revert: suspect causing unit_tests failure on Linux MSAN Tests: https://ci.chromium.org/p/chromium/builders/ci/Linux%20MSan%20Tests/17649 PageInfoBubbleViewTest.ChangingFlashSettingForSiteIsRemembered PageInfoBubbleViewTest.EnsureCloseCallback PageInfoBubbleViewTest.NotificationPermissionRevokeUkm PageInfoBubbleViewTest.OpenPageInfoBubbleAfterNavigationStart PageInfoBubbleViewTest.SetPermissionInfo PageInfoBubbleViewTest.SetPermissionInfoForUsbGuard PageInfoBubbleViewTest.SetPermissionInfoWithPolicyUsbDevices PageInfoBubbleViewTest.SetPermissionInfoWithUsbDevice PageInfoBubbleViewTest.SetPermissionInfoWithUserAndPolicyUsbDevices PageInfoBubbleViewTest.UpdatingSiteDataRetainsLayout https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8909718923797040064/+/steps/unit_tests/0/logs/Deterministic_failure:_PageInfoBubbleViewTest.ChangingFlashSettingForSiteIsRemembered__status_CRASH_/0 [ RUN ] PageInfoBubbleViewTest.ChangingFlashSettingForSiteIsRemembered ==9056==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x561baaab15ec in PageInfoUI::GetSecurityDescription(PageInfoUI::IdentityInfo const&) const ./../../chrome/browser/ui/page_info/page_info_ui.cc:250:3 #1 0x561bab6a1548 in PageInfoBubbleView::SetIdentityInfo(PageInfoUI::IdentityInfo const&) ./../../chrome/browser/ui/views/page_info/page_info_bubble_view.cc:802:7 #2 0x561baaaab3bb in PageInfo::PresentSiteIdentity() ./../../chrome/browser/ui/page_info/page_info.cc:969:8 #3 0x561baaaa0a21 in PageInfo::PageInfo(PageInfoUI*, Profile*, TabSpecificContentSettings*, content::WebContents*, GURL const&, security_state::SecurityLevel, security_state::VisibleSecurityState const&) ./../../chrome/browser/ui/page_info/page_info.cc:344:3 #4 0x561bab69b6dd in PageInfoBubbleView::PageInfoBubbleView(views::View*, gfx::Rect const&, aura::Window*, Profile*, content::WebContents*, GURL const&, security_state::SecurityLevel, security_state::VisibleSecurityState const&, base::OnceCallback<void (views::Widget::ClosedReason, bool)>) ./../../chrome/browser/ui/views/page_info/page_info_bubble_view.cc:576:24 ... Original change's description: > PageInfo: decouple safe browsing and TLS statii. > > Previously, the Page Info bubble maintained a single variable to > identify all reasons that a page might have a non-standard status. This > lead to the display logic making assumptions about, for instance, the > validity of a certificate when the page was flagged by Safe Browsing. > > This CL separates out the Safe Browsing status from the site identity > status so that the page info bubble can inform the user that the site's > certificate is invalid, even if it's also flagged by Safe Browsing. > > Bug: 869925 > Change-Id: I34107225b4206c8f32771ccd75e9367668d0a72b > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1662537 > Reviewed-by: Mustafa Emre Acer <meacer@chromium.org> > Reviewed-by: Bret Sepulveda <bsep@chromium.org> > Auto-Submit: Joe DeBlasio <jdeblasio@chromium.org> > Commit-Queue: Joe DeBlasio <jdeblasio@chromium.org> > Cr-Commit-Position: refs/heads/master@{#671847} TBR=meacer@chromium.org,bsep@chromium.org,jdeblasio@chromium.org Change-Id: I8be652952e7276bcc9266124693352e467159cc4 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 869925 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1673985 Reviewed-by: Takashi Sakamoto <tasak@google.com> Commit-Queue: Takashi Sakamoto <tasak@google.com> Cr-Commit-Position: refs/heads/master@{#671932} CWE ID: CWE-311
0
138,013
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: DOMImplementation& Document::implementation() { if (!implementation_) implementation_ = DOMImplementation::Create(*this); return *implementation_; } Commit Message: Cleanup and remove dead code in SetFocusedElement This early-out was added in: https://crrev.com/ce8ea3446283965c7eabab592cbffe223b1cf2bc Back then, we applied fragment focus in LayoutUpdated() which could cause this issue. This got cleaned up in: https://crrev.com/45236fd563e9df53dc45579be1f3d0b4784885a2 so that focus is no longer applied after layout. +Cleanup: Goto considered harmful Bug: 795381 Change-Id: Ifeb4d2e03e872fd48cca6720b1d4de36ad1ecbb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1524417 Commit-Queue: David Bokan <bokan@chromium.org> Reviewed-by: Stefan Zager <szager@chromium.org> Cr-Commit-Position: refs/heads/master@{#641101} CWE ID: CWE-416
0
129,971
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 Parcel::writeByteVector(const std::vector<uint8_t>& val) { return writeByteVectorInternal(this, val); } Commit Message: Add bound checks to utf16_to_utf8 Bug: 29250543 Change-Id: I518e7b2fe10aaa3f1c1987586a09b1110aff7e1a (cherry picked from commit 7e93b2ddcb49b5365fbe1dab134ffb38e6f1c719) CWE ID: CWE-119
0
163,607
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::runModal() { if (m_webView->client()) m_webView->client()->runModal(); } 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,645
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 struct hid_device_id *hid_match_device(struct hid_device *hdev, struct hid_driver *hdrv) { struct hid_dynid *dynid; spin_lock(&hdrv->dyn_lock); list_for_each_entry(dynid, &hdrv->dyn_list, list) { if (hid_match_one_id(hdev, &dynid->id)) { spin_unlock(&hdrv->dyn_lock); return &dynid->id; } } spin_unlock(&hdrv->dyn_lock); return hid_match_id(hdev, hdrv->id_table); } Commit Message: HID: core: prevent out-of-bound readings Plugging a Logitech DJ receiver with KASAN activated raises a bunch of out-of-bound readings. The fields are allocated up to MAX_USAGE, meaning that potentially, we do not have enough fields to fit the incoming values. Add checks and silence KASAN. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> CWE ID: CWE-125
0
49,499
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: PHP_FUNCTION(curl_errno) { zval *zid; php_curl *ch; if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zid) == FAILURE) { return; } if ((ch = (php_curl*)zend_fetch_resource(Z_RES_P(zid), le_curl_name, le_curl)) == NULL) { RETURN_FALSE; } RETURN_LONG(ch->err.no); } Commit Message: Fix bug #72674 - check both curl_escape and curl_unescape CWE ID: CWE-119
0
50,126
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 dentry *__d_lookup(const struct dentry *parent, const struct qstr *name) { unsigned int len = name->len; unsigned int hash = name->hash; const unsigned char *str = name->name; struct hlist_bl_head *b = d_hash(parent, hash); struct hlist_bl_node *node; struct dentry *found = NULL; struct dentry *dentry; /* * Note: There is significant duplication with __d_lookup_rcu which is * required to prevent single threaded performance regressions * especially on architectures where smp_rmb (in seqcounts) are costly. * Keep the two functions in sync. */ /* * The hash list is protected using RCU. * * Take d_lock when comparing a candidate dentry, to avoid races * with d_move(). * * It is possible that concurrent renames can mess up our list * walk here and result in missing our dentry, resulting in the * false-negative result. d_lookup() protects against concurrent * renames using rename_lock seqlock. * * See Documentation/filesystems/path-lookup.txt for more details. */ rcu_read_lock(); hlist_bl_for_each_entry_rcu(dentry, node, b, d_hash) { if (dentry->d_name.hash != hash) continue; spin_lock(&dentry->d_lock); if (dentry->d_parent != parent) goto next; if (d_unhashed(dentry)) goto next; /* * It is safe to compare names since d_move() cannot * change the qstr (protected by d_lock). */ if (parent->d_flags & DCACHE_OP_COMPARE) { int tlen = dentry->d_name.len; const char *tname = dentry->d_name.name; if (parent->d_op->d_compare(parent, dentry, tlen, tname, name)) goto next; } else { if (dentry->d_name.len != len) goto next; if (dentry_cmp(dentry, str, len)) goto next; } dentry->d_lockref.count++; found = dentry; spin_unlock(&dentry->d_lock); break; next: spin_unlock(&dentry->d_lock); } rcu_read_unlock(); return found; } Commit Message: dcache: Handle escaped paths in prepend_path A rename can result in a dentry that by walking up d_parent will never reach it's mnt_root. For lack of a better term I call this an escaped path. prepend_path is called by four different functions __d_path, d_absolute_path, d_path, and getcwd. __d_path only wants to see paths are connected to the root it passes in. So __d_path needs prepend_path to return an error. d_absolute_path similarly wants to see paths that are connected to some root. Escaped paths are not connected to any mnt_root so d_absolute_path needs prepend_path to return an error greater than 1. So escaped paths will be treated like paths on lazily unmounted mounts. getcwd needs to prepend "(unreachable)" so getcwd also needs prepend_path to return an error. d_path is the interesting hold out. d_path just wants to print something, and does not care about the weird cases. Which raises the question what should be printed? Given that <escaped_path>/<anything> should result in -ENOENT I believe it is desirable for escaped paths to be printed as empty paths. As there are not really any meaninful path components when considered from the perspective of a mount tree. So tweak prepend_path to return an empty path with an new error code of 3 when it encounters an escaped path. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> CWE ID: CWE-254
0
94,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: status_t NuMediaExtractor::setDataSource(int fd, off64_t offset, off64_t size) { ALOGV("setDataSource fd=%d (%s), offset=%lld, length=%lld", fd, nameForFd(fd).c_str(), (long long) offset, (long long) size); Mutex::Autolock autoLock(mLock); if (mImpl != NULL) { return -EINVAL; } sp<FileSource> fileSource = new FileSource(dup(fd), offset, size); status_t err = fileSource->initCheck(); if (err != OK) { return err; } mImpl = MediaExtractor::Create(fileSource); if (mImpl == NULL) { return ERROR_UNSUPPORTED; } err = updateDurationAndBitrate(); if (err == OK) { mDataSource = fileSource; } return OK; } Commit Message: Fix integer overflow and divide-by-zero Bug: 35763994 Test: ran CTS with and without fix Change-Id: If835e97ce578d4fa567e33e349e48fb7b2559e0e (cherry picked from commit 8538a603ef992e75f29336499cb783f3ec19f18c) CWE ID: CWE-190
0
162,429
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 skcipher_accept_parent(void *private, struct sock *sk) { struct skcipher_ctx *ctx; struct alg_sock *ask = alg_sk(sk); unsigned int len = sizeof(*ctx) + crypto_skcipher_reqsize(private); ctx = sock_kmalloc(sk, len, GFP_KERNEL); if (!ctx) return -ENOMEM; ctx->iv = sock_kmalloc(sk, crypto_skcipher_ivsize(private), GFP_KERNEL); if (!ctx->iv) { sock_kfree_s(sk, ctx, len); return -ENOMEM; } memset(ctx->iv, 0, crypto_skcipher_ivsize(private)); INIT_LIST_HEAD(&ctx->tsgl); ctx->len = len; ctx->used = 0; ctx->more = 0; ctx->merge = 0; ctx->enc = 0; atomic_set(&ctx->inflight, 0); af_alg_init_completion(&ctx->completion); ask->private = ctx; skcipher_request_set_tfm(&ctx->req, private); skcipher_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_BACKLOG, af_alg_complete, &ctx->completion); sk->sk_destruct = skcipher_sock_destruct; return 0; } Commit Message: crypto: algif_skcipher - Require setkey before accept(2) Some cipher implementations will crash if you try to use them without calling setkey first. This patch adds a check so that the accept(2) call will fail with -ENOKEY if setkey hasn't been done on the socket yet. Cc: stable@vger.kernel.org Reported-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Tested-by: Dmitry Vyukov <dvyukov@google.com> CWE ID: CWE-476
1
167,454
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 RenderViewHostImpl::OnRenderViewGone(int status, int exit_code) { render_view_termination_status_ = static_cast<base::TerminationStatus>(status); ClearPowerSaveBlockers(); RendererExited(render_view_termination_status_, exit_code); delegate_->RenderViewGone(this, static_cast<base::TerminationStatus>(status), exit_code); } Commit Message: Filter more incoming URLs in the CreateWindow path. BUG=170532 Review URL: https://chromiumcodereview.appspot.com/12036002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178728 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID:
0
117,254
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: tt_cmap0_char_next( TT_CMap cmap, FT_UInt32 *pchar_code ) { FT_Byte* table = cmap->data; FT_UInt32 charcode = *pchar_code; FT_UInt32 result = 0; FT_UInt gindex = 0; table += 6; /* go to glyph IDs */ while ( ++charcode < 256 ) { gindex = table[charcode]; if ( gindex != 0 ) { result = charcode; break; } } *pchar_code = result; return gindex; } Commit Message: CWE ID: CWE-189
0
4,172
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 platform_device *platform_device_alloc(const char *name, int id) { struct platform_object *pa; pa = kzalloc(sizeof(*pa) + strlen(name) + 1, GFP_KERNEL); if (pa) { strcpy(pa->name, name); pa->pdev.name = pa->name; pa->pdev.id = id; device_initialize(&pa->pdev.dev); pa->pdev.dev.release = platform_device_release; arch_setup_pdev_archdata(&pa->pdev); } return pa ? &pa->pdev : NULL; } Commit Message: driver core: platform: fix race condition with driver_override The driver_override implementation is susceptible to race condition when different threads are reading vs storing a different driver override. Add locking to avoid race condition. Fixes: 3d713e0e382e ("driver core: platform: add device binding path 'driver_override'") Cc: stable@vger.kernel.org Signed-off-by: Adrian Salido <salidoa@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> CWE ID: CWE-362
0
63,090
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: QueryManager::QueryManager( GLES2Decoder* decoder, FeatureInfo* feature_info) : decoder_(decoder), use_arb_occlusion_query2_for_occlusion_query_boolean_( feature_info->feature_flags( ).use_arb_occlusion_query2_for_occlusion_query_boolean), use_arb_occlusion_query_for_occlusion_query_boolean_( feature_info->feature_flags( ).use_arb_occlusion_query_for_occlusion_query_boolean), query_count_(0) { DCHECK(!(use_arb_occlusion_query_for_occlusion_query_boolean_ && use_arb_occlusion_query2_for_occlusion_query_boolean_)); } Commit Message: Add bounds validation to AsyncPixelTransfersCompletedQuery::End BUG=351852 R=jbauman@chromium.org, jorgelo@chromium.org Review URL: https://codereview.chromium.org/198253002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256723 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-119
0
121,465
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: gx_dc_devn_masked_load(gx_device_color * pdevc, const gs_gstate * pgs, gx_device * dev, gs_color_select_t select) { int code = (*gx_dc_type_data_devn.load) (pdevc, pgs, dev, select); if (code < 0) return code; FINISH_PATTERN_LOAD } Commit Message: CWE ID: CWE-704
0
1,671
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 bitmap_position_extended(const unsigned char *sha1) { khash_sha1_pos *positions = bitmap_git.ext_index.positions; khiter_t pos = kh_get_sha1_pos(positions, sha1); if (pos < kh_end(positions)) { int bitmap_pos = kh_value(positions, pos); return bitmap_pos + bitmap_git.pack->num_objects; } return -1; } 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
54,923
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 CSPSourceList::parseSource(const UChar* begin, const UChar* end, String& scheme, String& host, int& port, String& path, CSPSource::WildcardDisposition& hostWildcard, CSPSource::WildcardDisposition& portWildcard) { if (begin == end) return false; if (equalIgnoringCase("'none'", begin, end - begin)) return false; if (end - begin == 1 && *begin == '*') { addSourceStar(); return true; } if (equalIgnoringCase("'self'", begin, end - begin)) { addSourceSelf(); return true; } if (equalIgnoringCase("'unsafe-inline'", begin, end - begin)) { addSourceUnsafeInline(); return true; } if (equalIgnoringCase("'unsafe-eval'", begin, end - begin)) { addSourceUnsafeEval(); return true; } String nonce; if (!parseNonce(begin, end, nonce)) return false; if (!nonce.isNull()) { addSourceNonce(nonce); return true; } DigestValue hash; ContentSecurityPolicyHashAlgorithm algorithm = ContentSecurityPolicyHashAlgorithmNone; if (!parseHash(begin, end, hash, algorithm)) return false; if (hash.size() > 0) { addSourceHash(algorithm, hash); return true; } const UChar* position = begin; const UChar* beginHost = begin; const UChar* beginPath = end; const UChar* beginPort = 0; skipWhile<UChar, isNotColonOrSlash>(position, end); if (position == end) { return parseHost(beginHost, position, host, hostWildcard); } if (position < end && *position == '/') { return parseHost(beginHost, position, host, hostWildcard) && parsePath(position, end, path); } if (position < end && *position == ':') { if (end - position == 1) { return parseScheme(begin, position, scheme); } if (position[1] == '/') { if (!parseScheme(begin, position, scheme) || !skipExactly<UChar>(position, end, ':') || !skipExactly<UChar>(position, end, '/') || !skipExactly<UChar>(position, end, '/')) return false; if (position == end) return false; beginHost = position; skipWhile<UChar, isNotColonOrSlash>(position, end); } if (position < end && *position == ':') { beginPort = position; skipUntil<UChar>(position, end, '/'); } } if (position < end && *position == '/') { if (position == beginHost) return false; beginPath = position; } if (!parseHost(beginHost, beginPort ? beginPort : beginPath, host, hostWildcard)) return false; if (beginPort) { if (!parsePort(beginPort, beginPath, port, portWildcard)) return false; } else { port = 0; } if (beginPath != end) { if (!parsePath(beginPath, end, path)) return false; } return true; } Commit Message: Disallow CSP source * matching of data:, blob:, and filesystem: URLs The CSP spec specifically excludes matching of data:, blob:, and filesystem: URLs with the source '*' wildcard. This adds checks to make sure that doesn't happen, along with tests. BUG=534570 R=mkwst@chromium.org Review URL: https://codereview.chromium.org/1361763005 Cr-Commit-Position: refs/heads/master@{#350950} CWE ID: CWE-264
0
125,399
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 cm_remove_port_fs(struct cm_port *port) { int i; for (i = 0; i < CM_COUNTER_GROUPS; i++) kobject_put(&port->counter_group[i].obj); kobject_put(&port->port_obj); } Commit Message: IB/core: Don't resolve passive side RoCE L2 address in CMA REQ handler The code that resolves the passive side source MAC within the rdma_cm connection request handler was both redundant and buggy, so remove it. It was redundant since later, when an RC QP is modified to RTR state, the resolution will take place in the ib_core module. It was buggy because this callback also deals with UD SIDR exchange, for which we incorrectly looked at the REQ member of the CM event and dereferenced a random value. Fixes: dd5f03beb4f7 ("IB/core: Ethernet L2 attributes in verbs/cm structures") Signed-off-by: Moni Shoua <monis@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com> CWE ID: CWE-20
0
38,416
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 decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes) { const unsigned int bsize = CAST6_BLOCK_SIZE; struct crypt_priv *ctx = priv; int i; ctx->fpu_enabled = cast6_fpu_begin(ctx->fpu_enabled, nbytes); if (nbytes == bsize * CAST6_PARALLEL_BLOCKS) { cast6_ecb_dec_8way(ctx->ctx, srcdst, srcdst); return; } for (i = 0; i < nbytes / bsize; i++, srcdst += bsize) __cast6_decrypt(ctx->ctx, srcdst, srcdst); } 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,911
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 sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) { struct sock *sk = sock->sk; int val; int valbool; struct linger ling; int ret = 0; /* * Options without arguments */ if (optname == SO_BINDTODEVICE) return sock_setbindtodevice(sk, optval, optlen); if (optlen < sizeof(int)) return -EINVAL; if (get_user(val, (int __user *)optval)) return -EFAULT; valbool = val ? 1 : 0; lock_sock(sk); switch (optname) { case SO_DEBUG: if (val && !capable(CAP_NET_ADMIN)) ret = -EACCES; else sock_valbool_flag(sk, SOCK_DBG, valbool); break; case SO_REUSEADDR: sk->sk_reuse = (valbool ? SK_CAN_REUSE : SK_NO_REUSE); break; case SO_REUSEPORT: sk->sk_reuseport = valbool; break; case SO_TYPE: case SO_PROTOCOL: case SO_DOMAIN: case SO_ERROR: ret = -ENOPROTOOPT; break; case SO_DONTROUTE: sock_valbool_flag(sk, SOCK_LOCALROUTE, valbool); break; case SO_BROADCAST: sock_valbool_flag(sk, SOCK_BROADCAST, valbool); break; case SO_SNDBUF: /* Don't error on this BSD doesn't and if you think * about it this is right. Otherwise apps have to * play 'guess the biggest size' games. RCVBUF/SNDBUF * are treated in BSD as hints */ val = min_t(u32, val, sysctl_wmem_max); set_sndbuf: sk->sk_userlocks |= SOCK_SNDBUF_LOCK; sk->sk_sndbuf = max_t(u32, val * 2, SOCK_MIN_SNDBUF); /* Wake up sending tasks if we upped the value. */ sk->sk_write_space(sk); break; case SO_SNDBUFFORCE: if (!capable(CAP_NET_ADMIN)) { ret = -EPERM; break; } goto set_sndbuf; case SO_RCVBUF: /* Don't error on this BSD doesn't and if you think * about it this is right. Otherwise apps have to * play 'guess the biggest size' games. RCVBUF/SNDBUF * are treated in BSD as hints */ val = min_t(u32, val, sysctl_rmem_max); set_rcvbuf: sk->sk_userlocks |= SOCK_RCVBUF_LOCK; /* * We double it on the way in to account for * "struct sk_buff" etc. overhead. Applications * assume that the SO_RCVBUF setting they make will * allow that much actual data to be received on that * socket. * * Applications are unaware that "struct sk_buff" and * other overheads allocate from the receive buffer * during socket buffer allocation. * * And after considering the possible alternatives, * returning the value we actually used in getsockopt * is the most desirable behavior. */ sk->sk_rcvbuf = max_t(u32, val * 2, SOCK_MIN_RCVBUF); break; case SO_RCVBUFFORCE: if (!capable(CAP_NET_ADMIN)) { ret = -EPERM; break; } goto set_rcvbuf; case SO_KEEPALIVE: #ifdef CONFIG_INET if (sk->sk_protocol == IPPROTO_TCP && sk->sk_type == SOCK_STREAM) tcp_set_keepalive(sk, valbool); #endif sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool); break; case SO_OOBINLINE: sock_valbool_flag(sk, SOCK_URGINLINE, valbool); break; case SO_NO_CHECK: sk->sk_no_check_tx = valbool; break; case SO_PRIORITY: if ((val >= 0 && val <= 6) || ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) sk->sk_priority = val; else ret = -EPERM; break; case SO_LINGER: if (optlen < sizeof(ling)) { ret = -EINVAL; /* 1003.1g */ break; } if (copy_from_user(&ling, optval, sizeof(ling))) { ret = -EFAULT; break; } if (!ling.l_onoff) sock_reset_flag(sk, SOCK_LINGER); else { #if (BITS_PER_LONG == 32) if ((unsigned int)ling.l_linger >= MAX_SCHEDULE_TIMEOUT/HZ) sk->sk_lingertime = MAX_SCHEDULE_TIMEOUT; else #endif sk->sk_lingertime = (unsigned int)ling.l_linger * HZ; sock_set_flag(sk, SOCK_LINGER); } break; case SO_BSDCOMPAT: sock_warn_obsolete_bsdism("setsockopt"); break; case SO_PASSCRED: if (valbool) set_bit(SOCK_PASSCRED, &sock->flags); else clear_bit(SOCK_PASSCRED, &sock->flags); break; case SO_TIMESTAMP: case SO_TIMESTAMPNS: if (valbool) { if (optname == SO_TIMESTAMP) sock_reset_flag(sk, SOCK_RCVTSTAMPNS); else sock_set_flag(sk, SOCK_RCVTSTAMPNS); sock_set_flag(sk, SOCK_RCVTSTAMP); sock_enable_timestamp(sk, SOCK_TIMESTAMP); } else { sock_reset_flag(sk, SOCK_RCVTSTAMP); sock_reset_flag(sk, SOCK_RCVTSTAMPNS); } break; case SO_TIMESTAMPING: if (val & ~SOF_TIMESTAMPING_MASK) { ret = -EINVAL; break; } if (val & SOF_TIMESTAMPING_OPT_ID && !(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID)) { if (sk->sk_protocol == IPPROTO_TCP && sk->sk_type == SOCK_STREAM) { if ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) { ret = -EINVAL; break; } sk->sk_tskey = tcp_sk(sk)->snd_una; } else { sk->sk_tskey = 0; } } sk->sk_tsflags = val; if (val & SOF_TIMESTAMPING_RX_SOFTWARE) sock_enable_timestamp(sk, SOCK_TIMESTAMPING_RX_SOFTWARE); else sock_disable_timestamp(sk, (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE)); break; case SO_RCVLOWAT: if (val < 0) val = INT_MAX; sk->sk_rcvlowat = val ? : 1; break; case SO_RCVTIMEO: ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen); break; case SO_SNDTIMEO: ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen); break; case SO_ATTACH_FILTER: ret = -EINVAL; if (optlen == sizeof(struct sock_fprog)) { struct sock_fprog fprog; ret = -EFAULT; if (copy_from_user(&fprog, optval, sizeof(fprog))) break; ret = sk_attach_filter(&fprog, sk); } break; case SO_ATTACH_BPF: ret = -EINVAL; if (optlen == sizeof(u32)) { u32 ufd; ret = -EFAULT; if (copy_from_user(&ufd, optval, sizeof(ufd))) break; ret = sk_attach_bpf(ufd, sk); } break; case SO_ATTACH_REUSEPORT_CBPF: ret = -EINVAL; if (optlen == sizeof(struct sock_fprog)) { struct sock_fprog fprog; ret = -EFAULT; if (copy_from_user(&fprog, optval, sizeof(fprog))) break; ret = sk_reuseport_attach_filter(&fprog, sk); } break; case SO_ATTACH_REUSEPORT_EBPF: ret = -EINVAL; if (optlen == sizeof(u32)) { u32 ufd; ret = -EFAULT; if (copy_from_user(&ufd, optval, sizeof(ufd))) break; ret = sk_reuseport_attach_bpf(ufd, sk); } break; case SO_DETACH_FILTER: ret = sk_detach_filter(sk); break; case SO_LOCK_FILTER: if (sock_flag(sk, SOCK_FILTER_LOCKED) && !valbool) ret = -EPERM; else sock_valbool_flag(sk, SOCK_FILTER_LOCKED, valbool); break; case SO_PASSSEC: if (valbool) set_bit(SOCK_PASSSEC, &sock->flags); else clear_bit(SOCK_PASSSEC, &sock->flags); break; case SO_MARK: if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) ret = -EPERM; else sk->sk_mark = val; break; case SO_RXQ_OVFL: sock_valbool_flag(sk, SOCK_RXQ_OVFL, valbool); break; case SO_WIFI_STATUS: sock_valbool_flag(sk, SOCK_WIFI_STATUS, valbool); break; case SO_PEEK_OFF: if (sock->ops->set_peek_off) ret = sock->ops->set_peek_off(sk, val); else ret = -EOPNOTSUPP; break; case SO_NOFCS: sock_valbool_flag(sk, SOCK_NOFCS, valbool); break; case SO_SELECT_ERR_QUEUE: sock_valbool_flag(sk, SOCK_SELECT_ERR_QUEUE, valbool); break; #ifdef CONFIG_NET_RX_BUSY_POLL case SO_BUSY_POLL: /* allow unprivileged users to decrease the value */ if ((val > sk->sk_ll_usec) && !capable(CAP_NET_ADMIN)) ret = -EPERM; else { if (val < 0) ret = -EINVAL; else sk->sk_ll_usec = val; } break; #endif case SO_MAX_PACING_RATE: sk->sk_max_pacing_rate = val; sk->sk_pacing_rate = min(sk->sk_pacing_rate, sk->sk_max_pacing_rate); break; case SO_INCOMING_CPU: sk->sk_incoming_cpu = val; break; case SO_CNX_ADVICE: if (val == 1) dst_negative_advice(sk); break; default: ret = -ENOPROTOOPT; break; } release_sock(sk); return ret; } Commit Message: net: avoid signed overflows for SO_{SND|RCV}BUFFORCE CAP_NET_ADMIN users should not be allowed to set negative sk_sndbuf or sk_rcvbuf values, as it can lead to various memory corruptions, crashes, OOM... Note that before commit 82981930125a ("net: cleanups in sock_setsockopt()"), the bug was even more serious, since SO_SNDBUF and SO_RCVBUF were vulnerable. This needs to be backported to all known linux kernels. Again, many thanks to syzkaller team for discovering this gem. Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-119
1
166,846
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 crypto_exit_skcipher_ops_ablkcipher(struct crypto_tfm *tfm) { struct crypto_ablkcipher **ctx = crypto_tfm_ctx(tfm); crypto_free_ablkcipher(*ctx); } Commit Message: crypto: skcipher - Add missing API setkey checks The API setkey checks for key sizes and alignment went AWOL during the skcipher conversion. This patch restores them. Cc: <stable@vger.kernel.org> Fixes: 4e6c3df4d729 ("crypto: skcipher - Add low-level skcipher...") Reported-by: Baozeng <sploving1@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> CWE ID: CWE-476
0
64,768
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: SafeBrowsingBlockingPage* CreateSafeBrowsingPage( SafeBrowsingUIManager* ui_manager, WebContents* web_contents, const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) { if (unsafe_resources.size() == 1 && (unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE || unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_PHISHING)) { return new SafeBrowsingBlockingPageV2(ui_manager, web_contents, unsafe_resources); } return new SafeBrowsingBlockingPageV1(ui_manager, web_contents, unsafe_resources); } Commit Message: Check for a negative integer properly. BUG=169966 Review URL: https://chromiumcodereview.appspot.com/11892002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176879 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-119
0
115,130
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void LoadOptimizationHints(const base::Version& ruleset_format) { std::unique_ptr<base::DictionaryValue> manifest(new base::DictionaryValue); if (ruleset_format.IsValid()) { manifest->SetString( OptimizationHintsComponentInstallerPolicy::kManifestRulesetFormatKey, ruleset_format.GetString()); } ASSERT_TRUE( policy_->VerifyInstallation(*manifest, component_install_dir())); const base::Version expected_version(kTestHintsVersion); policy_->ComponentReady(expected_version, component_install_dir(), std::move(manifest)); base::RunLoop().RunUntilIdle(); } 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,793
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int out_get_render_position(const struct audio_stream_out *stream, uint32_t *dsp_frames) { (void)stream; *dsp_frames = 0; return -EINVAL; } Commit Message: Fix audio record pre-processing proc_buf_out consistently initialized. intermediate scratch buffers consistently initialized. prevent read failure from overwriting memory. Test: POC, CTS, camera record Bug: 62873231 Change-Id: Ie26e12a419a5819c1c5c3a0bcf1876d6d7aca686 (cherry picked from commit 6d7b330c27efba944817e647955da48e54fd74eb) CWE ID: CWE-125
0
162,315
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static Image *ReadDDSImage(const ImageInfo *image_info,ExceptionInfo *exception) { Image *image; MagickBooleanType status, cubemap = MagickFalse, volume = MagickFalse, matte; CompressionType compression; DDSInfo dds_info; DDSDecoder *decoder; size_t n, num_images; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=AcquireImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } /* Initialize image structure. */ if (ReadDDSInfo(image, &dds_info) != MagickTrue) { ThrowReaderException(CorruptImageError,"ImproperImageHeader"); } if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP) cubemap = MagickTrue; if (dds_info.ddscaps2 & DDSCAPS2_VOLUME && dds_info.depth > 0) volume = MagickTrue; (void) SeekBlob(image, 128, SEEK_SET); /* Determine pixel format */ if (dds_info.pixelformat.flags & DDPF_RGB) { compression = NoCompression; if (dds_info.pixelformat.flags & DDPF_ALPHAPIXELS) { matte = MagickTrue; decoder = ReadUncompressedRGBA; } else { matte = MagickTrue; decoder = ReadUncompressedRGB; } } else if (dds_info.pixelformat.flags & DDPF_LUMINANCE) { compression = NoCompression; if (dds_info.pixelformat.flags & DDPF_ALPHAPIXELS) { /* Not sure how to handle this */ ThrowReaderException(CorruptImageError, "ImageTypeNotSupported"); } else { matte = MagickFalse; decoder = ReadUncompressedRGB; } } else if (dds_info.pixelformat.flags & DDPF_FOURCC) { switch (dds_info.pixelformat.fourcc) { case FOURCC_DXT1: { matte = MagickFalse; compression = DXT1Compression; decoder = ReadDXT1; break; } case FOURCC_DXT3: { matte = MagickTrue; compression = DXT3Compression; decoder = ReadDXT3; break; } case FOURCC_DXT5: { matte = MagickTrue; compression = DXT5Compression; decoder = ReadDXT5; break; } default: { /* Unknown FOURCC */ ThrowReaderException(CorruptImageError, "ImageTypeNotSupported"); } } } else { /* Neither compressed nor uncompressed... thus unsupported */ ThrowReaderException(CorruptImageError, "ImageTypeNotSupported"); } num_images = 1; if (cubemap) { /* Determine number of faces defined in the cubemap */ num_images = 0; if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEX) num_images++; if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEX) num_images++; if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEY) num_images++; if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEY) num_images++; if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEZ) num_images++; if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ) num_images++; } if (volume) num_images = dds_info.depth; for (n = 0; n < num_images; n++) { if (n != 0) { if (EOFBlob(image) != MagickFalse) ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile"); /* Start a new image */ AcquireNextImage(image_info,image); if (GetNextImageInList(image) == (Image *) NULL) return(DestroyImageList(image)); image=SyncNextImageInList(image); } image->matte = matte; image->compression = compression; image->columns = dds_info.width; image->rows = dds_info.height; image->storage_class = DirectClass; image->endian = LSBEndian; image->depth = 8; if (image_info->ping != MagickFalse) { (void) CloseBlob(image); return(GetFirstImageInList(image)); } status=SetImageExtent(image,image->columns,image->rows); if (status == MagickFalse) { InheritException(exception,&image->exception); return(DestroyImageList(image)); } if ((decoder)(image, &dds_info, exception) != MagickTrue) { (void) CloseBlob(image); return(GetFirstImageInList(image)); } } if (EOFBlob(image) != MagickFalse) ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", image->filename); (void) CloseBlob(image); return(GetFirstImageInList(image)); } Commit Message: CWE ID: CWE-399
0
74,001
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 int32_t decode_unicode_escape(const char *str) { int i; int32_t value = 0; assert(str[0] == 'u'); for(i = 1; i <= 4; i++) { char c = str[i]; value <<= 4; if(l_isdigit(c)) value += c - '0'; else if(l_islower(c)) value += c - 'a' + 10; else if(l_isupper(c)) value += c - 'A' + 10; else return -1; } return value; } Commit Message: Fix for issue #282 The fix limits recursion depths when parsing arrays and objects. The limit is configurable via the `JSON_PARSER_MAX_DEPTH` setting within `jansson_config.h` and is set by default to 2048. Update the RFC conformance document to note the limit; the RFC allows limits to be set by the implementation so nothing has actually changed w.r.t. conformance state. Reported by Gustavo Grieco. CWE ID: CWE-20
0
53,336
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: JsVar *jsvArrayJoin(JsVar *arr, JsVar *filler) { JsVar *str = jsvNewFromEmptyString(); if (!str) return 0; // out of memory JsvIterator it; jsvIteratorNew(&it, arr, JSIF_EVERY_ARRAY_ELEMENT); bool first = true; while (!jspIsInterrupted() && jsvIteratorHasElement(&it)) { JsVar *key = jsvIteratorGetKey(&it); if (jsvIsInt(key)) { if (filler && !first) jsvAppendStringVarComplete(str, filler); first = false; JsVar *value = jsvIteratorGetValue(&it); if (value && !jsvIsNull(value)) { JsVar *valueStr = jsvAsString(value, false); if (valueStr) { // could be out of memory jsvAppendStringVarComplete(str, valueStr); jsvUnLock(valueStr); } } jsvUnLock(value); } jsvUnLock(key); jsvIteratorNext(&it); } jsvIteratorFree(&it); return str; } Commit Message: fix jsvGetString regression CWE ID: CWE-119
0
82,367
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 debugfs_fpuemu(void) { struct dentry *d, *dir; if (!mips_debugfs_dir) return -ENODEV; dir = debugfs_create_dir("fpuemustats", mips_debugfs_dir); if (!dir) return -ENOMEM; #define FPU_STAT_CREATE(M) \ do { \ d = debugfs_create_file(#M , S_IRUGO, dir, \ (void *)offsetof(struct mips_fpu_emulator_stats, M), \ &fops_fpuemu_stat); \ if (!d) \ return -ENOMEM; \ } while (0) FPU_STAT_CREATE(emulated); FPU_STAT_CREATE(loads); FPU_STAT_CREATE(stores); FPU_STAT_CREATE(cp1ops); FPU_STAT_CREATE(cp1xops); FPU_STAT_CREATE(errors); return 0; } Commit Message: perf: Remove the nmi parameter from the swevent and overflow interface The nmi parameter indicated if we could do wakeups from the current context, if not, we would set some state and self-IPI and let the resulting interrupt do the wakeup. For the various event classes: - hardware: nmi=0; PMI is in fact an NMI or we run irq_work_run from the PMI-tail (ARM etc.) - tracepoint: nmi=0; since tracepoint could be from NMI context. - software: nmi=[0,1]; some, like the schedule thing cannot perform wakeups, and hence need 0. As one can see, there is very little nmi=1 usage, and the down-side of not using it is that on some platforms some software events can have a jiffy delay in wakeup (when arch_irq_work_raise isn't implemented). The up-side however is that we can remove the nmi parameter and save a bunch of conditionals in fast paths. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Michael Cree <mcree@orcon.net.nz> Cc: Will Deacon <will.deacon@arm.com> Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com> Cc: Anton Blanchard <anton@samba.org> Cc: Eric B Munson <emunson@mgebm.net> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Paul Mundt <lethal@linux-sh.org> Cc: David S. Miller <davem@davemloft.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jason Wessel <jason.wessel@windriver.com> Cc: Don Zickus <dzickus@redhat.com> Link: http://lkml.kernel.org/n/tip-agjev8eu666tvknpb3iaj0fg@git.kernel.org Signed-off-by: Ingo Molnar <mingo@elte.hu> CWE ID: CWE-399
0
25,436
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 WebBluetoothServiceImpl::OnStartNotifySessionSuccess( blink::mojom::WebBluetoothCharacteristicClientAssociatedPtr client, RemoteCharacteristicStartNotificationsCallback callback, std::unique_ptr<device::BluetoothGattNotifySession> notify_session) { DCHECK_CURRENTLY_ON(BrowserThread::UI); std::string characteristic_instance_id = notify_session->GetCharacteristicIdentifier(); std::move(callback).Run(blink::mojom::WebBluetoothResult::SUCCESS); auto gatt_notify_session_and_client = std::make_unique<GATTNotifySessionAndCharacteristicClient>( std::move(notify_session), std::move(client)); characteristic_id_to_notify_session_[characteristic_instance_id] = std::move(gatt_notify_session_and_client); } Commit Message: bluetooth: Implement getAvailability() This change implements the getAvailability() method for navigator.bluetooth as defined in the specification. Bug: 707640 Change-Id: I9e9b3e7f8ea7f259e975f71cb6d9570e5f04b479 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1651516 Reviewed-by: Chris Harrelson <chrishtr@chromium.org> Reviewed-by: Giovanni Ortuño Urquidi <ortuno@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Commit-Queue: Ovidio de Jesús Ruiz-Henríquez <odejesush@chromium.org> Auto-Submit: Ovidio de Jesús Ruiz-Henríquez <odejesush@chromium.org> Cr-Commit-Position: refs/heads/master@{#688987} CWE ID: CWE-119
0
138,129
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 BaseMultipleFieldsDateAndTimeInputType::didBlurFromControl() { element()->setFocus(false); } Commit Message: Setting input.x-webkit-speech should not cause focus change In r150866, we introduced element()->focus() in destroyShadowSubtree() to retain focus on <input> when its type attribute gets changed. But when x-webkit-speech attribute is changed, the element is detached before calling destroyShadowSubtree() and element()->focus() failed This patch moves detach() after destroyShadowSubtree() to fix the problem. BUG=243818 TEST=fast/forms/input-type-change-focusout.html NOTRY=true Review URL: https://chromiumcodereview.appspot.com/16084005 git-svn-id: svn://svn.chromium.org/blink/trunk@151444 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-20
0
112,830
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 cma_any_port(struct sockaddr *addr) { return !cma_port(addr); } Commit Message: IB/core: Don't resolve passive side RoCE L2 address in CMA REQ handler The code that resolves the passive side source MAC within the rdma_cm connection request handler was both redundant and buggy, so remove it. It was redundant since later, when an RC QP is modified to RTR state, the resolution will take place in the ib_core module. It was buggy because this callback also deals with UD SIDR exchange, for which we incorrectly looked at the REQ member of the CM event and dereferenced a random value. Fixes: dd5f03beb4f7 ("IB/core: Ethernet L2 attributes in verbs/cm structures") Signed-off-by: Moni Shoua <monis@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com> CWE ID: CWE-20
0
38,453
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 __weak bpf_stackmap_copy(struct bpf_map *map, void *key, void *value) { return -ENOTSUPP; } Commit Message: bpf: fix refcnt overflow On a system with >32Gbyte of phyiscal memory and infinite RLIMIT_MEMLOCK, the malicious application may overflow 32-bit bpf program refcnt. It's also possible to overflow map refcnt on 1Tb system. Impose 32k hard limit which means that the same bpf program or map cannot be shared by more than 32k processes. Fixes: 1be7f75d1668 ("bpf: enable non-root eBPF programs") Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID:
0
53,069
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 PrintWebViewHelper::PrintPreviewContext::InitWithFrame( WebKit::WebFrame* web_frame) { DCHECK(web_frame); state_ = INITIALIZED; frame_ = web_frame; node_.reset(); } Commit Message: Fix print preview workflow to reflect settings of selected printer. BUG=95110 TEST=none Review URL: http://codereview.chromium.org/7831041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102242 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
97,521
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: xps_parse_glyph_index(char *s, int *glyph_index) { if (*s >= '0' && *s <= '9') s = xps_parse_digits(s, glyph_index); return s; } Commit Message: CWE ID: CWE-125
0
5,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: int btrfs_wait_marked_extents(struct btrfs_root *root, struct extent_io_tree *dirty_pages, int mark) { int err = 0; int werr = 0; struct address_space *mapping = root->fs_info->btree_inode->i_mapping; struct extent_state *cached_state = NULL; u64 start = 0; u64 end; while (!find_first_extent_bit(dirty_pages, start, &start, &end, EXTENT_NEED_WAIT, &cached_state)) { clear_extent_bit(dirty_pages, start, end, EXTENT_NEED_WAIT, 0, 0, &cached_state, GFP_NOFS); err = filemap_fdatawait_range(mapping, start, end); if (err) werr = err; cond_resched(); start = end + 1; } if (err) werr = err; return werr; } Commit Message: Btrfs: fix hash overflow handling The handling for directory crc hash overflows was fairly obscure, split_leaf returns EOVERFLOW when we try to extend the item and that is supposed to bubble up to userland. For a while it did so, but along the way we added better handling of errors and forced the FS readonly if we hit IO errors during the directory insertion. Along the way, we started testing only for EEXIST and the EOVERFLOW case was dropped. The end result is that we may force the FS readonly if we catch a directory hash bucket overflow. This fixes a few problem spots. First I add tests for EOVERFLOW in the places where we can safely just return the error up the chain. btrfs_rename is harder though, because it tries to insert the new directory item only after it has already unlinked anything the rename was going to overwrite. Rather than adding very complex logic, I added a helper to test for the hash overflow case early while it is still safe to bail out. Snapshot and subvolume creation had a similar problem, so they are using the new helper now too. Signed-off-by: Chris Mason <chris.mason@fusionio.com> Reported-by: Pascal Junod <pascal@junod.info> CWE ID: CWE-310
0
34,481
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 CParaNdisTX::SendMapped(bool IsInterrupt, PNET_BUFFER_LIST &NBLFailNow) { if(!ParaNdis_IsSendPossible(m_Context)) { NBLFailNow = RemoveAllNonWaitingNBLs(); if (NBLFailNow) { DPrintf(0, (__FUNCTION__ " Failing send")); } } else { bool SentOutSomeBuffers = false; auto HaveBuffers = true; while (HaveBuffers && HaveMappedNBLs()) { auto NBLHolder = PopMappedNBL(); if (NBLHolder->HaveMappedBuffers()) { auto NBHolder = NBLHolder->PopMappedNB(); auto result = m_VirtQueue.SubmitPacket(*NBHolder); switch (result) { case SUBMIT_NO_PLACE_IN_QUEUE: NBLHolder->PushMappedNB(NBHolder); PushMappedNBL(NBLHolder); HaveBuffers = false; break; case SUBMIT_FAILURE: case SUBMIT_SUCCESS: case SUBMIT_PACKET_TOO_LARGE: if (!NBLHolder->HaveMappedBuffers()) { m_WaitingList.Push(NBLHolder); } else { PushMappedNBL(NBLHolder); } if (result == SUBMIT_SUCCESS) { SentOutSomeBuffers = true; } else { NBHolder->SendComplete(); CNB::Destroy(NBHolder, m_Context->MiniportHandle); } break; default: ASSERT(false); break; } } else { m_WaitingList.Push(NBLHolder); } } if (SentOutSomeBuffers) { DPrintf(2, ("[%s] sent down\n", __FUNCTION__, SentOutSomeBuffers)); if (IsInterrupt) { return true; } else { m_VirtQueue.Kick(); } } } return false; } Commit Message: NetKVM: BZ#1169718: Checking the length only on read Signed-off-by: Joseph Hindin <yhindin@rehat.com> CWE ID: CWE-20
0
96,337
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 ohci_realize_pxa(DeviceState *dev, Error **errp) { OHCISysBusState *s = SYSBUS_OHCI(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); /* Cannot fail as we pass NULL for masterbus */ usb_ohci_init(&s->ohci, dev, s->num_ports, s->dma_offset, NULL, 0, &address_space_memory, &error_abort); sysbus_init_irq(sbd, &s->ohci.irq); sysbus_init_mmio(sbd, &s->ohci.mem); } Commit Message: CWE ID: CWE-835
0
5,933
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 EAS_I32 WT_UpdatePhaseInc (S_WT_VOICE *pWTVoice, const S_ARTICULATION *pArt, S_SYNTH_CHANNEL *pChannel, EAS_I32 pitchCents) { EAS_I32 temp; /*pitchCents due to CC1 = LFO * (CC1 / 128) * DEFAULT_LFO_MOD_WHEEL_TO_PITCH_CENTS */ temp = MULT_EG1_EG1(DEFAULT_LFO_MOD_WHEEL_TO_PITCH_CENTS, ((pChannel->modWheel) << (NUM_EG1_FRAC_BITS -7))); /* pitchCents due to channel pressure = LFO * (channel pressure / 128) * DEFAULT_LFO_CHANNEL_PRESSURE_TO_PITCH_CENTS */ temp += MULT_EG1_EG1(DEFAULT_LFO_CHANNEL_PRESSURE_TO_PITCH_CENTS, ((pChannel->channelPressure) << (NUM_EG1_FRAC_BITS -7))); /* now multiply the (channel pressure + CC1) pitch values by the LFO value */ temp = MULT_EG1_EG1(pWTVoice->modLFO.lfoValue, temp); /* add in the LFO pitch due to channel pressure and CC1 along with the LFO pitch, the EG2 pitch, and the "static" pitch for this voice on this channel */ temp += pitchCents + (MULT_EG1_EG1(pWTVoice->eg2Value, pArt->eg2ToPitch)) + (MULT_EG1_EG1(pWTVoice->modLFO.lfoValue, pArt->lfoToPitch)); /* convert from cents to linear phase increment */ return EAS_Calculate2toX(temp); } Commit Message: Sonivox: sanity check numSamples. Bug: 26366256 Change-Id: I066888c25035ea4c60c88f316db4508dc4dab6bc CWE ID: CWE-119
0
161,580
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 key_wait_bit(void *flags) { schedule(); return 0; } Commit Message: KEYS: Remove key_type::match in favour of overriding default by match_preparse A previous patch added a ->match_preparse() method to the key type. This is allowed to override the function called by the iteration algorithm. Therefore, we can just set a default that simply checks for an exact match of the key description with the original criterion data and allow match_preparse to override it as needed. The key_type::match op is then redundant and can be removed, as can the user_match() function. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Vivek Goyal <vgoyal@redhat.com> CWE ID: CWE-476
0
69,546
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: EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptExecutionContextAndScriptStateObjException(ExecState* exec) { JSValue thisValue = exec->hostThisValue(); if (!thisValue.inherits(&JSTestObj::s_info)) return throwVMTypeError(exec); JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue)); ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info); TestObj* impl = static_cast<TestObj*>(castedThis->impl()); ExceptionCode ec = 0; ScriptExecutionContext* scriptContext = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext(); if (!scriptContext) return JSValue::encode(jsUndefined()); JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->withScriptExecutionContextAndScriptStateObjException(exec, scriptContext, ec))); setDOMException(exec, ec); if (exec->hadException()) return JSValue::encode(jsUndefined()); return JSValue::encode(result); } Commit Message: [JSC] Implement a helper method createNotEnoughArgumentsError() https://bugs.webkit.org/show_bug.cgi?id=85102 Reviewed by Geoffrey Garen. In bug 84787, kbr@ requested to avoid hard-coding createTypeError(exec, "Not enough arguments") here and there. This patch implements createNotEnoughArgumentsError(exec) and uses it in JSC bindings. c.f. a corresponding bug for V8 bindings is bug 85097. Source/JavaScriptCore: * runtime/Error.cpp: (JSC::createNotEnoughArgumentsError): (JSC): * runtime/Error.h: (JSC): Source/WebCore: Test: bindings/scripts/test/TestObj.idl * bindings/scripts/CodeGeneratorJS.pm: Modified as described above. (GenerateArgumentsCountCheck): * bindings/js/JSDataViewCustom.cpp: Ditto. (WebCore::getDataViewMember): (WebCore::setDataViewMember): * bindings/js/JSDeprecatedPeerConnectionCustom.cpp: (WebCore::JSDeprecatedPeerConnectionConstructor::constructJSDeprecatedPeerConnection): * bindings/js/JSDirectoryEntryCustom.cpp: (WebCore::JSDirectoryEntry::getFile): (WebCore::JSDirectoryEntry::getDirectory): * bindings/js/JSSharedWorkerCustom.cpp: (WebCore::JSSharedWorkerConstructor::constructJSSharedWorker): * bindings/js/JSWebKitMutationObserverCustom.cpp: (WebCore::JSWebKitMutationObserverConstructor::constructJSWebKitMutationObserver): (WebCore::JSWebKitMutationObserver::observe): * bindings/js/JSWorkerCustom.cpp: (WebCore::JSWorkerConstructor::constructJSWorker): * bindings/scripts/test/JS/JSFloat64Array.cpp: Updated run-bindings-tests. (WebCore::jsFloat64ArrayPrototypeFunctionFoo): * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: (WebCore::jsTestActiveDOMObjectPrototypeFunctionExcitingFunction): (WebCore::jsTestActiveDOMObjectPrototypeFunctionPostMessage): * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp: (WebCore::jsTestCustomNamedGetterPrototypeFunctionAnotherFunction): * bindings/scripts/test/JS/JSTestEventTarget.cpp: (WebCore::jsTestEventTargetPrototypeFunctionItem): (WebCore::jsTestEventTargetPrototypeFunctionAddEventListener): (WebCore::jsTestEventTargetPrototypeFunctionRemoveEventListener): (WebCore::jsTestEventTargetPrototypeFunctionDispatchEvent): * bindings/scripts/test/JS/JSTestInterface.cpp: (WebCore::JSTestInterfaceConstructor::constructJSTestInterface): (WebCore::jsTestInterfacePrototypeFunctionSupplementalMethod2): * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp: (WebCore::jsTestMediaQueryListListenerPrototypeFunctionMethod): * bindings/scripts/test/JS/JSTestNamedConstructor.cpp: (WebCore::JSTestNamedConstructorNamedConstructor::constructJSTestNamedConstructor): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObjConstructor::constructJSTestObj): (WebCore::jsTestObjPrototypeFunctionVoidMethodWithArgs): (WebCore::jsTestObjPrototypeFunctionIntMethodWithArgs): (WebCore::jsTestObjPrototypeFunctionObjMethodWithArgs): (WebCore::jsTestObjPrototypeFunctionMethodWithSequenceArg): (WebCore::jsTestObjPrototypeFunctionMethodReturningSequence): (WebCore::jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows): (WebCore::jsTestObjPrototypeFunctionSerializedValue): (WebCore::jsTestObjPrototypeFunctionIdbKey): (WebCore::jsTestObjPrototypeFunctionOptionsObject): (WebCore::jsTestObjPrototypeFunctionAddEventListener): (WebCore::jsTestObjPrototypeFunctionRemoveEventListener): (WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg): (WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs): (WebCore::jsTestObjPrototypeFunctionMethodWithCallbackArg): (WebCore::jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod1): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod2): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod3): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod4): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod5): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod6): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod7): (WebCore::jsTestObjConstructorFunctionClassMethod2): (WebCore::jsTestObjConstructorFunctionOverloadedMethod11): (WebCore::jsTestObjConstructorFunctionOverloadedMethod12): (WebCore::jsTestObjPrototypeFunctionMethodWithUnsignedLongArray): (WebCore::jsTestObjPrototypeFunctionConvert1): (WebCore::jsTestObjPrototypeFunctionConvert2): (WebCore::jsTestObjPrototypeFunctionConvert3): (WebCore::jsTestObjPrototypeFunctionConvert4): (WebCore::jsTestObjPrototypeFunctionConvert5): (WebCore::jsTestObjPrototypeFunctionStrictFunction): * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp: (WebCore::JSTestSerializedScriptValueInterfaceConstructor::constructJSTestSerializedScriptValueInterface): (WebCore::jsTestSerializedScriptValueInterfacePrototypeFunctionAcceptTransferList): git-svn-id: svn://svn.chromium.org/blink/trunk@115536 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-20
0
101,275
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 sched_domain *__build_numa_sched_domains(struct s_data *d, const struct cpumask *cpu_map, struct sched_domain_attr *attr, int i) { struct sched_domain *sd = NULL; #ifdef CONFIG_NUMA struct sched_domain *parent; d->sd_allnodes = 0; if (cpumask_weight(cpu_map) > SD_NODES_PER_DOMAIN * cpumask_weight(d->nodemask)) { sd = &per_cpu(allnodes_domains, i).sd; SD_INIT(sd, ALLNODES); set_domain_attribute(sd, attr); cpumask_copy(sched_domain_span(sd), cpu_map); cpu_to_allnodes_group(i, cpu_map, &sd->groups, d->tmpmask); d->sd_allnodes = 1; } parent = sd; sd = &per_cpu(node_domains, i).sd; SD_INIT(sd, NODE); set_domain_attribute(sd, attr); sched_domain_node_span(cpu_to_node(i), sched_domain_span(sd)); sd->parent = parent; if (parent) parent->child = sd; cpumask_and(sched_domain_span(sd), sched_domain_span(sd), cpu_map); #endif return sd; } 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,296
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 vm_area_struct *next_vma(struct vm_area_struct *this_vma, struct vm_area_struct *gate_vma) { struct vm_area_struct *ret; ret = this_vma->vm_next; if (ret) return ret; if (this_vma == gate_vma) return NULL; return gate_vma; } Commit Message: regset: Prevent null pointer reference on readonly regsets The regset common infrastructure assumed that regsets would always have .get and .set methods, but not necessarily .active methods. Unfortunately people have since written regsets without .set methods. Rather than putting in stub functions everywhere, handle regsets with null .get or .set methods explicitly. Signed-off-by: H. Peter Anvin <hpa@zytor.com> Reviewed-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Roland McGrath <roland@hack.frob.com> Cc: <stable@vger.kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID:
0
21,465
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static jobject android_net_wifi_get_rtt_capabilities(JNIEnv *env, jclass cls, jint iface) { JNIHelper helper(env); wifi_rtt_capabilities rtt_capabilities; wifi_interface_handle handle = getIfaceHandle(helper, cls, iface); wifi_error ret = hal_fn.wifi_get_rtt_capabilities(handle, &rtt_capabilities); if(WIFI_SUCCESS == ret) { JNIObject<jobject> capabilities = helper.createObject( "android/net/wifi/RttManager$RttCapabilities"); helper.setBooleanField(capabilities, "oneSidedRttSupported", rtt_capabilities.rtt_one_sided_supported == 1); helper.setBooleanField(capabilities, "twoSided11McRttSupported", rtt_capabilities.rtt_ftm_supported == 1); helper.setBooleanField(capabilities, "lciSupported", rtt_capabilities.lci_support); helper.setBooleanField(capabilities, "lcrSupported", rtt_capabilities.lcr_support); helper.setIntField(capabilities, "preambleSupported", rtt_capabilities.preamble_support); helper.setIntField(capabilities, "bwSupported", rtt_capabilities.bw_support); ALOGD("One side RTT is: %s", rtt_capabilities.rtt_one_sided_supported ==1 ? "support" : "not support"); ALOGD("Two side RTT is: %s", rtt_capabilities.rtt_ftm_supported == 1 ? "support" : "not support"); ALOGD("LCR is: %s", rtt_capabilities.lcr_support == 1 ? "support" : "not support"); ALOGD("LCI is: %s", rtt_capabilities.lci_support == 1 ? "support" : "not support"); ALOGD("Support Preamble is : %d support BW is %d", rtt_capabilities.preamble_support, rtt_capabilities.bw_support); return capabilities.detach(); } else { return NULL; } } Commit Message: Deal correctly with short strings The parseMacAddress function anticipates only properly formed MAC addresses (6 hexadecimal octets separated by ":"). This change properly deals with situations where the string is shorter than expected, making sure that the passed in char* reference in parseHexByte never exceeds the end of the string. BUG: 28164077 TEST: Added a main function: int main(int argc, char **argv) { unsigned char addr[6]; if (argc > 1) { memset(addr, 0, sizeof(addr)); parseMacAddress(argv[1], addr); printf("Result: %02x:%02x:%02x:%02x:%02x:%02x\n", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); } } Tested with "", "a" "ab" "ab:c" "abxc". Change-Id: I0db8d0037e48b62333d475296a45b22ab0efe386 CWE ID: CWE-200
0
159,084
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: NewTabObserver::~NewTabObserver() { } Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt. BUG=107201 TEST=no visible change Review URL: https://chromiumcodereview.appspot.com/11293205 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
117,686
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void SupervisedUserService::OnBrowserSetLastActive(Browser* browser) { bool profile_became_active = profile_->IsSameProfile(browser->profile()); if (!is_profile_active_ && profile_became_active) base::RecordAction(UserMetricsAction("ManagedUsers_OpenProfile")); else if (is_profile_active_ && !profile_became_active) base::RecordAction(UserMetricsAction("ManagedUsers_SwitchProfile")); is_profile_active_ = profile_became_active; } Commit Message: [signin] Add metrics to track the source for refresh token updated events This CL add a source for update and revoke credentials operations. It then surfaces the source in the chrome://signin-internals page. This CL also records the following histograms that track refresh token events: * Signin.RefreshTokenUpdated.ToValidToken.Source * Signin.RefreshTokenUpdated.ToInvalidToken.Source * Signin.RefreshTokenRevoked.Source These histograms are needed to validate the assumptions of how often tokens are revoked by the browser and the sources for the token revocations. Bug: 896182 Change-Id: I2fcab80ee8e5699708e695bc3289fa6d34859a90 Reviewed-on: https://chromium-review.googlesource.com/c/1286464 Reviewed-by: Jochen Eisinger <jochen@chromium.org> Reviewed-by: David Roger <droger@chromium.org> Reviewed-by: Ilya Sherman <isherman@chromium.org> Commit-Queue: Mihai Sardarescu <msarda@chromium.org> Cr-Commit-Position: refs/heads/master@{#606181} CWE ID: CWE-20
0
143,107
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: png_read_filter_row_up(png_row_infop row_info, png_bytep row, png_const_bytep prev_row) { size_t i; size_t istop = row_info->rowbytes; png_bytep rp = row; png_const_bytep pp = prev_row; for (i = 0; i < istop; i++) { *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); rp++; } } Commit Message: [libpng16] Fix the calculation of row_factor in png_check_chunk_length (Bug report by Thuan Pham, SourceForge issue #278) CWE ID: CWE-190
0
79,762
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 cgsleep_ms(int ms) { cgtimer_t ts_start; cgsleep_prepare_r(&ts_start); cgsleep_ms_r(&ts_start, ms); } Commit Message: stratum: parse_notify(): Don't die on malformed bbversion/prev_hash/nbit/ntime. Might have introduced a memory leak, don't have time to check. :( Should the other hex2bin()'s be checked? Thanks to Mick Ayzenberg <mick.dejavusecurity.com> for finding this. CWE ID: CWE-20
0
36,565