instruction
stringclasses
1 value
input
stringlengths
64
129k
output
int64
0
1
__index_level_0__
int64
0
30k
Analyze the following 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 jas_iccprof_readhdr(jas_stream_t *in, jas_icchdr_t *hdr) { if (jas_iccgetuint32(in, &hdr->size) || jas_iccgetuint32(in, &hdr->cmmtype) || jas_iccgetuint32(in, &hdr->version) || jas_iccgetuint32(in, &hdr->clas) || jas_iccgetuint32(in, &hdr->colorspc) || jas_iccgetuint32(in, &hdr->refcolorspc) || jas_iccgettime(in, &hdr->ctime) || jas_iccgetuint32(in, &hdr->magic) || jas_iccgetuint32(in, &hdr->platform) || jas_iccgetuint32(in, &hdr->flags) || jas_iccgetuint32(in, &hdr->maker) || jas_iccgetuint32(in, &hdr->model) || jas_iccgetuint64(in, &hdr->attr) || jas_iccgetuint32(in, &hdr->intent) || jas_iccgetxyz(in, &hdr->illum) || jas_iccgetuint32(in, &hdr->creator) || jas_stream_gobble(in, 44) != 44) return -1; return 0; } Commit Message: The generation of the configuration file jas_config.h has been completely reworked in order to avoid pollution of the global namespace. Some problematic types like uchar, ulong, and friends have been replaced with names with a jas_ prefix. An option max_samples has been added to the BMP and JPEG decoders to restrict the maximum size of image that they can decode. This change was made as a (possibly temporary) fix to address security concerns. A max_samples command-line option has also been added to imginfo. Whether an image component (for jas_image_t) is stored in memory or on disk is now based on the component size (rather than the image size). Some debug log message were added. Some new integer overflow checks were added. Some new safe integer add/multiply functions were added. More pre-C99 cruft was removed. JasPer has numerous "hacks" to handle pre-C99 compilers. JasPer now assumes C99 support. So, this pre-C99 cruft is unnecessary and can be removed. The regression jasper-doublefree-mem_close.jpg has been re-enabled. Theoretically, it should work more predictably now. CWE ID: CWE-190
0
1,607
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int skcipher_accept_parent(void *private, struct sock *sk) { struct skcipher_ctx *ctx; struct alg_sock *ask = alg_sk(sk); unsigned int len = sizeof(*ctx) + crypto_skcipher_reqsize(private); ctx = sock_kmalloc(sk, len, GFP_KERNEL); if (!ctx) return -ENOMEM; ctx->iv = sock_kmalloc(sk, crypto_skcipher_ivsize(private), GFP_KERNEL); if (!ctx->iv) { sock_kfree_s(sk, ctx, len); return -ENOMEM; } memset(ctx->iv, 0, crypto_skcipher_ivsize(private)); INIT_LIST_HEAD(&ctx->tsgl); ctx->len = len; ctx->used = 0; ctx->more = 0; ctx->merge = 0; ctx->enc = 0; atomic_set(&ctx->inflight, 0); af_alg_init_completion(&ctx->completion); ask->private = ctx; skcipher_request_set_tfm(&ctx->req, private); skcipher_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_BACKLOG, af_alg_complete, &ctx->completion); sk->sk_destruct = skcipher_sock_destruct; return 0; } Commit Message: crypto: algif_skcipher - Require setkey before accept(2) Some cipher implementations will crash if you try to use them without calling setkey first. This patch adds a check so that the accept(2) call will fail with -ENOKEY if setkey hasn't been done on the socket yet. Cc: stable@vger.kernel.org Reported-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Tested-by: Dmitry Vyukov <dvyukov@google.com> CWE ID: CWE-476
1
4,650
Analyze the following 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 ScrollHitTestDisplayItem::Record( GraphicsContext& context, const DisplayItemClient& client, DisplayItem::Type type, scoped_refptr<const TransformPaintPropertyNode> scroll_offset_node) { PaintController& paint_controller = context.GetPaintController(); DCHECK_NE(paint_controller.CurrentPaintChunkProperties().Transform(), scroll_offset_node.get()); if (paint_controller.DisplayItemConstructionIsDisabled()) return; paint_controller.CreateAndAppend<ScrollHitTestDisplayItem>( client, type, std::move(scroll_offset_node)); } Commit Message: Reland "[CI] Make paint property nodes non-ref-counted" This reverts commit 887383b30842d9d9006e11bb6932660a3cb5b1b7. Reason for revert: Retry in M69. Original change's description: > Revert "[CI] Make paint property nodes non-ref-counted" > > This reverts commit 70fc0b018c9517558b7aa2be00edf2debb449123. > > Reason for revert: Caused bugs found by clusterfuzz > > Original change's description: > > [CI] Make paint property nodes non-ref-counted > > > > Now all paint property nodes are owned by ObjectPaintProperties > > (and LocalFrameView temporarily before removing non-RLS mode). > > Others just use raw pointers or references. > > > > Bug: 833496 > > Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2 > > Change-Id: I2d544fe153bb94698623248748df63c8aa2081ae > > Reviewed-on: https://chromium-review.googlesource.com/1031101 > > Reviewed-by: Tien-Ren Chen <trchen@chromium.org> > > Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#554626} > > TBR=wangxianzhu@chromium.org,trchen@chromium.org,chrishtr@chromium.org > > Change-Id: I02bb50d6744cb81a797246a0116b677e80a3c69f > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: 833496,837932,837943 > Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2 > Reviewed-on: https://chromium-review.googlesource.com/1034292 > Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org> > Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> > Cr-Commit-Position: refs/heads/master@{#554653} TBR=wangxianzhu@chromium.org,trchen@chromium.org,chrishtr@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: 833496, 837932, 837943 Change-Id: I0b4ef70db1f1f211ba97c30d617225355c750992 Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2 Reviewed-on: https://chromium-review.googlesource.com/1083491 Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org> Cr-Commit-Position: refs/heads/master@{#563930} CWE ID:
1
14,631
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: hb_buffer_get_script (hb_buffer_t *buffer) { return buffer->script; } Commit Message: CWE ID:
0
10,837
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: xps_select_font_encoding(xps_font_t *font, int idx) { byte *cmapdata, *entry; int pid, eid; if (idx < 0 || idx >= font->cmapsubcount) return 0; cmapdata = font->data + font->cmaptable; entry = cmapdata + 4 + idx * 8; pid = u16(entry + 0); eid = u16(entry + 2); font->cmapsubtable = font->cmaptable + u32(entry + 4); if (font->cmapsubtable >= font->length) { font->cmapsubtable = 0; return 0; } font->usepua = (pid == 3 && eid == 0); return 1; } Commit Message: CWE ID: CWE-125
0
9,155
Analyze the following 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 perf_tp_event(u16 event_type, u64 count, void *record, int entry_size, struct pt_regs *regs, struct hlist_head *head, int rctx, struct task_struct *task) { struct perf_sample_data data; struct perf_event *event; struct perf_raw_record raw = { .frag = { .size = entry_size, .data = record, }, }; perf_sample_data_init(&data, 0, 0); data.raw = &raw; perf_trace_buf_update(record, event_type); hlist_for_each_entry_rcu(event, head, hlist_entry) { if (perf_tp_event_match(event, &data, regs)) perf_swevent_event(event, count, &data, regs); } /* * If we got specified a target task, also iterate its context and * deliver this event there too. */ if (task && task != current) { struct perf_event_context *ctx; struct trace_entry *entry = record; rcu_read_lock(); ctx = rcu_dereference(task->perf_event_ctxp[perf_sw_context]); if (!ctx) goto unlock; list_for_each_entry_rcu(event, &ctx->event_list, event_entry) { if (event->attr.type != PERF_TYPE_TRACEPOINT) continue; if (event->attr.config != entry->type) continue; if (perf_tp_event_match(event, &data, regs)) perf_swevent_event(event, count, &data, regs); } unlock: rcu_read_unlock(); } perf_swevent_put_recursion_context(rctx); } Commit Message: perf/core: Fix concurrent sys_perf_event_open() vs. 'move_group' race Di Shen reported a race between two concurrent sys_perf_event_open() calls where both try and move the same pre-existing software group into a hardware context. The problem is exactly that described in commit: f63a8daa5812 ("perf: Fix event->ctx locking") ... where, while we wait for a ctx->mutex acquisition, the event->ctx relation can have changed under us. That very same commit failed to recognise sys_perf_event_context() as an external access vector to the events and thereby didn't apply the established locking rules correctly. So while one sys_perf_event_open() call is stuck waiting on mutex_lock_double(), the other (which owns said locks) moves the group about. So by the time the former sys_perf_event_open() acquires the locks, the context we've acquired is stale (and possibly dead). Apply the established locking rules as per perf_event_ctx_lock_nested() to the mutex_lock_double() for the 'move_group' case. This obviously means we need to validate state after we acquire the locks. Reported-by: Di Shen (Keen Lab) Tested-by: John Dias <joaodias@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Kees Cook <keescook@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Min Chong <mchong@google.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Fixes: f63a8daa5812 ("perf: Fix event->ctx locking") Link: http://lkml.kernel.org/r/20170106131444.GZ3174@twins.programming.kicks-ass.net Signed-off-by: Ingo Molnar <mingo@kernel.org> CWE ID: CWE-362
0
4,473
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: nfs4_xdr_enc_getacl(struct rpc_rqst *req, __be32 *p, struct nfs_getaclargs *args) { struct xdr_stream xdr; struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth; struct compound_hdr hdr = { .nops = 2, }; int replen, status; xdr_init_encode(&xdr, &req->rq_snd_buf, p); encode_compound_hdr(&xdr, &hdr); status = encode_putfh(&xdr, args->fh); if (status) goto out; status = encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0); /* set up reply buffer: */ replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_getacl_sz) << 2; xdr_inline_pages(&req->rq_rcv_buf, replen, args->acl_pages, args->acl_pgbase, args->acl_len); out: return status; } Commit Message: NFSv4: Convert the open and close ops to use fmode Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> CWE ID:
0
17,443
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const int len, const cJSON_bool fmt) { printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; if ((len < 0) || (buf == NULL)) { return false; } p.buffer = (unsigned char*)buf; p.length = (size_t)len; p.offset = 0; p.noalloc = true; p.format = fmt; p.hooks = global_hooks; return print_value(item, &p); } Commit Message: Fix crash of cJSON_GetObjectItemCaseSensitive when calling it on arrays CWE ID: CWE-754
0
19,723
Analyze the following 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* sspi_SecureHandleGetUpperPointer(SecHandle* handle) { void* pointer; if (!handle) return NULL; pointer = (void*) ~((size_t) handle->dwUpper); return pointer; } Commit Message: nla: invalidate sec handle after creation If sec pointer isn't invalidated after creation it is not possible to check if the upper and lower pointers are valid. This fixes a segfault in the server part if the client disconnects before the authentication was finished. CWE ID: CWE-476
1
15,965
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: test_bson_visit_unsupported_type (void) { /* {k: 1}, but instead of BSON type 0x10 (int32), use unknown type 0x33 */ const char data[] = "\x0c\x00\x00\x00\x33k\x00\x01\x00\x00\x00\x00"; bson_t b; bson_iter_t iter; unsupported_type_test_data_t context = {0}; bson_visitor_t visitor = {0}; visitor.visit_unsupported_type = visit_unsupported_type; BSON_ASSERT (bson_init_static (&b, (const uint8_t *) data, sizeof data - 1)); BSON_ASSERT (bson_iter_init (&iter, &b)); BSON_ASSERT (!bson_iter_visit_all (&iter, &visitor, (void *) &context)); BSON_ASSERT (!bson_iter_next (&iter)); BSON_ASSERT (context.visited); BSON_ASSERT (!strcmp (context.key, "k")); BSON_ASSERT (context.type_code == '\x33'); } Commit Message: Fix for CVE-2018-16790 -- Verify bounds before binary length read. As reported here: https://jira.mongodb.org/browse/CDRIVER-2819, a heap overread occurs due a failure to correctly verify data bounds. In the original check, len - o returns the data left including the sizeof(l) we just read. Instead, the comparison should check against the data left NOT including the binary int32, i.e. just subtype (byte*) instead of int32 subtype (byte*). Added in test for corrupted BSON example. CWE ID: CWE-125
0
24,985
Analyze the following 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 SimulateGesturePinchSequence(WebContents* web_contents, const gfx::Point& point, float scale, blink::WebGestureDevice source_device) { RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From( web_contents->GetRenderViewHost()->GetWidget()); blink::WebGestureEvent pinch_begin(blink::WebInputEvent::kGesturePinchBegin, blink::WebInputEvent::kNoModifiers, ui::EventTimeForNow(), source_device); pinch_begin.SetPositionInWidget(gfx::PointF(point)); pinch_begin.SetPositionInScreen(gfx::PointF(point)); widget_host->ForwardGestureEvent(pinch_begin); blink::WebGestureEvent pinch_update(pinch_begin); pinch_update.SetType(blink::WebInputEvent::kGesturePinchUpdate); pinch_update.data.pinch_update.scale = scale; widget_host->ForwardGestureEvent(pinch_update); blink::WebGestureEvent pinch_end(pinch_begin); pinch_update.SetType(blink::WebInputEvent::kGesturePinchEnd); widget_host->ForwardGestureEvent(pinch_end); } Commit Message: Apply ExtensionNavigationThrottle filesystem/blob checks to all frames. BUG=836858 Change-Id: I34333a72501129fd40b5a9aa6378c9f35f1e7fc2 Reviewed-on: https://chromium-review.googlesource.com/1028511 Reviewed-by: Devlin <rdevlin.cronin@chromium.org> Reviewed-by: Alex Moshchuk <alexmos@chromium.org> Reviewed-by: Nick Carter <nick@chromium.org> Commit-Queue: Charlie Reis <creis@chromium.org> Cr-Commit-Position: refs/heads/master@{#553867} CWE ID: CWE-20
0
5,595
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: String AXNodeObject::nativeTextAlternative( AXObjectSet& visited, AXNameFrom& nameFrom, AXRelatedObjectVector* relatedObjects, NameSources* nameSources, bool* foundTextAlternative) const { if (!getNode()) return String(); if (nameSources) ASSERT(relatedObjects); String textAlternative; AXRelatedObjectVector localRelatedObjects; const HTMLInputElement* inputElement = nullptr; if (isHTMLInputElement(getNode())) inputElement = toHTMLInputElement(getNode()); HTMLElement* htmlElement = nullptr; if (getNode()->isHTMLElement()) htmlElement = toHTMLElement(getNode()); if (htmlElement && htmlElement->isLabelable()) { nameFrom = AXNameFromRelatedElement; if (nameSources) { nameSources->push_back(NameSource(*foundTextAlternative)); nameSources->back().type = nameFrom; nameSources->back().nativeSource = AXTextFromNativeHTMLLabel; } LabelsNodeList* labels = toLabelableElement(htmlElement)->labels(); if (labels && labels->length() > 0) { HeapVector<Member<Element>> labelElements; for (unsigned labelIndex = 0; labelIndex < labels->length(); ++labelIndex) { Element* label = labels->item(labelIndex); if (nameSources) { if (!label->getAttribute(forAttr).isEmpty() && label->getAttribute(forAttr) == htmlElement->getIdAttribute()) { nameSources->back().nativeSource = AXTextFromNativeHTMLLabelFor; } else { nameSources->back().nativeSource = AXTextFromNativeHTMLLabelWrapped; } } labelElements.push_back(label); } textAlternative = textFromElements(false, visited, labelElements, relatedObjects); if (!textAlternative.isNull()) { *foundTextAlternative = true; if (nameSources) { NameSource& source = nameSources->back(); source.relatedObjects = *relatedObjects; source.text = textAlternative; } else { return textAlternative; } } else if (nameSources) { nameSources->back().invalid = true; } } } if (inputElement && inputElement->isTextButton()) { nameFrom = AXNameFromValue; if (nameSources) { nameSources->push_back(NameSource(*foundTextAlternative, valueAttr)); nameSources->back().type = nameFrom; } String value = inputElement->value(); if (!value.isNull()) { textAlternative = value; if (nameSources) { NameSource& source = nameSources->back(); source.text = textAlternative; *foundTextAlternative = true; } else { return textAlternative; } } if (!getLayoutObject()) { String defaultLabel = inputElement->valueOrDefaultLabel(); if (value.isNull() && !defaultLabel.isNull()) { nameFrom = AXNameFromContents; if (nameSources) { nameSources->push_back(NameSource(*foundTextAlternative)); nameSources->back().type = nameFrom; } textAlternative = defaultLabel; if (nameSources) { NameSource& source = nameSources->back(); source.text = textAlternative; *foundTextAlternative = true; } else { return textAlternative; } } } return textAlternative; } if (inputElement && inputElement->getAttribute(typeAttr) == InputTypeNames::image) { nameFrom = AXNameFromAttribute; if (nameSources) { nameSources->push_back(NameSource(*foundTextAlternative, altAttr)); nameSources->back().type = nameFrom; } const AtomicString& alt = inputElement->getAttribute(altAttr); if (!alt.isNull()) { textAlternative = alt; if (nameSources) { NameSource& source = nameSources->back(); source.attributeValue = alt; source.text = textAlternative; *foundTextAlternative = true; } else { return textAlternative; } } if (nameSources) { nameSources->push_back(NameSource(*foundTextAlternative, valueAttr)); nameSources->back().type = nameFrom; } nameFrom = AXNameFromAttribute; String value = inputElement->value(); if (!value.isNull()) { textAlternative = value; if (nameSources) { NameSource& source = nameSources->back(); source.text = textAlternative; *foundTextAlternative = true; } else { return textAlternative; } } nameFrom = AXNameFromValue; textAlternative = inputElement->locale().queryString( WebLocalizedString::SubmitButtonDefaultLabel); if (nameSources) { nameSources->push_back(NameSource(*foundTextAlternative, typeAttr)); NameSource& source = nameSources->back(); source.attributeValue = inputElement->getAttribute(typeAttr); source.type = nameFrom; source.text = textAlternative; *foundTextAlternative = true; } else { return textAlternative; } return textAlternative; } if (htmlElement && htmlElement->isTextControl()) { nameFrom = AXNameFromPlaceholder; if (nameSources) { nameSources->push_back( NameSource(*foundTextAlternative, placeholderAttr)); NameSource& source = nameSources->back(); source.type = nameFrom; } const String placeholder = placeholderFromNativeAttribute(); if (!placeholder.isEmpty()) { textAlternative = placeholder; if (nameSources) { NameSource& source = nameSources->back(); source.text = textAlternative; source.attributeValue = htmlElement->fastGetAttribute(placeholderAttr); *foundTextAlternative = true; } else { return textAlternative; } } nameFrom = AXNameFromPlaceholder; if (nameSources) { nameSources->push_back( NameSource(*foundTextAlternative, aria_placeholderAttr)); NameSource& source = nameSources->back(); source.type = nameFrom; } const AtomicString& ariaPlaceholder = getAOMPropertyOrARIAAttribute(AOMStringProperty::kPlaceholder); if (!ariaPlaceholder.isEmpty()) { textAlternative = ariaPlaceholder; if (nameSources) { NameSource& source = nameSources->back(); source.text = textAlternative; source.attributeValue = ariaPlaceholder; *foundTextAlternative = true; } else { return textAlternative; } } return textAlternative; } if (getNode()->hasTagName(figureTag)) { nameFrom = AXNameFromRelatedElement; if (nameSources) { nameSources->push_back(NameSource(*foundTextAlternative)); nameSources->back().type = nameFrom; nameSources->back().nativeSource = AXTextFromNativeHTMLFigcaption; } Element* figcaption = nullptr; for (Element& element : ElementTraversal::descendantsOf(*(getNode()))) { if (element.hasTagName(figcaptionTag)) { figcaption = &element; break; } } if (figcaption) { AXObject* figcaptionAXObject = axObjectCache().getOrCreate(figcaption); if (figcaptionAXObject) { textAlternative = recursiveTextAlternative(*figcaptionAXObject, false, visited); if (relatedObjects) { localRelatedObjects.push_back( new NameSourceRelatedObject(figcaptionAXObject, textAlternative)); *relatedObjects = localRelatedObjects; localRelatedObjects.clear(); } if (nameSources) { NameSource& source = nameSources->back(); source.relatedObjects = *relatedObjects; source.text = textAlternative; *foundTextAlternative = true; } else { return textAlternative; } } } return textAlternative; } if (isHTMLImageElement(getNode()) || isHTMLAreaElement(getNode()) || (getLayoutObject() && getLayoutObject()->isSVGImage())) { nameFrom = AXNameFromAttribute; if (nameSources) { nameSources->push_back(NameSource(*foundTextAlternative, altAttr)); nameSources->back().type = nameFrom; } const AtomicString& alt = getAttribute(altAttr); if (!alt.isNull()) { textAlternative = alt; if (nameSources) { NameSource& source = nameSources->back(); source.attributeValue = alt; source.text = textAlternative; *foundTextAlternative = true; } else { return textAlternative; } } return textAlternative; } if (isHTMLTableElement(getNode())) { HTMLTableElement* tableElement = toHTMLTableElement(getNode()); nameFrom = AXNameFromCaption; if (nameSources) { nameSources->push_back(NameSource(*foundTextAlternative)); nameSources->back().type = nameFrom; nameSources->back().nativeSource = AXTextFromNativeHTMLTableCaption; } HTMLTableCaptionElement* caption = tableElement->caption(); if (caption) { AXObject* captionAXObject = axObjectCache().getOrCreate(caption); if (captionAXObject) { textAlternative = recursiveTextAlternative(*captionAXObject, false, visited); if (relatedObjects) { localRelatedObjects.push_back( new NameSourceRelatedObject(captionAXObject, textAlternative)); *relatedObjects = localRelatedObjects; localRelatedObjects.clear(); } if (nameSources) { NameSource& source = nameSources->back(); source.relatedObjects = *relatedObjects; source.text = textAlternative; *foundTextAlternative = true; } else { return textAlternative; } } } nameFrom = AXNameFromAttribute; if (nameSources) { nameSources->push_back(NameSource(*foundTextAlternative, summaryAttr)); nameSources->back().type = nameFrom; } const AtomicString& summary = getAttribute(summaryAttr); if (!summary.isNull()) { textAlternative = summary; if (nameSources) { NameSource& source = nameSources->back(); source.attributeValue = summary; source.text = textAlternative; *foundTextAlternative = true; } else { return textAlternative; } } return textAlternative; } if (getNode()->isSVGElement()) { nameFrom = AXNameFromRelatedElement; if (nameSources) { nameSources->push_back(NameSource(*foundTextAlternative)); nameSources->back().type = nameFrom; nameSources->back().nativeSource = AXTextFromNativeHTMLTitleElement; } ASSERT(getNode()->isContainerNode()); Element* title = ElementTraversal::firstChild( toContainerNode(*(getNode())), HasTagName(SVGNames::titleTag)); if (title) { AXObject* titleAXObject = axObjectCache().getOrCreate(title); if (titleAXObject && !visited.contains(titleAXObject)) { textAlternative = recursiveTextAlternative(*titleAXObject, false, visited); if (relatedObjects) { localRelatedObjects.push_back( new NameSourceRelatedObject(titleAXObject, textAlternative)); *relatedObjects = localRelatedObjects; localRelatedObjects.clear(); } } if (nameSources) { NameSource& source = nameSources->back(); source.text = textAlternative; source.relatedObjects = *relatedObjects; *foundTextAlternative = true; } else { return textAlternative; } } } if (isHTMLFieldSetElement(getNode())) { nameFrom = AXNameFromRelatedElement; if (nameSources) { nameSources->push_back(NameSource(*foundTextAlternative)); nameSources->back().type = nameFrom; nameSources->back().nativeSource = AXTextFromNativeHTMLLegend; } HTMLElement* legend = toHTMLFieldSetElement(getNode())->legend(); if (legend) { AXObject* legendAXObject = axObjectCache().getOrCreate(legend); if (legendAXObject && !visited.contains(legendAXObject)) { textAlternative = recursiveTextAlternative(*legendAXObject, false, visited); if (relatedObjects) { localRelatedObjects.push_back( new NameSourceRelatedObject(legendAXObject, textAlternative)); *relatedObjects = localRelatedObjects; localRelatedObjects.clear(); } if (nameSources) { NameSource& source = nameSources->back(); source.relatedObjects = *relatedObjects; source.text = textAlternative; *foundTextAlternative = true; } else { return textAlternative; } } } } if (isWebArea()) { Document* document = this->getDocument(); if (document) { nameFrom = AXNameFromAttribute; if (nameSources) { nameSources->push_back( NameSource(foundTextAlternative, aria_labelAttr)); nameSources->back().type = nameFrom; } if (Element* documentElement = document->documentElement()) { const AtomicString& ariaLabel = AccessibleNode::getProperty( documentElement, AOMStringProperty::kLabel); if (!ariaLabel.isEmpty()) { textAlternative = ariaLabel; if (nameSources) { NameSource& source = nameSources->back(); source.text = textAlternative; source.attributeValue = ariaLabel; *foundTextAlternative = true; } else { return textAlternative; } } } nameFrom = AXNameFromRelatedElement; if (nameSources) { nameSources->push_back(NameSource(*foundTextAlternative)); nameSources->back().type = nameFrom; nameSources->back().nativeSource = AXTextFromNativeHTMLTitleElement; } textAlternative = document->title(); Element* titleElement = document->titleElement(); AXObject* titleAXObject = axObjectCache().getOrCreate(titleElement); if (titleAXObject) { if (relatedObjects) { localRelatedObjects.push_back( new NameSourceRelatedObject(titleAXObject, textAlternative)); *relatedObjects = localRelatedObjects; localRelatedObjects.clear(); } if (nameSources) { NameSource& source = nameSources->back(); source.relatedObjects = *relatedObjects; source.text = textAlternative; *foundTextAlternative = true; } else { return textAlternative; } } } } return textAlternative; } 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
6,193
Analyze the following 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 NavigationNotificationObserver::ConditionMet( AutomationMsg_NavigationResponseValues navigation_result) { if (automation_) { if (use_json_interface_) { if (navigation_result == AUTOMATION_MSG_NAVIGATION_SUCCESS) { DictionaryValue dict; dict.SetInteger("result", navigation_result); AutomationJSONReply(automation_, reply_message_.release()).SendSuccess( &dict); } else { AutomationJSONReply(automation_, reply_message_.release()).SendError( StringPrintf("Navigation failed with error code=%d.", navigation_result)); } } else { IPC::ParamTraits<int>::Write( reply_message_.get(), navigation_result); automation_->Send(reply_message_.release()); } } delete this; } Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt. BUG=107201 TEST=no visible change Review URL: https://chromiumcodereview.appspot.com/11293205 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
23,415
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: get_schema_version(const char *name) { int lpc = 0; if(name == NULL) { name = "none"; } for (; lpc < xml_schema_max; lpc++) { if (safe_str_eq(name, known_schemas[lpc].name)) { return lpc; } } return -1; } Commit Message: Fix: acl: Do not delay evaluation of added nodes in some situations It is not appropriate when the node has no children as it is not a placeholder CWE ID: CWE-264
0
27,432
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: String AXNodeObject::placeholderFromNativeAttribute() const { Node* node = getNode(); if (!node || !isTextControlElement(node)) return String(); return toTextControlElement(node)->strippedPlaceholder(); } 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
8,002
Analyze the following 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 SendNotifications(AppCacheEventID event_id) { for (NotifyHostMap::iterator it = hosts_to_notify.begin(); it != hosts_to_notify.end(); ++it) { AppCacheFrontend* frontend = it->first; frontend->OnEventRaised(it->second, event_id); } } Commit Message: AppCache: fix a browser crashing bug that can happen during updates. BUG=558589 Review URL: https://codereview.chromium.org/1463463003 Cr-Commit-Position: refs/heads/master@{#360967} CWE ID:
0
14,742
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Plugin::GetExitStatus(NaClSrpcArg* prop_value) { PLUGIN_PRINTF(("GetExitStatus (this=%p)\n", reinterpret_cast<void*>(this))); prop_value->tag = NACL_SRPC_ARG_TYPE_INT; prop_value->u.ival = exit_status(); } Commit Message: Revert 143656 - Add an IPC channel between the NaCl loader process and the renderer. BUG=116317 TEST=ppapi, nacl tests, manual testing for experimental IPC proxy. Review URL: https://chromiumcodereview.appspot.com/10641016 TBR=bbudge@chromium.org Review URL: https://chromiumcodereview.appspot.com/10625007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143665 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
11,919
Analyze the following 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 append_camera_metadata(camera_metadata_t *dst, const camera_metadata_t *src) { if (dst == NULL || src == NULL ) return ERROR; if (dst->entry_capacity < src->entry_count + dst->entry_count) return ERROR; if (dst->data_capacity < src->data_count + dst->data_count) return ERROR; memcpy(get_entries(dst) + dst->entry_count, get_entries(src), sizeof(camera_metadata_buffer_entry_t[src->entry_count])); memcpy(get_data(dst) + dst->data_count, get_data(src), sizeof(uint8_t[src->data_count])); if (dst->data_count != 0) { camera_metadata_buffer_entry_t *entry = get_entries(dst) + dst->entry_count; for (size_t i = 0; i < src->entry_count; i++, entry++) { if ( calculate_camera_metadata_entry_data_size(entry->type, entry->count) > 0 ) { entry->data.offset += dst->data_count; } } } if (dst->entry_count == 0) { dst->flags |= src->flags & FLAG_SORTED; } else if (src->entry_count != 0) { dst->flags &= ~FLAG_SORTED; } else { } dst->entry_count += src->entry_count; dst->data_count += src->data_count; assert(validate_camera_metadata_structure(dst, NULL) == OK); return OK; } Commit Message: Camera: Prevent data size overflow Add a function to check overflow when calculating metadata data size. Bug: 30741779 Change-Id: I6405fe608567a4f4113674050f826f305ecae030 CWE ID: CWE-119
0
6,015
Analyze the following 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 PPResultAndExceptionToNPResult::IgnoreException() { checked_exception_ = true; } Commit Message: Fix invalid read in ppapi code BUG=77493 TEST=attached test Review URL: http://codereview.chromium.org/6883059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82172 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-119
0
23,929
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void RTCPeerConnectionHandlerChromium::setLocalDescription(PassRefPtr<RTCVoidRequest> request, PassRefPtr<RTCSessionDescriptionDescriptor> sessionDescription) { if (!m_webHandler) return; m_webHandler->setLocalDescription(request, sessionDescription); } Commit Message: Unreviewed, rolling out r127612, r127660, and r127664. http://trac.webkit.org/changeset/127612 http://trac.webkit.org/changeset/127660 http://trac.webkit.org/changeset/127664 https://bugs.webkit.org/show_bug.cgi?id=95920 Source/Platform: * Platform.gypi: * chromium/public/WebRTCPeerConnectionHandler.h: (WebKit): (WebRTCPeerConnectionHandler): * chromium/public/WebRTCVoidRequest.h: Removed. Source/WebCore: * CMakeLists.txt: * GNUmakefile.list.am: * Modules/mediastream/RTCErrorCallback.h: (WebCore): (RTCErrorCallback): * Modules/mediastream/RTCErrorCallback.idl: * Modules/mediastream/RTCPeerConnection.cpp: (WebCore::RTCPeerConnection::createOffer): * Modules/mediastream/RTCPeerConnection.h: (WebCore): (RTCPeerConnection): * Modules/mediastream/RTCPeerConnection.idl: * Modules/mediastream/RTCSessionDescriptionCallback.h: (WebCore): (RTCSessionDescriptionCallback): * Modules/mediastream/RTCSessionDescriptionCallback.idl: * Modules/mediastream/RTCSessionDescriptionRequestImpl.cpp: (WebCore::RTCSessionDescriptionRequestImpl::create): (WebCore::RTCSessionDescriptionRequestImpl::RTCSessionDescriptionRequestImpl): (WebCore::RTCSessionDescriptionRequestImpl::requestSucceeded): (WebCore::RTCSessionDescriptionRequestImpl::requestFailed): (WebCore::RTCSessionDescriptionRequestImpl::clear): * Modules/mediastream/RTCSessionDescriptionRequestImpl.h: (RTCSessionDescriptionRequestImpl): * Modules/mediastream/RTCVoidRequestImpl.cpp: Removed. * Modules/mediastream/RTCVoidRequestImpl.h: Removed. * WebCore.gypi: * platform/chromium/support/WebRTCVoidRequest.cpp: Removed. * platform/mediastream/RTCPeerConnectionHandler.cpp: (RTCPeerConnectionHandlerDummy): (WebCore::RTCPeerConnectionHandlerDummy::RTCPeerConnectionHandlerDummy): * platform/mediastream/RTCPeerConnectionHandler.h: (WebCore): (WebCore::RTCPeerConnectionHandler::~RTCPeerConnectionHandler): (RTCPeerConnectionHandler): (WebCore::RTCPeerConnectionHandler::RTCPeerConnectionHandler): * platform/mediastream/RTCVoidRequest.h: Removed. * platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp: * platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h: (RTCPeerConnectionHandlerChromium): Tools: * DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp: (MockWebRTCPeerConnectionHandler::SuccessCallbackTask::SuccessCallbackTask): (MockWebRTCPeerConnectionHandler::SuccessCallbackTask::runIfValid): (MockWebRTCPeerConnectionHandler::FailureCallbackTask::FailureCallbackTask): (MockWebRTCPeerConnectionHandler::FailureCallbackTask::runIfValid): (MockWebRTCPeerConnectionHandler::createOffer): * DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.h: (MockWebRTCPeerConnectionHandler): (SuccessCallbackTask): (FailureCallbackTask): LayoutTests: * fast/mediastream/RTCPeerConnection-createOffer.html: * fast/mediastream/RTCPeerConnection-localDescription-expected.txt: Removed. * fast/mediastream/RTCPeerConnection-localDescription.html: Removed. * fast/mediastream/RTCPeerConnection-remoteDescription-expected.txt: Removed. * fast/mediastream/RTCPeerConnection-remoteDescription.html: Removed. git-svn-id: svn://svn.chromium.org/blink/trunk@127679 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-20
1
4,643
Analyze the following 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 bi_complete(struct bio *bio, int error) { complete((struct completion *)bio->bi_private); } Commit Message: ext4: use ext4_get_block_write in buffer write Allocate uninitialized extent before ext4 buffer write and convert the extent to initialized after io completes. The purpose is to make sure an extent can only be marked initialized after it has been written with new data so we can safely drop the i_mutex lock in ext4 DIO read without exposing stale data. This helps to improve multi-thread DIO read performance on high-speed disks. Skip the nobh and data=journal mount cases to make things simple for now. Signed-off-by: Jiaying Zhang <jiayingz@google.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> CWE ID:
0
16,315
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static __init int ftrace_test_event_filter(void) { int i; printk(KERN_INFO "Testing ftrace filter: "); for (i = 0; i < DATA_CNT; i++) { struct event_filter *filter = NULL; struct test_filter_data_t *d = &test_filter_data[i]; int err; err = create_filter(&event_ftrace_test_filter, d->filter, false, &filter); if (err) { printk(KERN_INFO "Failed to get filter for '%s', err %d\n", d->filter, err); __free_filter(filter); break; } /* Needed to dereference filter->prog */ mutex_lock(&event_mutex); /* * The preemption disabling is not really needed for self * tests, but the rcu dereference will complain without it. */ preempt_disable(); if (*d->not_visited) update_pred_fn(filter, d->not_visited); test_pred_visited = 0; err = filter_match_preds(filter, &d->rec); preempt_enable(); mutex_unlock(&event_mutex); __free_filter(filter); if (test_pred_visited) { printk(KERN_INFO "Failed, unwanted pred visited for filter %s\n", d->filter); break; } if (err != d->match) { printk(KERN_INFO "Failed to match filter '%s', expected %d\n", d->filter, d->match); break; } } if (i == DATA_CNT) printk(KERN_CONT "OK\n"); return 0; } Commit Message: Merge tag 'trace-v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace Pull tracing fixes from Steven Rostedt: "This contains a few fixes and a clean up. - a bad merge caused an "endif" to go in the wrong place in scripts/Makefile.build - softirq tracing fix for tracing that corrupts lockdep and causes a false splat - histogram documentation typo fixes - fix a bad memory reference when passing in no filter to the filter code - simplify code by using the swap macro instead of open coding the swap" * tag 'trace-v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Fix SKIP_STACK_VALIDATION=1 build due to bad merge with -mrecord-mcount tracing: Fix some errors in histogram documentation tracing: Use swap macro in update_max_tr softirq: Reorder trace_softirqs_on to prevent lockdep splat tracing: Check for no filter when processing event filters CWE ID: CWE-787
0
10,221
Analyze the following 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 icccomponents(i_ctx_t * i_ctx_p, ref *space, int *n) { int code = 0; ref *tempref, ICCdict; code = array_get(imemory, space, 1, &ICCdict); if (code < 0) return code; code = dict_find_string(&ICCdict, "N", &tempref); if (code < 0) return code; if (code == 0) return gs_note_error(gs_error_undefined); *n = tempref->value.intval; return 0; } Commit Message: CWE ID: CWE-704
0
12,198
Analyze the following 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 HTMLFormControlElement::didRecalcStyle(StyleRecalcChange) { if (RenderObject* renderer = this->renderer()) renderer->updateFromElement(); } Commit Message: Add HTMLFormControlElement::supportsAutofocus to fix a FIXME comment. This virtual function should return true if the form control can hanlde 'autofocucs' attribute if it is specified. Note: HTMLInputElement::supportsAutofocus reuses InputType::isInteractiveContent because interactiveness is required for autofocus capability. BUG=none TEST=none; no behavior changes. Review URL: https://codereview.chromium.org/143343003 git-svn-id: svn://svn.chromium.org/blink/trunk@165432 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-119
0
27,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: void AutocompleteEditModel::FinalizeInstantQuery( const string16& input_text, const string16& suggest_text, bool skip_inline_autocomplete) { if (skip_inline_autocomplete) { const string16 final_text = input_text + suggest_text; view_->OnBeforePossibleChange(); view_->SetWindowTextAndCaretPos(final_text, final_text.length(), false, false); view_->OnAfterPossibleChange(); } else if (popup_->IsOpen()) { SearchProvider* search_provider = autocomplete_controller_->search_provider(); if (search_provider) search_provider->FinalizeInstantQuery(input_text, suggest_text); } } Commit Message: Adds per-provider information to omnibox UMA logs. Adds a fairly general structure to omnibox logs that can be used to pass information (that's not per-result information) from providers to the UMA logs. Right now it's only used to pass whether the asynchronous pass of a provider has finished, but it will probably be used for other things in the future. BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10380007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137288 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID:
0
11,764
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: JNI_ChromeFeatureList_GetFieldTrialParamByFeature( JNIEnv* env, const JavaParamRef<jclass>& clazz, const JavaParamRef<jstring>& jfeature_name, const JavaParamRef<jstring>& jparam_name) { const base::Feature* feature = FindFeatureExposedToJava(ConvertJavaStringToUTF8(env, jfeature_name)); const std::string& param_name = ConvertJavaStringToUTF8(env, jparam_name); const std::string& param_value = base::GetFieldTrialParamValueByFeature(*feature, param_name); return ConvertUTF8ToJavaString(env, param_value); } Commit Message: Add search bar to Android password settings By enabling the feature PasswordSearch, a search icon will appear in the action bar in Chrome > Settings > Save Passwords. Clicking the icon will trigger a search box that hides non-password views. Every newly typed letter will instantly filter passwords which don't contain the query. Ignores case. Update: instead of adding a new white icon, the ic_search is recolored. Update: merged with WIP crrev/c/868213 Bug: 794108 Change-Id: I9b4e3c7754bb5b0cc56e3156a746bcbf44aa5bd3 Reviewed-on: https://chromium-review.googlesource.com/866830 Commit-Queue: Friedrich Horschig <fhorschig@chromium.org> Reviewed-by: Maxim Kolosovskiy <kolos@chromium.org> Reviewed-by: Theresa <twellington@chromium.org> Cr-Commit-Position: refs/heads/master@{#531891} CWE ID: CWE-284
0
21,386
Analyze the following 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 __dev_set_mtu(struct net_device *dev, int new_mtu) { const struct net_device_ops *ops = dev->netdev_ops; if (ops->ndo_change_mtu) return ops->ndo_change_mtu(dev, new_mtu); dev->mtu = new_mtu; return 0; } Commit Message: tunnels: Don't apply GRO to multiple layers of encapsulation. When drivers express support for TSO of encapsulated packets, they only mean that they can do it for one layer of encapsulation. Supporting additional levels would mean updating, at a minimum, more IP length fields and they are unaware of this. No encapsulation device expresses support for handling offloaded encapsulated packets, so we won't generate these types of frames in the transmit path. However, GRO doesn't have a check for multiple levels of encapsulation and will attempt to build them. UDP tunnel GRO actually does prevent this situation but it only handles multiple UDP tunnels stacked on top of each other. This generalizes that solution to prevent any kind of tunnel stacking that would cause problems. Fixes: bf5a755f ("net-gre-gro: Add GRE support to the GRO stack") Signed-off-by: Jesse Gross <jesse@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-400
0
8,985
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: zisofs_finish_entry(struct archive_write *a) { struct iso9660 *iso9660 = a->format_data; struct isofile *file = iso9660->cur_file; unsigned char buff[16]; size_t s; int64_t tail; /* Direct temp file stream to zisofs temp file stream. */ archive_entry_set_size(file->entry, iso9660->zisofs.total_size); /* * Save a file pointer which points the end of current zisofs data. */ tail = wb_offset(a); /* * Make a header. * * +-----------------+----------------+-----------------+ * | Header 16 bytes | Block Pointers | Compressed data | * +-----------------+----------------+-----------------+ * 0 16 +X * Block Pointers : * 4 * (((Uncompressed file size + block_size -1) / block_size) + 1) * * Write zisofs header. * Magic number * +----+----+----+----+----+----+----+----+ * | 37 | E4 | 53 | 96 | C9 | DB | D6 | 07 | * +----+----+----+----+----+----+----+----+ * 0 1 2 3 4 5 6 7 8 * * +------------------------+------------------+ * | Uncompressed file size | header_size >> 2 | * +------------------------+------------------+ * 8 12 13 * * +-----------------+----------------+ * | log2 block_size | Reserved(0000) | * +-----------------+----------------+ * 13 14 16 */ memcpy(buff, zisofs_magic, 8); set_num_731(buff+8, file->zisofs.uncompressed_size); buff[12] = file->zisofs.header_size; buff[13] = file->zisofs.log2_bs; buff[14] = buff[15] = 0;/* Reserved */ /* Move to the right position to write the header. */ wb_set_offset(a, file->content.offset_of_temp); /* Write the header. */ if (wb_write_to_temp(a, buff, 16) != ARCHIVE_OK) return (ARCHIVE_FATAL); /* * Write zisofs Block Pointers. */ s = iso9660->zisofs.block_pointers_cnt * sizeof(iso9660->zisofs.block_pointers[0]); if (wb_write_to_temp(a, iso9660->zisofs.block_pointers, s) != ARCHIVE_OK) return (ARCHIVE_FATAL); /* Set a file pointer back to the end of the temporary file. */ wb_set_offset(a, tail); return (ARCHIVE_OK); } Commit Message: Issue 711: Be more careful about verifying filename lengths when writing ISO9660 archives * Don't cast size_t to int, since this can lead to overflow on machines where sizeof(int) < sizeof(size_t) * Check a + b > limit by writing it as a > limit || b > limit || a + b > limit to avoid problems when a + b wraps around. CWE ID: CWE-190
0
19,810
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Browser::ContentRestrictionsChanged(WebContents* source) { command_controller_->ContentRestrictionsChanged(); } Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt. BUG=107201 TEST=no visible change Review URL: https://chromiumcodereview.appspot.com/11293205 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
8,553
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: client_skip_proxy(struct archive_read_filter *self, int64_t request) { if (request < 0) __archive_errx(1, "Negative skip requested."); if (request == 0) return 0; if (self->archive->client.skipper != NULL) { /* Seek requests over 1GiB are broken down into * multiple seeks. This avoids overflows when the * requests get passed through 32-bit arguments. */ int64_t skip_limit = (int64_t)1 << 30; int64_t total = 0; for (;;) { int64_t get, ask = request; if (ask > skip_limit) ask = skip_limit; get = (self->archive->client.skipper) (&self->archive->archive, self->data, ask); if (get == 0) return (total); request -= get; total += get; } } else if (self->archive->client.seeker != NULL && request > 64 * 1024) { /* If the client provided a seeker but not a skipper, * we can use the seeker to skip forward. * * Note: This isn't always a good idea. The client * skipper is allowed to skip by less than requested * if it needs to maintain block alignment. The * seeker is not allowed to play such games, so using * the seeker here may be a performance loss compared * to just reading and discarding. That's why we * only do this for skips of over 64k. */ int64_t before = self->position; int64_t after = (self->archive->client.seeker) (&self->archive->archive, self->data, request, SEEK_CUR); if (after != before + request) return ARCHIVE_FATAL; return after - before; } return 0; } Commit Message: Fix a potential crash issue discovered by Alexander Cherepanov: It seems bsdtar automatically handles stacked compression. This is a nice feature but it could be problematic when it's completely unlimited. Most clearly it's illustrated with quines: $ curl -sRO http://www.maximumcompression.com/selfgz.gz $ (ulimit -v 10000000 && bsdtar -tvf selfgz.gz) bsdtar: Error opening archive: Can't allocate data for gzip decompression Without ulimit, bsdtar will eat all available memory. This could also be a problem for other applications using libarchive. CWE ID: CWE-399
0
10,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: static HB_Error Lookup_PairPos( GPOS_Instance* gpi, HB_GPOS_SubTable* st, HB_Buffer buffer, HB_UShort flags, HB_UShort context_length, int nesting_level ) { HB_Error error; HB_UShort index, property; HB_UInt first_pos; HB_GPOSHeader* gpos = gpi->gpos; HB_PairPos* pp = &st->pair; HB_UNUSED(nesting_level); if ( buffer->in_pos >= buffer->in_length - 1 ) return HB_Err_Not_Covered; /* Not enough glyphs in stream */ if ( context_length != 0xFFFF && context_length < 2 ) return HB_Err_Not_Covered; if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) ) return error; error = _HB_OPEN_Coverage_Index( &pp->Coverage, IN_CURGLYPH(), &index ); if ( error ) return error; /* second glyph */ first_pos = buffer->in_pos; (buffer->in_pos)++; while ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) ) { if ( error && error != HB_Err_Not_Covered ) return error; if ( buffer->in_pos == buffer->in_length ) { buffer->in_pos = first_pos; return HB_Err_Not_Covered; } (buffer->in_pos)++; } switch ( pp->PosFormat ) { case 1: error = Lookup_PairPos1( gpi, &pp->ppf.ppf1, buffer, first_pos, index, pp->ValueFormat1, pp->ValueFormat2 ); break; case 2: error = Lookup_PairPos2( gpi, &pp->ppf.ppf2, buffer, first_pos, pp->ValueFormat1, pp->ValueFormat2 ); break; default: return ERR(HB_Err_Invalid_SubTable_Format); } /* if we don't have coverage for the second glyph don't skip it for further lookups but reset in_pos back to the first_glyph and let the caller in Do_String_Lookup increment in_pos */ if ( error == HB_Err_Not_Covered ) buffer->in_pos = first_pos; /* adjusting the `next' glyph */ if ( pp->ValueFormat2 ) (buffer->in_pos)++; return error; } Commit Message: CWE ID: CWE-119
0
1,518
Analyze the following 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 tcp_cookie_generator(u32 *bakery) { unsigned long jiffy = jiffies; if (unlikely(time_after_eq(jiffy, tcp_secret_generating->expires))) { spin_lock_bh(&tcp_secret_locker); if (!time_after_eq(jiffy, tcp_secret_generating->expires)) { /* refreshed by another */ memcpy(bakery, &tcp_secret_generating->secrets[0], COOKIE_WORKSPACE_WORDS); } else { /* still needs refreshing */ get_random_bytes(bakery, COOKIE_WORKSPACE_WORDS); /* The first time, paranoia assumes that the * randomization function isn't as strong. But, * this secret initialization is delayed until * the last possible moment (packet arrival). * Although that time is observable, it is * unpredictably variable. Mash in the most * volatile clock bits available, and expire the * secret extra quickly. */ if (unlikely(tcp_secret_primary->expires == tcp_secret_secondary->expires)) { struct timespec tv; getnstimeofday(&tv); bakery[COOKIE_DIGEST_WORDS+0] ^= (u32)tv.tv_nsec; tcp_secret_secondary->expires = jiffy + TCP_SECRET_1MSL + (0x0f & tcp_cookie_work(bakery, 0)); } else { tcp_secret_secondary->expires = jiffy + TCP_SECRET_LIFE + (0xff & tcp_cookie_work(bakery, 1)); tcp_secret_primary->expires = jiffy + TCP_SECRET_2MSL + (0x1f & tcp_cookie_work(bakery, 2)); } memcpy(&tcp_secret_secondary->secrets[0], bakery, COOKIE_WORKSPACE_WORDS); rcu_assign_pointer(tcp_secret_generating, tcp_secret_secondary); rcu_assign_pointer(tcp_secret_retiring, tcp_secret_primary); /* * Neither call_rcu() nor synchronize_rcu() needed. * Retiring data is not freed. It is replaced after * further (locked) pointer updates, and a quiet time * (minimum 1MSL, maximum LIFE - 2MSL). */ } spin_unlock_bh(&tcp_secret_locker); } else { rcu_read_lock_bh(); memcpy(bakery, &rcu_dereference(tcp_secret_generating)->secrets[0], COOKIE_WORKSPACE_WORDS); rcu_read_unlock_bh(); } return 0; } Commit Message: net: Fix oops from tcp_collapse() when using splice() tcp_read_sock() can have a eat skbs without immediately advancing copied_seq. This can cause a panic in tcp_collapse() if it is called as a result of the recv_actor dropping the socket lock. A userspace program that splices data from a socket to either another socket or to a file can trigger this bug. Signed-off-by: Steven J. Magnani <steve@digidescorp.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-119
0
17,941
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void __exit ecryptfs_exit(void) { int rc; rc = ecryptfs_destroy_crypto(); if (rc) printk(KERN_ERR "Failure whilst attempting to destroy crypto; " "rc = [%d]\n", rc); ecryptfs_release_messaging(); ecryptfs_destroy_kthread(); do_sysfs_unregistration(); unregister_filesystem(&ecryptfs_fs_type); ecryptfs_free_kmem_caches(); } Commit Message: Ecryptfs: Add mount option to check uid of device being mounted = expect uid Close a TOCTOU race for mounts done via ecryptfs-mount-private. The mount source (device) can be raced when the ownership test is done in userspace. Provide Ecryptfs a means to force the uid check at mount time. Signed-off-by: John Johansen <john.johansen@canonical.com> Cc: <stable@kernel.org> Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com> CWE ID: CWE-264
0
13,618
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int WebPEncodeProgress(int percent,const WebPPicture* picture) { #define EncodeImageTag "Encode/Image" Image *image; MagickBooleanType status; image=(Image *) picture->custom_ptr; status=SetImageProgress(image,EncodeImageTag,percent-1,100); return(status == MagickFalse ? 0 : 1); } Commit Message: Fixed fd leak for webp coder (patch from #382) CWE ID: CWE-119
0
12,136
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void ResetState() { nav_handle1_.reset(); nav_handle2_.reset(); nav_handle3_.reset(); throttle1_.reset(); throttle2_.reset(); throttle3_.reset(); contents1_.reset(); contents2_.reset(); contents3_.reset(); } Commit Message: Connect the LocalDB to TabManager. Bug: 773382 Change-Id: Iec8fe5226ee175105d51f300f30b4865478ac099 Reviewed-on: https://chromium-review.googlesource.com/1118611 Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org> Reviewed-by: François Doray <fdoray@chromium.org> Cr-Commit-Position: refs/heads/master@{#572871} CWE ID:
1
29,859
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval **rval) { var_entries *var_hash = (*var_hashx)->last_dtor; #if VAR_ENTRIES_DBG fprintf(stderr, "var_push_dtor_no_addref(%ld): %d (%d)\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval), Z_REFCOUNT_PP(rval)); #endif if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) { var_hash = emalloc(sizeof(var_entries)); var_hash->used_slots = 0; var_hash->next = 0; if (!(*var_hashx)->first_dtor) { (*var_hashx)->first_dtor = var_hash; } else { ((var_entries *) (*var_hashx)->last_dtor)->next = var_hash; } (*var_hashx)->last_dtor = var_hash; } var_hash->data[var_hash->used_slots++] = *rval; } Commit Message: CWE ID:
0
28,130
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void FactoryRegistry::ResetFunctions() { RegisterFunction<GetWindowFunction>(); RegisterFunction<GetCurrentWindowFunction>(); RegisterFunction<GetLastFocusedWindowFunction>(); RegisterFunction<GetAllWindowsFunction>(); RegisterFunction<CreateWindowFunction>(); RegisterFunction<UpdateWindowFunction>(); RegisterFunction<RemoveWindowFunction>(); RegisterFunction<GetTabFunction>(); RegisterFunction<GetCurrentTabFunction>(); RegisterFunction<GetSelectedTabFunction>(); RegisterFunction<GetAllTabsInWindowFunction>(); RegisterFunction<CreateTabFunction>(); RegisterFunction<UpdateTabFunction>(); RegisterFunction<MoveTabFunction>(); RegisterFunction<RemoveTabFunction>(); RegisterFunction<DetectTabLanguageFunction>(); RegisterFunction<CaptureVisibleTabFunction>(); RegisterFunction<TabsExecuteScriptFunction>(); RegisterFunction<TabsInsertCSSFunction>(); RegisterFunction<EnablePageActionFunction>(); RegisterFunction<DisablePageActionFunction>(); RegisterFunction<PageActionShowFunction>(); RegisterFunction<PageActionHideFunction>(); RegisterFunction<PageActionSetIconFunction>(); RegisterFunction<PageActionSetTitleFunction>(); RegisterFunction<PageActionSetPopupFunction>(); RegisterFunction<BrowserActionSetIconFunction>(); RegisterFunction<BrowserActionSetTitleFunction>(); RegisterFunction<BrowserActionSetBadgeTextFunction>(); RegisterFunction<BrowserActionSetBadgeBackgroundColorFunction>(); RegisterFunction<BrowserActionSetPopupFunction>(); RegisterFunction<GetBookmarksFunction>(); RegisterFunction<GetBookmarkChildrenFunction>(); RegisterFunction<GetBookmarkRecentFunction>(); RegisterFunction<GetBookmarkTreeFunction>(); RegisterFunction<GetBookmarkSubTreeFunction>(); RegisterFunction<SearchBookmarksFunction>(); RegisterFunction<RemoveBookmarkFunction>(); RegisterFunction<RemoveTreeBookmarkFunction>(); RegisterFunction<CreateBookmarkFunction>(); RegisterFunction<MoveBookmarkFunction>(); RegisterFunction<UpdateBookmarkFunction>(); RegisterFunction<ShowInfoBarFunction>(); RegisterFunction<CopyBookmarkManagerFunction>(); RegisterFunction<CutBookmarkManagerFunction>(); RegisterFunction<PasteBookmarkManagerFunction>(); RegisterFunction<CanPasteBookmarkManagerFunction>(); RegisterFunction<ImportBookmarksFunction>(); RegisterFunction<ExportBookmarksFunction>(); RegisterFunction<SortChildrenBookmarkManagerFunction>(); RegisterFunction<BookmarkManagerGetStringsFunction>(); RegisterFunction<StartDragBookmarkManagerFunction>(); RegisterFunction<DropBookmarkManagerFunction>(); RegisterFunction<GetSubtreeBookmarkManagerFunction>(); RegisterFunction<CanEditBookmarkManagerFunction>(); RegisterFunction<AddUrlHistoryFunction>(); RegisterFunction<DeleteAllHistoryFunction>(); RegisterFunction<DeleteRangeHistoryFunction>(); RegisterFunction<DeleteUrlHistoryFunction>(); RegisterFunction<GetVisitsHistoryFunction>(); RegisterFunction<SearchHistoryFunction>(); RegisterFunction<ExtensionIdleQueryStateFunction>(); RegisterFunction<GetAcceptLanguagesFunction>(); RegisterFunction<GetProcessIdForTabFunction>(); RegisterFunction<MetricsGetEnabledFunction>(); RegisterFunction<MetricsSetEnabledFunction>(); RegisterFunction<MetricsRecordUserActionFunction>(); RegisterFunction<MetricsRecordValueFunction>(); RegisterFunction<MetricsRecordPercentageFunction>(); RegisterFunction<MetricsRecordCountFunction>(); RegisterFunction<MetricsRecordSmallCountFunction>(); RegisterFunction<MetricsRecordMediumCountFunction>(); RegisterFunction<MetricsRecordTimeFunction>(); RegisterFunction<MetricsRecordMediumTimeFunction>(); RegisterFunction<MetricsRecordLongTimeFunction>(); #if defined(OS_WIN) RegisterFunction<RlzRecordProductEventFunction>(); RegisterFunction<RlzGetAccessPointRlzFunction>(); RegisterFunction<RlzSendFinancialPingFunction>(); RegisterFunction<RlzClearProductStateFunction>(); #endif RegisterFunction<GetCookieFunction>(); RegisterFunction<GetAllCookiesFunction>(); RegisterFunction<SetCookieFunction>(); RegisterFunction<RemoveCookieFunction>(); RegisterFunction<GetAllCookieStoresFunction>(); RegisterFunction<ExtensionTestPassFunction>(); RegisterFunction<ExtensionTestFailFunction>(); RegisterFunction<ExtensionTestLogFunction>(); RegisterFunction<ExtensionTestQuotaResetFunction>(); RegisterFunction<ExtensionTestCreateIncognitoTabFunction>(); RegisterFunction<ExtensionTestSendMessageFunction>(); RegisterFunction<ExtensionTestGetConfigFunction>(); RegisterFunction<GetFocusedControlFunction>(); RegisterFunction<SetAccessibilityEnabledFunction>(); RegisterFunction<ExtensionTtsSpeakFunction>(); RegisterFunction<ExtensionTtsStopSpeakingFunction>(); RegisterFunction<ExtensionTtsIsSpeakingFunction>(); RegisterFunction<ExtensionTtsSpeakCompletedFunction>(); RegisterFunction<CreateContextMenuFunction>(); RegisterFunction<UpdateContextMenuFunction>(); RegisterFunction<RemoveContextMenuFunction>(); RegisterFunction<RemoveAllContextMenusFunction>(); RegisterFunction<OmniboxSendSuggestionsFunction>(); RegisterFunction<OmniboxSetDefaultSuggestionFunction>(); RegisterFunction<CollapseSidebarFunction>(); RegisterFunction<ExpandSidebarFunction>(); RegisterFunction<GetStateSidebarFunction>(); RegisterFunction<HideSidebarFunction>(); RegisterFunction<NavigateSidebarFunction>(); RegisterFunction<SetBadgeTextSidebarFunction>(); RegisterFunction<SetIconSidebarFunction>(); RegisterFunction<SetTitleSidebarFunction>(); RegisterFunction<ShowSidebarFunction>(); #if defined(TOOLKIT_VIEWS) RegisterFunction<SendKeyboardEventInputFunction>(); #endif #if defined(TOUCH_UI) RegisterFunction<HideKeyboardFunction>(); RegisterFunction<SetKeyboardHeightFunction>(); #endif #if defined(OS_CHROMEOS) && defined(TOUCH_UI) RegisterFunction<CandidateClickedInputUiFunction>(); RegisterFunction<CursorUpInputUiFunction>(); RegisterFunction<CursorDownInputUiFunction>(); RegisterFunction<PageUpInputUiFunction>(); RegisterFunction<PageDownInputUiFunction>(); RegisterFunction<RegisterInputUiFunction>(); RegisterFunction<PageUpInputUiFunction>(); RegisterFunction<PageDownInputUiFunction>(); #endif RegisterFunction<GetAllExtensionsFunction>(); RegisterFunction<GetExtensionByIdFunction>(); RegisterFunction<LaunchAppFunction>(); RegisterFunction<SetEnabledFunction>(); RegisterFunction<UninstallFunction>(); RegisterFunction<SetUpdateUrlDataFunction>(); RegisterFunction<IsAllowedIncognitoAccessFunction>(); RegisterFunction<IsAllowedFileSchemeAccessFunction>(); RegisterFunction<GetBrowserLoginFunction>(); RegisterFunction<GetStoreLoginFunction>(); RegisterFunction<SetStoreLoginFunction>(); RegisterFunction<PromptBrowserLoginFunction>(); RegisterFunction<BeginInstallFunction>(); RegisterFunction<BeginInstallWithManifestFunction>(); RegisterFunction<CompleteInstallFunction>(); RegisterFunction<WebRequestAddEventListener>(); RegisterFunction<WebRequestEventHandled>(); RegisterFunction<GetPreferenceFunction>(); RegisterFunction<SetPreferenceFunction>(); RegisterFunction<ClearPreferenceFunction>(); #if defined(OS_CHROMEOS) RegisterFunction<GetChromeosInfoFunction>(); RegisterFunction<CancelFileDialogFunction>(); RegisterFunction<ExecuteTasksFileBrowserFunction>(); RegisterFunction<FileDialogStringsFunction>(); RegisterFunction<GetFileTasksFileBrowserFunction>(); RegisterFunction<GetVolumeMetadataFunction>(); RegisterFunction<RequestLocalFileSystemFunction>(); RegisterFunction<AddFileWatchBrowserFunction>(); RegisterFunction<RemoveFileWatchBrowserFunction>(); RegisterFunction<SelectFileFunction>(); RegisterFunction<SelectFilesFunction>(); RegisterFunction<UnmountVolumeFunction>(); RegisterFunction<ViewFilesFunction>(); RegisterFunction<PlayAtMediaplayerFunction>(); RegisterFunction<SetPlaybackErrorMediaplayerFunction>(); RegisterFunction<GetPlaylistMediaplayerFunction>(); RegisterFunction<TogglePlaylistPanelMediaplayerFunction>(); RegisterFunction<ToggleFullscreenMediaplayerFunction>(); #if defined(TOUCH_UI) RegisterFunction<SendHandwritingStrokeFunction>(); RegisterFunction<CancelHandwritingStrokesFunction>(); #endif #endif RegisterFunction<WebSocketProxyPrivateGetPassportForTCPFunction>(); RegisterFunction<AttachDebuggerFunction>(); RegisterFunction<DetachDebuggerFunction>(); RegisterFunction<SendRequestDebuggerFunction>(); RegisterFunction<GetResourceIdentifiersFunction>(); RegisterFunction<ClearContentSettingsFunction>(); RegisterFunction<GetContentSettingFunction>(); RegisterFunction<SetContentSettingFunction>(); RegisterFunction<AppNotifyFunction>(); RegisterFunction<AppClearAllNotificationsFunction>(); } Commit Message: Extend TTS extension API to support richer events returned from the engine to the client. Previously we just had a completed event; this adds start, word boundary, sentence boundary, and marker boundary. In addition, interrupted and canceled, which were previously errors, now become events. Mac and Windows implementations extended to support as many of these events as possible. BUG=67713 BUG=70198 BUG=75106 BUG=83404 TEST=Updates all TTS API tests to be event-based, and adds new tests. Review URL: http://codereview.chromium.org/6792014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91665 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
1
22,005
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void CloseObjectFiles() { #if !defined(NDEBUG) std::map<std::string, int>::iterator it; for (it = modules_.begin(); it != modules_.end(); ++it) { int ret = IGNORE_EINTR(close(it->second)); DCHECK(!ret); it->second = -1; } modules_.clear(); #endif // !defined(NDEBUG) } Commit Message: Convert ARRAYSIZE_UNSAFE -> arraysize in base/. R=thestig@chromium.org BUG=423134 Review URL: https://codereview.chromium.org/656033009 Cr-Commit-Position: refs/heads/master@{#299835} CWE ID: CWE-189
0
14,147
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: gst_asf_demux_handle_src_event (GstPad * pad, GstObject * parent, GstEvent * event) { GstASFDemux *demux; gboolean ret; demux = GST_ASF_DEMUX (parent); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_SEEK: GST_LOG_OBJECT (pad, "seek event"); ret = gst_asf_demux_handle_seek_event (demux, event); gst_event_unref (event); break; case GST_EVENT_QOS: case GST_EVENT_NAVIGATION: /* just drop these two silently */ gst_event_unref (event); ret = FALSE; break; default: GST_LOG_OBJECT (pad, "%s event", GST_EVENT_TYPE_NAME (event)); ret = gst_pad_event_default (pad, parent, event); break; } return ret; } Commit Message: asfdemux: Check that we have enough data available before parsing bool/uint extended content descriptors https://bugzilla.gnome.org/show_bug.cgi?id=777955 CWE ID: CWE-125
0
15,131
Analyze the following 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 BrowserWindowGtk::InvalidateInfoBarBits() { gtk_widget_queue_draw(toolbar_border_); gtk_widget_queue_draw(toolbar_->widget()); if (bookmark_bar_.get() && browser_->bookmark_bar_state() != BookmarkBar::DETACHED) { gtk_widget_queue_draw(bookmark_bar_->widget()); } } Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt. BUG=107201 TEST=no visible change Review URL: https://chromiumcodereview.appspot.com/11293205 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
22,013
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: _zip_u2d_time(time_t intime, zip_uint16_t *dtime, zip_uint16_t *ddate) { struct tm *tm; tm = localtime(&intime); if (tm->tm_year < 80) { tm->tm_year = 80; } *ddate = (zip_uint16_t)(((tm->tm_year+1900-1980)<<9) + ((tm->tm_mon+1)<<5) + tm->tm_mday); *dtime = (zip_uint16_t)(((tm->tm_hour)<<11) + ((tm->tm_min)<<5) + ((tm->tm_sec)>>1)); return; } Commit Message: Fix double free(). Found by Brian 'geeknik' Carpenter using AFL. CWE ID: CWE-415
0
7,422
Analyze the following 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 ProcessInfoObserver::OnDetailsAvailable() { scoped_ptr<DictionaryValue> return_value(new DictionaryValue); ListValue* browser_proc_list = new ListValue(); const std::vector<ProcessData>& all_processes = processes(); for (size_t index = 0; index < all_processes.size(); ++index) { DictionaryValue* browser_data = new DictionaryValue(); browser_data->SetString("name", all_processes[index].name); browser_data->SetString("process_name", all_processes[index].process_name); ListValue* proc_list = new ListValue(); for (ProcessMemoryInformationList::const_iterator iterator = all_processes[index].processes.begin(); iterator != all_processes[index].processes.end(); ++iterator) { DictionaryValue* proc_data = new DictionaryValue(); proc_data->SetInteger("pid", iterator->pid); DictionaryValue* working_set = new DictionaryValue(); working_set->SetInteger("priv", iterator->working_set.priv); working_set->SetInteger("shareable", iterator->working_set.shareable); working_set->SetInteger("shared", iterator->working_set.shared); proc_data->Set("working_set_mem", working_set); DictionaryValue* committed = new DictionaryValue(); committed->SetInteger("priv", iterator->committed.priv); committed->SetInteger("mapped", iterator->committed.mapped); committed->SetInteger("image", iterator->committed.image); proc_data->Set("committed_mem", committed); proc_data->SetString("version", iterator->version); proc_data->SetString("product_name", iterator->product_name); proc_data->SetInteger("num_processes", iterator->num_processes); proc_data->SetBoolean("is_diagnostics", iterator->is_diagnostics); std::string process_type = "Unknown"; if (iterator->type != content::PROCESS_TYPE_UNKNOWN) process_type = content::GetProcessTypeNameInEnglish(iterator->type); proc_data->SetString("child_process_type", process_type); std::string renderer_type = "Unknown"; if (iterator->renderer_type != ProcessMemoryInformation::RENDERER_UNKNOWN) { renderer_type = ProcessMemoryInformation::GetRendererTypeNameInEnglish( iterator->renderer_type); } proc_data->SetString("renderer_type", renderer_type); ListValue* titles = new ListValue(); for (size_t title_index = 0; title_index < iterator->titles.size(); ++title_index) titles->Append(Value::CreateStringValue(iterator->titles[title_index])); proc_data->Set("titles", titles); proc_list->Append(proc_data); } browser_data->Set("processes", proc_list); browser_proc_list->Append(browser_data); } return_value->Set("browsers", browser_proc_list); if (automation_) { AutomationJSONReply(automation_, reply_message_.release()) .SendSuccess(return_value.get()); } } Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt. BUG=107201 TEST=no visible change Review URL: https://chromiumcodereview.appspot.com/11293205 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
25,481
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data) { struct mount *mnt; struct dentry *root; if (!type) return ERR_PTR(-ENODEV); mnt = alloc_vfsmnt(name); if (!mnt) return ERR_PTR(-ENOMEM); if (flags & MS_KERNMOUNT) mnt->mnt.mnt_flags = MNT_INTERNAL; root = mount_fs(type, flags, name, data); if (IS_ERR(root)) { mnt_free_id(mnt); free_vfsmnt(mnt); return ERR_CAST(root); } mnt->mnt.mnt_root = root; mnt->mnt.mnt_sb = root->d_sb; mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_parent = mnt; lock_mount_hash(); list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts); unlock_mount_hash(); return &mnt->mnt; } Commit Message: mnt: Correct permission checks in do_remount While invesgiating the issue where in "mount --bind -oremount,ro ..." would result in later "mount --bind -oremount,rw" succeeding even if the mount started off locked I realized that there are several additional mount flags that should be locked and are not. In particular MNT_NOSUID, MNT_NODEV, MNT_NOEXEC, and the atime flags in addition to MNT_READONLY should all be locked. These flags are all per superblock, can all be changed with MS_BIND, and should not be changable if set by a more privileged user. The following additions to the current logic are added in this patch. - nosuid may not be clearable by a less privileged user. - nodev may not be clearable by a less privielged user. - noexec may not be clearable by a less privileged user. - atime flags may not be changeable by a less privileged user. The logic with atime is that always setting atime on access is a global policy and backup software and auditing software could break if atime bits are not updated (when they are configured to be updated), and serious performance degradation could result (DOS attack) if atime updates happen when they have been explicitly disabled. Therefore an unprivileged user should not be able to mess with the atime bits set by a more privileged user. The additional restrictions are implemented with the addition of MNT_LOCK_NOSUID, MNT_LOCK_NODEV, MNT_LOCK_NOEXEC, and MNT_LOCK_ATIME mnt flags. Taken together these changes and the fixes for MNT_LOCK_READONLY should make it safe for an unprivileged user to create a user namespace and to call "mount --bind -o remount,... ..." without the danger of mount flags being changed maliciously. Cc: stable@vger.kernel.org Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> CWE ID: CWE-264
0
10,454
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: struct sock *nfc_llcp_accept_dequeue(struct sock *parent, struct socket *newsock) { struct nfc_llcp_sock *lsk, *n, *llcp_parent; struct sock *sk; llcp_parent = nfc_llcp_sock(parent); list_for_each_entry_safe(lsk, n, &llcp_parent->accept_queue, accept_queue) { sk = &lsk->sk; lock_sock(sk); if (sk->sk_state == LLCP_CLOSED) { release_sock(sk); nfc_llcp_accept_unlink(sk); continue; } if (sk->sk_state == LLCP_CONNECTED || !newsock) { list_del_init(&lsk->accept_queue); sock_put(sk); if (newsock) sock_graft(sk, newsock); release_sock(sk); pr_debug("Returning sk state %d\n", sk->sk_state); sk_acceptq_removed(parent); return sk; } release_sock(sk); } return NULL; } Commit Message: NFC: llcp: fix info leaks via msg_name in llcp_sock_recvmsg() The code in llcp_sock_recvmsg() does not initialize all the members of struct sockaddr_nfc_llcp when filling the sockaddr info. Nor does it initialize the padding bytes of the structure inserted by the compiler for alignment. Also, if the socket is in state LLCP_CLOSED or is shutting down during receive the msg_namelen member is not updated to 0 while otherwise returning with 0, i.e. "success". The msg_namelen update is also missing for stream and seqpacket sockets which don't fill the sockaddr info. Both issues lead to the fact that the code will leak uninitialized kernel stack bytes in net/socket.c. Fix the first issue by initializing the memory used for sockaddr info with memset(0). Fix the second one by setting msg_namelen to 0 early. It will be updated later if we're going to fill the msg_name member. Cc: Lauro Ramos Venancio <lauro.venancio@openbossa.org> Cc: Aloisio Almeida Jr <aloisio.almeida@openbossa.org> Cc: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-200
0
6,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: blink::WebMediaPlayer* RenderFrameImpl::createMediaPlayer( blink::WebLocalFrame* frame, const blink::WebURL& url, WebMediaPlayerClient* client, WebMediaPlayerEncryptedMediaClient* encrypted_client, WebContentDecryptionModule* initial_cdm) { #if defined(VIDEO_HOLE) if (!contains_media_player_) { render_view_->RegisterVideoHoleFrame(this); contains_media_player_ = true; } #endif // defined(VIDEO_HOLE) blink::WebMediaStream web_stream( blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); if (!web_stream.isNull()) return CreateWebMediaPlayerForMediaStream(client); #if defined(OS_ANDROID) && !defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) return CreateAndroidWebMediaPlayer(client, encrypted_client, GetMediaPermission(), initial_cdm); #else scoped_refptr<media::MediaLog> media_log(new RenderMediaLog()); RenderThreadImpl* render_thread = RenderThreadImpl::current(); media::WebMediaPlayerParams params( base::Bind(&ContentRendererClient::DeferMediaLoad, base::Unretained(GetContentClient()->renderer()), static_cast<RenderFrame*>(this), has_played_media_), render_thread->GetAudioRendererMixerManager()->CreateInput(routing_id_), media_log, render_thread->GetMediaThreadTaskRunner(), render_thread->GetWorkerTaskRunner(), render_thread->compositor_task_runner(), base::Bind(&GetSharedMainThreadContext3D), GetMediaPermission(), initial_cdm); #if defined(ENABLE_MOJO_MEDIA) scoped_ptr<media::RendererFactory> media_renderer_factory( new media::MojoRendererFactory(GetMediaServiceFactory())); #else scoped_ptr<media::RendererFactory> media_renderer_factory = GetContentClient()->renderer()->CreateMediaRendererFactory( this, render_thread->GetGpuFactories(), media_log); if (!media_renderer_factory.get()) { media_renderer_factory.reset(new media::DefaultRendererFactory( media_log, render_thread->GetGpuFactories(), *render_thread->GetAudioHardwareConfig())); } #endif // defined(ENABLE_MOJO_MEDIA) return new media::WebMediaPlayerImpl( frame, client, encrypted_client, weak_factory_.GetWeakPtr(), media_renderer_factory.Pass(), GetCdmFactory(), params); #endif // defined(OS_ANDROID) && !defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) } Commit Message: Connect WebUSB client interface to the devices app This provides a basic WebUSB client interface in content/renderer. Most of the interface is unimplemented, but this CL hooks up navigator.usb.getDevices() to the browser's Mojo devices app to enumerate available USB devices. BUG=492204 Review URL: https://codereview.chromium.org/1293253002 Cr-Commit-Position: refs/heads/master@{#344881} CWE ID: CWE-399
0
25,811
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static inline void dirtyLineBoxesForRenderer(RenderObject* o, bool fullLayout) { if (o->isText()) { RenderText* renderText = toRenderText(o); renderText->dirtyLineBoxes(fullLayout); } else toRenderInline(o)->dirtyLineBoxes(fullLayout); } Commit Message: Update containtingIsolate to go back all the way to top isolate from current root, rather than stopping at the first isolate it finds. This works because the current root is always updated with each isolate run. BUG=279277 Review URL: https://chromiumcodereview.appspot.com/23972003 git-svn-id: svn://svn.chromium.org/blink/trunk@157268 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-399
0
3,348
Analyze the following 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 smp_task_done(struct sas_task *task) { if (!del_timer(&task->slow_task->timer)) return; complete(&task->slow_task->completion); } Commit Message: scsi: libsas: fix memory leak in sas_smp_get_phy_events() We've got a memory leak with the following producer: while true; do cat /sys/class/sas_phy/phy-1:0:12/invalid_dword_count >/dev/null; done The buffer req is allocated and not freed after we return. Fix it. Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver") Signed-off-by: Jason Yan <yanaijie@huawei.com> CC: John Garry <john.garry@huawei.com> CC: chenqilin <chenqilin2@huawei.com> CC: chenxiang <chenxiang66@hisilicon.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> CWE ID: CWE-772
0
7,975
Analyze the following 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 DownloadItemImpl::UpdateValidatorsOnResumption( const DownloadCreateInfo& new_create_info) { DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_EQ(RESUMING_INTERNAL, state_); DCHECK(!new_create_info.url_chain.empty()); std::vector<GURL>::const_iterator chain_iter = new_create_info.url_chain.begin(); if (*chain_iter == request_info_.url_chain.back()) ++chain_iter; int origin_state = 0; bool is_partial = GetReceivedBytes() > 0; if (chain_iter != new_create_info.url_chain.end()) origin_state |= ORIGIN_STATE_ON_RESUMPTION_ADDITIONAL_REDIRECTS; if (etag_ != new_create_info.etag || last_modified_time_ != new_create_info.last_modified) { received_slices_.clear(); destination_info_.received_bytes = 0; origin_state |= ORIGIN_STATE_ON_RESUMPTION_VALIDATORS_CHANGED; } if (content_disposition_ != new_create_info.content_disposition) origin_state |= ORIGIN_STATE_ON_RESUMPTION_CONTENT_DISPOSITION_CHANGED; RecordOriginStateOnResumption( is_partial, static_cast<OriginStateOnResumption>(origin_state)); request_info_.url_chain.insert(request_info_.url_chain.end(), chain_iter, new_create_info.url_chain.end()); etag_ = new_create_info.etag; last_modified_time_ = new_create_info.last_modified; response_headers_ = new_create_info.response_headers; content_disposition_ = new_create_info.content_disposition; mime_type_ = new_create_info.mime_type; } Commit Message: Downloads : Fixed an issue of opening incorrect download file When one download overwrites another completed download, calling download.open in the old download causes the new download to open, which could be dangerous and undesirable. In this CL, we are trying to avoid this by blocking the opening of the old download. Bug: 793620 Change-Id: Ic948175756700ad7c08489c3cc347330daedb6f8 Reviewed-on: https://chromium-review.googlesource.com/826477 Reviewed-by: David Trainor <dtrainor@chromium.org> Reviewed-by: Xing Liu <xingliu@chromium.org> Reviewed-by: John Abd-El-Malek <jam@chromium.org> Commit-Queue: Shakti Sahu <shaktisahu@chromium.org> Cr-Commit-Position: refs/heads/master@{#525810} CWE ID: CWE-20
0
5,712
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: gdImagePtr gdImageScaleTwoPass(const gdImagePtr src, const unsigned int src_width, const unsigned int src_height, const unsigned int new_width, const unsigned int new_height) { gdImagePtr tmp_im; gdImagePtr dst; tmp_im = gdImageCreateTrueColor(new_width, src_height); if (tmp_im == NULL) { return NULL; } gdImageSetInterpolationMethod(tmp_im, src->interpolation_id); _gdScaleHoriz(src, src_width, src_height, tmp_im, new_width, src_height); dst = gdImageCreateTrueColor(new_width, new_height); if (dst == NULL) { gdFree(tmp_im); return NULL; } gdImageSetInterpolationMethod(dst, src->interpolation_id); _gdScaleVert(tmp_im, new_width, src_height, dst, new_width, new_height); gdFree(tmp_im); return dst; } Commit Message: Fixed bug #72227: imagescale out-of-bounds read Ported from https://github.com/libgd/libgd/commit/4f65a3e4eedaffa1efcf9ee1eb08f0b504fbc31a CWE ID: CWE-125
0
22,297
Analyze the following 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 hmac_sha256_init(struct ahash_request *req) { struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); struct hash_ctx *ctx = crypto_ahash_ctx(tfm); ctx->config.data_format = HASH_DATA_8_BITS; ctx->config.algorithm = HASH_ALGO_SHA256; ctx->config.oper_mode = HASH_OPER_MODE_HMAC; ctx->digestsize = SHA256_DIGEST_SIZE; return hash_init(req); } Commit Message: crypto: prefix module autoloading with "crypto-" This prefixes all crypto module loading with "crypto-" so we never run the risk of exposing module auto-loading to userspace via a crypto API, as demonstrated by Mathias Krause: https://lkml.org/lkml/2013/3/4/70 Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> CWE ID: CWE-264
0
10,636
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: virtual ~CQTest() {} Commit Message: Merge Conflict Fix CL to lmp-mr1-release for ag/849478 DO NOT MERGE - libvpx: Pull from upstream Current HEAD: 7105df53d7dc13d5e575bc8df714ec8d1da36b06 BUG=23452792 Change-Id: Ic78176fc369e0bacc71d423e0e2e6075d004aaec CWE ID: CWE-119
0
2,771
Analyze the following 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 nntp_connect_error(struct NntpServer *nserv) { nserv->status = NNTP_NONE; mutt_error(_("Server closed connection!")); return -1; } Commit Message: Add alloc fail check in nntp_fetch_headers CWE ID: CWE-20
0
12,534
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: xsltMergeSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style, const xmlChar *name, const xmlChar *ns, ATTRIBUTE_UNUSED const xmlChar *ignored) { int ret; xsltAttrElemPtr topSet; ret = xmlHashAddEntry2(style->attributeSets, name, ns, values); if (ret < 0) { /* * Add failed, this attribute set can be removed. */ #ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "attribute set %s present already in top stylesheet" " - merging\n", name); #endif topSet = xmlHashLookup2(style->attributeSets, name, ns); if (topSet==NULL) { xsltGenericError(xsltGenericErrorContext, "xsl:attribute-set : logic error merging from imports for" " attribute-set %s\n", name); } else { topSet = xsltMergeAttrElemList(style, topSet, values); xmlHashUpdateEntry2(style->attributeSets, name, ns, topSet, NULL); } xsltFreeAttrElemList(values); #ifdef WITH_XSLT_DEBUG_ATTRIBUTES } else { xsltGenericDebug(xsltGenericDebugContext, "attribute set %s moved to top stylesheet\n", name); #endif } } 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
28,124
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void freefieldlist(struct fieldlist *l) { struct fieldlist *n; while (l) { n = l->next; free(l->section); strarray_free(l->fields); free(l->trail); if (l->rock) free(l->rock); free((char *)l); l = n; } } Commit Message: imapd: check for isadmin BEFORE parsing sync lines CWE ID: CWE-20
0
28,395
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: SynchronousCompositorOutputSurface::DemandDrawSw(SkCanvas* canvas) { DCHECK(CalledOnValidThread()); DCHECK(canvas); DCHECK(!current_sw_canvas_); base::AutoReset<SkCanvas*> canvas_resetter(&current_sw_canvas_, canvas); SkIRect canvas_clip; canvas->getClipDeviceBounds(&canvas_clip); gfx::Rect clip = gfx::SkIRectToRect(canvas_clip); gfx::Transform transform(gfx::Transform::kSkipInitialization); transform.matrix() = canvas->getTotalMatrix(); // Converts 3x3 matrix to 4x4. surface_size_ = gfx::Size(canvas->getDeviceSize().width(), canvas->getDeviceSize().height()); InvokeComposite(transform, clip, clip, cached_hw_viewport_rect_for_tile_priority_, cached_hw_transform_for_tile_priority_, false); return frame_holder_.Pass(); } Commit Message: sync compositor: pass simple gfx types by const ref See bug for reasoning BUG=159273 Review URL: https://codereview.chromium.org/1417893006 Cr-Commit-Position: refs/heads/master@{#356653} CWE ID: CWE-399
0
12,450
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: _tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) { size_t size_io = (size_t) size; if ((tmsize_t) size_io != size) { errno=EINVAL; return (tmsize_t) -1; } return ((tmsize_t) write((int) fd, buf, size_io)); } Commit Message: * libtiff/tif_{unix,vms,win32}.c (_TIFFmalloc): ANSI C does not require malloc() to return NULL pointer if requested allocation size is zero. Assure that _TIFFmalloc does. CWE ID: CWE-369
0
21,771
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: GF_Err odtt_dump(GF_Box *a, FILE * trace) { GF_OMADRMTransactionTrackingBox *ptr = (GF_OMADRMTransactionTrackingBox *)a; gf_isom_box_dump_start(a, "OMADRMTransactionTrackingBox", trace); fprintf(trace, "TransactionID=\""); dump_data(trace, ptr->TransactionID, 16); fprintf(trace, "\">\n"); gf_isom_box_dump_done("OMADRMTransactionTrackingBox", a, trace); return GF_OK; } Commit Message: fixed 2 possible heap overflows (inc. #1088) CWE ID: CWE-125
0
28,208
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: Document* Document::CreateForTest() { return MakeGarbageCollected<Document>(DocumentInit::Create()); } 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
1,072
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool RenderFrameImpl::OverrideLegacySymantecCertConsoleMessage( const blink::WebURL& url, blink::WebString* console_message) { std::string console_message_string; if (GetContentClient()->renderer()->OverrideLegacySymantecCertConsoleMessage( GURL(url), &console_message_string)) { *console_message = blink::WebString::FromASCII(console_message_string); return true; } return false; } Commit Message: If a page calls |window.focus()|, kick it out of fullscreen. BUG=776418, 800056 Change-Id: I1880fe600e4814c073f247c43b1c1ac80c8fc017 Reviewed-on: https://chromium-review.googlesource.com/852378 Reviewed-by: Nasko Oskov <nasko@chromium.org> Reviewed-by: Philip Jägenstedt <foolip@chromium.org> Commit-Queue: Avi Drissman <avi@chromium.org> Cr-Commit-Position: refs/heads/master@{#533790} CWE ID:
0
27,154
Analyze the following 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 svcauth_gss_set_log_badauth_func( auth_gssapi_log_badauth_func func, caddr_t data) { log_badauth = func; log_badauth_data = data; } Commit Message: Fix gssrpc data leakage [CVE-2014-9423] [MITKRB5-SA-2015-001] In svcauth_gss_accept_sec_context(), do not copy bytes from the union context into the handle field we send to the client. We do not use this handle field, so just supply a fixed string of "xxxx". In gss_union_ctx_id_struct, remove the unused "interposer" field which was causing part of the union context to remain uninitialized. ticket: 8058 (new) target_version: 1.13.1 tags: pullup CWE ID: CWE-200
0
23,017
Analyze the following 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 ScrollPaintPropertyNode::State ScrollState1() { ScrollPaintPropertyNode::State state; state.container_rect = IntRect(3, 5, 11, 13); state.contents_rect = IntRect(-3, -5, 27, 31); state.user_scrollable_horizontal = true; return state; } Commit Message: Reland "[CI] Make paint property nodes non-ref-counted" This reverts commit 887383b30842d9d9006e11bb6932660a3cb5b1b7. Reason for revert: Retry in M69. Original change's description: > Revert "[CI] Make paint property nodes non-ref-counted" > > This reverts commit 70fc0b018c9517558b7aa2be00edf2debb449123. > > Reason for revert: Caused bugs found by clusterfuzz > > Original change's description: > > [CI] Make paint property nodes non-ref-counted > > > > Now all paint property nodes are owned by ObjectPaintProperties > > (and LocalFrameView temporarily before removing non-RLS mode). > > Others just use raw pointers or references. > > > > Bug: 833496 > > Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2 > > Change-Id: I2d544fe153bb94698623248748df63c8aa2081ae > > Reviewed-on: https://chromium-review.googlesource.com/1031101 > > Reviewed-by: Tien-Ren Chen <trchen@chromium.org> > > Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#554626} > > TBR=wangxianzhu@chromium.org,trchen@chromium.org,chrishtr@chromium.org > > Change-Id: I02bb50d6744cb81a797246a0116b677e80a3c69f > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: 833496,837932,837943 > Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2 > Reviewed-on: https://chromium-review.googlesource.com/1034292 > Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org> > Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> > Cr-Commit-Position: refs/heads/master@{#554653} TBR=wangxianzhu@chromium.org,trchen@chromium.org,chrishtr@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: 833496, 837932, 837943 Change-Id: I0b4ef70db1f1f211ba97c30d617225355c750992 Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2 Reviewed-on: https://chromium-review.googlesource.com/1083491 Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org> Cr-Commit-Position: refs/heads/master@{#563930} CWE ID:
0
4,171
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: GURL ExtensionTabUtil::ResolvePossiblyRelativeURL(const std::string& url_string, const extensions::Extension* extension) { NOTIMPLEMENTED(); return GURL(); } Commit Message: Do not pass URLs in onUpdated events to extensions unless they have the "tabs" permission. BUG=168442 Review URL: https://chromiumcodereview.appspot.com/11824004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176406 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-264
0
9,457
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: rad_init_send_request(struct rad_handle *h, int *fd, struct timeval *tv) { int srv; /* Make sure we have a socket to use */ if (h->fd == -1) { struct sockaddr_in sin; if ((h->fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { #ifdef PHP_WIN32 generr(h, "Cannot create socket: %d", WSAGetLastError()); #else generr(h, "Cannot create socket: %s", strerror(errno)); #endif return -1; } memset(&sin, 0, sizeof sin); sin.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY; sin.sin_port = htons(0); if (bind(h->fd, (const struct sockaddr *)&sin, sizeof sin) == -1) { #ifdef PHP_WIN32 generr(h, "bind: %d", WSAGetLastError()); #else generr(h, "bind: %s", strerror(errno)); #endif close(h->fd); h->fd = -1; return -1; } } if (h->request[POS_CODE] == RAD_ACCOUNTING_REQUEST) { /* Make sure no password given */ if (h->pass_pos || h->chap_pass) { generr(h, "User or Chap Password in accounting request"); return -1; } } else { /* Make sure the user gave us a password */ if (h->pass_pos == 0 && !h->chap_pass) { generr(h, "No User or Chap Password attributes given"); return -1; } if (h->pass_pos != 0 && h->chap_pass) { generr(h, "Both User and Chap Password attributes given"); return -1; } } /* Fill in the length field in the message */ h->request[POS_LENGTH] = h->req_len >> 8; h->request[POS_LENGTH+1] = h->req_len; /* * Count the total number of tries we will make, and zero the * counter for each server. */ h->total_tries = 0; for (srv = 0; srv < h->num_servers; srv++) { h->total_tries += h->servers[srv].max_tries; h->servers[srv].num_tries = 0; } if (h->total_tries == 0) { generr(h, "No RADIUS servers specified"); return -1; } h->try = h->srv = 0; return rad_continue_send_request(h, 0, fd, tv); } Commit Message: Fix a security issue in radius_get_vendor_attr(). The underlying rad_get_vendor_attr() function assumed that it would always be given valid VSA data. Indeed, the buffer length wasn't even passed in; the assumption was that the length field within the VSA structure would be valid. This could result in denial of service by providing a length that would be beyond the memory limit, or potential arbitrary memory access by providing a length greater than the actual data given. rad_get_vendor_attr() has been changed to require the raw data length be provided, and this is then used to check that the VSA is valid. Conflicts: radlib_vs.h CWE ID: CWE-119
0
4,818
Analyze the following 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 OmniboxViewViews::UpdateContextMenu(ui::SimpleMenuModel* menu_contents) { if (send_tab_to_self::ShouldOfferFeature( location_bar_view_->GetWebContents())) { send_tab_to_self::RecordSendTabToSelfClickResult( send_tab_to_self::kOmniboxMenu, SendTabToSelfClickResult::kShowItem); int index = menu_contents->GetIndexOfCommandId(IDS_APP_UNDO); if (index) menu_contents->InsertSeparatorAt(index++, ui::NORMAL_SEPARATOR); menu_contents->InsertItemWithStringIdAt(index, IDC_SEND_TAB_TO_SELF, IDS_CONTEXT_MENU_SEND_TAB_TO_SELF); menu_contents->SetIcon(index, gfx::Image(*send_tab_to_self::GetImageSkia())); menu_contents->InsertSeparatorAt(++index, ui::NORMAL_SEPARATOR); } int paste_position = menu_contents->GetIndexOfCommandId(IDS_APP_PASTE); DCHECK_GE(paste_position, 0); menu_contents->InsertItemWithStringIdAt(paste_position + 1, IDC_PASTE_AND_GO, IDS_PASTE_AND_GO); if (base::FeatureList::IsEnabled(omnibox::kQueryInOmnibox)) { if (!read_only() && !model()->user_input_in_progress() && text() != controller()->GetLocationBarModel()->GetFormattedFullURL()) { menu_contents->AddItemWithStringId(IDS_SHOW_URL, IDS_SHOW_URL); } } menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, IDS_EDIT_SEARCH_ENGINES); } Commit Message: omnibox: experiment with restoring placeholder when caret shows Shows the "Search Google or type a URL" omnibox placeholder even when the caret (text edit cursor) is showing / when focused. views::Textfield works this way, as does <input placeholder="">. Omnibox and the NTP's "fakebox" are exceptions in this regard and this experiment makes this more consistent. R=tommycli@chromium.org BUG=955585 Change-Id: I23c299c0973f2feb43f7a2be3bd3425a80b06c2d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1582315 Commit-Queue: Dan Beam <dbeam@chromium.org> Reviewed-by: Tommy Li <tommycli@chromium.org> Cr-Commit-Position: refs/heads/master@{#654279} CWE ID: CWE-200
0
9,124
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void NavigationControllerImpl::NotifyNavigationEntryCommitted( LoadCommittedDetails* details) { details->entry = GetLastCommittedEntry(); ssl_manager_.DidCommitProvisionalLoad(*details); delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL); delegate_->NotifyNavigationEntryCommitted(*details); NotificationDetails notification_details = Details<LoadCommittedDetails>(details); NotificationService::current()->Notify( NOTIFICATION_NAV_ENTRY_COMMITTED, Source<NavigationController>(this), notification_details); } Commit Message: Add DumpWithoutCrashing in RendererDidNavigateToExistingPage This is intended to be reverted after investigating the linked bug. BUG=688425 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation Review-Url: https://codereview.chromium.org/2701523004 Cr-Commit-Position: refs/heads/master@{#450900} CWE ID: CWE-362
0
28,873
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: struct inode *find_inode_nowait(struct super_block *sb, unsigned long hashval, int (*match)(struct inode *, unsigned long, void *), void *data) { struct hlist_head *head = inode_hashtable + hash(sb, hashval); struct inode *inode, *ret_inode = NULL; int mval; spin_lock(&inode_hash_lock); hlist_for_each_entry(inode, head, i_hash) { if (inode->i_sb != sb) continue; mval = match(inode, hashval, data); if (mval == 0) continue; if (mval == 1) ret_inode = inode; goto out; } out: spin_unlock(&inode_hash_lock); return ret_inode; } Commit Message: Fix up non-directory creation in SGID directories sgid directories have special semantics, making newly created files in the directory belong to the group of the directory, and newly created subdirectories will also become sgid. This is historically used for group-shared directories. But group directories writable by non-group members should not imply that such non-group members can magically join the group, so make sure to clear the sgid bit on non-directories for non-members (but remember that sgid without group execute means "mandatory locking", just to confuse things even more). Reported-by: Jann Horn <jannh@google.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID: CWE-269
0
10,078
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: Document& Document::AxObjectCacheOwner() const { Document* doc = const_cast<Document*>(this); if (doc->GetFrame() && doc->GetFrame()->PagePopupOwner()) { DCHECK(!doc->ax_object_cache_); return doc->GetFrame() ->PagePopupOwner() ->GetDocument() .AxObjectCacheOwner(); } return *doc; } 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
16,855
Analyze the following 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 WebPagePrivate::setCompositorDrawsRootLayer(bool compositorDrawsRootLayer) { #if USE(ACCELERATED_COMPOSITING) if (m_page->settings()->forceCompositingMode() == compositorDrawsRootLayer) return; m_page->settings()->setForceCompositingMode(compositorDrawsRootLayer); if (!m_mainFrame) return; if (FrameView* view = m_mainFrame->view()) view->updateCompositingLayers(); #endif } Commit Message: [BlackBerry] Adapt to new BlackBerry::Platform::TouchPoint API https://bugs.webkit.org/show_bug.cgi?id=105143 RIM PR 171941 Reviewed by Rob Buis. Internally reviewed by George Staikos. Source/WebCore: TouchPoint instances now provide document coordinates for the viewport and content position of the touch event. The pixel coordinates stored in the TouchPoint should no longer be needed in WebKit. Also adapt to new method names and encapsulation of TouchPoint data members. No change in behavior, no new tests. * platform/blackberry/PlatformTouchPointBlackBerry.cpp: (WebCore::PlatformTouchPoint::PlatformTouchPoint): Source/WebKit/blackberry: TouchPoint instances now provide document coordinates for the viewport and content position of the touch event. The pixel coordinates stored in the TouchPoint should no longer be needed in WebKit. One exception is when passing events to a full screen plugin. Also adapt to new method names and encapsulation of TouchPoint data members. * Api/WebPage.cpp: (BlackBerry::WebKit::WebPage::touchEvent): (BlackBerry::WebKit::WebPage::touchPointAsMouseEvent): (BlackBerry::WebKit::WebPagePrivate::dispatchTouchEventToFullScreenPlugin): (BlackBerry::WebKit::WebPagePrivate::dispatchTouchPointAsMouseEventToFullScreenPlugin): * WebKitSupport/InputHandler.cpp: (BlackBerry::WebKit::InputHandler::shouldRequestSpellCheckingOptionsForPoint): * WebKitSupport/InputHandler.h: (InputHandler): * WebKitSupport/TouchEventHandler.cpp: (BlackBerry::WebKit::TouchEventHandler::doFatFingers): (BlackBerry::WebKit::TouchEventHandler::handleTouchPoint): * WebKitSupport/TouchEventHandler.h: (TouchEventHandler): Tools: Adapt to new method names and encapsulation of TouchPoint data members. * DumpRenderTree/blackberry/EventSender.cpp: (addTouchPointCallback): (updateTouchPointCallback): (touchEndCallback): (releaseTouchPointCallback): (sendTouchEvent): git-svn-id: svn://svn.chromium.org/blink/trunk@137880 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID:
0
12,023
Analyze the following 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 apr_byte_t oidc_check_cookie_domain(request_rec *r, oidc_cfg *cfg, oidc_session_t *session) { const char *c_cookie_domain = cfg->cookie_domain ? cfg->cookie_domain : oidc_get_current_url_host(r); const char *s_cookie_domain = oidc_session_get_cookie_domain(r, session); if ((s_cookie_domain == NULL) || (apr_strnatcmp(c_cookie_domain, s_cookie_domain) != 0)) { oidc_warn(r, "aborting: detected attempt to play cookie against a different domain/host than issued for! (issued=%s, current=%s)", s_cookie_domain, c_cookie_domain); return FALSE; } return TRUE; } Commit Message: release 2.3.10.2: fix XSS vulnerability for poll parameter in OIDC Session Management RP iframe; CSNC-2019-001; thanks Mischa Bachmann Signed-off-by: Hans Zandbelt <hans.zandbelt@zmartzone.eu> CWE ID: CWE-79
0
23,322
Analyze the following 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 perWorldBindingsReadonlyTestInterfaceEmptyAttributeAttributeGetterForMainWorld(const v8::PropertyCallbackInfo<v8::Value>& info) { TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); RefPtr<TestInterfaceEmpty> result(imp->perWorldBindingsReadonlyTestInterfaceEmptyAttribute()); if (result && DOMDataStore::setReturnValueFromWrapperForMainWorld<V8TestInterfaceEmpty>(info.GetReturnValue(), result.get())) return; v8::Handle<v8::Value> wrapper = toV8(result.get(), info.Holder(), info.GetIsolate()); if (!wrapper.IsEmpty()) { V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), v8AtomicString(info.GetIsolate(), "perWorldBindingsReadonlyTestInterfaceEmptyAttribute"), wrapper); v8SetReturnValue(info, wrapper); } } Commit Message: document.location bindings fix BUG=352374 R=jochen@chromium.org Review URL: https://codereview.chromium.org/196343011 git-svn-id: svn://svn.chromium.org/blink/trunk@169176 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-399
0
7,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: irc_server_timer_sasl_cb (void *data, int remaining_calls) { struct t_irc_server *server; /* make C compiler happy */ (void) remaining_calls; server = (struct t_irc_server *)data; if (!server) return WEECHAT_RC_ERROR; server->hook_timer_sasl = NULL; if (!server->is_connected) { weechat_printf (server->buffer, _("%s%s: sasl authentication timeout"), weechat_prefix ("error"), IRC_PLUGIN_NAME); irc_server_sendf (server, 0, NULL, "CAP END"); } return WEECHAT_RC_OK; } Commit Message: CWE ID: CWE-20
0
26,865
Analyze the following 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 checkMidpoints(LineMidpointState& lineMidpointState, InlineIterator& lBreak) { if (lBreak.m_obj && lineMidpointState.numMidpoints && !(lineMidpointState.numMidpoints % 2)) { InlineIterator* midpoints = lineMidpointState.midpoints.data(); InlineIterator& endpoint = midpoints[lineMidpointState.numMidpoints - 2]; const InlineIterator& startpoint = midpoints[lineMidpointState.numMidpoints - 1]; InlineIterator currpoint = endpoint; while (!currpoint.atEnd() && currpoint != startpoint && currpoint != lBreak) currpoint.increment(); if (currpoint == lBreak) { lineMidpointState.numMidpoints--; if (endpoint.m_obj->style()->collapseWhiteSpace()) endpoint.m_pos--; } } } Commit Message: Update containtingIsolate to go back all the way to top isolate from current root, rather than stopping at the first isolate it finds. This works because the current root is always updated with each isolate run. BUG=279277 Review URL: https://chromiumcodereview.appspot.com/23972003 git-svn-id: svn://svn.chromium.org/blink/trunk@157268 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-399
0
19,992
Analyze the following 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 coolkey_final_iterator(list_t *list) { list_iterator_stop(list); return SC_SUCCESS; } 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
16,198
Analyze the following 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(stream_context_set_params) { zval *params, *zcontext; php_stream_context *context; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ra", &zcontext, &params) == FAILURE) { RETURN_FALSE; } context = decode_context_param(zcontext TSRMLS_CC); if (!context) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid stream/context parameter"); RETURN_FALSE; } RETVAL_BOOL(parse_context_params(context, params TSRMLS_CC) == SUCCESS); } Commit Message: CWE ID: CWE-254
0
2,398
Analyze the following 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 dbus_uint32_t fromAscii(char ascii) { if(ascii >= '0' && ascii <= '9') return ascii - '0'; if(ascii >= 'A' && ascii <= 'F') return ascii - 'A' + 10; if(ascii >= 'a' && ascii <= 'f') return ascii - 'a' + 10; return 0; } Commit Message: CWE ID: CWE-20
0
9,832
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ssh_packet_read_seqnr(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p) { struct session_state *state = ssh->state; int len, r, ms_remain; fd_set *setp; char buf[8192]; struct timeval timeout, start, *timeoutp = NULL; DBG(debug("packet_read()")); setp = calloc(howmany(state->connection_in + 1, NFDBITS), sizeof(fd_mask)); if (setp == NULL) return SSH_ERR_ALLOC_FAIL; /* * Since we are blocking, ensure that all written packets have * been sent. */ if ((r = ssh_packet_write_wait(ssh)) != 0) goto out; /* Stay in the loop until we have received a complete packet. */ for (;;) { /* Try to read a packet from the buffer. */ r = ssh_packet_read_poll_seqnr(ssh, typep, seqnr_p); if (r != 0) break; if (!compat20 && ( *typep == SSH_SMSG_SUCCESS || *typep == SSH_SMSG_FAILURE || *typep == SSH_CMSG_EOF || *typep == SSH_CMSG_EXIT_CONFIRMATION)) if ((r = sshpkt_get_end(ssh)) != 0) break; /* If we got a packet, return it. */ if (*typep != SSH_MSG_NONE) break; /* * Otherwise, wait for some data to arrive, add it to the * buffer, and try again. */ memset(setp, 0, howmany(state->connection_in + 1, NFDBITS) * sizeof(fd_mask)); FD_SET(state->connection_in, setp); if (state->packet_timeout_ms > 0) { ms_remain = state->packet_timeout_ms; timeoutp = &timeout; } /* Wait for some data to arrive. */ for (;;) { if (state->packet_timeout_ms != -1) { ms_to_timeval(&timeout, ms_remain); gettimeofday(&start, NULL); } if ((r = select(state->connection_in + 1, setp, NULL, NULL, timeoutp)) >= 0) break; if (errno != EAGAIN && errno != EINTR) break; if (state->packet_timeout_ms == -1) continue; ms_subtract_diff(&start, &ms_remain); if (ms_remain <= 0) { r = 0; break; } } if (r == 0) return SSH_ERR_CONN_TIMEOUT; /* Read data from the socket. */ len = read(state->connection_in, buf, sizeof(buf)); if (len == 0) { r = SSH_ERR_CONN_CLOSED; goto out; } if (len < 0) { r = SSH_ERR_SYSTEM_ERROR; goto out; } /* Append it to the buffer. */ if ((r = ssh_packet_process_incoming(ssh, buf, len)) != 0) goto out; } out: free(setp); return r; } Commit Message: Remove support for pre-authentication compression. Doing compression early in the protocol probably seemed reasonable in the 1990s, but today it's clearly a bad idea in terms of both cryptography (cf. multiple compression oracle attacks in TLS) and attack surface. Moreover, to support it across privilege-separation zlib needed the assistance of a complex shared-memory manager that made the required attack surface considerably larger. Prompted by Guido Vranken pointing out a compiler-elided security check in the shared memory manager found by Stack (http://css.csail.mit.edu/stack/); ok deraadt@ markus@ NB. pre-auth authentication has been disabled by default in sshd for >10 years. CWE ID: CWE-119
0
20,089
Analyze the following 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 VideoCaptureManager::TakePhoto( int session_id, media::VideoCaptureDevice::TakePhotoCallback callback) { DCHECK_CURRENTLY_ON(BrowserThread::IO); VideoCaptureController* controller = LookupControllerBySessionId(session_id); if (!controller) return; if (controller->IsDeviceAlive()) { controller->TakePhoto(std::move(callback)); return; } photo_request_queue_.emplace_back( session_id, base::Bind(&VideoCaptureController::TakePhoto, base::Unretained(controller), base::Passed(&callback))); } Commit Message: Make MediaStreamDispatcherHost per-request instead of per-frame. Instead of having RenderFrameHost own a single MSDH to handle all requests from a frame, MSDH objects will be owned by a strong binding. A consequence of this is that an additional requester ID is added to requests to MediaStreamManager, so that an MSDH is able to cancel only requests generated by it. In practice, MSDH will continue to be per frame in most cases since each frame normally makes a single request for an MSDH object. This fixes a lifetime issue caused by the IO thread executing tasks after the RenderFrameHost dies. Drive-by: Fix some minor lint issues. Bug: 912520 Change-Id: I52742ffc98b9fc57ce8e6f5093a61aed86d3e516 Reviewed-on: https://chromium-review.googlesource.com/c/1369799 Reviewed-by: Emircan Uysaler <emircan@chromium.org> Reviewed-by: Ken Buchanan <kenrb@chromium.org> Reviewed-by: Olga Sharonova <olka@chromium.org> Commit-Queue: Guido Urdaneta <guidou@chromium.org> Cr-Commit-Position: refs/heads/master@{#616347} CWE ID: CWE-189
0
14,382
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: RootInlineBox* RenderBlock::lineAtIndex(int i) const { ASSERT(i >= 0); if (style()->visibility() != VISIBLE) return 0; if (childrenInline()) { for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox()) if (!i--) return box; } else { for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { if (!shouldCheckLines(child)) continue; if (RootInlineBox* box = toRenderBlock(child)->lineAtIndex(i)) return box; } } return 0; } Commit Message: Separate repaint and layout requirements of StyleDifference (Step 1) Previously StyleDifference was an enum that proximately bigger values imply smaller values (e.g. StyleDifferenceLayout implies StyleDifferenceRepaint). This causes unnecessary repaints in some cases on layout change. Convert StyleDifference to a structure containing relatively independent flags. This change doesn't directly improve the result, but can make further repaint optimizations possible. Step 1 doesn't change any functionality. RenderStyle still generate the legacy StyleDifference enum when comparing styles and convert the result to the new StyleDifference. Implicit requirements are not handled during the conversion. Converted call sites to use the new StyleDifference according to the following conversion rules: - diff == StyleDifferenceEqual (&& !context) => diff.hasNoChange() - diff == StyleDifferenceRepaint => diff.needsRepaintObjectOnly() - diff == StyleDifferenceRepaintLayer => diff.needsRepaintLayer() - diff == StyleDifferenceRepaint || diff == StyleDifferenceRepaintLayer => diff.needsRepaintLayer() - diff >= StyleDifferenceRepaint => diff.needsRepaint() || diff.needsLayout() - diff >= StyleDifferenceRepaintLayer => diff.needsRepaintLayer() || diff.needsLayout() - diff > StyleDifferenceRepaintLayer => diff.needsLayout() - diff == StyleDifferencePositionedMovementLayoutOnly => diff.needsPositionedMovementLayoutOnly() - diff == StyleDifferenceLayout => diff.needsFullLayout() BUG=358460 TEST=All existing layout tests. R=eseidel@chromium.org, esprehn@chromium.org, jchaffraix@chromium.org Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=171983 Review URL: https://codereview.chromium.org/236203020 git-svn-id: svn://svn.chromium.org/blink/trunk@172331 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-119
0
18,910
Analyze the following 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 HTMLFormElement::matchesValidityPseudoClasses() const { return true; } Commit Message: Enforce form-action CSP even when form.target is present. BUG=630332 Review-Url: https://codereview.chromium.org/2464123004 Cr-Commit-Position: refs/heads/master@{#429922} CWE ID: CWE-19
0
21,254
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void CL_DownloadsComplete( void ) { #ifdef USE_CURL if(clc.cURLUsed) { clc.cURLUsed = qfalse; CL_cURL_Shutdown(); if( clc.cURLDisconnected ) { if(clc.downloadRestart) { FS_Restart(clc.checksumFeed); clc.downloadRestart = qfalse; } clc.cURLDisconnected = qfalse; CL_Reconnect_f(); return; } } #endif if (clc.downloadRestart) { clc.downloadRestart = qfalse; FS_Restart(clc.checksumFeed); // We possibly downloaded a pak, restart the file system to load it CL_AddReliableCommand("donedl", qfalse); return; } clc.state = CA_LOADING; Com_EventLoop(); if ( clc.state != CA_LOADING ) { return; } Cvar_Set("r_uiFullScreen", "0"); CL_FlushMemory(); cls.cgameStarted = qtrue; CL_InitCGame(); CL_SendPureChecksums(); CL_WritePacket(); CL_WritePacket(); CL_WritePacket(); } Commit Message: Don't load .pk3s as .dlls, and don't load user config files from .pk3s. CWE ID: CWE-269
0
28,939
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ProfileSyncServiceHarness* LiveSyncTest::GetClient(int index) { if (clients_.empty()) LOG(FATAL) << "SetupClients() has not yet been called."; if (index < 0 || index >= static_cast<int>(clients_.size())) LOG(FATAL) << "GetClient(): Index is out of bounds."; return clients_[index]; } Commit Message: Use URLFetcher::Create instead of new in http_bridge.cc. This change modified http_bridge so that it uses a factory to construct the URLFetcher. Moreover, it modified sync_backend_host_unittest.cc to use an URLFetcher factory which will prevent access to www.example.com during the test. BUG=none TEST=sync_backend_host_unittest.cc Review URL: http://codereview.chromium.org/7053011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87227 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
13,531
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: GLvoid StubGLVertexAttrib4fv(GLuint indx, const GLfloat* values) { glVertexAttrib4fv(indx, values); } Commit Message: Add chromium_code: 1 to surface.gyp and gl.gyp to pick up -Werror. It looks like this was dropped accidentally in http://codereview.chromium.org/6718027 (surface.gyp) and http://codereview.chromium.org/6722026 (gl.gyp) Remove now-redudant code that's implied by chromium_code: 1. Fix the warnings that have crept in since chromium_code: 1 was removed. BUG=none TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=91598 Review URL: http://codereview.chromium.org/7227009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91813 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-189
0
27,885
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: xsltCompilationCtxtFree(xsltCompilerCtxtPtr cctxt) { if (cctxt == NULL) return; #ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "Freeing compilation context\n"); xsltGenericDebug(xsltGenericDebugContext, "### Max inodes: %d\n", cctxt->maxNodeInfos); xsltGenericDebug(xsltGenericDebugContext, "### Max LREs : %d\n", cctxt->maxLREs); #endif /* * Free node-infos. */ if (cctxt->inodeList != NULL) { xsltCompilerNodeInfoPtr tmp, cur = cctxt->inodeList; while (cur != NULL) { tmp = cur; cur = cur->next; xmlFree(tmp); } } if (cctxt->tmpList != NULL) xsltPointerListFree(cctxt->tmpList); #ifdef XSLT_REFACTORED_XPATHCOMP if (cctxt->xpathCtxt != NULL) xmlXPathFreeContext(cctxt->xpathCtxt); #endif if (cctxt->nsAliases != NULL) xsltFreeNsAliasList(cctxt->nsAliases); if (cctxt->ivars) xsltCompilerVarInfoFree(cctxt); xmlFree(cctxt); } 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
26,540
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: free_options(struct mtree_option *head) { struct mtree_option *next; for (; head != NULL; head = next) { next = head->next; free(head->value); free(head); } } Commit Message: Fix libarchive/archive_read_support_format_mtree.c:1388:11: error: array subscript is above array bounds CWE ID: CWE-119
0
22,164
Analyze the following 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 Wait() { std::vector<DownloadItem*> downloads; manager_->GetAllDownloads(&downloads); if (!downloads.empty()) return; waiting_ = true; content::RunMessageLoop(); waiting_ = false; } 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
9,685
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void RenderViewImpl::willSendRequest(WebFrame* frame, unsigned identifier, WebURLRequest& request, const WebURLResponse& redirect_response) { if (request.url().isEmpty()) return; WebFrame* top_frame = frame->top(); if (!top_frame) top_frame = frame; WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); WebDataSource* top_data_source = top_frame->dataSource(); WebDataSource* data_source = provisional_data_source ? provisional_data_source : top_data_source; PageTransition transition_type = PAGE_TRANSITION_LINK; DocumentState* document_state = DocumentState::FromDataSource(data_source); DCHECK(document_state); NavigationState* navigation_state = document_state->navigation_state(); transition_type = navigation_state->transition_type(); GURL request_url(request.url()); GURL new_url; if (GetContentClient()->renderer()->WillSendRequest( frame, transition_type, request_url, request.firstPartyForCookies(), &new_url)) { request.setURL(WebURL(new_url)); } if (document_state->is_cache_policy_override_set()) request.setCachePolicy(document_state->cache_policy_override()); WebKit::WebReferrerPolicy referrer_policy; if (document_state && document_state->is_referrer_policy_set()) { referrer_policy = document_state->referrer_policy(); document_state->clear_referrer_policy(); } else { referrer_policy = frame->document().referrerPolicy(); } WebString custom_user_agent; if (request.extraData()) { webkit_glue::WebURLRequestExtraDataImpl* old_extra_data = static_cast<webkit_glue::WebURLRequestExtraDataImpl*>( request.extraData()); custom_user_agent = old_extra_data->custom_user_agent(); if (!custom_user_agent.isNull()) { if (custom_user_agent.isEmpty()) request.clearHTTPHeaderField("User-Agent"); else request.setHTTPHeaderField("User-Agent", custom_user_agent); } } request.setExtraData( new RequestExtraData(referrer_policy, custom_user_agent, (frame == top_frame), frame->identifier(), frame->parent() == top_frame, frame->parent() ? frame->parent()->identifier() : -1, navigation_state->allow_download(), transition_type, navigation_state->transferred_request_child_id(), navigation_state->transferred_request_request_id())); DocumentState* top_document_state = DocumentState::FromDataSource(top_data_source); if (top_document_state && request.targetType() == WebURLRequest::TargetIsPrefetch) top_document_state->set_was_prefetcher(true); request.setRequestorID(routing_id_); request.setHasUserGesture(frame->isProcessingUserGesture()); if (!renderer_preferences_.enable_referrers) request.clearHTTPHeaderField("Referer"); } Commit Message: Let the browser handle external navigations from DevTools. BUG=180555 Review URL: https://chromiumcodereview.appspot.com/12531004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186793 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-264
0
13,581
Analyze the following 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 reportResourceTiming(ResourceTimingInfo* info, Document* initiatorDocument, bool isMainResource) { if (initiatorDocument && isMainResource) initiatorDocument = initiatorDocument->parentDocument(); if (!initiatorDocument || !initiatorDocument->loader()) return; if (DOMWindow* initiatorWindow = initiatorDocument->domWindow()) initiatorWindow->performance().addResourceTiming(*info, initiatorDocument); } Commit Message: Enforce SVG image security rules SVG images have unique security rules that prevent them from loading any external resources. This patch enforces these rules in ResourceFetcher::canRequest for all non-data-uri resources. This locks down our SVG resource handling and fixes two security bugs. In the case of SVG images that reference other images, we had a bug where a cached subresource would be used directly from the cache. This has been fixed because the canRequest check occurs before we use cached resources. In the case of SVG images that use CSS imports, we had a bug where imports were blindly requested. This has been fixed by stopping all non-data-uri requests in SVG images. With this patch we now match Gecko's behavior on both testcases. BUG=380885, 382296 Review URL: https://codereview.chromium.org/320763002 git-svn-id: svn://svn.chromium.org/blink/trunk@176084 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-264
0
14,022
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ExtensionFunction::ResponseAction TabsGoForwardFunction::Run() { std::unique_ptr<tabs::GoForward::Params> params( tabs::GoForward::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); int tab_id = params->tab_id ? *params->tab_id : -1; std::string error; WebContents* web_contents = GetTabsAPIDefaultWebContents(this, tab_id, &error); if (!web_contents) return RespondNow(Error(error)); NavigationController& controller = web_contents->GetController(); if (!controller.CanGoForward()) return RespondNow(Error(tabs_constants::kNotFoundNextPageError)); controller.GoForward(); return RespondNow(NoArguments()); } 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
19,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: static void readonlyDOMTimeStampMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); TestObjectPythonV8Internal::readonlyDOMTimeStampMethodMethod(info); TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); } Commit Message: document.location bindings fix BUG=352374 R=jochen@chromium.org Review URL: https://codereview.chromium.org/196343011 git-svn-id: svn://svn.chromium.org/blink/trunk@169176 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-399
0
19,917
Analyze the following 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 ShouldHandle(const HttpRequest& request, const std::string& path_prefix) { GURL url = request.GetURL(); return url.path() == path_prefix || base::StartsWith(url.path(), path_prefix + "/", base::CompareCase::SENSITIVE); } Commit Message: Fix ChromeResourceDispatcherHostDelegateMirrorBrowserTest.MirrorRequestHeader with network service. The functionality worked, as part of converting DICE, however the test code didn't work since it depended on accessing the net objects directly. Switch the tests to use the EmbeddedTestServer, to better match production, which removes the dependency on net/. Also: -make GetFilePathWithReplacements replace strings in the mock headers if they're present -add a global to google_util to ignore ports; that way other tests can be converted without having to modify each callsite to google_util Bug: 881976 Change-Id: Ic52023495c1c98c1248025c11cdf37f433fef058 Reviewed-on: https://chromium-review.googlesource.com/c/1328142 Commit-Queue: John Abd-El-Malek <jam@chromium.org> Reviewed-by: Ramin Halavati <rhalavati@chromium.org> Reviewed-by: Maks Orlovich <morlovich@chromium.org> Reviewed-by: Peter Kasting <pkasting@chromium.org> Cr-Commit-Position: refs/heads/master@{#607652} CWE ID:
0
14,437
Analyze the following 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 WallpaperManagerBase::OnCustomizedDefaultWallpaperDecoded( const GURL& wallpaper_url, std::unique_ptr<CustomizedWallpaperRescaledFiles> rescaled_files, std::unique_ptr<user_manager::UserImage> wallpaper) { DCHECK(thread_checker_.CalledOnValidThread()); if (wallpaper->image().isNull()) { LOG(WARNING) << "Failed to decode customized wallpaper."; return; } wallpaper->image().EnsureRepsForSupportedScales(); std::unique_ptr<gfx::ImageSkia> deep_copy(wallpaper->image().DeepCopy()); std::unique_ptr<bool> success(new bool(false)); std::unique_ptr<gfx::ImageSkia> small_wallpaper_image(new gfx::ImageSkia); std::unique_ptr<gfx::ImageSkia> large_wallpaper_image(new gfx::ImageSkia); base::Closure resize_closure = base::Bind( &WallpaperManagerBase::ResizeCustomizedDefaultWallpaper, base::Passed(&deep_copy), base::Unretained(rescaled_files.get()), base::Unretained(success.get()), base::Unretained(small_wallpaper_image.get()), base::Unretained(large_wallpaper_image.get())); base::Closure on_resized_closure = base::Bind( &WallpaperManagerBase::OnCustomizedDefaultWallpaperResized, weak_factory_.GetWeakPtr(), wallpaper_url, base::Passed(std::move(rescaled_files)), base::Passed(std::move(success)), base::Passed(std::move(small_wallpaper_image)), base::Passed(std::move(large_wallpaper_image))); if (!task_runner_->PostTaskAndReply(FROM_HERE, resize_closure, on_resized_closure)) { LOG(WARNING) << "Failed to start Customized Wallpaper resize."; } } Commit Message: [reland] Do not set default wallpaper unless it should do so. TBR=bshe@chromium.org, alemate@chromium.org Bug: 751382 Change-Id: Id0793dfe467f737526a95b1e66ed01fbb8860bda Reviewed-on: https://chromium-review.googlesource.com/619754 Commit-Queue: Xiaoqian Dai <xdai@chromium.org> Reviewed-by: Alexander Alekseev <alemate@chromium.org> Reviewed-by: Biao She <bshe@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#498325} Reviewed-on: https://chromium-review.googlesource.com/646430 Cr-Commit-Position: refs/heads/master@{#498982} CWE ID: CWE-200
0
7,955
Analyze the following 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 Editor::canDeleteRange(const EphemeralRange& range) const { if (range.isCollapsed()) return false; Node* startContainer = range.startPosition().computeContainerNode(); Node* endContainer = range.endPosition().computeContainerNode(); if (!startContainer || !endContainer) return false; return hasEditableStyle(*startContainer) && hasEditableStyle(*endContainer); } Commit Message: Make TypingCommand::insertText() to take SelectionInDOMTree instead of VisibleSelection This patch makes |TypingCommand::insertText()| to take |SelectionInDOMTree| instead of |VisibleSelection| to reduce usage of |VisibleSelection| for improving code health. BUG=657237 TEST=n/a Review-Url: https://codereview.chromium.org/2733183002 Cr-Commit-Position: refs/heads/master@{#455368} CWE ID:
0
15,802
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, struct cpumask *groupmask) { struct sched_group *group = sd->groups; cpumask_clear(groupmask); printk(KERN_DEBUG "%*s domain %d: ", level, "", level); if (!(sd->flags & SD_LOAD_BALANCE)) { printk("does not load-balance\n"); if (sd->parent) printk(KERN_ERR "ERROR: !SD_LOAD_BALANCE domain" " has parent"); return -1; } printk(KERN_CONT "span %*pbl level %s\n", cpumask_pr_args(sched_domain_span(sd)), sd->name); if (!cpumask_test_cpu(cpu, sched_domain_span(sd))) { printk(KERN_ERR "ERROR: domain->span does not contain " "CPU%d\n", cpu); } if (!cpumask_test_cpu(cpu, sched_group_cpus(group))) { printk(KERN_ERR "ERROR: domain->groups does not contain" " CPU%d\n", cpu); } printk(KERN_DEBUG "%*s groups:", level + 1, ""); do { if (!group) { printk("\n"); printk(KERN_ERR "ERROR: group is NULL\n"); break; } if (!cpumask_weight(sched_group_cpus(group))) { printk(KERN_CONT "\n"); printk(KERN_ERR "ERROR: empty group\n"); break; } if (!(sd->flags & SD_OVERLAP) && cpumask_intersects(groupmask, sched_group_cpus(group))) { printk(KERN_CONT "\n"); printk(KERN_ERR "ERROR: repeated CPUs\n"); break; } cpumask_or(groupmask, groupmask, sched_group_cpus(group)); printk(KERN_CONT " %*pbl", cpumask_pr_args(sched_group_cpus(group))); if (group->sgc->capacity != SCHED_CAPACITY_SCALE) { printk(KERN_CONT " (cpu_capacity = %d)", group->sgc->capacity); } group = group->next; } while (group != sd->groups); printk(KERN_CONT "\n"); if (!cpumask_equal(sched_domain_span(sd), groupmask)) printk(KERN_ERR "ERROR: groups don't span domain->span\n"); if (sd->parent && !cpumask_subset(groupmask, sched_domain_span(sd->parent))) printk(KERN_ERR "ERROR: parent span is not a superset " "of domain->span\n"); return 0; } Commit Message: Merge branch 'stacking-fixes' (vfs stacking fixes from Jann) Merge filesystem stacking fixes from Jann Horn. * emailed patches from Jann Horn <jannh@google.com>: sched: panic on corrupted stack end ecryptfs: forbid opening files without mmap handler proc: prevent stacking filesystems on top CWE ID: CWE-119
0
8,855
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: exsltDateDurationFunction (xmlXPathParserContextPtr ctxt, int nargs) { xmlChar *ret; xmlChar *number = NULL; if ((nargs < 0) || (nargs > 1)) { xmlXPathSetArityError(ctxt); return; } if (nargs == 1) { number = xmlXPathPopString(ctxt); if (xmlXPathCheckError(ctxt)) { xmlXPathSetTypeError(ctxt); return; } } ret = exsltDateDuration(number); if (number != NULL) xmlFree(number); if (ret == NULL) xmlXPathReturnEmptyString(ctxt); else xmlXPathReturnString(ctxt, ret); } 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
23,328
Analyze the following 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 IRCView::updateAppearance() { if (Preferences::self()->customTextFont()) setFont(Preferences::self()->textFont()); else setFont(KGlobalSettings::generalFont()); setVerticalScrollBarPolicy(Preferences::self()->showIRCViewScrollBar() ? Qt::ScrollBarAlwaysOn : Qt::ScrollBarAlwaysOff); if (Preferences::self()->showBackgroundImage()) { KUrl url = Preferences::self()->backgroundImage(); if (url.hasPath()) { viewport()->setStyleSheet("QWidget { background-image: url("+url.path()+"); background-attachment:fixed; }"); return; } } if (!viewport()->styleSheet().isEmpty()) viewport()->setStyleSheet(""); QPalette p; p.setColor(QPalette::Base, Preferences::self()->color(Preferences::TextViewBackground)); viewport()->setPalette(p); } Commit Message: CWE ID:
0
2,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: void FileAPIMessageFilter::OnCreateSnapshotFile( int request_id, const GURL& blob_url, const GURL& path) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); FileSystemURL url(path); base::Callback<void(const FilePath&)> register_file_callback = base::Bind(&FileAPIMessageFilter::RegisterFileAsBlob, this, blob_url, url.path()); FileSystemOperation* operation = GetNewOperation(url, request_id); if (!operation) return; operation->CreateSnapshotFile( url, base::Bind(&FileAPIMessageFilter::DidCreateSnapshot, this, request_id, register_file_callback)); } Commit Message: File permission fix: now we selectively grant read permission for Sandboxed files We also need to check the read permission and call GrantReadFile() for sandboxed files for CreateSnapshotFile(). BUG=162114 TEST=manual Review URL: https://codereview.chromium.org/11280231 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170181 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-264
1
21,854
Analyze the following 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 test_path_access(const char *program, int mode) { char *envpath, *p, *colon; int ret, our_errno = 1500; /* outside errno range */ if (program[0] == '/' || !(envpath = getenv("PATH"))) return access(program, mode); if (!(envpath = strdup(envpath))) { errno = ENOMEM; return -1; } for (p = envpath; p; p = colon + 1) { char *path; colon = strchr(p, ':'); if (colon) *colon = 0; asprintf(&path, "%s/%s", p, program); ret = access(path, mode); free(path); if (!ret) break; if (ret < 0) { if (errno == ENOENT) continue; if (our_errno > errno) our_errno = errno; } if (!colon) break; } free(envpath); if (!ret) errno = 0; else errno = our_errno; return ret; } Commit Message: halfway revert hack/configure changes - switch order of daemon_init/drop_privileges CWE ID: CWE-665
0
4,929
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static inline void tcp_set_rto(struct sock *sk) { const struct tcp_sock *tp = tcp_sk(sk); /* Old crap is replaced with new one. 8) * * More seriously: * 1. If rtt variance happened to be less 50msec, it is hallucination. * It cannot be less due to utterly erratic ACK generation made * at least by solaris and freebsd. "Erratic ACKs" has _nothing_ * to do with delayed acks, because at cwnd>2 true delack timeout * is invisible. Actually, Linux-2.4 also generates erratic * ACKs in some circumstances. */ inet_csk(sk)->icsk_rto = __tcp_set_rto(tp); /* 2. Fixups made earlier cannot be right. * If we do not estimate RTO correctly without them, * all the algo is pure shit and should be replaced * with correct one. It is exactly, which we pretend to do. */ /* NOTE: clamping at TCP_RTO_MIN is not required, current algo * guarantees that rto is higher. */ tcp_bound_rto(sk); } Commit Message: tcp: drop SYN+FIN messages Denys Fedoryshchenko reported that SYN+FIN attacks were bringing his linux machines to their limits. Dont call conn_request() if the TCP flags includes SYN flag Reported-by: Denys Fedoryshchenko <denys@visp.net.lb> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-399
0
9,503
Analyze the following 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 GetBookmarkDragOperation(content::BrowserContext* browser_context, const BookmarkNode* node) { PrefService* prefs = user_prefs::UserPrefs::Get(browser_context); BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(browser_context); int move = ui::DragDropTypes::DRAG_MOVE; if (!prefs->GetBoolean(bookmarks::prefs::kEditBookmarksEnabled) || !model->client()->CanBeEditedByUser(node)) { move = ui::DragDropTypes::DRAG_NONE; } if (node->is_url()) return ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK | move; return ui::DragDropTypes::DRAG_COPY | move; } Commit Message: Prevent interpretating userinfo as url scheme when editing bookmarks Chrome's Edit Bookmark dialog formats urls for display such that a url of http://javascript:scripttext@host.com is later converted to a javascript url scheme, allowing persistence of a script injection attack within the user's bookmarks. This fix prevents such misinterpretations by always showing the scheme when a userinfo component is present within the url. BUG=639126 Review-Url: https://codereview.chromium.org/2368593002 Cr-Commit-Position: refs/heads/master@{#422467} CWE ID: CWE-79
0
9,120
Analyze the following 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 insert_header(struct ctl_dir *dir, struct ctl_table_header *header) { struct ctl_table *entry; int err; /* Is this a permanently empty directory? */ if (is_empty_dir(&dir->header)) return -EROFS; /* Am I creating a permanently empty directory? */ if (header->ctl_table == sysctl_mount_point) { if (!RB_EMPTY_ROOT(&dir->root)) return -EINVAL; set_empty_dir(dir); } dir->header.nreg++; header->parent = dir; err = insert_links(header); if (err) goto fail_links; for (entry = header->ctl_table; entry->procname; entry++) { err = insert_entry(header, entry); if (err) goto fail; } return 0; fail: erase_header(header); put_links(header); fail_links: if (header->ctl_table == sysctl_mount_point) clear_empty_dir(dir); header->parent = NULL; drop_sysctl_table(&dir->header); return err; } Commit Message: sysctl: Drop reference added by grab_header in proc_sys_readdir Fixes CVE-2016-9191, proc_sys_readdir doesn't drop reference added by grab_header when return from !dir_emit_dots path. It can cause any path called unregister_sysctl_table will wait forever. The calltrace of CVE-2016-9191: [ 5535.960522] Call Trace: [ 5535.963265] [<ffffffff817cdaaf>] schedule+0x3f/0xa0 [ 5535.968817] [<ffffffff817d33fb>] schedule_timeout+0x3db/0x6f0 [ 5535.975346] [<ffffffff817cf055>] ? wait_for_completion+0x45/0x130 [ 5535.982256] [<ffffffff817cf0d3>] wait_for_completion+0xc3/0x130 [ 5535.988972] [<ffffffff810d1fd0>] ? wake_up_q+0x80/0x80 [ 5535.994804] [<ffffffff8130de64>] drop_sysctl_table+0xc4/0xe0 [ 5536.001227] [<ffffffff8130de17>] drop_sysctl_table+0x77/0xe0 [ 5536.007648] [<ffffffff8130decd>] unregister_sysctl_table+0x4d/0xa0 [ 5536.014654] [<ffffffff8130deff>] unregister_sysctl_table+0x7f/0xa0 [ 5536.021657] [<ffffffff810f57f5>] unregister_sched_domain_sysctl+0x15/0x40 [ 5536.029344] [<ffffffff810d7704>] partition_sched_domains+0x44/0x450 [ 5536.036447] [<ffffffff817d0761>] ? __mutex_unlock_slowpath+0x111/0x1f0 [ 5536.043844] [<ffffffff81167684>] rebuild_sched_domains_locked+0x64/0xb0 [ 5536.051336] [<ffffffff8116789d>] update_flag+0x11d/0x210 [ 5536.057373] [<ffffffff817cf61f>] ? mutex_lock_nested+0x2df/0x450 [ 5536.064186] [<ffffffff81167acb>] ? cpuset_css_offline+0x1b/0x60 [ 5536.070899] [<ffffffff810fce3d>] ? trace_hardirqs_on+0xd/0x10 [ 5536.077420] [<ffffffff817cf61f>] ? mutex_lock_nested+0x2df/0x450 [ 5536.084234] [<ffffffff8115a9f5>] ? css_killed_work_fn+0x25/0x220 [ 5536.091049] [<ffffffff81167ae5>] cpuset_css_offline+0x35/0x60 [ 5536.097571] [<ffffffff8115aa2c>] css_killed_work_fn+0x5c/0x220 [ 5536.104207] [<ffffffff810bc83f>] process_one_work+0x1df/0x710 [ 5536.110736] [<ffffffff810bc7c0>] ? process_one_work+0x160/0x710 [ 5536.117461] [<ffffffff810bce9b>] worker_thread+0x12b/0x4a0 [ 5536.123697] [<ffffffff810bcd70>] ? process_one_work+0x710/0x710 [ 5536.130426] [<ffffffff810c3f7e>] kthread+0xfe/0x120 [ 5536.135991] [<ffffffff817d4baf>] ret_from_fork+0x1f/0x40 [ 5536.142041] [<ffffffff810c3e80>] ? kthread_create_on_node+0x230/0x230 One cgroup maintainer mentioned that "cgroup is trying to offline a cpuset css, which takes place under cgroup_mutex. The offlining ends up trying to drain active usages of a sysctl table which apprently is not happening." The real reason is that proc_sys_readdir doesn't drop reference added by grab_header when return from !dir_emit_dots path. So this cpuset offline path will wait here forever. See here for details: http://www.openwall.com/lists/oss-security/2016/11/04/13 Fixes: f0c3b5093add ("[readdir] convert procfs") Cc: stable@vger.kernel.org Reported-by: CAI Qian <caiqian@redhat.com> Tested-by: Yang Shukui <yangshukui@huawei.com> Signed-off-by: Zhou Chengming <zhouchengming1@huawei.com> Acked-by: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> CWE ID: CWE-20
0
23,215