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: PrintMsg_Print_Params CalculatePrintParamsForCss( blink::WebLocalFrame* frame, int page_index, const PrintMsg_Print_Params& page_params, bool ignore_css_margins, bool fit_to_page, double* scale_factor) { PrintMsg_Print_Params css_params = GetCssPrintParams(frame, page_index, page_params); PrintMsg_Print_Params params = page_params; EnsureOrientationMatches(css_params, &params); params.content_size = ScaleAndRoundSize(params.content_size, *scale_factor); if (ignore_css_margins && fit_to_page) return params; PrintMsg_Print_Params result_params = css_params; bool scale = !params.print_to_pdf; double page_scaling = scale ? *scale_factor : 1.0f; if (!fit_to_page) { result_params.page_size = ScaleAndRoundSize(result_params.page_size, page_scaling); } if (ignore_css_margins) { params.margin_left = ScaleAndRound(params.margin_left, page_scaling); params.margin_top = ScaleAndRound(params.margin_top, page_scaling); params.page_size = ScaleAndRoundSize(params.page_size, page_scaling); result_params.margin_top = params.margin_top; result_params.margin_left = params.margin_left; DCHECK(!fit_to_page); int default_margin_right = params.page_size.width() - params.content_size.width() - params.margin_left; int default_margin_bottom = params.page_size.height() - params.content_size.height() - params.margin_top; result_params.content_size = gfx::Size(result_params.page_size.width() - result_params.margin_left - default_margin_right, result_params.page_size.height() - result_params.margin_top - default_margin_bottom); } else { result_params.content_size = ScaleAndRoundSize(result_params.content_size, *scale_factor); if (fit_to_page) { double factor = FitPrintParamsToPage(params, &result_params); if (scale_factor) *scale_factor *= factor; } else { result_params.margin_left = ScaleAndRound(result_params.margin_left, page_scaling); result_params.margin_top = ScaleAndRound(result_params.margin_top, page_scaling); } } return result_params; } Commit Message: Correct mojo::WrapSharedMemoryHandle usage Fixes some incorrect uses of mojo::WrapSharedMemoryHandle which were assuming that the call actually has any control over the memory protection applied to a handle when mapped. Where fixing usage is infeasible for this CL, TODOs are added to annotate follow-up work. Also updates the API and documentation to (hopefully) improve clarity and avoid similar mistakes from being made in the future. BUG=792900 Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Change-Id: I0578aaa9ca3bfcb01aaf2451315d1ede95458477 Reviewed-on: https://chromium-review.googlesource.com/818282 Reviewed-by: Wei Li <weili@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: John Abd-El-Malek <jam@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org> Reviewed-by: Yuzhu Shen <yzshen@chromium.org> Reviewed-by: Robert Sesek <rsesek@chromium.org> Commit-Queue: Ken Rockot <rockot@chromium.org> Cr-Commit-Position: refs/heads/master@{#530268} CWE ID: CWE-787
0
149,071
Analyze the following 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 SSLManager::Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { switch (type) { case content::NOTIFICATION_RESOURCE_RESPONSE_STARTED: DidStartResourceResponse( content::Details<ResourceRequestDetails>(details).ptr()); break; case content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT: DidReceiveResourceRedirect( content::Details<ResourceRedirectDetails>(details).ptr()); break; case content::NOTIFICATION_LOAD_FROM_MEMORY_CACHE: DidLoadFromMemoryCache( content::Details<LoadFromMemoryCacheDetails>(details).ptr()); break; case content::NOTIFICATION_SSL_INTERNAL_STATE_CHANGED: DidChangeSSLInternalState(); break; default: NOTREACHED() << "The SSLManager received an unexpected notification."; } } Commit Message: Inherits SupportsWeakPtr<T> instead of having WeakPtrFactory<T> This change refines r137676. BUG=122654 TEST=browser_test Review URL: https://chromiumcodereview.appspot.com/10332233 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139771 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-119
0
107,953
Analyze the following 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 ebt_unregister_table(struct net *net, struct ebt_table *table, const struct nf_hook_ops *ops) { if (ops) nf_unregister_net_hooks(net, ops, hweight32(table->valid_hooks)); __ebt_unregister_table(net, table); } Commit Message: netfilter: ebtables: CONFIG_COMPAT: don't trust userland offsets We need to make sure the offsets are not out of range of the total size. Also check that they are in ascending order. The WARN_ON triggered by syzkaller (it sets panic_on_warn) is changed to also bail out, no point in continuing parsing. Briefly tested with simple ruleset of -A INPUT --limit 1/s' --log plus jump to custom chains using 32bit ebtables binary. Reported-by: <syzbot+845a53d13171abf8bf29@syzkaller.appspotmail.com> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> CWE ID: CWE-787
0
84,872
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr) { const struct in6_addr *saddr; const struct in6_addr *daddr; struct sock *sk; bool delivered = false; __u8 hash; struct net *net; saddr = &ipv6_hdr(skb)->saddr; daddr = saddr + 1; hash = nexthdr & (RAW_HTABLE_SIZE - 1); read_lock(&raw_v6_hashinfo.lock); sk = sk_head(&raw_v6_hashinfo.ht[hash]); if (sk == NULL) goto out; net = dev_net(skb->dev); sk = __raw_v6_lookup(net, sk, nexthdr, daddr, saddr, IP6CB(skb)->iif); while (sk) { int filtered; delivered = true; switch (nexthdr) { case IPPROTO_ICMPV6: filtered = icmpv6_filter(sk, skb); break; #if IS_ENABLED(CONFIG_IPV6_MIP6) case IPPROTO_MH: { /* XXX: To validate MH only once for each packet, * this is placed here. It should be after checking * xfrm policy, however it doesn't. The checking xfrm * policy is placed in rawv6_rcv() because it is * required for each socket. */ mh_filter_t *filter; filter = rcu_dereference(mh_filter); filtered = filter ? (*filter)(sk, skb) : 0; break; } #endif default: filtered = 0; break; } if (filtered < 0) break; if (filtered == 0) { struct sk_buff *clone = skb_clone(skb, GFP_ATOMIC); /* Not releasing hash table! */ if (clone) { nf_reset(clone); rawv6_rcv(sk, clone); } } sk = __raw_v6_lookup(net, sk_next(sk), nexthdr, daddr, saddr, IP6CB(skb)->iif); } out: read_unlock(&raw_v6_hashinfo.lock); return delivered; } Commit Message: inet: prevent leakage of uninitialized memory to user in recv syscalls Only update *addr_len when we actually fill in sockaddr, otherwise we can return uninitialized memory from the stack to the caller in the recvfrom, recvmmsg and recvmsg syscalls. Drop the the (addr_len == NULL) checks because we only get called with a valid addr_len pointer either from sock_common_recvmsg or inet_recvmsg. If a blocking read waits on a socket which is concurrently shut down we now return zero and set msg_msgnamelen to 0. Reported-by: mpb <mpb.mail@gmail.com> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-200
0
40,185
Analyze the following 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 Clipboard::DidWriteURL(const std::string& utf8_text) { gtk_clipboard_set_text(primary_selection_, utf8_text.c_str(), utf8_text.length()); } Commit Message: Use XFixes to update the clipboard sequence number. BUG=73478 TEST=manual testing Review URL: http://codereview.chromium.org/8501002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109528 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID:
0
107,343
Analyze the following 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 eventHandlerAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Value> v8Value = info[0]; TestInterfaceNodeV8Internal::eventHandlerAttributeAttributeSetter(v8Value, info); } Commit Message: binding: Removes unused code in templates/attributes.cpp. Faking {{cpp_class}} and {{c8_class}} doesn't make sense. Probably it made sense before the introduction of virtual ScriptWrappable::wrap(). Checking the existence of window->document() doesn't seem making sense to me, and CQ tests seem passing without the check. BUG= Review-Url: https://codereview.chromium.org/2268433002 Cr-Commit-Position: refs/heads/master@{#413375} CWE ID: CWE-189
0
119,260
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void splice_from_pipe_end(struct pipe_inode_info *pipe, struct splice_desc *sd) { if (sd->need_wakeup) wakeup_pipe_writers(pipe); } Commit Message: Merge branch 'page-refs' (page ref overflow) Merge page ref overflow branch. Jann Horn reported that he can overflow the page ref count with sufficient memory (and a filesystem that is intentionally extremely slow). Admittedly it's not exactly easy. To have more than four billion references to a page requires a minimum of 32GB of kernel memory just for the pointers to the pages, much less any metadata to keep track of those pointers. Jann needed a total of 140GB of memory and a specially crafted filesystem that leaves all reads pending (in order to not ever free the page references and just keep adding more). Still, we have a fairly straightforward way to limit the two obvious user-controllable sources of page references: direct-IO like page references gotten through get_user_pages(), and the splice pipe page duplication. So let's just do that. * branch page-refs: fs: prevent page refcount overflow in pipe_buf_get mm: prevent get_user_pages() from overflowing page refcount mm: add 'try_get_page()' helper function mm: make page ref count overflow check tighter and more explicit CWE ID: CWE-416
0
96,889
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void lodepng_state_init(LodePNGState* state) { #ifdef LODEPNG_COMPILE_DECODER lodepng_decoder_settings_init(&state->decoder); #endif /*LODEPNG_COMPILE_DECODER*/ #ifdef LODEPNG_COMPILE_ENCODER lodepng_encoder_settings_init(&state->encoder); #endif /*LODEPNG_COMPILE_ENCODER*/ lodepng_color_mode_init(&state->info_raw); lodepng_info_init(&state->info_png); state->error = 1; } Commit Message: Fixed #5645: realloc return handling CWE ID: CWE-772
0
87,573
Analyze the following 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 CheckRestrictedUrls(const Extension* extension, bool block_chrome_urls) { const std::string& name = extension->name(); const GURL chrome_settings_url("chrome://settings/"); const GURL chrome_extension_url("chrome-extension://foo/bar.html"); const GURL google_url("https://www.google.com/"); const GURL self_url("chrome-extension://" + extension->id() + "/foo.html"); const GURL invalid_url("chrome-debugger://foo/bar.html"); std::string error; EXPECT_EQ(block_chrome_urls, extension->permissions_data()->IsRestrictedUrl( chrome_settings_url, &error)) << name; if (block_chrome_urls) EXPECT_EQ(manifest_errors::kCannotAccessChromeUrl, error) << name; else EXPECT_TRUE(error.empty()) << name; error.clear(); EXPECT_EQ(block_chrome_urls, extension->permissions_data()->IsRestrictedUrl( chrome_extension_url, &error)) << name; if (block_chrome_urls) EXPECT_EQ(manifest_errors::kCannotAccessExtensionUrl, error) << name; else EXPECT_TRUE(error.empty()) << name; error.clear(); EXPECT_FALSE( extension->permissions_data()->IsRestrictedUrl(google_url, &error)) << name; EXPECT_TRUE(error.empty()) << name; error.clear(); EXPECT_FALSE(extension->permissions_data()->IsRestrictedUrl(self_url, &error)) << name; EXPECT_TRUE(error.empty()) << name; error.clear(); bool allow_on_other_schemes = PermissionsData::CanExecuteScriptEverywhere( extension->id(), extension->location()); EXPECT_EQ(!allow_on_other_schemes, extension->permissions_data()->IsRestrictedUrl(invalid_url, &error)) << name; if (!allow_on_other_schemes) { EXPECT_EQ(ErrorUtils::FormatErrorMessage( manifest_errors::kCannotAccessPage, invalid_url.spec()), error) << name; } else { EXPECT_TRUE(error.empty()); } } Commit Message: Call CanCaptureVisiblePage in page capture API. Currently the pageCapture permission allows access to arbitrary local files and chrome:// pages which can be a security concern. In order to address this, the page capture API needs to be changed similar to the captureVisibleTab API. The API will now only allow extensions to capture otherwise-restricted URLs if the user has granted activeTab. In addition, file:// URLs are only capturable with the "Allow on file URLs" option enabled. Bug: 893087 Change-Id: I6d6225a3efb70fc033e2e1c031c633869afac624 Reviewed-on: https://chromium-review.googlesource.com/c/1330689 Commit-Queue: Bettina Dea <bdea@chromium.org> Reviewed-by: Devlin <rdevlin.cronin@chromium.org> Reviewed-by: Varun Khaneja <vakh@chromium.org> Cr-Commit-Position: refs/heads/master@{#615248} CWE ID: CWE-20
0
151,562
Analyze the following 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 GLES2DecoderImpl::DoTexParameterf( GLenum target, GLenum pname, GLfloat param) { TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); if (!info) { SetGLError(GL_INVALID_VALUE, "glTexParameterf", "unknown texture"); return; } if (!texture_manager()->SetParameter( info, pname, static_cast<GLint>(param))) { SetGLErrorInvalidEnum("glTexParameterf", pname, "pname"); return; } glTexParameterf(target, pname, param); } Commit Message: Fix SafeAdd and SafeMultiply BUG=145648,145544 Review URL: https://chromiumcodereview.appspot.com/10916165 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155478 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-189
0
103,556
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int entersafe_select_aid(sc_card_t *card, const sc_path_t *in_path, sc_file_t **file_out) { int r = 0; if (card->cache.valid && card->cache.current_path.type == SC_PATH_TYPE_DF_NAME && card->cache.current_path.len == in_path->len && memcmp(card->cache.current_path.value, in_path->value, in_path->len)==0 ) { if(file_out) { *file_out = sc_file_new(); if(!file_out) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY); } } else { r = iso_ops->select_file(card,in_path,file_out); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); /* update cache */ card->cache.current_path.type = SC_PATH_TYPE_DF_NAME; card->cache.current_path.len = in_path->len; memcpy(card->cache.current_path.value,in_path->value,in_path->len); } if (file_out) { sc_file_t *file = *file_out; assert(file); file->type = SC_FILE_TYPE_DF; file->ef_structure = SC_FILE_EF_UNKNOWN; file->path.len = 0; file->size = 0; /* AID */ memcpy(file->name,in_path->value,in_path->len); file->namelen = in_path->len; file->id = 0x0000; } SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r); } Commit Message: fixed out of bounds reads Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting and suggesting security fixes. CWE ID: CWE-125
0
78,355
Analyze the following 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 DiscardableSharedMemoryManager::OnPurgeMemory() { base::AutoLock lock(lock_); ReduceMemoryUsageUntilWithinLimit(0); } Commit Message: Correct mojo::WrapSharedMemoryHandle usage Fixes some incorrect uses of mojo::WrapSharedMemoryHandle which were assuming that the call actually has any control over the memory protection applied to a handle when mapped. Where fixing usage is infeasible for this CL, TODOs are added to annotate follow-up work. Also updates the API and documentation to (hopefully) improve clarity and avoid similar mistakes from being made in the future. BUG=792900 Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Change-Id: I0578aaa9ca3bfcb01aaf2451315d1ede95458477 Reviewed-on: https://chromium-review.googlesource.com/818282 Reviewed-by: Wei Li <weili@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: John Abd-El-Malek <jam@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org> Reviewed-by: Yuzhu Shen <yzshen@chromium.org> Reviewed-by: Robert Sesek <rsesek@chromium.org> Commit-Queue: Ken Rockot <rockot@chromium.org> Cr-Commit-Position: refs/heads/master@{#530268} CWE ID: CWE-787
0
149,058
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: update_info_media_detection (Device *device) { gboolean detected; gboolean polling; gboolean inhibitable; gboolean inhibited; detected = FALSE; polling = FALSE; inhibitable = FALSE; inhibited = FALSE; if (device->priv->device_is_removable) { guint64 evt_media_change; GUdevDevice *parent; evt_media_change = sysfs_get_uint64 (device->priv->native_path, "../../evt_media_change"); if (evt_media_change & 1) { /* SATA AN capabable drive */ polling = FALSE; detected = TRUE; goto determined; } parent = g_udev_device_get_parent_with_subsystem (device->priv->d, "platform", NULL); if (parent != NULL) { /* never poll PC floppy drives, they are noisy (fdo #22149) */ if (g_str_has_prefix (g_udev_device_get_name (parent), "floppy.")) { g_object_unref (parent); goto determined; } g_object_unref (parent); } /* assume the device needs polling */ polling = TRUE; inhibitable = TRUE; /* custom udev rules might want to disable polling for known-broken * devices (fdo #26508) */ if (g_udev_device_has_property (device->priv->d, "UDISKS_DISABLE_POLLING") && g_udev_device_get_property_as_boolean (device->priv->d, "UDISKS_DISABLE_POLLING")) polling = FALSE; if (device->priv->polling_inhibitors != NULL || daemon_local_has_polling_inhibitors (device->priv->daemon)) { detected = FALSE; inhibited = TRUE; } else { detected = TRUE; inhibited = FALSE; } } determined: device_set_device_is_media_change_detected (device, detected); device_set_device_is_media_change_detection_polling (device, polling); device_set_device_is_media_change_detection_inhibitable (device, inhibitable); device_set_device_is_media_change_detection_inhibited (device, inhibited); return TRUE; } Commit Message: CWE ID: CWE-200
0
11,849
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ResourceDispatcherHostImpl::GetOutstandingRequestsStats( const ResourceRequestInfoImpl& info) { auto entry = outstanding_requests_stats_map_.find(info.GetChildID()); OustandingRequestsStats stats = { 0, 0 }; if (entry != outstanding_requests_stats_map_.end()) stats = entry->second; return stats; } Commit Message: When turning a download into a navigation, navigate the right frame Code changes from Nate Chapin <japhet@chromium.org> Bug: 926105 Change-Id: I098599394e6ebe7d2fce5af838014297a337d294 Reviewed-on: https://chromium-review.googlesource.com/c/1454962 Reviewed-by: Camille Lamy <clamy@chromium.org> Commit-Queue: Jochen Eisinger <jochen@chromium.org> Cr-Commit-Position: refs/heads/master@{#629547} CWE ID: CWE-284
0
152,012
Analyze the following 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 AttachRequestBodyBlobDataHandles( ResourceRequestBody* body, storage::BlobStorageContext* blob_context) { DCHECK(blob_context); for (size_t i = 0; i < body->elements()->size(); ++i) { const ResourceRequestBody::Element& element = (*body->elements())[i]; if (element.type() != ResourceRequestBody::Element::TYPE_BLOB) continue; scoped_ptr<storage::BlobDataHandle> handle = blob_context->GetBlobDataFromUUID(element.blob_uuid()); DCHECK(handle); if (!handle) continue; const void* key = handle.get(); body->SetUserData(key, handle.release()); } } Commit Message: Block a compromised renderer from reusing request ids. BUG=578882 Review URL: https://codereview.chromium.org/1608573002 Cr-Commit-Position: refs/heads/master@{#372547} CWE ID: CWE-362
0
132,795
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: cmd_http_accept(CMD_ARGS) { struct http *hp; (void)cmd; (void)vl; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); AZ(av[1]); assert(hp->sfd != NULL); assert(*hp->sfd >= 0); if (hp->fd >= 0) VTCP_close(&hp->fd); vtc_log(vl, 4, "Accepting"); hp->fd = accept(*hp->sfd, NULL, NULL); if (hp->fd < 0) vtc_log(vl, hp->fatal, "Accepted failed: %s", strerror(errno)); vtc_log(vl, 3, "Accepted socket fd is %d", hp->fd); } Commit Message: Do not consider a CR by itself as a valid line terminator Varnish (prior to version 4.0) was not following the standard with regard to line separator. Spotted and analyzed by: Régis Leroy [regilero] regis.leroy@makina-corpus.com CWE ID:
0
95,016
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: SMB2_logoff(const unsigned int xid, struct cifs_ses *ses) { struct smb2_logoff_req *req; /* response is also trivial struct */ int rc = 0; struct TCP_Server_Info *server; cifs_dbg(FYI, "disconnect session %p\n", ses); if (ses && (ses->server)) server = ses->server; else return -EIO; /* no need to send SMB logoff if uid already closed due to reconnect */ if (ses->need_reconnect) goto smb2_session_already_dead; rc = small_smb2_init(SMB2_LOGOFF, NULL, (void **) &req); if (rc) return rc; /* since no tcon, smb2_init can not do this, so do here */ req->hdr.SessionId = ses->Suid; if (server->sign) req->hdr.Flags |= SMB2_FLAGS_SIGNED; rc = SendReceiveNoRsp(xid, ses, (char *) &req->hdr, 0); /* * No tcon so can't do * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]); */ smb2_session_already_dead: return rc; } Commit Message: [CIFS] Possible null ptr deref in SMB2_tcon As Raphael Geissert pointed out, tcon_error_exit can dereference tcon and there is one path in which tcon can be null. Signed-off-by: Steve French <smfrench@gmail.com> CC: Stable <stable@vger.kernel.org> # v3.7+ Reported-by: Raphael Geissert <geissert@debian.org> CWE ID: CWE-399
0
35,977
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: createCroppedImage(struct image_data *image, struct crop_mask *crop, unsigned char **read_buff_ptr, unsigned char **crop_buff_ptr) { tsize_t cropsize; unsigned char *read_buff = NULL; unsigned char *crop_buff = NULL; unsigned char *new_buff = NULL; static tsize_t prev_cropsize = 0; read_buff = *read_buff_ptr; /* process full image, no crop buffer needed */ crop_buff = read_buff; *crop_buff_ptr = read_buff; crop->combined_width = image->width; crop->combined_length = image->length; cropsize = crop->bufftotal; crop_buff = *crop_buff_ptr; if (!crop_buff) { crop_buff = (unsigned char *)_TIFFmalloc(cropsize); *crop_buff_ptr = crop_buff; _TIFFmemset(crop_buff, 0, cropsize); prev_cropsize = cropsize; } else { if (prev_cropsize < cropsize) { new_buff = _TIFFrealloc(crop_buff, cropsize); if (!new_buff) { free (crop_buff); crop_buff = (unsigned char *)_TIFFmalloc(cropsize); } else crop_buff = new_buff; _TIFFmemset(crop_buff, 0, cropsize); } } if (!crop_buff) { TIFFError("createCroppedImage", "Unable to allocate/reallocate crop buffer"); return (-1); } *crop_buff_ptr = crop_buff; if (crop->crop_mode & CROP_INVERT) { switch (crop->photometric) { /* Just change the interpretation */ case PHOTOMETRIC_MINISWHITE: case PHOTOMETRIC_MINISBLACK: image->photometric = crop->photometric; break; case INVERT_DATA_ONLY: case INVERT_DATA_AND_TAG: if (invertImage(image->photometric, image->spp, image->bps, crop->combined_width, crop->combined_length, crop_buff)) { TIFFError("createCroppedImage", "Failed to invert colorspace for image or cropped selection"); return (-1); } if (crop->photometric == INVERT_DATA_AND_TAG) { switch (image->photometric) { case PHOTOMETRIC_MINISWHITE: image->photometric = PHOTOMETRIC_MINISBLACK; break; case PHOTOMETRIC_MINISBLACK: image->photometric = PHOTOMETRIC_MINISWHITE; break; default: break; } } break; default: break; } } if (crop->crop_mode & CROP_MIRROR) { if (mirrorImage(image->spp, image->bps, crop->mirror, crop->combined_width, crop->combined_length, crop_buff)) { TIFFError("createCroppedImage", "Failed to mirror image or cropped selection %s", (crop->rotation == MIRROR_HORIZ) ? "horizontally" : "vertically"); return (-1); } } if (crop->crop_mode & CROP_ROTATE) /* rotate should be last as it can reallocate the buffer */ { if (rotateImage(crop->rotation, image, &crop->combined_width, &crop->combined_length, crop_buff_ptr)) { TIFFError("createCroppedImage", "Failed to rotate image or cropped selection by %d degrees", crop->rotation); return (-1); } } if (crop_buff == read_buff) /* we used the read buffer for the crop buffer */ *read_buff_ptr = NULL; /* so we don't try to free it later */ return (0); } /* end createCroppedImage */ Commit Message: * tools/tiffcrop.c: fix out-of-bound read of up to 3 bytes in readContigTilesIntoBuffer(). Reported as MSVR 35092 by Axel Souchet & Vishal Chauhan from the MSRC Vulnerabilities & Mitigations team. CWE ID: CWE-125
0
48,236
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int get_name_from_EF_DatiPersonali(unsigned char *EFdata, char name[], int name_len) { /* * Bytes 0-5 contain the ASCII encoding of the following TLV * structure's total size, in base 16. */ const unsigned int EF_personaldata_maxlen = 400; const unsigned int tlv_length_size = 6; char *file = (char*)&EFdata[tlv_length_size]; int file_size = hextoint((char*)EFdata, tlv_length_size); enum { f_issuer_code = 0, f_issuing_date, f_expiry_date, f_last_name, f_first_name, f_birth_date, f_sex, f_height, f_codice_fiscale, f_citizenship_code, f_birth_township_code, f_birth_country, f_birth_certificate, f_residence_township_code, f_residence_address, f_expat_notes }; /* Read the fields up to f_first_name */ struct { int len; char value[256]; } fields[f_first_name+1]; int i=0; /* offset inside the file */ int f; /* field number */ if(file_size < 0) return -1; /* * This shouldn't happen, but let us be protected against wrong * or malicious cards */ if(file_size > (int)EF_personaldata_maxlen - (int)tlv_length_size) file_size = EF_personaldata_maxlen - tlv_length_size; memset(fields, 0, sizeof(fields)); for(f=0; f<f_first_name+1; f++) { int field_size; /* Don't read beyond the allocated buffer */ if(i > file_size) return -1; field_size = hextoint((char*) &file[i], 2); if((field_size < 0) || (field_size+i > file_size)) return -1; i += 2; if(field_size >= (int)sizeof(fields[f].value)) return -1; fields[f].len = field_size; strncpy(fields[f].value, &file[i], field_size); fields[f].value[field_size] = '\0'; i += field_size; } if (fields[f_first_name].len + fields[f_last_name].len + 1 >= name_len) return -1; /* the lengths are already checked that they will fit in buffer */ snprintf(name, name_len, "%.*s %.*s", fields[f_first_name].len, fields[f_first_name].value, fields[f_last_name].len, fields[f_last_name].value); return 0; } Commit Message: fixed out of bounds reads Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting and suggesting security fixes. CWE ID: CWE-125
0
78,709
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int a2dp_read_audio_config(struct a2dp_stream_common *common) { char cmd = A2DP_CTRL_GET_AUDIO_CONFIG; uint32_t sample_rate; uint8_t channel_count; if (a2dp_command(common, A2DP_CTRL_GET_AUDIO_CONFIG) < 0) { ERROR("check a2dp ready failed"); return -1; } if (a2dp_ctrl_receive(common, &sample_rate, 4) < 0) return -1; if (a2dp_ctrl_receive(common, &channel_count, 1) < 0) return -1; common->cfg.channel_flags = (channel_count == 1 ? AUDIO_CHANNEL_IN_MONO : AUDIO_CHANNEL_IN_STEREO); common->cfg.format = AUDIO_STREAM_DEFAULT_FORMAT; common->cfg.rate = sample_rate; INFO("got config %d %d", common->cfg.format, common->cfg.rate); return 0; } Commit Message: DO NOT MERGE Fix potential DoS caused by delivering signal to BT process Bug: 28885210 Change-Id: I63866d894bfca47464d6e42e3fb0357c4f94d360 Conflicts: btif/co/bta_hh_co.c btif/src/btif_core.c Merge conflict resolution of ag/1161415 (referencing ag/1164670) - Directly into mnc-mr2-release CWE ID: CWE-284
0
158,451
Analyze the following 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 pop_fetch_headers(struct Context *ctx) { struct PopData *pop_data = (struct PopData *) ctx->data; struct Progress progress; #ifdef USE_HCACHE header_cache_t *hc = pop_hcache_open(pop_data, ctx->path); #endif time(&pop_data->check_time); pop_data->clear_cache = false; for (int i = 0; i < ctx->msgcount; i++) ctx->hdrs[i]->refno = -1; const int old_count = ctx->msgcount; int ret = pop_fetch_data(pop_data, "UIDL\r\n", NULL, fetch_uidl, ctx); const int new_count = ctx->msgcount; ctx->msgcount = old_count; if (pop_data->cmd_uidl == 2) { if (ret == 0) { pop_data->cmd_uidl = 1; mutt_debug(1, "set UIDL capability\n"); } if (ret == -2 && pop_data->cmd_uidl == 2) { pop_data->cmd_uidl = 0; mutt_debug(1, "unset UIDL capability\n"); snprintf(pop_data->err_msg, sizeof(pop_data->err_msg), "%s", _("Command UIDL is not supported by server.")); } } if (!ctx->quiet) { mutt_progress_init(&progress, _("Fetching message headers..."), MUTT_PROGRESS_MSG, ReadInc, new_count - old_count); } if (ret == 0) { int i, deleted; for (i = 0, deleted = 0; i < old_count; i++) { if (ctx->hdrs[i]->refno == -1) { ctx->hdrs[i]->deleted = true; deleted++; } } if (deleted > 0) { mutt_error( ngettext("%d message has been lost. Try reopening the mailbox.", "%d messages have been lost. Try reopening the mailbox.", deleted), deleted); } bool hcached = false; for (i = old_count; i < new_count; i++) { if (!ctx->quiet) mutt_progress_update(&progress, i + 1 - old_count, -1); #ifdef USE_HCACHE void *data = mutt_hcache_fetch(hc, ctx->hdrs[i]->data, strlen(ctx->hdrs[i]->data)); if (data) { char *uidl = mutt_str_strdup(ctx->hdrs[i]->data); int refno = ctx->hdrs[i]->refno; int index = ctx->hdrs[i]->index; /* * - POP dynamically numbers headers and relies on h->refno * to map messages; so restore header and overwrite restored * refno with current refno, same for index * - h->data needs to a separate pointer as it's driver-specific * data freed separately elsewhere * (the old h->data should point inside a malloc'd block from * hcache so there shouldn't be a memleak here) */ struct Header *h = mutt_hcache_restore((unsigned char *) data); mutt_hcache_free(hc, &data); mutt_header_free(&ctx->hdrs[i]); ctx->hdrs[i] = h; ctx->hdrs[i]->refno = refno; ctx->hdrs[i]->index = index; ctx->hdrs[i]->data = uidl; ret = 0; hcached = true; } else #endif if ((ret = pop_read_header(pop_data, ctx->hdrs[i])) < 0) break; #ifdef USE_HCACHE else { mutt_hcache_store(hc, ctx->hdrs[i]->data, strlen(ctx->hdrs[i]->data), ctx->hdrs[i], 0); } #endif /* * faked support for flags works like this: * - if 'hcached' is true, we have the message in our hcache: * - if we also have a body: read * - if we don't have a body: old * (if $mark_old is set which is maybe wrong as * $mark_old should be considered for syncing the * folder and not when opening it XXX) * - if 'hcached' is false, we don't have the message in our hcache: * - if we also have a body: read * - if we don't have a body: new */ const bool bcached = (mutt_bcache_exists(pop_data->bcache, ctx->hdrs[i]->data) == 0); ctx->hdrs[i]->old = false; ctx->hdrs[i]->read = false; if (hcached) { if (bcached) ctx->hdrs[i]->read = true; else if (MarkOld) ctx->hdrs[i]->old = true; } else { if (bcached) ctx->hdrs[i]->read = true; } ctx->msgcount++; } if (i > old_count) mx_update_context(ctx, i - old_count); } #ifdef USE_HCACHE mutt_hcache_close(hc); #endif if (ret < 0) { for (int i = ctx->msgcount; i < new_count; i++) mutt_header_free(&ctx->hdrs[i]); return ret; } /* after putting the result into our structures, * clean up cache, i.e. wipe messages deleted outside * the availability of our cache */ if (MessageCacheClean) mutt_bcache_list(pop_data->bcache, msg_cache_check, (void *) ctx); mutt_clear_error(); return (new_count - old_count); } Commit Message: sanitise cache paths Co-authored-by: JerikoOne <jeriko.one@gmx.us> CWE ID: CWE-22
1
169,121
Analyze the following 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 SiteInstanceImpl::HasRelatedSiteInstance(const GURL& url) { return browsing_instance_->HasSiteInstance(url); } 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,508
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: NodeIterator* Document::createNodeIterator(Node* root, unsigned what_to_show, V8NodeFilterCondition* filter) { DCHECK(root); return NodeIterator::Create(root, what_to_show, filter); } Commit Message: Inherit CSP when we inherit the security origin This prevents attacks that use main window navigation to get out of the existing csp constraints such as the related bug Bug: 747847 Change-Id: I1e57b50da17f65d38088205b0a3c7c49ef2ae4d8 Reviewed-on: https://chromium-review.googlesource.com/592027 Reviewed-by: Mike West <mkwst@chromium.org> Commit-Queue: Andy Paicu <andypaicu@chromium.org> Cr-Commit-Position: refs/heads/master@{#492333} CWE ID: CWE-732
0
134,213
Analyze the following 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 samldb_next_step(struct samldb_ctx *ac) { if (ac->curstep->next) { ac->curstep = ac->curstep->next; return ac->curstep->fn(ac); } /* We exit the samldb module here. If someone set an "ares" to forward * controls and response back to the caller, use them. */ if (ac->ares) { return ldb_module_done(ac->req, ac->ares->controls, ac->ares->response, LDB_SUCCESS); } else { return ldb_module_done(ac->req, NULL, NULL, LDB_SUCCESS); } } Commit Message: CWE ID: CWE-264
0
16
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: SPL_ARRAY_METHOD(Array, asort, SPL_ARRAY_METHOD_MAY_USER_ARG) /* }}} */ /* {{{ proto int ArrayObject::ksort([int $sort_flags = SORT_REGULAR ]) Commit Message: Fix bug #73029 - Missing type check when unserializing SplArray CWE ID: CWE-20
0
49,850
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void TemplateURL::ResizeURLRefVector() { const size_t new_size = data_.alternate_urls.size() + 1; if (url_refs_.size() == new_size) return; url_refs_.clear(); url_refs_.reserve(new_size); for (size_t i = 0; i != data_.alternate_urls.size(); ++i) url_refs_.emplace_back(this, i); url_refs_.emplace_back(this, TemplateURLRef::SEARCH); url_ref_ = &url_refs_.back(); } Commit Message: [Contextual Search] Change "Now on Tap" to "Contextual Cards" BUG=644934 Review-Url: https://codereview.chromium.org/2361163003 Cr-Commit-Position: refs/heads/master@{#420899} CWE ID:
0
120,308
Analyze the following 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 vmmcall_interception(struct vcpu_svm *svm) { svm->next_rip = kvm_rip_read(&svm->vcpu) + 3; skip_emulated_instruction(&svm->vcpu); kvm_emulate_hypercall(&svm->vcpu); return 1; } Commit Message: KVM: x86: Check non-canonical addresses upon WRMSR Upon WRMSR, the CPU should inject #GP if a non-canonical value (address) is written to certain MSRs. The behavior is "almost" identical for AMD and Intel (ignoring MSRs that are not implemented in either architecture since they would anyhow #GP). However, IA32_SYSENTER_ESP and IA32_SYSENTER_EIP cause #GP if non-canonical address is written on Intel but not on AMD (which ignores the top 32-bits). Accordingly, this patch injects a #GP on the MSRs which behave identically on Intel and AMD. To eliminate the differences between the architecutres, the value which is written to IA32_SYSENTER_ESP and IA32_SYSENTER_EIP is turned to canonical value before writing instead of injecting a #GP. Some references from Intel and AMD manuals: According to Intel SDM description of WRMSR instruction #GP is expected on WRMSR "If the source register contains a non-canonical address and ECX specifies one of the following MSRs: IA32_DS_AREA, IA32_FS_BASE, IA32_GS_BASE, IA32_KERNEL_GS_BASE, IA32_LSTAR, IA32_SYSENTER_EIP, IA32_SYSENTER_ESP." According to AMD manual instruction manual: LSTAR/CSTAR (SYSCALL): "The WRMSR instruction loads the target RIP into the LSTAR and CSTAR registers. If an RIP written by WRMSR is not in canonical form, a general-protection exception (#GP) occurs." IA32_GS_BASE and IA32_FS_BASE (WRFSBASE/WRGSBASE): "The address written to the base field must be in canonical form or a #GP fault will occur." IA32_KERNEL_GS_BASE (SWAPGS): "The address stored in the KernelGSbase MSR must be in canonical form." This patch fixes CVE-2014-3610. Cc: stable@vger.kernel.org Signed-off-by: Nadav Amit <namit@cs.technion.ac.il> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> CWE ID: CWE-264
0
37,926
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: xsltShutdownExt(xsltExtDataPtr data, xsltStylesheetPtr style, const xmlChar * URI) { xsltExtModulePtr module; if ((data == NULL) || (style == NULL) || (URI == NULL)) return; module = data->extModule; if ((module == NULL) || (module->styleShutdownFunc == NULL)) return; #ifdef WITH_XSLT_DEBUG_EXTENSIONS xsltGenericDebug(xsltGenericDebugContext, "Shutting down module : %s\n", URI); #endif module->styleShutdownFunc(style, URI, data->extData); /* * Don't remove the entry from the hash table here, since * this will produce segfaults - this fixes bug #340624. * * xmlHashRemoveEntry(style->extInfos, URI, * (xmlHashDeallocator) xsltFreeExtData); */ } Commit Message: Roll libxslt to 891681e3e948f31732229f53cb6db7215f740fc7 BUG=583156,583171 Review URL: https://codereview.chromium.org/1853083002 Cr-Commit-Position: refs/heads/master@{#385338} CWE ID: CWE-119
0
156,714
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: launch_location_free (LaunchLocation *location) { nautilus_file_unref (location->file); g_free (location->uri); g_free (location); } Commit Message: mime-actions: use file metadata for trusting desktop files Currently we only trust desktop files that have the executable bit set, and don't replace the displayed icon or the displayed name until it's trusted, which prevents for running random programs by a malicious desktop file. However, the executable permission is preserved if the desktop file comes from a compressed file. To prevent this, add a metadata::trusted metadata to the file once the user acknowledges the file as trusted. This adds metadata to the file, which cannot be added unless it has access to the computer. Also remove the SHEBANG "trusted" content we were putting inside the desktop file, since that doesn't add more security since it can come with the file itself. https://bugzilla.gnome.org/show_bug.cgi?id=777991 CWE ID: CWE-20
0
61,191
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: PHP_FUNCTION(openssl_public_decrypt) { zval **key, *crypted; EVP_PKEY *pkey; int cryptedlen; unsigned char *cryptedbuf = NULL; unsigned char *crypttemp; int successful = 0; long keyresource = -1; long padding = RSA_PKCS1_PADDING; char * data; int data_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szZ|l", &data, &data_len, &crypted, &key, &padding) == FAILURE) { return; } RETVAL_FALSE; pkey = php_openssl_evp_from_zval(key, 1, NULL, 0, &keyresource TSRMLS_CC); if (pkey == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "key parameter is not a valid public key"); RETURN_FALSE; } cryptedlen = EVP_PKEY_size(pkey); crypttemp = emalloc(cryptedlen + 1); switch (pkey->type) { case EVP_PKEY_RSA: case EVP_PKEY_RSA2: cryptedlen = RSA_public_decrypt(data_len, (unsigned char *)data, crypttemp, pkey->pkey.rsa, padding); if (cryptedlen != -1) { cryptedbuf = emalloc(cryptedlen + 1); memcpy(cryptedbuf, crypttemp, cryptedlen); successful = 1; } break; default: php_error_docref(NULL TSRMLS_CC, E_WARNING, "key type not supported in this PHP build!"); } efree(crypttemp); if (successful) { zval_dtor(crypted); cryptedbuf[cryptedlen] = '\0'; ZVAL_STRINGL(crypted, (char *)cryptedbuf, cryptedlen, 0); cryptedbuf = NULL; RETVAL_TRUE; } if (cryptedbuf) { efree(cryptedbuf); } if (keyresource == -1) { EVP_PKEY_free(pkey); } } Commit Message: CWE ID: CWE-119
0
125
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void ChromeContentRendererClient::RenderViewCreated( content::RenderView* render_view) { ContentSettingsObserver* content_settings = new ContentSettingsObserver(render_view); if (chrome_observer_.get()) { content_settings->SetContentSettingRules( chrome_observer_->content_setting_rules()); } new ExtensionHelper(render_view, extension_dispatcher_.get()); new PageLoadHistograms(render_view, histogram_snapshots_.get()); new PrintWebViewHelper(render_view); new SearchBox(render_view); new SpellCheckProvider(render_view, this); #if defined(ENABLE_SAFE_BROWSING) safe_browsing::MalwareDOMDetails::Create(render_view); #endif PasswordAutofillManager* password_autofill_manager = new PasswordAutofillManager(render_view); AutofillAgent* autofill_agent = new AutofillAgent(render_view, password_autofill_manager); PageClickTracker* page_click_tracker = new PageClickTracker(render_view); page_click_tracker->AddListener(password_autofill_manager); page_click_tracker->AddListener(autofill_agent); TranslateHelper* translate = new TranslateHelper(render_view); new ChromeRenderViewObserver( render_view, content_settings, chrome_observer_.get(), extension_dispatcher_.get(), translate); if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kDomAutomationController)) { new AutomationRendererHelper(render_view); } if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnablePasswordGeneration)) { new PasswordGenerationManager(render_view); } } Commit Message: Do not require DevTools extension resources to be white-listed in manifest. Currently, resources used by DevTools extensions need to be white-listed as web_accessible_resources in manifest. This is quite inconvenitent and appears to be an overkill, given the fact that DevTools front-end is (a) trusted and (b) picky on the frames it loads. This change adds resources that belong to DevTools extensions and are being loaded into a DevTools front-end page to the list of exceptions from web_accessible_resources check. BUG=none TEST=DevToolsExtensionTest.* Review URL: https://chromiumcodereview.appspot.com/9663076 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126378 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-119
0
108,153
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int do_fetch_class_prepare(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ { zend_class_entry * ce = stmt->fetch.cls.ce; zend_fcall_info * fci = &stmt->fetch.cls.fci; zend_fcall_info_cache * fcc = &stmt->fetch.cls.fcc; fci->size = sizeof(zend_fcall_info); if (!ce) { stmt->fetch.cls.ce = ZEND_STANDARD_CLASS_DEF_PTR; ce = ZEND_STANDARD_CLASS_DEF_PTR; } if (ce->constructor) { fci->function_table = &ce->function_table; fci->function_name = NULL; fci->symbol_table = NULL; fci->retval_ptr_ptr = &stmt->fetch.cls.retval_ptr; fci->params = NULL; fci->no_separation = 1; zend_fcall_info_args(fci, stmt->fetch.cls.ctor_args TSRMLS_CC); fcc->initialized = 1; fcc->function_handler = ce->constructor; fcc->calling_scope = EG(scope); fcc->called_scope = ce; return 1; } else if (stmt->fetch.cls.ctor_args) { pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied class does not have a constructor, use NULL for the ctor_params parameter, or simply omit it" TSRMLS_CC); return 0; } else { return 1; /* no ctor no args is also ok */ } } /* }}} */ Commit Message: Fix bug #73331 - do not try to serialize/unserialize objects wddx can not handle Proper soltion would be to call serialize/unserialize and deal with the result, but this requires more work that should be done by wddx maintainer (not me). CWE ID: CWE-476
0
72,414
Analyze the following 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_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode, unsigned, dev) { struct dentry *dentry; struct path path; int error; unsigned int lookup_flags = 0; error = may_mknod(mode); if (error) return error; retry: dentry = user_path_create(dfd, filename, &path, lookup_flags); if (IS_ERR(dentry)) return PTR_ERR(dentry); if (!IS_POSIXACL(path.dentry->d_inode)) mode &= ~current_umask(); error = security_path_mknod(&path, dentry, mode, dev); if (error) goto out; switch (mode & S_IFMT) { case 0: case S_IFREG: error = vfs_create(path.dentry->d_inode,dentry,mode,true); if (!error) ima_post_path_mknod(dentry); break; case S_IFCHR: case S_IFBLK: error = vfs_mknod(path.dentry->d_inode,dentry,mode, new_decode_dev(dev)); break; case S_IFIFO: case S_IFSOCK: error = vfs_mknod(path.dentry->d_inode,dentry,mode,0); break; } out: done_path_create(&path, dentry); if (retry_estale(error, lookup_flags)) { lookup_flags |= LOOKUP_REVAL; goto retry; } return error; } Commit Message: dentry name snapshots take_dentry_name_snapshot() takes a safe snapshot of dentry name; if the name is a short one, it gets copied into caller-supplied structure, otherwise an extra reference to external name is grabbed (those are never modified). In either case the pointer to stable string is stored into the same structure. dentry must be held by the caller of take_dentry_name_snapshot(), but may be freely dropped afterwards - the snapshot will stay until destroyed by release_dentry_name_snapshot(). Intended use: struct name_snapshot s; take_dentry_name_snapshot(&s, dentry); ... access s.name ... release_dentry_name_snapshot(&s); Replaces fsnotify_oldname_...(), gets used in fsnotify to obtain the name to pass down with event. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> CWE ID: CWE-362
0
67,407
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void WebContentsImpl::DidNavigateMainFramePreCommit( bool navigation_is_within_page) { if (navigation_is_within_page) { return; } if (IsFullscreenForCurrentTab()) ExitFullscreen(false); DCHECK(!IsFullscreenForCurrentTab()); } Commit Message: If JavaScript shows a dialog, cause the page to lose fullscreen. BUG=670135, 550017, 726761, 728276 Review-Url: https://codereview.chromium.org/2906133004 Cr-Commit-Position: refs/heads/master@{#478884} CWE ID: CWE-20
0
135,673
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool fuse_request_queue_background(struct fuse_conn *fc, struct fuse_req *req) { bool queued = false; WARN_ON(!test_bit(FR_BACKGROUND, &req->flags)); if (!test_bit(FR_WAITING, &req->flags)) { __set_bit(FR_WAITING, &req->flags); atomic_inc(&fc->num_waiting); } __set_bit(FR_ISREPLY, &req->flags); spin_lock(&fc->bg_lock); if (likely(fc->connected)) { fc->num_background++; if (fc->num_background == fc->max_background) fc->blocked = 1; if (fc->num_background == fc->congestion_threshold && fc->sb) { set_bdi_congested(fc->sb->s_bdi, BLK_RW_SYNC); set_bdi_congested(fc->sb->s_bdi, BLK_RW_ASYNC); } list_add_tail(&req->list, &fc->bg_queue); flush_bg_queue(fc); queued = true; } spin_unlock(&fc->bg_lock); return queued; } Commit Message: Merge branch 'page-refs' (page ref overflow) Merge page ref overflow branch. Jann Horn reported that he can overflow the page ref count with sufficient memory (and a filesystem that is intentionally extremely slow). Admittedly it's not exactly easy. To have more than four billion references to a page requires a minimum of 32GB of kernel memory just for the pointers to the pages, much less any metadata to keep track of those pointers. Jann needed a total of 140GB of memory and a specially crafted filesystem that leaves all reads pending (in order to not ever free the page references and just keep adding more). Still, we have a fairly straightforward way to limit the two obvious user-controllable sources of page references: direct-IO like page references gotten through get_user_pages(), and the splice pipe page duplication. So let's just do that. * branch page-refs: fs: prevent page refcount overflow in pipe_buf_get mm: prevent get_user_pages() from overflowing page refcount mm: add 'try_get_page()' helper function mm: make page ref count overflow check tighter and more explicit CWE ID: CWE-416
0
96,827
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void ContentSecurityPolicy::DidSendViolationReport(const String& report) { violation_reports_sent_.insert(report.Impl()->GetHash()); } Commit Message: Inherit the navigation initiator when navigating instead of the parent/opener Spec PR: https://github.com/w3c/webappsec-csp/pull/358 Bug: 905301, 894228, 836148 Change-Id: I43ada2266d42d1cd56dbe3c6dd89d115e878a83a Reviewed-on: https://chromium-review.googlesource.com/c/1314633 Commit-Queue: Andy Paicu <andypaicu@chromium.org> Reviewed-by: Mike West <mkwst@chromium.org> Cr-Commit-Position: refs/heads/master@{#610850} CWE ID: CWE-20
0
152,479
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: MojoResult DataPipeProducerDispatcher::AddWatcherRef( const scoped_refptr<WatcherDispatcher>& watcher, uintptr_t context) { base::AutoLock lock(lock_); if (is_closed_ || in_transit_) return MOJO_RESULT_INVALID_ARGUMENT; return watchers_.Add(watcher, context, GetHandleSignalsStateNoLock()); } Commit Message: [mojo-core] Validate data pipe endpoint metadata Ensures that we don't blindly trust specified buffer size and offset metadata when deserializing data pipe consumer and producer handles. Bug: 877182 Change-Id: I30f3eceafb5cee06284c2714d08357ef911d6fd9 Reviewed-on: https://chromium-review.googlesource.com/1192922 Reviewed-by: Reilly Grant <reillyg@chromium.org> Commit-Queue: Ken Rockot <rockot@chromium.org> Cr-Commit-Position: refs/heads/master@{#586704} CWE ID: CWE-20
0
154,397
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ofputil_encode_table_features_request(enum ofp_version ofp_version) { struct ofpbuf *request = NULL; switch (ofp_version) { case OFP10_VERSION: case OFP11_VERSION: case OFP12_VERSION: ovs_fatal(0, "dump-table-features needs OpenFlow 1.3 or later " "(\'-O OpenFlow13\')"); case OFP13_VERSION: case OFP14_VERSION: case OFP15_VERSION: case OFP16_VERSION: request = ofpraw_alloc(OFPRAW_OFPST13_TABLE_FEATURES_REQUEST, ofp_version, 0); break; default: OVS_NOT_REACHED(); } return request; } Commit Message: ofp-group: Don't assert-fail decoding bad OF1.5 group mod type or command. When decoding a group mod, the current code validates the group type and command after the whole group mod has been decoded. The OF1.5 decoder, however, tries to use the type and command earlier, when it might still be invalid. This caused an assertion failure (via OVS_NOT_REACHED). This commit fixes the problem. ovs-vswitchd does not enable support for OpenFlow 1.5 by default. Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9249 Signed-off-by: Ben Pfaff <blp@ovn.org> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com> CWE ID: CWE-617
0
77,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: int sock_get_timestampns(struct sock *sk, struct timespec __user *userstamp) { struct timespec ts; if (!sock_flag(sk, SOCK_TIMESTAMP)) sock_enable_timestamp(sk, SOCK_TIMESTAMP); ts = ktime_to_timespec(sk->sk_stamp); if (ts.tv_sec == -1) return -ENOENT; if (ts.tv_sec == 0) { sk->sk_stamp = ktime_get_real(); ts = ktime_to_timespec(sk->sk_stamp); } return copy_to_user(userstamp, &ts, sizeof(ts)) ? -EFAULT : 0; } Commit Message: net: sock: validate data_len before allocating skb in sock_alloc_send_pskb() We need to validate the number of pages consumed by data_len, otherwise frags array could be overflowed by userspace. So this patch validate data_len and return -EMSGSIZE when data_len may occupies more frags than MAX_SKB_FRAGS. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-20
0
20,167
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool Document::SetFocusedElement(Element* new_focused_element, const FocusParams& params) { DCHECK(!lifecycle_.InDetach()); clear_focused_element_timer_.Stop(); if (new_focused_element && (new_focused_element->GetDocument() != this)) return true; if (NodeChildRemovalTracker::IsBeingRemoved(new_focused_element)) return true; if (focused_element_ == new_focused_element) return true; bool focus_change_blocked = false; Element* old_focused_element = focused_element_; focused_element_ = nullptr; UpdateDistributionForFlatTreeTraversal(); Node* ancestor = (old_focused_element && old_focused_element->isConnected() && new_focused_element) ? FlatTreeTraversal::CommonAncestor(*old_focused_element, *new_focused_element) : nullptr; if (old_focused_element) { old_focused_element->SetFocused(false, params.type); old_focused_element->SetHasFocusWithinUpToAncestor(false, ancestor); if (GetPage() && (GetPage()->GetFocusController().IsFocused())) { old_focused_element->DispatchBlurEvent(new_focused_element, params.type, params.source_capabilities); if (focused_element_) { focus_change_blocked = true; new_focused_element = nullptr; } old_focused_element->DispatchFocusOutEvent(EventTypeNames::focusout, new_focused_element, params.source_capabilities); old_focused_element->DispatchFocusOutEvent(EventTypeNames::DOMFocusOut, new_focused_element, params.source_capabilities); if (focused_element_) { focus_change_blocked = true; new_focused_element = nullptr; } } } if (new_focused_element) UpdateStyleAndLayoutTreeForNode(new_focused_element); if (new_focused_element && new_focused_element->IsFocusable()) { if (IsRootEditableElement(*new_focused_element) && !AcceptsEditingFocus(*new_focused_element)) { focus_change_blocked = true; goto SetFocusedElementDone; } focused_element_ = new_focused_element; SetSequentialFocusNavigationStartingPoint(focused_element_.Get()); last_focus_type_ = params.type; focused_element_->SetFocused(true, params.type); focused_element_->SetHasFocusWithinUpToAncestor(true, ancestor); if (focused_element_ != new_focused_element) { focus_change_blocked = true; goto SetFocusedElementDone; } CancelFocusAppearanceUpdate(); UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(focused_element_); if (focused_element_ != new_focused_element) { focus_change_blocked = true; goto SetFocusedElementDone; } focused_element_->UpdateFocusAppearanceWithOptions( params.selection_behavior, params.options); if (GetPage() && (GetPage()->GetFocusController().IsFocused())) { focused_element_->DispatchFocusEvent(old_focused_element, params.type, params.source_capabilities); if (focused_element_ != new_focused_element) { focus_change_blocked = true; goto SetFocusedElementDone; } focused_element_->DispatchFocusInEvent(EventTypeNames::focusin, old_focused_element, params.type, params.source_capabilities); if (focused_element_ != new_focused_element) { focus_change_blocked = true; goto SetFocusedElementDone; } focused_element_->DispatchFocusInEvent(EventTypeNames::DOMFocusIn, old_focused_element, params.type, params.source_capabilities); if (focused_element_ != new_focused_element) { focus_change_blocked = true; goto SetFocusedElementDone; } } } if (!focus_change_blocked && focused_element_) { if (AXObjectCache* cache = GetOrCreateAXObjectCache()) { cache->HandleFocusedUIElementChanged(old_focused_element, new_focused_element); } } if (!focus_change_blocked && GetPage()) { GetPage()->GetChromeClient().FocusedNodeChanged(old_focused_element, focused_element_.Get()); } SetFocusedElementDone: UpdateStyleAndLayoutTree(); if (LocalFrame* frame = GetFrame()) frame->Selection().DidChangeFocus(); return !focus_change_blocked; } Commit Message: Prevent sandboxed documents from reusing the default window Bug: 377995 Change-Id: Iff66c6d214dfd0cb7ea9c80f83afeedfff703541 Reviewed-on: https://chromium-review.googlesource.com/983558 Commit-Queue: Andy Paicu <andypaicu@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/master@{#567663} CWE ID: CWE-285
0
154,796
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void AutofillDialogViews::SetEditabilityForSection(DialogSection section) { const DetailInputs& inputs = delegate_->RequestedFieldsForSection(section); DetailsGroup* group = GroupForSection(section); for (DetailInputs::const_iterator iter = inputs.begin(); iter != inputs.end(); ++iter) { const DetailInput& input = *iter; bool editable = delegate_->InputIsEditable(input, section); TextfieldMap::iterator text_mapping = group->textfields.find(input.type); if (text_mapping != group->textfields.end()) { ExpandingTextfield* textfield = text_mapping->second; textfield->SetEditable(editable); continue; } ComboboxMap::iterator combo_mapping = group->comboboxes.find(input.type); if (combo_mapping != group->comboboxes.end()) { views::Combobox* combobox = combo_mapping->second; combobox->SetEnabled(editable); } } } Commit Message: Clear out some minor TODOs. BUG=none Review URL: https://codereview.chromium.org/1047063002 Cr-Commit-Position: refs/heads/master@{#322959} CWE ID: CWE-20
0
110,040
Analyze the following 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 coroutine_fn pdu_complete(V9fsPDU *pdu, ssize_t len) { int8_t id = pdu->id + 1; /* Response */ V9fsState *s = pdu->s; if (len < 0) { int err = -len; len = 7; if (s->proto_version != V9FS_PROTO_2000L) { V9fsString str; str.data = strerror(err); str.size = strlen(str.data); len += pdu_marshal(pdu, len, "s", &str); id = P9_RERROR; } len += pdu_marshal(pdu, len, "d", err); if (s->proto_version == V9FS_PROTO_2000L) { id = P9_RLERROR; } trace_v9fs_rerror(pdu->tag, pdu->id, err); /* Trace ERROR */ } /* fill out the header */ pdu_marshal(pdu, 0, "dbw", (int32_t)len, id, pdu->tag); /* keep these in sync */ pdu->size = len; pdu->id = id; pdu_push_and_notify(pdu); /* Now wakeup anybody waiting in flush for this request */ if (!qemu_co_queue_next(&pdu->complete)) { pdu_free(pdu); } } Commit Message: CWE ID: CWE-400
0
7,705
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: WebContents* WebContents::CreateWithSessionStorage( const WebContents::CreateParams& params, const SessionStorageNamespaceMap& session_storage_namespace_map) { WebContentsImpl* new_contents = new WebContentsImpl( params.browser_context, NULL); for (SessionStorageNamespaceMap::const_iterator it = session_storage_namespace_map.begin(); it != session_storage_namespace_map.end(); ++it) { new_contents->GetController() .SetSessionStorageNamespace(it->first, it->second.get()); } new_contents->Init(params); return new_contents; } Commit Message: Cancel JavaScript dialogs when an interstitial appears. BUG=295695 TEST=See bug for repro steps. Review URL: https://chromiumcodereview.appspot.com/24360011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225026 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID:
0
110,583
Analyze the following 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 CrosLibrary::TestApi::SetSyslogsLibrary( SyslogsLibrary* library, bool own) { library_->syslogs_lib_.SetImpl(library, own); } Commit Message: chromeos: Replace copy-and-pasted code with macros. This replaces a bunch of duplicated-per-library cros function definitions and comments. BUG=none TEST=built it Review URL: http://codereview.chromium.org/6086007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70070 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-189
1
170,646
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static UWORD32 ihevcd_map_error(IHEVCD_ERROR_T e_error) { UWORD32 error_code = 0; error_code = e_error; switch(error_code) { case IHEVCD_SUCCESS : break; case IHEVCD_INIT_NOT_DONE: case IHEVCD_LEVEL_UNSUPPORTED: case IHEVCD_NUM_REF_UNSUPPORTED: case IHEVCD_NUM_REORDER_UNSUPPORTED: case IHEVCD_NUM_EXTRA_DISP_UNSUPPORTED: case IHEVCD_INSUFFICIENT_MEM_MVBANK: case IHEVCD_INSUFFICIENT_MEM_PICBUF: error_code |= 1 << IVD_FATALERROR; break; case IHEVCD_INVALID_DISP_STRD: case IHEVCD_CXA_VERS_BUF_INSUFFICIENT: case IHEVCD_UNSUPPORTED_VPS_ID: case IHEVCD_UNSUPPORTED_SPS_ID: case IHEVCD_UNSUPPORTED_PPS_ID: case IHEVCD_UNSUPPORTED_CHROMA_FMT_IDC: case IHEVCD_UNSUPPORTED_BIT_DEPTH: case IHEVCD_BUF_MGR_ERROR: case IHEVCD_NO_FREE_MVBANK: case IHEVCD_NO_FREE_PICBUF: case IHEVCD_SLICE_IN_HEADER_MODE: case IHEVCD_END_OF_SEQUENCE: break; default: break; } return error_code; } Commit Message: Fix slice decrement for skipped slices Test: run the poc with and without the patch Bug: 63045918 Change-Id: I27804d42c55480c25303d1a5dbb43b1d86d7fa94 (cherry picked from commit 272f2c23c8ba8579adb0618b4124163b9bf086fb) CWE ID: CWE-682
0
162,166
Analyze the following 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 TestPlaybackRate(double playback_rate) { static const int kDefaultBufferSize = kSamplesPerSecond / 10; static const int kDefaultFramesRequested = 5 * kSamplesPerSecond; TestPlaybackRate(playback_rate, kDefaultBufferSize, kDefaultFramesRequested); } Commit Message: Protect AudioRendererAlgorithm from invalid step sizes. BUG=165430 TEST=unittests and asan pass. Review URL: https://codereview.chromium.org/11573023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173249 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-119
1
171,535
Analyze the following 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 Browser::CanCloseWithInProgressDownloads() { if (cancel_download_confirmation_state_ != NOT_PROMPTED) return cancel_download_confirmation_state_ != WAITING_FOR_RESPONSE; int num_downloads_blocking; Browser::DownloadClosePreventionType dialog_type = OkToCloseWithInProgressDownloads(&num_downloads_blocking); if (dialog_type == DOWNLOAD_CLOSE_OK) return true; cancel_download_confirmation_state_ = WAITING_FOR_RESPONSE; window_->ConfirmBrowserCloseWithPendingDownloads( num_downloads_blocking, dialog_type, false, base::Bind(&Browser::InProgressDownloadResponse, weak_factory_.GetWeakPtr())); return false; } Commit Message: Don't focus the location bar for NTP navigations in non-selected tabs. BUG=677716 TEST=See bug for repro steps. Review-Url: https://codereview.chromium.org/2624373002 Cr-Commit-Position: refs/heads/master@{#443338} CWE ID:
0
138,977
Analyze the following 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 ewk_frame_load_committed(Evas_Object* ewkFrame) { evas_object_smart_callback_call(ewkFrame, "load,committed", 0); } Commit Message: [EFL] fast/frames/frame-crash-with-page-cache.html is crashing https://bugs.webkit.org/show_bug.cgi?id=85879 Patch by Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> on 2012-05-17 Reviewed by Noam Rosenthal. Source/WebKit/efl: _ewk_frame_smart_del() is considering now that the frame can be present in cache. loader()->detachFromParent() is only applied for the main frame. loader()->cancelAndClear() is not used anymore. * ewk/ewk_frame.cpp: (_ewk_frame_smart_del): LayoutTests: * platform/efl/test_expectations.txt: Removed fast/frames/frame-crash-with-page-cache.html. git-svn-id: svn://svn.chromium.org/blink/trunk@117409 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-399
0
107,664
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: char *FLTGetBinaryComparisonCommonExpression(FilterEncodingNode *psFilterNode, layerObj *lp) { char szTmp[1024]; char *pszExpression = NULL, *pszTmpEscaped; int bString; int bDateTime; if (psFilterNode == NULL) return NULL; /* -------------------------------------------------------------------- */ /* check if the value is a numeric value or alphanumeric. If it */ /* is alphanumeric, add quotes around attribute and values. */ /* -------------------------------------------------------------------- */ bString = 0; bDateTime = 0; if (psFilterNode->psRightNode->pszValue) { const char* pszType; snprintf(szTmp, sizeof(szTmp), "%s_type", psFilterNode->psLeftNode->pszValue); pszType = msOWSLookupMetadata(&(lp->metadata), "OFG", szTmp); if (pszType!= NULL && (strcasecmp(pszType, "Character") == 0)) bString = 1; else if (pszType!= NULL && (strcasecmp(pszType, "Date") == 0)) bDateTime = 1; else if (FLTIsNumeric(psFilterNode->psRightNode->pszValue) == MS_FALSE) bString = 1; } /* specical case to be able to have empty strings in the expression. */ /* propertyislike is always treated as string */ if (psFilterNode->psRightNode->pszValue == NULL || strcasecmp(psFilterNode->pszValue, "PropertyIsLike") == 0) bString = 1; /* attribute */ if (bString) sprintf(szTmp, "%s", "(\"["); else sprintf(szTmp, "%s","(["); pszExpression = msStringConcatenate(pszExpression, szTmp); pszExpression = msStringConcatenate(pszExpression, psFilterNode->psLeftNode->pszValue); if (bString) sprintf(szTmp, "%s","]\" "); else sprintf(szTmp, "%s", "] "); pszExpression = msStringConcatenate(pszExpression, szTmp); if (strcasecmp(psFilterNode->pszValue, "PropertyIsEqualTo") == 0) { /* case insensitive set ? */ if (psFilterNode->psRightNode->pOther && (*(int *)psFilterNode->psRightNode->pOther) == 1) sprintf(szTmp, "%s", "=*"); else sprintf(szTmp, "%s", "="); } else if (strcasecmp(psFilterNode->pszValue, "PropertyIsNotEqualTo") == 0) sprintf(szTmp, "%s", "!="); else if (strcasecmp(psFilterNode->pszValue, "PropertyIsLessThan") == 0) sprintf(szTmp, "%s", "<"); else if (strcasecmp(psFilterNode->pszValue, "PropertyIsGreaterThan") == 0) sprintf(szTmp, "%s", ">"); else if (strcasecmp(psFilterNode->pszValue, "PropertyIsLessThanOrEqualTo") == 0) sprintf(szTmp, "%s", "<="); else if (strcasecmp(psFilterNode->pszValue, "PropertyIsGreaterThanOrEqualTo") == 0) sprintf(szTmp, "%s", ">="); else if (strcasecmp(psFilterNode->pszValue, "PropertyIsLike") == 0) sprintf(szTmp, "%s", "~"); pszExpression = msStringConcatenate(pszExpression, szTmp); pszExpression = msStringConcatenate(pszExpression, " "); /* value */ if (bString) { sprintf(szTmp, "%s", "\""); pszExpression = msStringConcatenate(pszExpression, szTmp); } else if (bDateTime) { sprintf(szTmp, "%s", "`"); pszExpression = msStringConcatenate(pszExpression, szTmp); } if (psFilterNode->psRightNode->pszValue) { pszTmpEscaped = msStringEscape(psFilterNode->psRightNode->pszValue); pszExpression = msStringConcatenate(pszExpression, pszTmpEscaped); if(pszTmpEscaped != psFilterNode->psRightNode->pszValue ) msFree(pszTmpEscaped); } if (bString) { sprintf(szTmp, "%s", "\""); pszExpression = msStringConcatenate(pszExpression, szTmp); } else if (bDateTime) { sprintf(szTmp, "%s", "`"); pszExpression = msStringConcatenate(pszExpression, szTmp); } sprintf(szTmp, "%s", ")"); pszExpression = msStringConcatenate(pszExpression, szTmp); return pszExpression; } Commit Message: security fix (patch by EvenR) CWE ID: CWE-119
0
69,031
Analyze the following 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 enum hrtimer_restart napi_watchdog(struct hrtimer *timer) { struct napi_struct *napi; napi = container_of(timer, struct napi_struct, timer); /* Note : we use a relaxed variant of napi_schedule_prep() not setting * NAPI_STATE_MISSED, since we do not react to a device IRQ. */ if (napi->gro_list && !napi_disable_pending(napi) && !test_and_set_bit(NAPI_STATE_SCHED, &napi->state)) __napi_schedule_irqoff(napi); return HRTIMER_NORESTART; } Commit Message: tun: call dev_get_valid_name() before register_netdevice() register_netdevice() could fail early when we have an invalid dev name, in which case ->ndo_uninit() is not called. For tun device, this is a problem because a timer etc. are already initialized and it expects ->ndo_uninit() to clean them up. We could move these initializations into a ->ndo_init() so that register_netdevice() knows better, however this is still complicated due to the logic in tun_detach(). Therefore, I choose to just call dev_get_valid_name() before register_netdevice(), which is quicker and much easier to audit. And for this specific case, it is already enough. Fixes: 96442e42429e ("tuntap: choose the txq based on rxq") Reported-by: Dmitry Alexeev <avekceeb@gmail.com> Cc: Jason Wang <jasowang@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-476
0
93,403
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: CorePageLoadMetricsObserver::CorePageLoadMetricsObserver() : transition_(ui::PAGE_TRANSITION_LINK), initiated_by_user_gesture_(false) {} Commit Message: Remove clock resolution page load histograms. These were temporary metrics intended to understand whether high/low resolution clocks adversely impact page load metrics. After collecting a few months of data it was determined that clock resolution doesn't adversely impact our metrics, and it that these histograms were no longer needed. BUG=394757 Review-Url: https://codereview.chromium.org/2155143003 Cr-Commit-Position: refs/heads/master@{#406143} CWE ID:
0
121,088
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ProcXF86DRICloseConnection(register ClientPtr client) { REQUEST(xXF86DRICloseConnectionReq); REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq); if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; return BadValue; } DRICloseConnection(screenInfo.screens[stuff->screen]); return Success; } Commit Message: CWE ID: CWE-20
0
17,732
Analyze the following 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 AXLayoutObject::detachRemoteSVGRoot() { if (AXSVGRoot* root = remoteSVGRootElement()) root->setParent(0); } Commit Message: Switch to equalIgnoringASCIICase throughout modules/accessibility BUG=627682 Review-Url: https://codereview.chromium.org/2793913007 Cr-Commit-Position: refs/heads/master@{#461858} CWE ID: CWE-254
0
127,029
Analyze the following 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 bool vfio_pci_is_vga(struct pci_dev *pdev) { return (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA; } Commit Message: vfio/pci: Fix integer overflows, bitmask check The VFIO_DEVICE_SET_IRQS ioctl did not sufficiently sanitize user-supplied integers, potentially allowing memory corruption. This patch adds appropriate integer overflow checks, checks the range bounds for VFIO_IRQ_SET_DATA_NONE, and also verifies that only single element in the VFIO_IRQ_SET_DATA_TYPE_MASK bitmask is set. VFIO_IRQ_SET_ACTION_TYPE_MASK is already correctly checked later in vfio_pci_set_irqs_ioctl(). Furthermore, a kzalloc is changed to a kcalloc because the use of a kzalloc with an integer multiplication allowed an integer overflow condition to be reached without this patch. kcalloc checks for overflow and should prevent a similar occurrence. Signed-off-by: Vlad Tsyrklevich <vlad@tsyrklevich.net> Signed-off-by: Alex Williamson <alex.williamson@redhat.com> CWE ID: CWE-190
0
48,591
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Document::EnqueueScrollEventForNode(Node* target) { Event* scroll_event = target->IsDocumentNode() ? Event::CreateBubble(event_type_names::kScroll) : Event::Create(event_type_names::kScroll); scroll_event->SetTarget(target); EnsureScriptedAnimationController().EnqueuePerFrameEvent(scroll_event); } 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,683
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void BooleanAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Local<v8::Object> holder = info.Holder(); TestObject* impl = V8TestObject::ToImpl(holder); V8SetReturnValueBool(info, impl->booleanAttribute()); } Commit Message: bindings: Support "attribute FrozenArray<T>?" Adds a quick hack to support a case of "attribute FrozenArray<T>?". Bug: 1028047 Change-Id: Ib3cecc4beb6bcc0fb0dbc667aca595454cc90c86 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1933866 Reviewed-by: Hitoshi Yoshida <peria@chromium.org> Commit-Queue: Yuki Shiino <yukishiino@chromium.org> Cr-Commit-Position: refs/heads/master@{#718676} CWE ID:
0
134,532
Analyze the following 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 ff_jref_idct4_add(uint8_t *dest, int line_size, int16_t *block) { ff_j_rev_dct4 (block); add_pixels_clamped4_c(block, dest, line_size); } Commit Message: avcodec/dsputil: fix signedness in sizeof() comparissions Signed-off-by: Michael Niedermayer <michaelni@gmx.at> CWE ID: CWE-189
0
28,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: static int vmci_transport_dgram_bind(struct vsock_sock *vsk, struct sockaddr_vm *addr) { u32 port; u32 flags; int err; /* VMCI will select a resource ID for us if we provide * VMCI_INVALID_ID. */ port = addr->svm_port == VMADDR_PORT_ANY ? VMCI_INVALID_ID : addr->svm_port; if (port <= LAST_RESERVED_PORT && !capable(CAP_NET_BIND_SERVICE)) return -EACCES; flags = addr->svm_cid == VMADDR_CID_ANY ? VMCI_FLAG_ANYCID_DG_HND : 0; err = vmci_transport_datagram_create_hnd(port, flags, vmci_transport_recv_dgram_cb, &vsk->sk, &vmci_trans(vsk)->dg_handle); if (err < VMCI_SUCCESS) return vmci_transport_error_to_vsock_error(err); vsock_addr_init(&vsk->local_addr, addr->svm_cid, vmci_trans(vsk)->dg_handle.resource); return 0; } Commit Message: VSOCK: vmci - fix possible info leak in vmci_transport_dgram_dequeue() In case we received no data on the call to skb_recv_datagram(), i.e. skb->data is NULL, vmci_transport_dgram_dequeue() will return with 0 without updating msg_namelen leading to net/socket.c leaking the local, uninitialized sockaddr_storage variable to userland -- 128 bytes of kernel stack memory. Fix this by moving the already existing msg_namelen assignment a few lines above. Cc: Andy King <acking@vmware.com> Cc: Dmitry Torokhov <dtor@vmware.com> Cc: George Zhang <georgezhang@vmware.com> Signed-off-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-200
0
30,373
Analyze the following 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 unix_create(struct net *net, struct socket *sock, int protocol, int kern) { if (protocol && protocol != PF_UNIX) return -EPROTONOSUPPORT; sock->state = SS_UNCONNECTED; switch (sock->type) { case SOCK_STREAM: sock->ops = &unix_stream_ops; break; /* * Believe it or not BSD has AF_UNIX, SOCK_RAW though * nothing uses it. */ case SOCK_RAW: sock->type = SOCK_DGRAM; case SOCK_DGRAM: sock->ops = &unix_dgram_ops; break; case SOCK_SEQPACKET: sock->ops = &unix_seqpacket_ops; break; default: return -ESOCKTNOSUPPORT; } return unix_create1(net, sock) ? 0 : -ENOMEM; } Commit Message: af_netlink: force credentials passing [CVE-2012-3520] Pablo Neira Ayuso discovered that avahi and potentially NetworkManager accept spoofed Netlink messages because of a kernel bug. The kernel passes all-zero SCM_CREDENTIALS ancillary data to the receiver if the sender did not provide such data, instead of not including any such data at all or including the correct data from the peer (as it is the case with AF_UNIX). This bug was introduced in commit 16e572626961 (af_unix: dont send SCM_CREDENTIALS by default) This patch forces passing credentials for netlink, as before the regression. Another fix would be to not add SCM_CREDENTIALS in netlink messages if not provided by the sender, but it might break some programs. With help from Florian Weimer & Petr Matousek This issue is designated as CVE-2012-3520 Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Petr Matousek <pmatouse@redhat.com> Cc: Florian Weimer <fweimer@redhat.com> Cc: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-287
0
19,287
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void hns_rcb_update_stats(struct hnae_queue *queue) { struct ring_pair_cb *ring = container_of(queue, struct ring_pair_cb, q); struct dsaf_device *dsaf_dev = ring->rcb_common->dsaf_dev; struct ppe_common_cb *ppe_common = dsaf_dev->ppe_common[ring->rcb_common->comm_index]; struct hns_ring_hw_stats *hw_stats = &ring->hw_stats; hw_stats->rx_pkts += dsaf_read_dev(queue, RCB_RING_RX_RING_PKTNUM_RECORD_REG); dsaf_write_dev(queue, RCB_RING_RX_RING_PKTNUM_RECORD_REG, 0x1); hw_stats->ppe_rx_ok_pkts += dsaf_read_dev(ppe_common, PPE_COM_HIS_RX_PKT_QID_OK_CNT_REG + 4 * ring->index); hw_stats->ppe_rx_drop_pkts += dsaf_read_dev(ppe_common, PPE_COM_HIS_RX_PKT_QID_DROP_CNT_REG + 4 * ring->index); hw_stats->tx_pkts += dsaf_read_dev(queue, RCB_RING_TX_RING_PKTNUM_RECORD_REG); dsaf_write_dev(queue, RCB_RING_TX_RING_PKTNUM_RECORD_REG, 0x1); hw_stats->ppe_tx_ok_pkts += dsaf_read_dev(ppe_common, PPE_COM_HIS_TX_PKT_QID_OK_CNT_REG + 4 * ring->index); hw_stats->ppe_tx_drop_pkts += dsaf_read_dev(ppe_common, PPE_COM_HIS_TX_PKT_QID_ERR_CNT_REG + 4 * ring->index); } Commit Message: net: hns: fix ethtool_get_strings overflow in hns driver hns_get_sset_count() returns HNS_NET_STATS_CNT and the data space allocated is not enough for ethtool_get_strings(), which will cause random memory corruption. When SLAB and DEBUG_SLAB are both enabled, memory corruptions like the the following can be observed without this patch: [ 43.115200] Slab corruption (Not tainted): Acpi-ParseExt start=ffff801fb0b69030, len=80 [ 43.115206] Redzone: 0x9f911029d006462/0x5f78745f31657070. [ 43.115208] Last user: [<5f7272655f746b70>](0x5f7272655f746b70) [ 43.115214] 010: 70 70 65 31 5f 74 78 5f 70 6b 74 00 6b 6b 6b 6b ppe1_tx_pkt.kkkk [ 43.115217] 030: 70 70 65 31 5f 74 78 5f 70 6b 74 5f 6f 6b 00 6b ppe1_tx_pkt_ok.k [ 43.115218] Next obj: start=ffff801fb0b69098, len=80 [ 43.115220] Redzone: 0x706d655f6f666966/0x9f911029d74e35b. [ 43.115229] Last user: [<ffff0000084b11b0>](acpi_os_release_object+0x28/0x38) [ 43.115231] 000: 74 79 00 6b 6b 6b 6b 6b 70 70 65 31 5f 74 78 5f ty.kkkkkppe1_tx_ [ 43.115232] 010: 70 6b 74 5f 65 72 72 5f 63 73 75 6d 5f 66 61 69 pkt_err_csum_fai Signed-off-by: Timmy Li <lixiaoping3@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-119
0
85,623
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs, const char *text, int length, int embedding_level, int *logical_widths) { /* Build a PangoGlyphItem so we can use PangoGlyphItemIter. * This API should have been made to take a PangoGlyphItem... */ PangoItem item = {0, length, g_utf8_strlen (text, length), {NULL, NULL, NULL, embedding_level, PANGO_GRAVITY_AUTO, 0, PANGO_SCRIPT_UNKNOWN, NULL, NULL}}; PangoGlyphItem glyph_item = {&item, glyphs}; PangoGlyphItemIter iter; gboolean has_cluster; int dir; dir = embedding_level % 2 == 0 ? +1 : -1; for (has_cluster = pango_glyph_item_iter_init_start (&iter, &glyph_item, text); has_cluster; has_cluster = pango_glyph_item_iter_next_cluster (&iter)) { int glyph_index, char_index, num_chars, cluster_width = 0, char_width; for (glyph_index = iter.start_glyph; glyph_index != iter.end_glyph; glyph_index += dir) { cluster_width += glyphs->glyphs[glyph_index].geometry.width; } num_chars = iter.end_char - iter.start_char; if (num_chars) /* pedantic */ { char_width = cluster_width / num_chars; for (char_index = iter.start_char; char_index < iter.end_char; char_index++) { logical_widths[char_index] = char_width; } /* add any residues to the first char */ logical_widths[iter.start_char] += cluster_width - (char_width * num_chars); } } } Commit Message: [glyphstring] Handle overflow with very long glyphstrings CWE ID: CWE-189
0
18,119
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: LocalDOMWindow* LocalDOMWindow::ToLocalDOMWindow() { return this; } 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
125,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: void WebBluetoothServiceImpl::OnBluetoothScanningPromptEvent( BluetoothScanningPrompt::Event event, BluetoothDeviceScanningPromptController* prompt_controller) { DCHECK(!scanning_clients_.empty()); auto client = scanning_clients_.end() - 1; DCHECK((*client)->prompt_controller() == prompt_controller); auto result = blink::mojom::WebBluetoothResult::SUCCESS; if (event == BluetoothScanningPrompt::Event::kAllow) { result = blink::mojom::WebBluetoothResult::SUCCESS; StoreAllowedScanOptions((*client)->scan_options()); } else if (event == BluetoothScanningPrompt::Event::kBlock) { result = blink::mojom::WebBluetoothResult::SCANNING_BLOCKED; const url::Origin requesting_origin = render_frame_host_->GetLastCommittedOrigin(); const url::Origin embedding_origin = web_contents()->GetMainFrame()->GetLastCommittedOrigin(); GetContentClient()->browser()->BlockBluetoothScanning( web_contents()->GetBrowserContext(), requesting_origin, embedding_origin); } else if (event == BluetoothScanningPrompt::Event::kCanceled) { result = blink::mojom::WebBluetoothResult::PROMPT_CANCELED; } else { NOTREACHED(); } (*client)->RunRequestScanningStartCallback(std::move(result)); (*client)->set_prompt_controller(nullptr); if (event == BluetoothScanningPrompt::Event::kAllow) { (*client)->set_allow_send_event(true); } else if (event == BluetoothScanningPrompt::Event::kBlock) { scanning_clients_.clear(); allowed_scan_filters_.clear(); accept_all_advertisements_ = false; } else if (event == BluetoothScanningPrompt::Event::kCanceled) { scanning_clients_.erase(client); } else { NOTREACHED(); } } 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,113
Analyze the following 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 zend_shared_alloc_register_xlat_entry(const void *old, const void *new) { zend_hash_index_update_ptr(&xlat_table, (zend_ulong)old, (void*)new); } Commit Message: CWE ID: CWE-416
0
5,259
Analyze the following 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 RenderProcessHostImpl::SendDisableAecDumpToRenderer() { Send(new AecDumpMsg_DisableAecDump()); } Commit Message: Switching AudioOutputAuthorizationHandler from using AudioManager interface to AudioSystem one. BUG=672468 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Review-Url: https://codereview.chromium.org/2692203003 Cr-Commit-Position: refs/heads/master@{#450939} CWE ID:
0
128,316
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int Session_SetReverseConfig(preproc_session_t *session, effect_config_t *config) { if (config->inputCfg.samplingRate != config->outputCfg.samplingRate || config->inputCfg.format != config->outputCfg.format || config->inputCfg.format != AUDIO_FORMAT_PCM_16_BIT) { return -EINVAL; } ALOGV("Session_SetReverseConfig sr %d cnl %08x", config->inputCfg.samplingRate, config->inputCfg.channels); if (session->state < PREPROC_SESSION_STATE_CONFIG) { return -ENOSYS; } if (config->inputCfg.samplingRate != session->samplingRate || config->inputCfg.format != AUDIO_FORMAT_PCM_16_BIT) { return -EINVAL; } uint32_t inCnl = audio_channel_count_from_out_mask(config->inputCfg.channels); int status = session->apm->set_num_reverse_channels(inCnl); if (status < 0) { return -EINVAL; } session->revChannelCount = inCnl; session->revFrame->_audioChannel = inCnl; session->revFrame->_frequencyInHz = session->apmSamplingRate; session->revBufSize = 0; session->framesRev = 0; return 0; } Commit Message: audio effects: fix heap overflow Check consistency of effect command reply sizes before copying to reply address. Also add null pointer check on reply size. Also remove unused parameter warning. Bug: 21953516. Change-Id: I4cf00c12eaed696af28f3b7613f7e36f47a160c4 (cherry picked from commit 0f714a464d2425afe00d6450535e763131b40844) CWE ID: CWE-119
0
157,493
Analyze the following 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 OobeUI::IsJSReady(const base::Closure& display_is_ready_callback) { if (!ready_) ready_callbacks_.push_back(display_is_ready_callback); return ready_; } Commit Message: One polymer_config.js to rule them all. R=michaelpg@chromium.org,fukino@chromium.org,mfoltz@chromium.org BUG=425626 Review URL: https://codereview.chromium.org/1224783005 Cr-Commit-Position: refs/heads/master@{#337882} CWE ID: CWE-399
0
123,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: int CMS_decrypt_set1_password(CMS_ContentInfo *cms, unsigned char *pass, ossl_ssize_t passlen) { STACK_OF(CMS_RecipientInfo) *ris; CMS_RecipientInfo *ri; int i, r; ris = CMS_get0_RecipientInfos(cms); for (i = 0; i < sk_CMS_RecipientInfo_num(ris); i++) { ri = sk_CMS_RecipientInfo_value(ris, i); if (CMS_RecipientInfo_type(ri) != CMS_RECIPINFO_PASS) continue; CMS_RecipientInfo_set0_password(ri, pass, passlen); r = CMS_RecipientInfo_decrypt(cms, ri); CMS_RecipientInfo_set0_password(ri, NULL, 0); if (r > 0) return 1; } CMSerr(CMS_F_CMS_DECRYPT_SET1_PASSWORD, CMS_R_NO_MATCHING_RECIPIENT); return 0; } Commit Message: CWE ID: CWE-311
0
11,936
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ZEND_API int _zend_ts_hash_init_ex(TsHashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC) { #ifdef ZTS ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; #endif return _zend_hash_init_ex(TS_HASH(ht), nSize, pDestructor, persistent, bApplyProtection ZEND_FILE_LINE_RELAY_CC); } Commit Message: CWE ID:
0
7,458
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void nested_vmx_cr_fixed1_bits_update(struct kvm_vcpu *vcpu) { struct vcpu_vmx *vmx = to_vmx(vcpu); struct kvm_cpuid_entry2 *entry; vmx->nested.msrs.cr0_fixed1 = 0xffffffff; vmx->nested.msrs.cr4_fixed1 = X86_CR4_PCE; #define cr4_fixed1_update(_cr4_mask, _reg, _cpuid_mask) do { \ if (entry && (entry->_reg & (_cpuid_mask))) \ vmx->nested.msrs.cr4_fixed1 |= (_cr4_mask); \ } while (0) entry = kvm_find_cpuid_entry(vcpu, 0x1, 0); cr4_fixed1_update(X86_CR4_VME, edx, bit(X86_FEATURE_VME)); cr4_fixed1_update(X86_CR4_PVI, edx, bit(X86_FEATURE_VME)); cr4_fixed1_update(X86_CR4_TSD, edx, bit(X86_FEATURE_TSC)); cr4_fixed1_update(X86_CR4_DE, edx, bit(X86_FEATURE_DE)); cr4_fixed1_update(X86_CR4_PSE, edx, bit(X86_FEATURE_PSE)); cr4_fixed1_update(X86_CR4_PAE, edx, bit(X86_FEATURE_PAE)); cr4_fixed1_update(X86_CR4_MCE, edx, bit(X86_FEATURE_MCE)); cr4_fixed1_update(X86_CR4_PGE, edx, bit(X86_FEATURE_PGE)); cr4_fixed1_update(X86_CR4_OSFXSR, edx, bit(X86_FEATURE_FXSR)); cr4_fixed1_update(X86_CR4_OSXMMEXCPT, edx, bit(X86_FEATURE_XMM)); cr4_fixed1_update(X86_CR4_VMXE, ecx, bit(X86_FEATURE_VMX)); cr4_fixed1_update(X86_CR4_SMXE, ecx, bit(X86_FEATURE_SMX)); cr4_fixed1_update(X86_CR4_PCIDE, ecx, bit(X86_FEATURE_PCID)); cr4_fixed1_update(X86_CR4_OSXSAVE, ecx, bit(X86_FEATURE_XSAVE)); entry = kvm_find_cpuid_entry(vcpu, 0x7, 0); cr4_fixed1_update(X86_CR4_FSGSBASE, ebx, bit(X86_FEATURE_FSGSBASE)); cr4_fixed1_update(X86_CR4_SMEP, ebx, bit(X86_FEATURE_SMEP)); cr4_fixed1_update(X86_CR4_SMAP, ebx, bit(X86_FEATURE_SMAP)); cr4_fixed1_update(X86_CR4_PKE, ecx, bit(X86_FEATURE_PKU)); cr4_fixed1_update(X86_CR4_UMIP, ecx, bit(X86_FEATURE_UMIP)); #undef cr4_fixed1_update } Commit Message: kvm: nVMX: Enforce cpl=0 for VMX instructions VMX instructions executed inside a L1 VM will always trigger a VM exit even when executed with cpl 3. This means we must perform the privilege check in software. Fixes: 70f3aac964ae("kvm: nVMX: Remove superfluous VMX instruction fault checks") Cc: stable@vger.kernel.org Signed-off-by: Felix Wilhelm <fwilhelm@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> CWE ID:
0
80,984
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: sync_max_show(struct mddev *mddev, char *page) { return sprintf(page, "%d (%s)\n", speed_max(mddev), mddev->sync_speed_max ? "local": "system"); } Commit Message: md: use kzalloc() when bitmap is disabled In drivers/md/md.c get_bitmap_file() uses kmalloc() for creating a mdu_bitmap_file_t called "file". 5769 file = kmalloc(sizeof(*file), GFP_NOIO); 5770 if (!file) 5771 return -ENOMEM; This structure is copied to user space at the end of the function. 5786 if (err == 0 && 5787 copy_to_user(arg, file, sizeof(*file))) 5788 err = -EFAULT But if bitmap is disabled only the first byte of "file" is initialized with zero, so it's possible to read some bytes (up to 4095) of kernel space memory from user space. This is an information leak. 5775 /* bitmap disabled, zero the first byte and copy out */ 5776 if (!mddev->bitmap_info.file) 5777 file->pathname[0] = '\0'; Signed-off-by: Benjamin Randazzo <benjamin@randazzo.fr> Signed-off-by: NeilBrown <neilb@suse.com> CWE ID: CWE-200
0
42,563
Analyze the following 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 nntp_check_msgid(struct Context *ctx, const char *msgid) { struct NntpData *nntp_data = ctx->data; char buf[LONG_STRING]; FILE *fp = mutt_file_mkstemp(); if (!fp) { mutt_perror("mutt_file_mkstemp() failed!"); return -1; } snprintf(buf, sizeof(buf), "HEAD %s\r\n", msgid); int rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), NULL, fetch_tempfile, fp); if (rc) { mutt_file_fclose(&fp); if (rc < 0) return -1; if (mutt_str_strncmp("430", buf, 3) == 0) return 1; mutt_error("HEAD: %s", buf); return -1; } /* parse header */ if (ctx->msgcount == ctx->hdrmax) mx_alloc_memory(ctx); struct Header *hdr = ctx->hdrs[ctx->msgcount] = mutt_header_new(); hdr->data = mutt_mem_calloc(1, sizeof(struct NntpHeaderData)); hdr->env = mutt_rfc822_read_header(fp, hdr, 0, 0); mutt_file_fclose(&fp); /* get article number */ if (hdr->env->xref) nntp_parse_xref(ctx, hdr); else { snprintf(buf, sizeof(buf), "STAT %s\r\n", msgid); if (nntp_query(nntp_data, buf, sizeof(buf)) < 0) { mutt_header_free(&hdr); return -1; } sscanf(buf + 4, ANUM, &NHDR(hdr)->article_num); } /* reset flags */ hdr->read = false; hdr->old = false; hdr->deleted = false; hdr->changed = true; hdr->received = hdr->date_sent; hdr->index = ctx->msgcount++; mx_update_context(ctx, 1); return 0; } Commit Message: Add alloc fail check in nntp_fetch_headers CWE ID: CWE-20
0
79,498
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: GahpClient::cream_job_status(const char *service, const char *job_id, char **job_status, int *exit_code, char **failure_reason) { static const char* command = "CREAM_JOB_STATUS"; if (server->m_commands_supported->contains_anycase(command)==FALSE) { return GAHPCLIENT_COMMAND_NOT_SUPPORTED; } if (!service) service=NULLSTRING; if (!job_id) job_id=NULLSTRING; std::string reqline; char *esc1 = strdup( escapeGahpString(service) ); char *esc2 = strdup( escapeGahpString(job_id) ); int job_number = 1; // Just query 1 job for now int x = sprintf(reqline, "%s %d %s", esc1, job_number, esc2); free( esc1 ); free( esc2 ); ASSERT( x > 0 ); const char *buf = reqline.c_str(); if ( !is_pending(command,buf) ) { if ( m_mode == results_only ) { return GAHPCLIENT_COMMAND_NOT_SUBMITTED; } now_pending(command,buf,normal_proxy,medium_prio); } Gahp_Args* result = get_pending_result(command,buf); if ( result ) { if (result->argc > 2) { if( result->argc != 3 + atoi(result->argv[2]) * 4){ EXCEPT("Bad %s Result",command); } } else if (result->argc != 2) { EXCEPT("Bad %s Result",command); } int rc; if (strcmp(result->argv[1], NULLSTRING) == 0) { rc = 0; } else { rc = 1; error_string = result->argv[1]; } if ( rc == 0 ) { *job_status = strdup(result->argv[4]); *exit_code = atoi(result->argv[5]); if ( strcasecmp(result->argv[6], NULLSTRING) ) { *failure_reason = strdup(result->argv[6]); } else { *failure_reason = NULL; } } delete result; return rc; } if ( check_pending_timeout(command,buf) ) { sprintf( error_string, "%s timed out", command ); return GAHPCLIENT_COMMAND_TIMED_OUT; } return GAHPCLIENT_COMMAND_PENDING; } Commit Message: CWE ID: CWE-134
0
16,158
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: SWFShape_end(SWFShape shape) { int i; byte* buffer; if ( shape->isEnded ) return; shape->isEnded = TRUE; buffer = SWFOutput_getBuffer(shape->out); buffer[0] = (SWFOutput_numBits(shape->nFills) << 4) + SWFOutput_numBits(shape->nLines); for ( i=0; i<shape->nRecords; ++i ) { if ( i < shape->nRecords-1 || shape->records[i].type != SHAPERECORD_STATECHANGE ) { SWFShape_writeShapeRecord(shape, shape->records[i], shape->out); } free(shape->records[i].record.stateChange); /* all in union are pointers */ } SWFOutput_writeBits(shape->out, 0, 6); /* end tag */ SWFOutput_byteAlign(shape->out); /* addStyleHeader creates a new output and adds the existing one after itself- so even though it's called afterwards it's written before, as it should be */ if ( BLOCK(shape)->type > 0 ) { switch (shape->useVersion) { case SWF_SHAPE1: BLOCK(shape)->type = SWF_DEFINESHAPE; break; case SWF_SHAPE2: BLOCK(shape)->type = SWF_DEFINESHAPE2; break; case SWF_SHAPE4: BLOCK(shape)->type = SWF_DEFINESHAPE4; break; } SWFShape_addStyleHeader(shape); } free(shape->records); shape->records = NULL; shape->nRecords = 0; } Commit Message: SWFShape_setLeftFillStyle: prevent fill overflow CWE ID: CWE-119
0
89,509
Analyze the following 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 vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b) { struct vb2_buffer *vb; int ret; if (b->type != q->type) { dprintk(1, "wrong buffer type\n"); return -EINVAL; } if (b->index >= q->num_buffers) { dprintk(1, "buffer index out of range\n"); return -EINVAL; } vb = q->bufs[b->index]; ret = __verify_planes_array(vb, b); if (!ret) vb2_core_querybuf(q, b->index, b); return ret; } Commit Message: [media] videobuf2-v4l2: Verify planes array in buffer dequeueing When a buffer is being dequeued using VIDIOC_DQBUF IOCTL, the exact buffer which will be dequeued is not known until the buffer has been removed from the queue. The number of planes is specific to a buffer, not to the queue. This does lead to the situation where multi-plane buffers may be requested and queued with n planes, but VIDIOC_DQBUF IOCTL may be passed an argument struct with fewer planes. __fill_v4l2_buffer() however uses the number of planes from the dequeued videobuf2 buffer, overwriting kernel memory (the m.planes array allocated in video_usercopy() in v4l2-ioctl.c) if the user provided fewer planes than the dequeued buffer had. Oops! Fixes: b0e0e1f83de3 ("[media] media: videobuf2: Prepare to divide videobuf2") Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: stable@vger.kernel.org # for v4.4 and later Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com> CWE ID: CWE-119
0
52,772
Analyze the following 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 ib_ucm_event_process(struct ib_cm_event *evt, struct ib_ucm_event *uvt) { void *info = NULL; switch (evt->event) { case IB_CM_REQ_RECEIVED: ib_ucm_event_req_get(&uvt->resp.u.req_resp, &evt->param.req_rcvd); uvt->data_len = IB_CM_REQ_PRIVATE_DATA_SIZE; uvt->resp.present = IB_UCM_PRES_PRIMARY; uvt->resp.present |= (evt->param.req_rcvd.alternate_path ? IB_UCM_PRES_ALTERNATE : 0); break; case IB_CM_REP_RECEIVED: ib_ucm_event_rep_get(&uvt->resp.u.rep_resp, &evt->param.rep_rcvd); uvt->data_len = IB_CM_REP_PRIVATE_DATA_SIZE; break; case IB_CM_RTU_RECEIVED: uvt->data_len = IB_CM_RTU_PRIVATE_DATA_SIZE; uvt->resp.u.send_status = evt->param.send_status; break; case IB_CM_DREQ_RECEIVED: uvt->data_len = IB_CM_DREQ_PRIVATE_DATA_SIZE; uvt->resp.u.send_status = evt->param.send_status; break; case IB_CM_DREP_RECEIVED: uvt->data_len = IB_CM_DREP_PRIVATE_DATA_SIZE; uvt->resp.u.send_status = evt->param.send_status; break; case IB_CM_MRA_RECEIVED: uvt->resp.u.mra_resp.timeout = evt->param.mra_rcvd.service_timeout; uvt->data_len = IB_CM_MRA_PRIVATE_DATA_SIZE; break; case IB_CM_REJ_RECEIVED: uvt->resp.u.rej_resp.reason = evt->param.rej_rcvd.reason; uvt->data_len = IB_CM_REJ_PRIVATE_DATA_SIZE; uvt->info_len = evt->param.rej_rcvd.ari_length; info = evt->param.rej_rcvd.ari; break; case IB_CM_LAP_RECEIVED: ib_copy_path_rec_to_user(&uvt->resp.u.lap_resp.path, evt->param.lap_rcvd.alternate_path); uvt->data_len = IB_CM_LAP_PRIVATE_DATA_SIZE; uvt->resp.present = IB_UCM_PRES_ALTERNATE; break; case IB_CM_APR_RECEIVED: uvt->resp.u.apr_resp.status = evt->param.apr_rcvd.ap_status; uvt->data_len = IB_CM_APR_PRIVATE_DATA_SIZE; uvt->info_len = evt->param.apr_rcvd.info_len; info = evt->param.apr_rcvd.apr_info; break; case IB_CM_SIDR_REQ_RECEIVED: uvt->resp.u.sidr_req_resp.pkey = evt->param.sidr_req_rcvd.pkey; uvt->resp.u.sidr_req_resp.port = evt->param.sidr_req_rcvd.port; uvt->data_len = IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE; break; case IB_CM_SIDR_REP_RECEIVED: ib_ucm_event_sidr_rep_get(&uvt->resp.u.sidr_rep_resp, &evt->param.sidr_rep_rcvd); uvt->data_len = IB_CM_SIDR_REP_PRIVATE_DATA_SIZE; uvt->info_len = evt->param.sidr_rep_rcvd.info_len; info = evt->param.sidr_rep_rcvd.info; break; default: uvt->resp.u.send_status = evt->param.send_status; break; } if (uvt->data_len) { uvt->data = kmemdup(evt->private_data, uvt->data_len, GFP_KERNEL); if (!uvt->data) goto err1; uvt->resp.present |= IB_UCM_PRES_DATA; } if (uvt->info_len) { uvt->info = kmemdup(info, uvt->info_len, GFP_KERNEL); if (!uvt->info) goto err2; uvt->resp.present |= IB_UCM_PRES_INFO; } return 0; err2: kfree(uvt->data); err1: return -ENOMEM; } Commit Message: IB/security: Restrict use of the write() interface The drivers/infiniband stack uses write() as a replacement for bi-directional ioctl(). This is not safe. There are ways to trigger write calls that result in the return structure that is normally written to user space being shunted off to user specified kernel memory instead. For the immediate repair, detect and deny suspicious accesses to the write API. For long term, update the user space libraries and the kernel API to something that doesn't present the same security vulnerabilities (likely a structured ioctl() interface). The impacted uAPI interfaces are generally only available if hardware from drivers/infiniband is installed in the system. Reported-by: Jann Horn <jann@thejh.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> [ Expanded check to all known write() entry points ] Cc: stable@vger.kernel.org Signed-off-by: Doug Ledford <dledford@redhat.com> CWE ID: CWE-264
0
52,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 uint32_t GetMaxNumberOfEntries(JSObject* receiver, FixedArrayBase* backing_store) { return NumberOfElementsImpl(receiver, backing_store); } Commit Message: Backport: Fix Object.entries/values with changing elements Bug: 111274046 Test: m -j proxy_resolver_v8_unittest && adb sync && adb shell \ /data/nativetest64/proxy_resolver_v8_unittest/proxy_resolver_v8_unittest Change-Id: I705fc512cc5837e9364ed187559cc75d079aa5cb (cherry picked from commit d8be9a10287afed07705ac8af027d6a46d4def99) CWE ID: CWE-704
0
163,118
Analyze the following 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 ServerStartedOnUI(base::WeakPtr<DevToolsHttpHandler> handler, base::Thread* thread, ServerWrapper* server_wrapper, DevToolsSocketFactory* socket_factory, std::unique_ptr<net::IPEndPoint> ip_address) { DCHECK_CURRENTLY_ON(BrowserThread::UI); if (handler && thread && server_wrapper) { handler->ServerStarted( std::unique_ptr<base::Thread>(thread), std::unique_ptr<ServerWrapper>(server_wrapper), std::unique_ptr<DevToolsSocketFactory>(socket_factory), std::move(ip_address)); } else { TerminateOnUI(std::unique_ptr<base::Thread>(thread), std::unique_ptr<ServerWrapper>(server_wrapper), std::unique_ptr<DevToolsSocketFactory>(socket_factory)); } } Commit Message: DevTools: check Host header for being IP or localhost when connecting over RDP. Bug: 813540 Change-Id: I9338aa2475c15090b8a60729be25502eb866efb7 Reviewed-on: https://chromium-review.googlesource.com/952522 Reviewed-by: Dmitry Gozman <dgozman@chromium.org> Commit-Queue: Pavel Feldman <pfeldman@chromium.org> Cr-Commit-Position: refs/heads/master@{#541547} CWE ID: CWE-20
0
148,276
Analyze the following 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 MemPage *btreePageLookup(BtShared *pBt, Pgno pgno){ DbPage *pDbPage; assert( sqlite3_mutex_held(pBt->mutex) ); pDbPage = sqlite3PagerLookup(pBt->pPager, pgno); if( pDbPage ){ return btreePageFromDbPage(pDbPage, pgno, pBt); } return 0; } Commit Message: sqlite: safely move pointer values through SQL. This lands https://www.sqlite.org/src/timeline?c=d6a44b35 in third_party/sqlite/src/ and third_party/sqlite/patches/0013-Add-new-interfaces-sqlite3_bind_pointer-sqlite3_resu.patch and re-generates third_party/sqlite/amalgamation/* using the script at third_party/sqlite/google_generate_amalgamation.sh. The CL also adds a layout test that verifies the patch works as intended. BUG=742407 Change-Id: I2e1a457459cd2e975e6241b630e7b79c82545981 Reviewed-on: https://chromium-review.googlesource.com/572976 Reviewed-by: Chris Mumford <cmumford@chromium.org> Commit-Queue: Victor Costan <pwnall@chromium.org> Cr-Commit-Position: refs/heads/master@{#487275} CWE ID: CWE-119
0
136,349
Analyze the following 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 release_ds_buffer(int cpu) { struct debug_store *ds = per_cpu(cpu_hw_events, cpu).ds; if (!ds) return; per_cpu(cpu_hw_events, cpu).ds = NULL; kfree(ds); } 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,843
Analyze the following 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 RenderViewImpl::StartNavStateSyncTimerIfNecessary(RenderFrameImpl* frame) { frames_with_pending_state_.insert(frame->GetRoutingID()); int delay; if (send_content_state_immediately_) delay = 0; else if (is_hidden()) delay = kDelaySecondsForContentStateSyncHidden; else delay = kDelaySecondsForContentStateSync; if (nav_state_sync_timer_.IsRunning()) { if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) return; nav_state_sync_timer_.Stop(); } nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, &RenderViewImpl::SendFrameStateUpdates); } 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,187
Analyze the following 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 TEE_Result umap_add_region(struct vm_info *vmi, struct vm_region *reg) { struct vm_region *r; struct vm_region *prev_r; vaddr_t va_range_base; size_t va_range_size; vaddr_t va; core_mmu_get_user_va_range(&va_range_base, &va_range_size); /* Check alignment, it has to be at least SMALL_PAGE based */ if ((reg->va | reg->size) & SMALL_PAGE_MASK) return TEE_ERROR_ACCESS_CONFLICT; /* Check that the mobj is defined for the entire range */ if ((reg->offset + reg->size) > ROUNDUP(reg->mobj->size, SMALL_PAGE_SIZE)) return TEE_ERROR_BAD_PARAMETERS; prev_r = NULL; TAILQ_FOREACH(r, &vmi->regions, link) { if (TAILQ_FIRST(&vmi->regions) == r) { va = select_va_in_range(va_range_base, 0, r->va, r->attr, reg); if (va) { reg->va = va; TAILQ_INSERT_HEAD(&vmi->regions, reg, link); return TEE_SUCCESS; } } else { va = select_va_in_range(prev_r->va + prev_r->size, prev_r->attr, r->va, r->attr, reg); if (va) { reg->va = va; TAILQ_INSERT_BEFORE(r, reg, link); return TEE_SUCCESS; } } prev_r = r; } r = TAILQ_LAST(&vmi->regions, vm_region_head); if (r) { va = select_va_in_range(r->va + r->size, r->attr, va_range_base + va_range_size, 0, reg); if (va) { reg->va = va; TAILQ_INSERT_TAIL(&vmi->regions, reg, link); return TEE_SUCCESS; } } else { va = select_va_in_range(va_range_base, 0, va_range_base + va_range_size, 0, reg); if (va) { reg->va = va; TAILQ_INSERT_HEAD(&vmi->regions, reg, link); return TEE_SUCCESS; } } return TEE_ERROR_ACCESS_CONFLICT; } Commit Message: core: tee_mmu_check_access_rights() check all pages Prior to this patch tee_mmu_check_access_rights() checks an address in each page of a supplied range. If both the start and length of that range is unaligned the last page in the range is sometimes not checked. With this patch the first address of each page in the range is checked to simplify the logic of checking each page and the range and also to cover the last page under all circumstances. Fixes: OP-TEE-2018-0005: "tee_mmu_check_access_rights does not check final page of TA buffer" Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Tested-by: Joakim Bech <joakim.bech@linaro.org> (QEMU v7, v8) Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Reported-by: Riscure <inforequest@riscure.com> Reported-by: Alyssa Milburn <a.a.milburn@vu.nl> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> CWE ID: CWE-20
0
86,984
Analyze the following 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 coroutine_fn v9fs_readdir(void *opaque) { int32_t fid; V9fsFidState *fidp; ssize_t retval = 0; size_t offset = 7; uint64_t initial_offset; int32_t count; uint32_t max_count; V9fsPDU *pdu = opaque; retval = pdu_unmarshal(pdu, offset, "dqd", &fid, &initial_offset, &max_count); if (retval < 0) { goto out_nofid; } trace_v9fs_readdir(pdu->tag, pdu->id, fid, initial_offset, max_count); fidp = get_fid(pdu, fid); if (fidp == NULL) { retval = -EINVAL; goto out_nofid; } if (!fidp->fs.dir.stream) { retval = -EINVAL; goto out; } if (initial_offset == 0) { v9fs_co_rewinddir(pdu, fidp); } else { v9fs_co_seekdir(pdu, fidp, initial_offset); } count = v9fs_do_readdir(pdu, fidp, max_count); if (count < 0) { retval = count; goto out; } retval = pdu_marshal(pdu, offset, "d", count); if (retval < 0) { goto out; } retval += count + offset; trace_v9fs_readdir_return(pdu->tag, pdu->id, count, retval); out: put_fid(pdu, fidp); out_nofid: pdu_complete(pdu, retval); } Commit Message: CWE ID: CWE-362
0
1,502
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: remove_prefix (char *p, size_t prefixlen) { char const *s = p + prefixlen; while ((*p++ = *s++)) /* do nothing */ ; } Commit Message: CWE ID: CWE-22
0
5,660
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int sctp_getsockopt_nodelay(struct sock *sk, int len, char __user *optval, int __user *optlen) { int val; if (len < sizeof(int)) return -EINVAL; len = sizeof(int); val = (sctp_sk(sk)->nodelay == 1); if (put_user(len, optlen)) return -EFAULT; if (copy_to_user(optval, &val, len)) return -EFAULT; return 0; } Commit Message: net/sctp: Validate parameter size for SCTP_GET_ASSOC_STATS Building sctp may fail with: In function ‘copy_from_user’, inlined from ‘sctp_getsockopt_assoc_stats’ at net/sctp/socket.c:5656:20: arch/x86/include/asm/uaccess_32.h:211:26: error: call to ‘copy_from_user_overflow’ declared with attribute error: copy_from_user() buffer size is not provably correct if built with W=1 due to a missing parameter size validation before the call to copy_from_user. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Vlad Yasevich <vyasevich@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-20
0
33,009
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void Ins_GETINFO( INS_ARG ) { Long K; K = 0; /* We return then Windows 3.1 version number */ /* for the font scaler */ if ( (args[0] & 1) != 0 ) K = 3; /* Has the glyph been rotated ? */ if ( CUR.metrics.rotated ) K |= 0x80; /* Has the glyph been stretched ? */ if ( CUR.metrics.stretched ) K |= 0x100; args[0] = K; } Commit Message: CWE ID: CWE-125
0
5,388
Analyze the following 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 set_ctxt_pkey(struct hfi1_ctxtdata *uctxt, unsigned subctxt, u16 pkey) { int ret = -ENOENT, i, intable = 0; struct hfi1_pportdata *ppd = uctxt->ppd; struct hfi1_devdata *dd = uctxt->dd; if (pkey == LIM_MGMT_P_KEY || pkey == FULL_MGMT_P_KEY) { ret = -EINVAL; goto done; } for (i = 0; i < ARRAY_SIZE(ppd->pkeys); i++) if (pkey == ppd->pkeys[i]) { intable = 1; break; } if (intable) ret = hfi1_set_ctxt_pkey(dd, uctxt->ctxt, pkey); done: return ret; } Commit Message: IB/security: Restrict use of the write() interface The drivers/infiniband stack uses write() as a replacement for bi-directional ioctl(). This is not safe. There are ways to trigger write calls that result in the return structure that is normally written to user space being shunted off to user specified kernel memory instead. For the immediate repair, detect and deny suspicious accesses to the write API. For long term, update the user space libraries and the kernel API to something that doesn't present the same security vulnerabilities (likely a structured ioctl() interface). The impacted uAPI interfaces are generally only available if hardware from drivers/infiniband is installed in the system. Reported-by: Jann Horn <jann@thejh.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> [ Expanded check to all known write() entry points ] Cc: stable@vger.kernel.org Signed-off-by: Doug Ledford <dledford@redhat.com> CWE ID: CWE-264
0
52,978
Analyze the following 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 *ns_get_path(struct path *path, struct task_struct *task, const struct proc_ns_operations *ns_ops) { struct ns_common *ns; void *ret; again: ns = ns_ops->get(task); if (!ns) return ERR_PTR(-ENOENT); ret = __ns_get_path(path, ns); if (IS_ERR(ret) && PTR_ERR(ret) == -EAGAIN) goto again; return ret; } Commit Message: nsfs: mark dentry with DCACHE_RCUACCESS Andrey reported a use-after-free in __ns_get_path(): spin_lock include/linux/spinlock.h:299 [inline] lockref_get_not_dead+0x19/0x80 lib/lockref.c:179 __ns_get_path+0x197/0x860 fs/nsfs.c:66 open_related_ns+0xda/0x200 fs/nsfs.c:143 sock_ioctl+0x39d/0x440 net/socket.c:1001 vfs_ioctl fs/ioctl.c:45 [inline] do_vfs_ioctl+0x1bf/0x1780 fs/ioctl.c:685 SYSC_ioctl fs/ioctl.c:700 [inline] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691 We are under rcu read lock protection at that point: rcu_read_lock(); d = atomic_long_read(&ns->stashed); if (!d) goto slow; dentry = (struct dentry *)d; if (!lockref_get_not_dead(&dentry->d_lockref)) goto slow; rcu_read_unlock(); but don't use a proper RCU API on the free path, therefore a parallel __d_free() could free it at the same time. We need to mark the stashed dentry with DCACHE_RCUACCESS so that __d_free() will be called after all readers leave RCU. Fixes: e149ed2b805f ("take the targets of /proc/*/ns/* symlinks to separate fs") Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Andrew Morton <akpm@linux-foundation.org> Reported-by: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID: CWE-416
0
84,662
Analyze the following 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::DidAddContentSecurityPolicies( const blink::WebVector<blink::WebContentSecurityPolicy>& policies) { std::vector<ContentSecurityPolicy> content_policies; for (const auto& policy : policies) content_policies.push_back(BuildContentSecurityPolicy(policy)); Send(new FrameHostMsg_DidAddContentSecurityPolicies(routing_id_, content_policies)); } Commit Message: Convert FrameHostMsg_DidAddMessageToConsole to Mojo. Note: Since this required changing the test RenderViewImplTest.DispatchBeforeUnloadCanDetachFrame, I manually re-introduced https://crbug.com/666714 locally (the bug the test was added for), and reran the test to confirm that it still covers the bug. Bug: 786836 Change-Id: I110668fa6f0f261fd2ac36bb91a8d8b31c99f4f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1526270 Commit-Queue: Lowell Manners <lowell@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Camille Lamy <clamy@chromium.org> Cr-Commit-Position: refs/heads/master@{#653137} CWE ID: CWE-416
0
139,567
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: virConnectGetDomainCapabilities(virConnectPtr conn, const char *emulatorbin, const char *arch, const char *machine, const char *virttype, unsigned int flags) { VIR_DEBUG("conn=%p, emulatorbin=%s, arch=%s, " "machine=%s, virttype=%s, flags=%x", conn, NULLSTR(emulatorbin), NULLSTR(arch), NULLSTR(machine), NULLSTR(virttype), flags); virResetLastError(); virCheckConnectReturn(conn, NULL); if (conn->driver->connectGetDomainCapabilities) { char *ret; ret = conn->driver->connectGetDomainCapabilities(conn, emulatorbin, arch, machine, virttype, flags); if (!ret) goto error; VIR_DEBUG("conn=%p, ret=%s", conn, ret); return ret; } virReportUnsupportedError(); error: virDispatchError(conn); return NULL; } Commit Message: virDomainGetTime: Deny on RO connections We have a policy that if API may end up talking to a guest agent it should require RW connection. We don't obey the rule in virDomainGetTime(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> CWE ID: CWE-254
0
93,753
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void assoc_array_rcu_cleanup(struct rcu_head *head) { struct assoc_array_edit *edit = container_of(head, struct assoc_array_edit, rcu); int i; pr_devel("-->%s()\n", __func__); if (edit->dead_leaf) edit->ops->free_object(assoc_array_ptr_to_leaf(edit->dead_leaf)); for (i = 0; i < ARRAY_SIZE(edit->excised_meta); i++) if (edit->excised_meta[i]) kfree(assoc_array_ptr_to_node(edit->excised_meta[i])); if (edit->excised_subtree) { BUG_ON(assoc_array_ptr_is_leaf(edit->excised_subtree)); if (assoc_array_ptr_is_node(edit->excised_subtree)) { struct assoc_array_node *n = assoc_array_ptr_to_node(edit->excised_subtree); n->back_pointer = NULL; } else { struct assoc_array_shortcut *s = assoc_array_ptr_to_shortcut(edit->excised_subtree); s->back_pointer = NULL; } assoc_array_destroy_subtree(edit->excised_subtree, edit->ops_for_excised_subtree); } kfree(edit); } Commit Message: KEYS: Fix termination condition in assoc array garbage collection This fixes CVE-2014-3631. It is possible for an associative array to end up with a shortcut node at the root of the tree if there are more than fan-out leaves in the tree, but they all crowd into the same slot in the lowest level (ie. they all have the same first nibble of their index keys). When assoc_array_gc() returns back up the tree after scanning some leaves, it can fall off of the root and crash because it assumes that the back pointer from a shortcut (after label ascend_old_tree) must point to a normal node - which isn't true of a shortcut node at the root. Should we find we're ascending rootwards over a shortcut, we should check to see if the backpointer is zero - and if it is, we have completed the scan. This particular bug cannot occur if the root node is not a shortcut - ie. if you have fewer than 17 keys in a keyring or if you have at least two keys that sit into separate slots (eg. a keyring and a non keyring). This can be reproduced by: ring=`keyctl newring bar @s` for ((i=1; i<=18; i++)); do last_key=`keyctl newring foo$i $ring`; done keyctl timeout $last_key 2 Doing this: echo 3 >/proc/sys/kernel/keys/gc_delay first will speed things up. If we do fall off of the top of the tree, we get the following oops: BUG: unable to handle kernel NULL pointer dereference at 0000000000000018 IP: [<ffffffff8136cea7>] assoc_array_gc+0x2f7/0x540 PGD dae15067 PUD cfc24067 PMD 0 Oops: 0000 [#1] SMP Modules linked in: xt_nat xt_mark nf_conntrack_netbios_ns nf_conntrack_broadcast ip6t_rpfilter ip6t_REJECT xt_conntrack ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_ni CPU: 0 PID: 26011 Comm: kworker/0:1 Not tainted 3.14.9-200.fc20.x86_64 #1 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 Workqueue: events key_garbage_collector task: ffff8800918bd580 ti: ffff8800aac14000 task.ti: ffff8800aac14000 RIP: 0010:[<ffffffff8136cea7>] [<ffffffff8136cea7>] assoc_array_gc+0x2f7/0x540 RSP: 0018:ffff8800aac15d40 EFLAGS: 00010206 RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff8800aaecacc0 RDX: ffff8800daecf440 RSI: 0000000000000001 RDI: ffff8800aadc2bc0 RBP: ffff8800aac15da8 R08: 0000000000000001 R09: 0000000000000003 R10: ffffffff8136ccc7 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000070 R15: 0000000000000001 FS: 0000000000000000(0000) GS:ffff88011fc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: 0000000000000018 CR3: 00000000db10d000 CR4: 00000000000006f0 Stack: ffff8800aac15d50 0000000000000011 ffff8800aac15db8 ffffffff812e2a70 ffff880091a00600 0000000000000000 ffff8800aadc2bc3 00000000cd42c987 ffff88003702df20 ffff88003702dfa0 0000000053b65c09 ffff8800aac15fd8 Call Trace: [<ffffffff812e2a70>] ? keyring_detect_cycle_iterator+0x30/0x30 [<ffffffff812e3e75>] keyring_gc+0x75/0x80 [<ffffffff812e1424>] key_garbage_collector+0x154/0x3c0 [<ffffffff810a67b6>] process_one_work+0x176/0x430 [<ffffffff810a744b>] worker_thread+0x11b/0x3a0 [<ffffffff810a7330>] ? rescuer_thread+0x3b0/0x3b0 [<ffffffff810ae1a8>] kthread+0xd8/0xf0 [<ffffffff810ae0d0>] ? insert_kthread_work+0x40/0x40 [<ffffffff816ffb7c>] ret_from_fork+0x7c/0xb0 [<ffffffff810ae0d0>] ? insert_kthread_work+0x40/0x40 Code: 08 4c 8b 22 0f 84 bf 00 00 00 41 83 c7 01 49 83 e4 fc 41 83 ff 0f 4c 89 65 c0 0f 8f 5a fe ff ff 48 8b 45 c0 4d 63 cf 49 83 c1 02 <4e> 8b 34 c8 4d 85 f6 0f 84 be 00 00 00 41 f6 c6 01 0f 84 92 RIP [<ffffffff8136cea7>] assoc_array_gc+0x2f7/0x540 RSP <ffff8800aac15d40> CR2: 0000000000000018 ---[ end trace 1129028a088c0cbd ]--- Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Don Zickus <dzickus@redhat.com> Signed-off-by: James Morris <james.l.morris@oracle.com> CWE ID:
0
37,703
Analyze the following 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 _zend_is_inconsistent(const HashTable *ht, const char *file, int line) { if ((ht->u.flags & HASH_MASK_CONSISTENCY) == HT_OK) { return; } switch ((ht->u.flags & HASH_MASK_CONSISTENCY)) { case HT_IS_DESTROYING: zend_output_debug_string(1, "%s(%d) : ht=%p is being destroyed", file, line, ht); break; case HT_DESTROYED: zend_output_debug_string(1, "%s(%d) : ht=%p is already destroyed", file, line, ht); break; case HT_CLEANING: zend_output_debug_string(1, "%s(%d) : ht=%p is being cleaned", file, line, ht); break; default: zend_output_debug_string(1, "%s(%d) : ht=%p is inconsistent", file, line, ht); break; } zend_bailout(); } Commit Message: Fix #73832 - leave the table in a safe state if the size is too big. CWE ID: CWE-190
0
69,153
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void kernel_sigaction(int sig, __sighandler_t action) { spin_lock_irq(&current->sighand->siglock); current->sighand->action[sig - 1].sa.sa_handler = action; if (action == SIG_IGN) { sigset_t mask; sigemptyset(&mask); sigaddset(&mask, sig); flush_sigqueue_mask(&mask, &current->signal->shared_pending); flush_sigqueue_mask(&mask, &current->pending); recalc_sigpending(); } spin_unlock_irq(&current->sighand->siglock); } Commit Message: kernel/signal.c: avoid undefined behaviour in kill_something_info When running kill(72057458746458112, 0) in userspace I hit the following issue. UBSAN: Undefined behaviour in kernel/signal.c:1462:11 negation of -2147483648 cannot be represented in type 'int': CPU: 226 PID: 9849 Comm: test Tainted: G B ---- ------- 3.10.0-327.53.58.70.x86_64_ubsan+ #116 Hardware name: Huawei Technologies Co., Ltd. RH8100 V3/BC61PBIA, BIOS BLHSV028 11/11/2014 Call Trace: dump_stack+0x19/0x1b ubsan_epilogue+0xd/0x50 __ubsan_handle_negate_overflow+0x109/0x14e SYSC_kill+0x43e/0x4d0 SyS_kill+0xe/0x10 system_call_fastpath+0x16/0x1b Add code to avoid the UBSAN detection. [akpm@linux-foundation.org: tweak comment] Link: http://lkml.kernel.org/r/1496670008-59084-1-git-send-email-zhongjiang@huawei.com Signed-off-by: zhongjiang <zhongjiang@huawei.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Michal Hocko <mhocko@kernel.org> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Xishi Qiu <qiuxishi@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID: CWE-119
0
83,230
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool venc_dev::venc_loaded_stop_done() { return true; } Commit Message: DO NOT MERGE mm-video-v4l2: venc: add checks before accessing heap pointers Heap pointers do not point to user virtual addresses in case of secure session. Set them to NULL and add checks to avoid accesing them Bug: 28815329 Bug: 28920116 Change-Id: I94fd5808e753b58654d65e175d3857ef46ffba26 CWE ID: CWE-200
0
159,273
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: kgdb_set_hw_break(unsigned long addr, int len, enum kgdb_bptype bptype) { int i; for (i = 0; i < HBP_NUM; i++) if (!breakinfo[i].enabled) break; if (i == HBP_NUM) return -1; switch (bptype) { case BP_HARDWARE_BREAKPOINT: len = 1; breakinfo[i].type = X86_BREAKPOINT_EXECUTE; break; case BP_WRITE_WATCHPOINT: breakinfo[i].type = X86_BREAKPOINT_WRITE; break; case BP_ACCESS_WATCHPOINT: breakinfo[i].type = X86_BREAKPOINT_RW; break; default: return -1; } switch (len) { case 1: breakinfo[i].len = X86_BREAKPOINT_LEN_1; break; case 2: breakinfo[i].len = X86_BREAKPOINT_LEN_2; break; case 4: breakinfo[i].len = X86_BREAKPOINT_LEN_4; break; #ifdef CONFIG_X86_64 case 8: breakinfo[i].len = X86_BREAKPOINT_LEN_8; break; #endif default: return -1; } breakinfo[i].addr = addr; if (hw_break_reserve_slot(i)) { breakinfo[i].addr = 0; return -1; } breakinfo[i].enabled = 1; return 0; } Commit Message: perf: Remove the nmi parameter from the swevent and overflow interface The nmi parameter indicated if we could do wakeups from the current context, if not, we would set some state and self-IPI and let the resulting interrupt do the wakeup. For the various event classes: - hardware: nmi=0; PMI is in fact an NMI or we run irq_work_run from the PMI-tail (ARM etc.) - tracepoint: nmi=0; since tracepoint could be from NMI context. - software: nmi=[0,1]; some, like the schedule thing cannot perform wakeups, and hence need 0. As one can see, there is very little nmi=1 usage, and the down-side of not using it is that on some platforms some software events can have a jiffy delay in wakeup (when arch_irq_work_raise isn't implemented). The up-side however is that we can remove the nmi parameter and save a bunch of conditionals in fast paths. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Michael Cree <mcree@orcon.net.nz> Cc: Will Deacon <will.deacon@arm.com> Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com> Cc: Anton Blanchard <anton@samba.org> Cc: Eric B Munson <emunson@mgebm.net> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Paul Mundt <lethal@linux-sh.org> Cc: David S. Miller <davem@davemloft.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jason Wessel <jason.wessel@windriver.com> Cc: Don Zickus <dzickus@redhat.com> Link: http://lkml.kernel.org/n/tip-agjev8eu666tvknpb3iaj0fg@git.kernel.org Signed-off-by: Ingo Molnar <mingo@elte.hu> CWE ID: CWE-399
0
25,883
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Browser::OpenAboutChromeDialog() { UserMetrics::RecordAction(UserMetricsAction("AboutChrome"), profile_); #if defined(OS_CHROMEOS) ShowSingletonTab(GURL(chrome::kChromeUIAboutURL)); #else window_->ShowAboutChromeDialog(); #endif } Commit Message: chromeos: fix bug where "aw snap" page replaces first tab if it was a NTP when closing window with > 1 tab. BUG=chromium-os:12088 TEST=verify bug per bug report. Review URL: http://codereview.chromium.org/6882058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83031 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
98,264
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void clientsCron(void) { /* Make sure to process at least numclients/server.hz of clients * per call. Since this function is called server.hz times per second * we are sure that in the worst case we process all the clients in 1 * second. */ int numclients = listLength(server.clients); int iterations = numclients/server.hz; mstime_t now = mstime(); /* Process at least a few clients while we are at it, even if we need * to process less than CLIENTS_CRON_MIN_ITERATIONS to meet our contract * of processing each client once per second. */ if (iterations < CLIENTS_CRON_MIN_ITERATIONS) iterations = (numclients < CLIENTS_CRON_MIN_ITERATIONS) ? numclients : CLIENTS_CRON_MIN_ITERATIONS; while(listLength(server.clients) && iterations--) { client *c; listNode *head; /* Rotate the list, take the current head, process. * This way if the client must be removed from the list it's the * first element and we don't incur into O(N) computation. */ listRotate(server.clients); head = listFirst(server.clients); c = listNodeValue(head); /* The following functions do different service checks on the client. * The protocol is that they return non-zero if the client was * terminated. */ if (clientsCronHandleTimeout(c,now)) continue; if (clientsCronResizeQueryBuffer(c)) continue; } } Commit Message: Security: Cross Protocol Scripting protection. This is an attempt at mitigating problems due to cross protocol scripting, an attack targeting services using line oriented protocols like Redis that can accept HTTP requests as valid protocol, by discarding the invalid parts and accepting the payloads sent, for example, via a POST request. For this to be effective, when we detect POST and Host: and terminate the connection asynchronously, the networking code was modified in order to never process further input. It was later verified that in a pipelined request containing a POST command, the successive commands are not executed. CWE ID: CWE-254
0
70,003
Analyze the following 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 V8TestObject::UrlStringAttributeAttributeSetterCallback( const v8::FunctionCallbackInfo<v8::Value>& info) { RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_urlStringAttribute_Setter"); v8::Local<v8::Value> v8_value = info[0]; test_object_v8_internal::UrlStringAttributeAttributeSetter(v8_value, info); } Commit Message: bindings: Support "attribute FrozenArray<T>?" Adds a quick hack to support a case of "attribute FrozenArray<T>?". Bug: 1028047 Change-Id: Ib3cecc4beb6bcc0fb0dbc667aca595454cc90c86 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1933866 Reviewed-by: Hitoshi Yoshida <peria@chromium.org> Commit-Queue: Yuki Shiino <yukishiino@chromium.org> Cr-Commit-Position: refs/heads/master@{#718676} CWE ID:
0
135,323
Analyze the following 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 ax25_release(struct socket *sock) { struct sock *sk = sock->sk; ax25_cb *ax25; if (sk == NULL) return 0; sock_hold(sk); sock_orphan(sk); lock_sock(sk); ax25 = sk_to_ax25(sk); if (sk->sk_type == SOCK_SEQPACKET) { switch (ax25->state) { case AX25_STATE_0: release_sock(sk); ax25_disconnect(ax25, 0); lock_sock(sk); ax25_destroy_socket(ax25); break; case AX25_STATE_1: case AX25_STATE_2: ax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND); release_sock(sk); ax25_disconnect(ax25, 0); lock_sock(sk); ax25_destroy_socket(ax25); break; case AX25_STATE_3: case AX25_STATE_4: ax25_clear_queues(ax25); ax25->n2count = 0; switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { case AX25_PROTO_STD_SIMPLEX: case AX25_PROTO_STD_DUPLEX: ax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND); ax25_stop_t2timer(ax25); ax25_stop_t3timer(ax25); ax25_stop_idletimer(ax25); break; #ifdef CONFIG_AX25_DAMA_SLAVE case AX25_PROTO_DAMA_SLAVE: ax25_stop_t3timer(ax25); ax25_stop_idletimer(ax25); break; #endif } ax25_calculate_t1(ax25); ax25_start_t1timer(ax25); ax25->state = AX25_STATE_2; sk->sk_state = TCP_CLOSE; sk->sk_shutdown |= SEND_SHUTDOWN; sk->sk_state_change(sk); sock_set_flag(sk, SOCK_DESTROY); break; default: break; } } else { sk->sk_state = TCP_CLOSE; sk->sk_shutdown |= SEND_SHUTDOWN; sk->sk_state_change(sk); ax25_destroy_socket(ax25); } sock->sk = NULL; release_sock(sk); sock_put(sk); return 0; } 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,461
Analyze the following 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 char *createAccessFlagStr(ut32 flags, AccessFor forWhat) { #define NUM_FLAGS 18 static const char* kAccessStrings[kAccessForMAX][NUM_FLAGS] = { { /* class, inner class */ "PUBLIC", /* 0x0001 */ "PRIVATE", /* 0x0002 */ "PROTECTED", /* 0x0004 */ "STATIC", /* 0x0008 */ "FINAL", /* 0x0010 */ "?", /* 0x0020 */ "?", /* 0x0040 */ "?", /* 0x0080 */ "?", /* 0x0100 */ "INTERFACE", /* 0x0200 */ "ABSTRACT", /* 0x0400 */ "?", /* 0x0800 */ "SYNTHETIC", /* 0x1000 */ "ANNOTATION", /* 0x2000 */ "ENUM", /* 0x4000 */ "?", /* 0x8000 */ "VERIFIED", /* 0x10000 */ "OPTIMIZED", /* 0x20000 */ }, { /* method */ "PUBLIC", /* 0x0001 */ "PRIVATE", /* 0x0002 */ "PROTECTED", /* 0x0004 */ "STATIC", /* 0x0008 */ "FINAL", /* 0x0010 */ "SYNCHRONIZED", /* 0x0020 */ "BRIDGE", /* 0x0040 */ "VARARGS", /* 0x0080 */ "NATIVE", /* 0x0100 */ "?", /* 0x0200 */ "ABSTRACT", /* 0x0400 */ "STRICT", /* 0x0800 */ "SYNTHETIC", /* 0x1000 */ "?", /* 0x2000 */ "?", /* 0x4000 */ "MIRANDA", /* 0x8000 */ "CONSTRUCTOR", /* 0x10000 */ "DECLARED_SYNCHRONIZED", /* 0x20000 */ }, { /* field */ "PUBLIC", /* 0x0001 */ "PRIVATE", /* 0x0002 */ "PROTECTED", /* 0x0004 */ "STATIC", /* 0x0008 */ "FINAL", /* 0x0010 */ "?", /* 0x0020 */ "VOLATILE", /* 0x0040 */ "TRANSIENT", /* 0x0080 */ "?", /* 0x0100 */ "?", /* 0x0200 */ "?", /* 0x0400 */ "?", /* 0x0800 */ "SYNTHETIC", /* 0x1000 */ "?", /* 0x2000 */ "ENUM", /* 0x4000 */ "?", /* 0x8000 */ "?", /* 0x10000 */ "?", /* 0x20000 */ }, }; const int kLongest = 21; int i, count; char* str; char* cp; count = countOnes(flags); cp = str = (char*) malloc (count * (kLongest + 1) + 1); for (i = 0; i < NUM_FLAGS; i++) { if (flags & 0x01) { const char* accessStr = kAccessStrings[forWhat][i]; int len = strlen(accessStr); if (cp != str) { *cp++ = ' '; } memcpy(cp, accessStr, len); cp += len; } flags >>= 1; } *cp = '\0'; return str; } Commit Message: fix #6872 CWE ID: CWE-476
0
68,085