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 void methodWithNonCallbackArgAndCallbackInterfaceArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "methodWithNonCallbackArgAndCallbackInterfaceArg", "TestObject", info.Holder(), info.GetIsolate()); if (UNLIKELY(info.Length() < 2)) { exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length())); exceptionState.throwIfNeeded(); return; } TestObject* imp = V8TestObject::toNative(info.Holder()); V8TRYCATCH_EXCEPTION_VOID(int, nonCallback, toInt32(info[0], exceptionState), exceptionState); if (info.Length() <= 1 || !info[1]->IsFunction()) { exceptionState.throwTypeError("The callback provided as parameter 2 is not a function."); exceptionState.throwIfNeeded(); return; } OwnPtr<TestCallbackInterface> callbackInterface = V8TestCallbackInterface::create(v8::Handle<v8::Function>::Cast(info[1]), currentExecutionContext(info.GetIsolate())); imp->methodWithNonCallbackArgAndCallbackInterfaceArg(nonCallback, callbackInterface.release()); } 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
18,556
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void SetShelfAutoHideBehaviorPref(int64_t display_id, ShelfAutoHideBehavior behavior) { PrefService* prefs = Shell::Get()->session_controller()->GetLastActiveUserPrefService(); if (!prefs) return; SetShelfAutoHideBehaviorPref(prefs, display_id, behavior); } Commit Message: cros: Enable some tests in //ash/wm in ash_unittests --mash For the ones that fail, disable them via filter file instead of in the code, per our disablement policy. Bug: 698085, 695556, 698878, 698888, 698093, 698894 Test: ash_unittests --mash Change-Id: Ic145ab6a95508968d6884d14fac2a3ca08888d26 Reviewed-on: https://chromium-review.googlesource.com/752423 Commit-Queue: James Cook <jamescook@chromium.org> Reviewed-by: Steven Bennetts <stevenjb@chromium.org> Cr-Commit-Position: refs/heads/master@{#513836} CWE ID: CWE-119
0
9,281
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static unsigned hub_is_wusb(struct usb_hub *hub) { struct usb_hcd *hcd; if (hub->hdev->parent != NULL) /* not a root hub? */ return 0; hcd = container_of(hub->hdev->bus, struct usb_hcd, self); return hcd->wireless; } Commit Message: USB: fix invalid memory access in hub_activate() Commit 8520f38099cc ("USB: change hub initialization sleeps to delayed_work") changed the hub_activate() routine to make part of it run in a workqueue. However, the commit failed to take a reference to the usb_hub structure or to lock the hub interface while doing so. As a result, if a hub is plugged in and quickly unplugged before the work routine can run, the routine will try to access memory that has been deallocated. Or, if the hub is unplugged while the routine is running, the memory may be deallocated while it is in active use. This patch fixes the problem by taking a reference to the usb_hub at the start of hub_activate() and releasing it at the end (when the work is finished), and by locking the hub interface while the work routine is running. It also adds a check at the start of the routine to see if the hub has already been disconnected, in which nothing should be done. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-by: Alexandru Cornea <alexandru.cornea@intel.com> Tested-by: Alexandru Cornea <alexandru.cornea@intel.com> Fixes: 8520f38099cc ("USB: change hub initialization sleeps to delayed_work") CC: <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> CWE ID:
0
17,239
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: SYSCALL_DEFINE2(umount, char __user *, name, int, flags) { struct path path; struct mount *mnt; int retval; int lookup_flags = 0; if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW)) return -EINVAL; if (!may_mount()) return -EPERM; if (!(flags & UMOUNT_NOFOLLOW)) lookup_flags |= LOOKUP_FOLLOW; retval = user_path_mountpoint_at(AT_FDCWD, name, lookup_flags, &path); if (retval) goto out; mnt = real_mount(path.mnt); retval = -EINVAL; if (path.dentry != path.mnt->mnt_root) goto dput_and_out; if (!check_mnt(mnt)) goto dput_and_out; if (mnt->mnt.mnt_flags & MNT_LOCKED) goto dput_and_out; retval = -EPERM; if (flags & MNT_FORCE && !capable(CAP_SYS_ADMIN)) goto dput_and_out; retval = do_umount(mnt, flags); dput_and_out: /* we mustn't call path_put() as that would clear mnt_expiry_mark */ dput(path.dentry); mntput_no_expire(mnt); out: return retval; } Commit Message: mnt: Add a per mount namespace limit on the number of mounts CAI Qian <caiqian@redhat.com> pointed out that the semantics of shared subtrees make it possible to create an exponentially increasing number of mounts in a mount namespace. mkdir /tmp/1 /tmp/2 mount --make-rshared / for i in $(seq 1 20) ; do mount --bind /tmp/1 /tmp/2 ; done Will create create 2^20 or 1048576 mounts, which is a practical problem as some people have managed to hit this by accident. As such CVE-2016-6213 was assigned. Ian Kent <raven@themaw.net> described the situation for autofs users as follows: > The number of mounts for direct mount maps is usually not very large because of > the way they are implemented, large direct mount maps can have performance > problems. There can be anywhere from a few (likely case a few hundred) to less > than 10000, plus mounts that have been triggered and not yet expired. > > Indirect mounts have one autofs mount at the root plus the number of mounts that > have been triggered and not yet expired. > > The number of autofs indirect map entries can range from a few to the common > case of several thousand and in rare cases up to between 30000 and 50000. I've > not heard of people with maps larger than 50000 entries. > > The larger the number of map entries the greater the possibility for a large > number of active mounts so it's not hard to expect cases of a 1000 or somewhat > more active mounts. So I am setting the default number of mounts allowed per mount namespace at 100,000. This is more than enough for any use case I know of, but small enough to quickly stop an exponential increase in mounts. Which should be perfect to catch misconfigurations and malfunctioning programs. For anyone who needs a higher limit this can be changed by writing to the new /proc/sys/fs/mount-max sysctl. Tested-by: CAI Qian <caiqian@redhat.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> CWE ID: CWE-400
0
27,630
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ShellWindowGeometryCache* TestExtensionSystem::shell_window_geometry_cache() { return shell_window_geometry_cache_.get(); } Commit Message: Check prefs before allowing extension file access in the permissions API. R=mpcomplete@chromium.org BUG=169632 Review URL: https://chromiumcodereview.appspot.com/11884008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176853 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-264
0
13,768
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void usage() { fputs("Usage: -b [<tid>]\n" " -b dump backtrace to console, otherwise dump full tombstone file\n" "\n" "If tid specified, sends a request to debuggerd to dump that task.\n" "Otherwise, starts the debuggerd server.\n", stderr); } Commit Message: debuggerd: verify that traced threads belong to the right process. Fix two races in debuggerd's PTRACE_ATTACH logic: 1. The target thread in a crash dump request could exit between the /proc/<pid>/task/<tid> check and the PTRACE_ATTACH. 2. Sibling threads could exit between listing /proc/<pid>/task and the PTRACE_ATTACH. Bug: http://b/29555636 Change-Id: I4dfe1ea30e2c211d2389321bd66e3684dd757591 CWE ID: CWE-264
0
10,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: smp_fetch_url_port(const struct arg *args, struct sample *smp, const char *kw, void *private) { struct http_txn *txn; struct sockaddr_storage addr; CHECK_HTTP_MESSAGE_FIRST(); txn = smp->strm->txn; url2sa(txn->req.chn->buf->p + txn->req.sl.rq.u, txn->req.sl.rq.u_l, &addr, NULL); if (((struct sockaddr_in *)&addr)->sin_family != AF_INET) return 0; smp->data.type = SMP_T_SINT; smp->data.u.sint = ntohs(((struct sockaddr_in *)&addr)->sin_port); smp->flags = 0; return 1; } Commit Message: CWE ID: CWE-200
0
24,776
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: UINT CSoundFile::GetSaveFormats() const { UINT n = 0; if ((!m_nSamples) || (!m_nChannels) || (m_nType == MOD_TYPE_NONE)) return 0; switch(m_nType) { case MOD_TYPE_MOD: n = MOD_TYPE_MOD; case MOD_TYPE_S3M: n = MOD_TYPE_S3M; } n |= MOD_TYPE_XM | MOD_TYPE_IT; if (!m_nInstruments) { if (m_nSamples < 32) n |= MOD_TYPE_MOD; n |= MOD_TYPE_S3M; } return n; } Commit Message: CWE ID:
0
21,537
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static bool ExecuteScrollPageForward(LocalFrame& frame, Event*, EditorCommandSource, const String&) { return frame.GetEventHandler().BubblingScroll(kScrollBlockDirectionForward, kScrollByPage); } Commit Message: Move Editor::Transpose() out of Editor class This patch moves |Editor::Transpose()| out of |Editor| class as preparation of expanding it into |ExecutTranspose()| in "EditorCommand.cpp" to make |Editor| class simpler for improving code health. Following patch will expand |Transpose()| into |ExecutTranspose()|. Bug: 672405 Change-Id: Icde253623f31813d2b4517c4da7d4798bd5fadf6 Reviewed-on: https://chromium-review.googlesource.com/583880 Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org> Commit-Queue: Yoshifumi Inoue <yosin@chromium.org> Cr-Commit-Position: refs/heads/master@{#489518} CWE ID:
0
1,694
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int gx_ttfReader__Tell(ttfReader *self) { gx_ttfReader *r = (gx_ttfReader *)self; return r->pos; } Commit Message: CWE ID: CWE-125
0
10,959
Analyze the following 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(pg_port) { php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_PORT); } Commit Message: CWE ID:
0
14,852
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: IW_IMPL(double) iw_convert_sample_to_linear(double v, const struct iw_csdescr *csdescr) { return (double)x_to_linear_sample(v,csdescr); } Commit Message: Fixed a bug that could cause invalid memory to be accessed The bug could happen when transparency is removed from an image. Also fixed a semi-related BMP error handling logic bug. Fixes issue #21 CWE ID: CWE-787
0
3,063
Analyze the following 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 qeth_init_tokens(struct qeth_card *card) { card->token.issuer_rm_w = 0x00010103UL; card->token.cm_filter_w = 0x00010108UL; card->token.cm_connection_w = 0x0001010aUL; card->token.ulp_filter_w = 0x0001010bUL; card->token.ulp_connection_w = 0x0001010dUL; } Commit Message: qeth: avoid buffer overflow in snmp ioctl Check user-defined length in snmp ioctl request and allow request only if it fits into a qeth command buffer. Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com> Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com> Reviewed-by: Heiko Carstens <heicars2@linux.vnet.ibm.com> Reported-by: Nico Golde <nico@ngolde.de> Reported-by: Fabian Yamaguchi <fabs@goesec.de> Cc: <stable@vger.kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-119
0
24,960
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: const viz::FrameSinkId& RenderWidgetHostImpl::GetFrameSinkId() const { return frame_sink_id_; } Commit Message: Start rendering timer after first navigation Currently the new content rendering timer in the browser process, which clears an old page's contents 4 seconds after a navigation if the new page doesn't draw in that time, is not set on the first navigation for a top-level frame. This is problematic because content can exist before the first navigation, for instance if it was created by a javascript: URL. This CL removes the code that skips the timer activation on the first navigation. Bug: 844881 Change-Id: I19b3ad1ff62c69ded3a5f7b1c0afde191aaf4584 Reviewed-on: https://chromium-review.googlesource.com/1188589 Reviewed-by: Fady Samuel <fsamuel@chromium.org> Reviewed-by: ccameron <ccameron@chromium.org> Commit-Queue: Ken Buchanan <kenrb@chromium.org> Cr-Commit-Position: refs/heads/master@{#586913} CWE ID: CWE-20
0
15,620
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int netlink_realloc_groups(struct sock *sk) { struct netlink_sock *nlk = nlk_sk(sk); unsigned int groups; unsigned long *new_groups; int err = 0; netlink_table_grab(); groups = nl_table[sk->sk_protocol].groups; if (!nl_table[sk->sk_protocol].registered) { err = -ENOENT; goto out_unlock; } if (nlk->ngroups >= groups) goto out_unlock; new_groups = krealloc(nlk->groups, NLGRPSZ(groups), GFP_ATOMIC); if (new_groups == NULL) { err = -ENOMEM; goto out_unlock; } memset((char *)new_groups + NLGRPSZ(nlk->ngroups), 0, NLGRPSZ(groups) - NLGRPSZ(nlk->ngroups)); nlk->groups = new_groups; nlk->ngroups = groups; out_unlock: netlink_table_ungrab(); return err; } Commit Message: af_netlink: force credentials passing [CVE-2012-3520] Pablo Neira Ayuso discovered that avahi and potentially NetworkManager accept spoofed Netlink messages because of a kernel bug. The kernel passes all-zero SCM_CREDENTIALS ancillary data to the receiver if the sender did not provide such data, instead of not including any such data at all or including the correct data from the peer (as it is the case with AF_UNIX). This bug was introduced in commit 16e572626961 (af_unix: dont send SCM_CREDENTIALS by default) This patch forces passing credentials for netlink, as before the regression. Another fix would be to not add SCM_CREDENTIALS in netlink messages if not provided by the sender, but it might break some programs. With help from Florian Weimer & Petr Matousek This issue is designated as CVE-2012-3520 Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Petr Matousek <pmatouse@redhat.com> Cc: Florian Weimer <fweimer@redhat.com> Cc: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-287
0
13,121
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool GLES2DecoderImpl::CreateShaderHelper(GLenum type, GLuint client_id) { if (GetShaderInfo(client_id)) { return false; } GLuint service_id = glCreateShader(type); if (service_id != 0) { CreateShaderInfo(client_id, service_id, type); } return true; } Commit Message: Revert "Revert 100494 - Fix bug in SimulateAttrib0.""" TEST=none BUG=95625 TBR=apatrick@chromium.org Review URL: http://codereview.chromium.org/7796016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100507 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-119
0
16,935
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: server_httperror_cmp(const void *a, const void *b) { const struct http_error *ea = a; const struct http_error *eb = b; return (ea->error_code - eb->error_code); } Commit Message: Reimplement httpd's support for byte ranges. The previous implementation loaded all the output into a single output buffer and used its size to determine the Content-Length of the body. The new implementation calculates the body length first and writes the individual ranges in an async way using the bufferevent mechanism. This prevents httpd from using too much memory and applies the watermark and throttling mechanisms to range requests. Problem reported by Pierre Kim (pierre.kim.sec at gmail.com) OK benno@ sunil@ CWE ID: CWE-770
0
1,321
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: device_job_cancel (Device *device, DBusGMethodInvocation *context) { uid_t uid; const gchar *action_id; if (!device->priv->job_in_progress) { throw_error (context, ERROR_FAILED, "There is no job to cancel"); goto out; } if (!device->priv->job_is_cancellable) { throw_error (context, ERROR_FAILED, "Job cannot be cancelled"); goto out; } daemon_local_get_uid (device->priv->daemon, &uid, context); action_id = NULL; if (device->priv->job_initiated_by_uid != uid) { action_id = "org.freedesktop.udisks.cancel-job-others"; } daemon_local_check_auth (device->priv->daemon, device, action_id, "JobCancel", TRUE, device_job_cancel_authorized_cb, context, 0); out: return TRUE; } Commit Message: CWE ID: CWE-200
0
24,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: bool RenderLayerScrollableArea::userInputScrollable(ScrollbarOrientation orientation) const { if (box().isIntristicallyScrollable(orientation)) return true; EOverflow overflowStyle = (orientation == HorizontalScrollbar) ? box().style()->overflowX() : box().style()->overflowY(); return (overflowStyle == OSCROLL || overflowStyle == OAUTO || overflowStyle == OOVERLAY); } Commit Message: Defer call to updateWidgetPositions() outside of RenderLayerScrollableArea. updateWidgetPositions() can destroy the render tree, so it should never be called from inside RenderLayerScrollableArea. Leaving it there allows for the potential of use-after-free bugs. BUG=402407 R=vollick@chromium.org Review URL: https://codereview.chromium.org/490473003 git-svn-id: svn://svn.chromium.org/blink/trunk@180681 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-416
0
24,451
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: uint64_t Histogram::name_hash() const { return samples_->id(); } Commit Message: Convert DCHECKs to CHECKs for histogram types When a histogram is looked up by name, there is currently a DCHECK that verifies the type of the stored histogram matches the expected type. A mismatch represents a significant problem because the returned HistogramBase is cast to a Histogram in ValidateRangeChecksum, potentially causing a crash. This CL converts the DCHECK to a CHECK to prevent the possibility of type confusion in release builds. BUG=651443 R=isherman@chromium.org Review-Url: https://codereview.chromium.org/2381893003 Cr-Commit-Position: refs/heads/master@{#421929} CWE ID: CWE-476
0
29,614
Analyze the following 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 JSTestSerializedScriptValueInterface::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(object); ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); return getStaticValueDescriptor<JSTestSerializedScriptValueInterface, Base>(exec, &JSTestSerializedScriptValueInterfaceTable, thisObject, propertyName, descriptor); } Commit Message: [JSC] Implement a helper method createNotEnoughArgumentsError() https://bugs.webkit.org/show_bug.cgi?id=85102 Reviewed by Geoffrey Garen. In bug 84787, kbr@ requested to avoid hard-coding createTypeError(exec, "Not enough arguments") here and there. This patch implements createNotEnoughArgumentsError(exec) and uses it in JSC bindings. c.f. a corresponding bug for V8 bindings is bug 85097. Source/JavaScriptCore: * runtime/Error.cpp: (JSC::createNotEnoughArgumentsError): (JSC): * runtime/Error.h: (JSC): Source/WebCore: Test: bindings/scripts/test/TestObj.idl * bindings/scripts/CodeGeneratorJS.pm: Modified as described above. (GenerateArgumentsCountCheck): * bindings/js/JSDataViewCustom.cpp: Ditto. (WebCore::getDataViewMember): (WebCore::setDataViewMember): * bindings/js/JSDeprecatedPeerConnectionCustom.cpp: (WebCore::JSDeprecatedPeerConnectionConstructor::constructJSDeprecatedPeerConnection): * bindings/js/JSDirectoryEntryCustom.cpp: (WebCore::JSDirectoryEntry::getFile): (WebCore::JSDirectoryEntry::getDirectory): * bindings/js/JSSharedWorkerCustom.cpp: (WebCore::JSSharedWorkerConstructor::constructJSSharedWorker): * bindings/js/JSWebKitMutationObserverCustom.cpp: (WebCore::JSWebKitMutationObserverConstructor::constructJSWebKitMutationObserver): (WebCore::JSWebKitMutationObserver::observe): * bindings/js/JSWorkerCustom.cpp: (WebCore::JSWorkerConstructor::constructJSWorker): * bindings/scripts/test/JS/JSFloat64Array.cpp: Updated run-bindings-tests. (WebCore::jsFloat64ArrayPrototypeFunctionFoo): * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: (WebCore::jsTestActiveDOMObjectPrototypeFunctionExcitingFunction): (WebCore::jsTestActiveDOMObjectPrototypeFunctionPostMessage): * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp: (WebCore::jsTestCustomNamedGetterPrototypeFunctionAnotherFunction): * bindings/scripts/test/JS/JSTestEventTarget.cpp: (WebCore::jsTestEventTargetPrototypeFunctionItem): (WebCore::jsTestEventTargetPrototypeFunctionAddEventListener): (WebCore::jsTestEventTargetPrototypeFunctionRemoveEventListener): (WebCore::jsTestEventTargetPrototypeFunctionDispatchEvent): * bindings/scripts/test/JS/JSTestInterface.cpp: (WebCore::JSTestInterfaceConstructor::constructJSTestInterface): (WebCore::jsTestInterfacePrototypeFunctionSupplementalMethod2): * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp: (WebCore::jsTestMediaQueryListListenerPrototypeFunctionMethod): * bindings/scripts/test/JS/JSTestNamedConstructor.cpp: (WebCore::JSTestNamedConstructorNamedConstructor::constructJSTestNamedConstructor): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::JSTestObjConstructor::constructJSTestObj): (WebCore::jsTestObjPrototypeFunctionVoidMethodWithArgs): (WebCore::jsTestObjPrototypeFunctionIntMethodWithArgs): (WebCore::jsTestObjPrototypeFunctionObjMethodWithArgs): (WebCore::jsTestObjPrototypeFunctionMethodWithSequenceArg): (WebCore::jsTestObjPrototypeFunctionMethodReturningSequence): (WebCore::jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows): (WebCore::jsTestObjPrototypeFunctionSerializedValue): (WebCore::jsTestObjPrototypeFunctionIdbKey): (WebCore::jsTestObjPrototypeFunctionOptionsObject): (WebCore::jsTestObjPrototypeFunctionAddEventListener): (WebCore::jsTestObjPrototypeFunctionRemoveEventListener): (WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg): (WebCore::jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs): (WebCore::jsTestObjPrototypeFunctionMethodWithCallbackArg): (WebCore::jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod1): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod2): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod3): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod4): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod5): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod6): (WebCore::jsTestObjPrototypeFunctionOverloadedMethod7): (WebCore::jsTestObjConstructorFunctionClassMethod2): (WebCore::jsTestObjConstructorFunctionOverloadedMethod11): (WebCore::jsTestObjConstructorFunctionOverloadedMethod12): (WebCore::jsTestObjPrototypeFunctionMethodWithUnsignedLongArray): (WebCore::jsTestObjPrototypeFunctionConvert1): (WebCore::jsTestObjPrototypeFunctionConvert2): (WebCore::jsTestObjPrototypeFunctionConvert3): (WebCore::jsTestObjPrototypeFunctionConvert4): (WebCore::jsTestObjPrototypeFunctionConvert5): (WebCore::jsTestObjPrototypeFunctionStrictFunction): * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp: (WebCore::JSTestSerializedScriptValueInterfaceConstructor::constructJSTestSerializedScriptValueInterface): (WebCore::jsTestSerializedScriptValueInterfacePrototypeFunctionAcceptTransferList): git-svn-id: svn://svn.chromium.org/blink/trunk@115536 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-20
0
1,014
Analyze the following 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 LocalSiteCharacteristicsDataImpl::OnInitCallback( base::Optional<SiteCharacteristicsProto> db_site_characteristics) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (db_site_characteristics) { auto this_features = GetAllFeaturesFromProto(&site_characteristics_); auto db_features = GetAllFeaturesFromProto(&db_site_characteristics.value()); auto this_features_iter = this_features.begin(); auto db_features_iter = db_features.begin(); for (; this_features_iter != this_features.end() && db_features_iter != db_features.end(); ++this_features_iter, ++db_features_iter) { if (!(*this_features_iter)->has_use_timestamp()) { if ((*db_features_iter)->has_use_timestamp()) { (*this_features_iter) ->set_use_timestamp((*db_features_iter)->use_timestamp()); (*this_features_iter) ->set_observation_duration( LocalSiteCharacteristicsDataImpl:: TimeDeltaToInternalRepresentation(base::TimeDelta())); } else { if (!(*this_features_iter)->has_observation_duration()) { (*this_features_iter) ->set_observation_duration( LocalSiteCharacteristicsDataImpl:: TimeDeltaToInternalRepresentation(base::TimeDelta())); } IncrementFeatureObservationDuration( (*this_features_iter), InternalRepresentationToTimeDelta( (*db_features_iter)->observation_duration())); } } } if (!site_characteristics_.has_last_loaded()) { site_characteristics_.set_last_loaded( db_site_characteristics->last_loaded()); } } else { InitWithDefaultValues(true /* only_init_uninitialized_fields */); } safe_to_write_to_db_ = true; DCHECK(site_characteristics_.IsInitialized()); } 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:
0
18,033
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void WebContentsImpl::SetFocusedFrame(FrameTreeNode* node, SiteInstance* source) { SetAsFocusedWebContentsIfNecessary(); frame_tree_.SetFocusedFrame(node, source); WebContentsImpl* inner_contents = node_.GetInnerWebContentsInFrame(node); WebContentsImpl* contents_to_focus = inner_contents ? inner_contents : this; contents_to_focus->SetAsFocusedWebContentsIfNecessary(); } Commit Message: If a page shows a popup, end fullscreen. This was implemented in Blink r159834, but it is susceptible to a popup/fullscreen race. This CL reverts that implementation and re-implements it in WebContents. BUG=752003 TEST=WebContentsImplBrowserTest.PopupsFromJavaScriptEndFullscreen Change-Id: Ia345cdeda273693c3231ad8f486bebfc3d83927f Reviewed-on: https://chromium-review.googlesource.com/606987 Commit-Queue: Avi Drissman <avi@chromium.org> Reviewed-by: Charlie Reis <creis@chromium.org> Reviewed-by: Philip Jägenstedt <foolip@chromium.org> Cr-Commit-Position: refs/heads/master@{#498171} CWE ID: CWE-20
0
3,173
Analyze the following 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 icmpv6_rcv(struct sk_buff *skb) { struct net_device *dev = skb->dev; struct inet6_dev *idev = __in6_dev_get(dev); const struct in6_addr *saddr, *daddr; struct icmp6hdr *hdr; u8 type; bool success = false; if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) { struct sec_path *sp = skb_sec_path(skb); int nh; if (!(sp && sp->xvec[sp->len - 1]->props.flags & XFRM_STATE_ICMP)) goto drop_no_count; if (!pskb_may_pull(skb, sizeof(*hdr) + sizeof(struct ipv6hdr))) goto drop_no_count; nh = skb_network_offset(skb); skb_set_network_header(skb, sizeof(*hdr)); if (!xfrm6_policy_check_reverse(NULL, XFRM_POLICY_IN, skb)) goto drop_no_count; skb_set_network_header(skb, nh); } __ICMP6_INC_STATS(dev_net(dev), idev, ICMP6_MIB_INMSGS); saddr = &ipv6_hdr(skb)->saddr; daddr = &ipv6_hdr(skb)->daddr; if (skb_checksum_validate(skb, IPPROTO_ICMPV6, ip6_compute_pseudo)) { net_dbg_ratelimited("ICMPv6 checksum failed [%pI6c > %pI6c]\n", saddr, daddr); goto csum_error; } if (!pskb_pull(skb, sizeof(*hdr))) goto discard_it; hdr = icmp6_hdr(skb); type = hdr->icmp6_type; ICMP6MSGIN_INC_STATS(dev_net(dev), idev, type); switch (type) { case ICMPV6_ECHO_REQUEST: icmpv6_echo_reply(skb); break; case ICMPV6_ECHO_REPLY: success = ping_rcv(skb); break; case ICMPV6_PKT_TOOBIG: /* BUGGG_FUTURE: if packet contains rthdr, we cannot update standard destination cache. Seems, only "advanced" destination cache will allow to solve this problem --ANK (980726) */ if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) goto discard_it; hdr = icmp6_hdr(skb); /* * Drop through to notify */ case ICMPV6_DEST_UNREACH: case ICMPV6_TIME_EXCEED: case ICMPV6_PARAMPROB: icmpv6_notify(skb, type, hdr->icmp6_code, hdr->icmp6_mtu); break; case NDISC_ROUTER_SOLICITATION: case NDISC_ROUTER_ADVERTISEMENT: case NDISC_NEIGHBOUR_SOLICITATION: case NDISC_NEIGHBOUR_ADVERTISEMENT: case NDISC_REDIRECT: ndisc_rcv(skb); break; case ICMPV6_MGM_QUERY: igmp6_event_query(skb); break; case ICMPV6_MGM_REPORT: igmp6_event_report(skb); break; case ICMPV6_MGM_REDUCTION: case ICMPV6_NI_QUERY: case ICMPV6_NI_REPLY: case ICMPV6_MLD2_REPORT: case ICMPV6_DHAAD_REQUEST: case ICMPV6_DHAAD_REPLY: case ICMPV6_MOBILE_PREFIX_SOL: case ICMPV6_MOBILE_PREFIX_ADV: break; default: /* informational */ if (type & ICMPV6_INFOMSG_MASK) break; net_dbg_ratelimited("icmpv6: msg of unknown type [%pI6c > %pI6c]\n", saddr, daddr); /* * error of unknown type. * must pass to upper level */ icmpv6_notify(skb, type, hdr->icmp6_code, hdr->icmp6_mtu); } /* until the v6 path can be better sorted assume failure and * preserve the status quo behaviour for the rest of the paths to here */ if (success) consume_skb(skb); else kfree_skb(skb); return 0; csum_error: __ICMP6_INC_STATS(dev_net(dev), idev, ICMP6_MIB_CSUMERRORS); discard_it: __ICMP6_INC_STATS(dev_net(dev), idev, ICMP6_MIB_INERRORS); drop_no_count: kfree_skb(skb); return 0; } Commit Message: net: handle no dst on skb in icmp6_send Andrey reported the following while fuzzing the kernel with syzkaller: kasan: CONFIG_KASAN_INLINE enabled kasan: GPF could be caused by NULL-ptr deref or user memory access general protection fault: 0000 [#1] SMP KASAN Modules linked in: CPU: 0 PID: 3859 Comm: a.out Not tainted 4.9.0-rc6+ #429 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 task: ffff8800666d4200 task.stack: ffff880067348000 RIP: 0010:[<ffffffff833617ec>] [<ffffffff833617ec>] icmp6_send+0x5fc/0x1e30 net/ipv6/icmp.c:451 RSP: 0018:ffff88006734f2c0 EFLAGS: 00010206 RAX: ffff8800666d4200 RBX: 0000000000000000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: dffffc0000000000 RDI: 0000000000000018 RBP: ffff88006734f630 R08: ffff880064138418 R09: 0000000000000003 R10: dffffc0000000000 R11: 0000000000000005 R12: 0000000000000000 R13: ffffffff84e7e200 R14: ffff880064138484 R15: ffff8800641383c0 FS: 00007fb3887a07c0(0000) GS:ffff88006cc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020000000 CR3: 000000006b040000 CR4: 00000000000006f0 Stack: ffff8800666d4200 ffff8800666d49f8 ffff8800666d4200 ffffffff84c02460 ffff8800666d4a1a 1ffff1000ccdaa2f ffff88006734f498 0000000000000046 ffff88006734f440 ffffffff832f4269 ffff880064ba7456 0000000000000000 Call Trace: [<ffffffff83364ddc>] icmpv6_param_prob+0x2c/0x40 net/ipv6/icmp.c:557 [< inline >] ip6_tlvopt_unknown net/ipv6/exthdrs.c:88 [<ffffffff83394405>] ip6_parse_tlv+0x555/0x670 net/ipv6/exthdrs.c:157 [<ffffffff8339a759>] ipv6_parse_hopopts+0x199/0x460 net/ipv6/exthdrs.c:663 [<ffffffff832ee773>] ipv6_rcv+0xfa3/0x1dc0 net/ipv6/ip6_input.c:191 ... icmp6_send / icmpv6_send is invoked for both rx and tx paths. In both cases the dst->dev should be preferred for determining the L3 domain if the dst has been set on the skb. Fallback to the skb->dev if it has not. This covers the case reported here where icmp6_send is invoked on Rx before the route lookup. Fixes: 5d41ce29e ("net: icmp6_send should use dst dev to determine L3 domain") Reported-by: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-20
0
18,100
Analyze the following 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::SetEmphasis(bool emphasize, const gfx::Range& range) { SkColor color = location_bar_view_->GetColor( emphasize ? OmniboxPart::LOCATION_BAR_TEXT_DEFAULT : OmniboxPart::LOCATION_BAR_TEXT_DIMMED); if (range.IsValid()) ApplyColor(color, range); else SetColor(color); } 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
16,281
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int tipc_nl_sk_dump(struct sk_buff *skb, struct netlink_callback *cb) { int err; struct tipc_sock *tsk; const struct bucket_table *tbl; struct rhash_head *pos; struct net *net = sock_net(skb->sk); struct tipc_net *tn = net_generic(net, tipc_net_id); u32 tbl_id = cb->args[0]; u32 prev_portid = cb->args[1]; rcu_read_lock(); tbl = rht_dereference_rcu((&tn->sk_rht)->tbl, &tn->sk_rht); for (; tbl_id < tbl->size; tbl_id++) { rht_for_each_entry_rcu(tsk, pos, tbl, tbl_id, node) { spin_lock_bh(&tsk->sk.sk_lock.slock); if (prev_portid && prev_portid != tsk->portid) { spin_unlock_bh(&tsk->sk.sk_lock.slock); continue; } err = __tipc_nl_add_sk(skb, cb, tsk); if (err) { prev_portid = tsk->portid; spin_unlock_bh(&tsk->sk.sk_lock.slock); goto out; } prev_portid = 0; spin_unlock_bh(&tsk->sk.sk_lock.slock); } } out: rcu_read_unlock(); cb->args[0] = tbl_id; cb->args[1] = prev_portid; return skb->len; } Commit Message: tipc: check nl sock before parsing nested attributes Make sure the socket for which the user is listing publication exists before parsing the socket netlink attributes. Prior to this patch a call without any socket caused a NULL pointer dereference in tipc_nl_publ_dump(). Tested-and-reported-by: Baozeng Ding <sploving1@gmail.com> Signed-off-by: Richard Alpe <richard.alpe@ericsson.com> Acked-by: Jon Maloy <jon.maloy@ericsson.cm> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID:
0
26,228
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: HIDDetectionView* OobeUI::GetHIDDetectionView() { return hid_detection_view_; } Commit Message: One polymer_config.js to rule them all. R=michaelpg@chromium.org,fukino@chromium.org,mfoltz@chromium.org BUG=425626 Review URL: https://codereview.chromium.org/1224783005 Cr-Commit-Position: refs/heads/master@{#337882} CWE ID: CWE-399
0
13,813
Analyze the following 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 manage_client_side_cookies(struct session *s, struct channel *req) { struct http_txn *txn = &s->txn; int preserve_hdr; int cur_idx, old_idx; char *hdr_beg, *hdr_end, *hdr_next, *del_from; char *prev, *att_beg, *att_end, *equal, *val_beg, *val_end, *next; /* Iterate through the headers, we start with the start line. */ old_idx = 0; hdr_next = req->buf->p + hdr_idx_first_pos(&txn->hdr_idx); while ((cur_idx = txn->hdr_idx.v[old_idx].next)) { struct hdr_idx_elem *cur_hdr; int val; cur_hdr = &txn->hdr_idx.v[cur_idx]; hdr_beg = hdr_next; hdr_end = hdr_beg + cur_hdr->len; hdr_next = hdr_end + cur_hdr->cr + 1; /* We have one full header between hdr_beg and hdr_end, and the * next header starts at hdr_next. We're only interested in * "Cookie:" headers. */ val = http_header_match2(hdr_beg, hdr_end, "Cookie", 6); if (!val) { old_idx = cur_idx; continue; } del_from = NULL; /* nothing to be deleted */ preserve_hdr = 0; /* assume we may kill the whole header */ /* Now look for cookies. Conforming to RFC2109, we have to support * attributes whose name begin with a '$', and associate them with * the right cookie, if we want to delete this cookie. * So there are 3 cases for each cookie read : * 1) it's a special attribute, beginning with a '$' : ignore it. * 2) it's a server id cookie that we *MAY* want to delete : save * some pointers on it (last semi-colon, beginning of cookie...) * 3) it's an application cookie : we *MAY* have to delete a previous * "special" cookie. * At the end of loop, if a "special" cookie remains, we may have to * remove it. If no application cookie persists in the header, we * *MUST* delete it. * * Note: RFC2965 is unclear about the processing of spaces around * the equal sign in the ATTR=VALUE form. A careful inspection of * the RFC explicitly allows spaces before it, and not within the * tokens (attrs or values). An inspection of RFC2109 allows that * too but section 10.1.3 lets one think that spaces may be allowed * after the equal sign too, resulting in some (rare) buggy * implementations trying to do that. So let's do what servers do. * Latest ietf draft forbids spaces all around. Also, earlier RFCs * allowed quoted strings in values, with any possible character * after a backslash, including control chars and delimitors, which * causes parsing to become ambiguous. Browsers also allow spaces * within values even without quotes. * * We have to keep multiple pointers in order to support cookie * removal at the beginning, middle or end of header without * corrupting the header. All of these headers are valid : * * Cookie:NAME1=VALUE1;NAME2=VALUE2;NAME3=VALUE3\r\n * Cookie:NAME1=VALUE1;NAME2_ONLY ;NAME3=VALUE3\r\n * Cookie: NAME1 = VALUE 1 ; NAME2 = VALUE2 ; NAME3 = VALUE3\r\n * | | | | | | | | | * | | | | | | | | hdr_end <--+ * | | | | | | | +--> next * | | | | | | +----> val_end * | | | | | +-----------> val_beg * | | | | +--------------> equal * | | | +----------------> att_end * | | +---------------------> att_beg * | +--------------------------> prev * +--------------------------------> hdr_beg */ for (prev = hdr_beg + 6; prev < hdr_end; prev = next) { /* Iterate through all cookies on this line */ /* find att_beg */ att_beg = prev + 1; while (att_beg < hdr_end && http_is_spht[(unsigned char)*att_beg]) att_beg++; /* find att_end : this is the first character after the last non * space before the equal. It may be equal to hdr_end. */ equal = att_end = att_beg; while (equal < hdr_end) { if (*equal == '=' || *equal == ',' || *equal == ';') break; if (http_is_spht[(unsigned char)*equal++]) continue; att_end = equal; } /* here, <equal> points to '=', a delimitor or the end. <att_end> * is between <att_beg> and <equal>, both may be identical. */ /* look for end of cookie if there is an equal sign */ if (equal < hdr_end && *equal == '=') { /* look for the beginning of the value */ val_beg = equal + 1; while (val_beg < hdr_end && http_is_spht[(unsigned char)*val_beg]) val_beg++; /* find the end of the value, respecting quotes */ next = find_cookie_value_end(val_beg, hdr_end); /* make val_end point to the first white space or delimitor after the value */ val_end = next; while (val_end > val_beg && http_is_spht[(unsigned char)*(val_end - 1)]) val_end--; } else { val_beg = val_end = next = equal; } /* We have nothing to do with attributes beginning with '$'. However, * they will automatically be removed if a header before them is removed, * since they're supposed to be linked together. */ if (*att_beg == '$') continue; /* Ignore cookies with no equal sign */ if (equal == next) { /* This is not our cookie, so we must preserve it. But if we already * scheduled another cookie for removal, we cannot remove the * complete header, but we can remove the previous block itself. */ preserve_hdr = 1; if (del_from != NULL) { int delta = del_hdr_value(req->buf, &del_from, prev); val_end += delta; next += delta; hdr_end += delta; hdr_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->req, delta); prev = del_from; del_from = NULL; } continue; } /* if there are spaces around the equal sign, we need to * strip them otherwise we'll get trouble for cookie captures, * or even for rewrites. Since this happens extremely rarely, * it does not hurt performance. */ if (unlikely(att_end != equal || val_beg > equal + 1)) { int stripped_before = 0; int stripped_after = 0; if (att_end != equal) { stripped_before = buffer_replace2(req->buf, att_end, equal, NULL, 0); equal += stripped_before; val_beg += stripped_before; } if (val_beg > equal + 1) { stripped_after = buffer_replace2(req->buf, equal + 1, val_beg, NULL, 0); val_beg += stripped_after; stripped_before += stripped_after; } val_end += stripped_before; next += stripped_before; hdr_end += stripped_before; hdr_next += stripped_before; cur_hdr->len += stripped_before; http_msg_move_end(&txn->req, stripped_before); } /* now everything is as on the diagram above */ /* First, let's see if we want to capture this cookie. We check * that we don't already have a client side cookie, because we * can only capture one. Also as an optimisation, we ignore * cookies shorter than the declared name. */ if (s->fe->capture_name != NULL && txn->cli_cookie == NULL && (val_end - att_beg >= s->fe->capture_namelen) && memcmp(att_beg, s->fe->capture_name, s->fe->capture_namelen) == 0) { int log_len = val_end - att_beg; if ((txn->cli_cookie = pool_alloc2(pool2_capture)) == NULL) { Alert("HTTP logging : out of memory.\n"); } else { if (log_len > s->fe->capture_len) log_len = s->fe->capture_len; memcpy(txn->cli_cookie, att_beg, log_len); txn->cli_cookie[log_len] = 0; } } /* Persistence cookies in passive, rewrite or insert mode have the * following form : * * Cookie: NAME=SRV[|<lastseen>[|<firstseen>]] * * For cookies in prefix mode, the form is : * * Cookie: NAME=SRV~VALUE */ if ((att_end - att_beg == s->be->cookie_len) && (s->be->cookie_name != NULL) && (memcmp(att_beg, s->be->cookie_name, att_end - att_beg) == 0)) { struct server *srv = s->be->srv; char *delim; /* if we're in cookie prefix mode, we'll search the delimitor so that we * have the server ID between val_beg and delim, and the original cookie between * delim+1 and val_end. Otherwise, delim==val_end : * * Cookie: NAME=SRV; # in all but prefix modes * Cookie: NAME=SRV~OPAQUE ; # in prefix mode * | || || | |+-> next * | || || | +--> val_end * | || || +---------> delim * | || |+------------> val_beg * | || +-------------> att_end = equal * | |+-----------------> att_beg * | +------------------> prev * +-------------------------> hdr_beg */ if (s->be->ck_opts & PR_CK_PFX) { for (delim = val_beg; delim < val_end; delim++) if (*delim == COOKIE_DELIM) break; } else { char *vbar1; delim = val_end; /* Now check if the cookie contains a date field, which would * appear after a vertical bar ('|') just after the server name * and before the delimiter. */ vbar1 = memchr(val_beg, COOKIE_DELIM_DATE, val_end - val_beg); if (vbar1) { /* OK, so left of the bar is the server's cookie and * right is the last seen date. It is a base64 encoded * 30-bit value representing the UNIX date since the * epoch in 4-second quantities. */ int val; delim = vbar1++; if (val_end - vbar1 >= 5) { val = b64tos30(vbar1); if (val > 0) txn->cookie_last_date = val << 2; } /* look for a second vertical bar */ vbar1 = memchr(vbar1, COOKIE_DELIM_DATE, val_end - vbar1); if (vbar1 && (val_end - vbar1 > 5)) { val = b64tos30(vbar1 + 1); if (val > 0) txn->cookie_first_date = val << 2; } } } /* if the cookie has an expiration date and the proxy wants to check * it, then we do that now. We first check if the cookie is too old, * then only if it has expired. We detect strict overflow because the * time resolution here is not great (4 seconds). Cookies with dates * in the future are ignored if their offset is beyond one day. This * allows an admin to fix timezone issues without expiring everyone * and at the same time avoids keeping unwanted side effects for too * long. */ if (txn->cookie_first_date && s->be->cookie_maxlife && (((signed)(date.tv_sec - txn->cookie_first_date) > (signed)s->be->cookie_maxlife) || ((signed)(txn->cookie_first_date - date.tv_sec) > 86400))) { txn->flags &= ~TX_CK_MASK; txn->flags |= TX_CK_OLD; delim = val_beg; // let's pretend we have not found the cookie txn->cookie_first_date = 0; txn->cookie_last_date = 0; } else if (txn->cookie_last_date && s->be->cookie_maxidle && (((signed)(date.tv_sec - txn->cookie_last_date) > (signed)s->be->cookie_maxidle) || ((signed)(txn->cookie_last_date - date.tv_sec) > 86400))) { txn->flags &= ~TX_CK_MASK; txn->flags |= TX_CK_EXPIRED; delim = val_beg; // let's pretend we have not found the cookie txn->cookie_first_date = 0; txn->cookie_last_date = 0; } /* Here, we'll look for the first running server which supports the cookie. * This allows to share a same cookie between several servers, for example * to dedicate backup servers to specific servers only. * However, to prevent clients from sticking to cookie-less backup server * when they have incidentely learned an empty cookie, we simply ignore * empty cookies and mark them as invalid. * The same behaviour is applied when persistence must be ignored. */ if ((delim == val_beg) || (s->flags & (SN_IGNORE_PRST | SN_ASSIGNED))) srv = NULL; while (srv) { if (srv->cookie && (srv->cklen == delim - val_beg) && !memcmp(val_beg, srv->cookie, delim - val_beg)) { if ((srv->state != SRV_ST_STOPPED) || (s->be->options & PR_O_PERSIST) || (s->flags & SN_FORCE_PRST)) { /* we found the server and we can use it */ txn->flags &= ~TX_CK_MASK; txn->flags |= (srv->state != SRV_ST_STOPPED) ? TX_CK_VALID : TX_CK_DOWN; s->flags |= SN_DIRECT | SN_ASSIGNED; s->target = &srv->obj_type; break; } else { /* we found a server, but it's down, * mark it as such and go on in case * another one is available. */ txn->flags &= ~TX_CK_MASK; txn->flags |= TX_CK_DOWN; } } srv = srv->next; } if (!srv && !(txn->flags & (TX_CK_DOWN|TX_CK_EXPIRED|TX_CK_OLD))) { /* no server matched this cookie or we deliberately skipped it */ txn->flags &= ~TX_CK_MASK; if ((s->flags & (SN_IGNORE_PRST | SN_ASSIGNED))) txn->flags |= TX_CK_UNUSED; else txn->flags |= TX_CK_INVALID; } /* depending on the cookie mode, we may have to either : * - delete the complete cookie if we're in insert+indirect mode, so that * the server never sees it ; * - remove the server id from the cookie value, and tag the cookie as an * application cookie so that it does not get accidentely removed later, * if we're in cookie prefix mode */ if ((s->be->ck_opts & PR_CK_PFX) && (delim != val_end)) { int delta; /* negative */ delta = buffer_replace2(req->buf, val_beg, delim + 1, NULL, 0); val_end += delta; next += delta; hdr_end += delta; hdr_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->req, delta); del_from = NULL; preserve_hdr = 1; /* we want to keep this cookie */ } else if (del_from == NULL && (s->be->ck_opts & (PR_CK_INS | PR_CK_IND)) == (PR_CK_INS | PR_CK_IND)) { del_from = prev; } } else { /* This is not our cookie, so we must preserve it. But if we already * scheduled another cookie for removal, we cannot remove the * complete header, but we can remove the previous block itself. */ preserve_hdr = 1; if (del_from != NULL) { int delta = del_hdr_value(req->buf, &del_from, prev); if (att_beg >= del_from) att_beg += delta; if (att_end >= del_from) att_end += delta; val_beg += delta; val_end += delta; next += delta; hdr_end += delta; hdr_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->req, delta); prev = del_from; del_from = NULL; } } /* Look for the appsession cookie unless persistence must be ignored */ if (!(s->flags & SN_IGNORE_PRST) && (s->be->appsession_name != NULL)) { int cmp_len, value_len; char *value_begin; if (s->be->options2 & PR_O2_AS_PFX) { cmp_len = MIN(val_end - att_beg, s->be->appsession_name_len); value_begin = att_beg + s->be->appsession_name_len; value_len = val_end - att_beg - s->be->appsession_name_len; } else { cmp_len = att_end - att_beg; value_begin = val_beg; value_len = val_end - val_beg; } /* let's see if the cookie is our appcookie */ if (cmp_len == s->be->appsession_name_len && memcmp(att_beg, s->be->appsession_name, cmp_len) == 0) { manage_client_side_appsession(s, value_begin, value_len); } } /* continue with next cookie on this header line */ att_beg = next; } /* for each cookie */ /* There are no more cookies on this line. * We may still have one (or several) marked for deletion at the * end of the line. We must do this now in two ways : * - if some cookies must be preserved, we only delete from the * mark to the end of line ; * - if nothing needs to be preserved, simply delete the whole header */ if (del_from) { int delta; if (preserve_hdr) { delta = del_hdr_value(req->buf, &del_from, hdr_end); hdr_end = del_from; cur_hdr->len += delta; } else { delta = buffer_replace2(req->buf, hdr_beg, hdr_next, NULL, 0); /* FIXME: this should be a separate function */ txn->hdr_idx.v[old_idx].next = cur_hdr->next; txn->hdr_idx.used--; cur_hdr->len = 0; cur_idx = old_idx; } hdr_next += delta; http_msg_move_end(&txn->req, delta); } /* check next header */ old_idx = cur_idx; } } Commit Message: CWE ID: CWE-189
0
26,335
Analyze the following 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 setcieabcspace(i_ctx_t * i_ctx_p, ref *r, int *stage, int *cont, int CIESubst) { int code = 0; ref CIEDict, *nocie; ulong dictkey; gs_md5_state_t md5; byte key[16]; if (i_ctx_p->language_level < 2) return_error(gs_error_undefined); code = dict_find_string(systemdict, "NOCIE", &nocie); if (code > 0) { if (!r_has_type(nocie, t_boolean)) return_error(gs_error_typecheck); if (nocie->value.boolval) return setrgbspace(i_ctx_p, r, stage, cont, 1); } *cont = 0; code = array_get(imemory, r, 1, &CIEDict); if (code < 0) return code; if ((*stage) > 0) { gs_client_color cc; int i; cc.pattern = 0x00; for (i=0;i<3;i++) cc.paint.values[i] = 0; code = gs_setcolor(igs, &cc); *stage = 0; return code; } gs_md5_init(&md5); /* If the hash (dictkey) is 0, we don't check for an existing * ICC profile dor this space. So if we get an error hashing * the space, we construct a new profile. */ dictkey = 0; if (hashcieabcspace(i_ctx_p, r, &md5)) { /* Ideally we would use the whole md5 hash, but the ICC code only * expects a long. I'm 'slightly' concerned about collisions here * but I think its unlikely really. If it ever becomes a problem * we could add the hash bytes up, or modify the ICC cache to store * the full 16 byte hashs. */ gs_md5_finish(&md5, key); dictkey = *(ulong *)&key[sizeof(key) - sizeof(ulong)]; } else { gs_md5_finish(&md5, key); } code = cieabcspace(i_ctx_p, &CIEDict,dictkey); *cont = 1; (*stage)++; return code; } Commit Message: CWE ID: CWE-704
0
8,948
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: mux_exit_message(Channel *c, int exitval) { Buffer m; Channel *mux_chan; debug3("%s: channel %d: exit message, exitval %d", __func__, c->self, exitval); if ((mux_chan = channel_by_id(c->ctl_chan)) == NULL) fatal("%s: channel %d missing mux channel %d", __func__, c->self, c->ctl_chan); /* Append exit message packet to control socket output queue */ buffer_init(&m); buffer_put_int(&m, MUX_S_EXIT_MESSAGE); buffer_put_int(&m, c->self); buffer_put_int(&m, exitval); buffer_put_string(&mux_chan->output, buffer_ptr(&m), buffer_len(&m)); buffer_free(&m); } Commit Message: CWE ID: CWE-254
0
914
Analyze the following 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 vlan_dev_get_realdev_name(const struct net_device *dev, char *result) { strncpy(result, vlan_dev_info(dev)->real_dev->name, 23); } Commit Message: net: Audit drivers to identify those needing IFF_TX_SKB_SHARING cleared After the last patch, We are left in a state in which only drivers calling ether_setup have IFF_TX_SKB_SHARING set (we assume that drivers touching real hardware call ether_setup for their net_devices and don't hold any state in their skbs. There are a handful of drivers that violate this assumption of course, and need to be fixed up. This patch identifies those drivers, and marks them as not being able to support the safe transmission of skbs by clearning the IFF_TX_SKB_SHARING flag in priv_flags Signed-off-by: Neil Horman <nhorman@tuxdriver.com> CC: Karsten Keil <isdn@linux-pingi.de> CC: "David S. Miller" <davem@davemloft.net> CC: Jay Vosburgh <fubar@us.ibm.com> CC: Andy Gospodarek <andy@greyhouse.net> CC: Patrick McHardy <kaber@trash.net> CC: Krzysztof Halasa <khc@pm.waw.pl> CC: "John W. Linville" <linville@tuxdriver.com> CC: Greg Kroah-Hartman <gregkh@suse.de> CC: Marcel Holtmann <marcel@holtmann.org> CC: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-264
0
21,944
Analyze the following 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 smaps_rollup_open(struct inode *inode, struct file *file) { int ret; struct proc_maps_private *priv; priv = kzalloc(sizeof(*priv), GFP_KERNEL_ACCOUNT); if (!priv) return -ENOMEM; ret = single_open(file, show_smaps_rollup, priv); if (ret) goto out_free; priv->inode = inode; priv->mm = proc_mem_open(inode, PTRACE_MODE_READ); if (IS_ERR(priv->mm)) { ret = PTR_ERR(priv->mm); single_release(inode, file); goto out_free; } return 0; out_free: kfree(priv); return ret; } Commit Message: coredump: fix race condition between mmget_not_zero()/get_task_mm() and core dumping The core dumping code has always run without holding the mmap_sem for writing, despite that is the only way to ensure that the entire vma layout will not change from under it. Only using some signal serialization on the processes belonging to the mm is not nearly enough. This was pointed out earlier. For example in Hugh's post from Jul 2017: https://lkml.kernel.org/r/alpine.LSU.2.11.1707191716030.2055@eggly.anvils "Not strictly relevant here, but a related note: I was very surprised to discover, only quite recently, how handle_mm_fault() may be called without down_read(mmap_sem) - when core dumping. That seems a misguided optimization to me, which would also be nice to correct" In particular because the growsdown and growsup can move the vm_start/vm_end the various loops the core dump does around the vma will not be consistent if page faults can happen concurrently. Pretty much all users calling mmget_not_zero()/get_task_mm() and then taking the mmap_sem had the potential to introduce unexpected side effects in the core dumping code. Adding mmap_sem for writing around the ->core_dump invocation is a viable long term fix, but it requires removing all copy user and page faults and to replace them with get_dump_page() for all binary formats which is not suitable as a short term fix. For the time being this solution manually covers the places that can confuse the core dump either by altering the vma layout or the vma flags while it runs. Once ->core_dump runs under mmap_sem for writing the function mmget_still_valid() can be dropped. Allowing mmap_sem protected sections to run in parallel with the coredump provides some minor parallelism advantage to the swapoff code (which seems to be safe enough by never mangling any vma field and can keep doing swapins in parallel to the core dumping) and to some other corner case. In order to facilitate the backporting I added "Fixes: 86039bd3b4e6" however the side effect of this same race condition in /proc/pid/mem should be reproducible since before 2.6.12-rc2 so I couldn't add any other "Fixes:" because there's no hash beyond the git genesis commit. Because find_extend_vma() is the only location outside of the process context that could modify the "mm" structures under mmap_sem for reading, by adding the mmget_still_valid() check to it, all other cases that take the mmap_sem for reading don't need the new check after mmget_not_zero()/get_task_mm(). The expand_stack() in page fault context also doesn't need the new check, because all tasks under core dumping are frozen. Link: http://lkml.kernel.org/r/20190325224949.11068-1-aarcange@redhat.com Fixes: 86039bd3b4e6 ("userfaultfd: add new syscall to provide memory externalization") Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Reported-by: Jann Horn <jannh@google.com> Suggested-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Peter Xu <peterx@redhat.com> Reviewed-by: Mike Rapoport <rppt@linux.ibm.com> Reviewed-by: Oleg Nesterov <oleg@redhat.com> Reviewed-by: Jann Horn <jannh@google.com> Acked-by: Jason Gunthorpe <jgg@mellanox.com> Acked-by: Michal Hocko <mhocko@suse.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID: CWE-362
0
4,026
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Document::setTitle(const String& title) { if (!isHTMLDocument() && !isXHTMLDocument()) { m_titleElement = nullptr; } else if (!m_titleElement) { HTMLElement* headElement = head(); if (!headElement) return; m_titleElement = HTMLTitleElement::create(*this); headElement->appendChild(m_titleElement.get()); } if (isHTMLTitleElement(m_titleElement)) toHTMLTitleElement(m_titleElement)->setText(title); else updateTitle(title); } Commit Message: Change Document::detach() to RELEASE_ASSERT all subframes are gone. BUG=556724,577105 Review URL: https://codereview.chromium.org/1667573002 Cr-Commit-Position: refs/heads/master@{#373642} CWE ID: CWE-264
0
16,782
Analyze the following 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 update_meta_page(struct f2fs_sb_info *sbi, void *src, block_t blk_addr) { struct page *page = grab_meta_page(sbi, blk_addr); void *dst = page_address(page); if (src) memcpy(dst, src, PAGE_SIZE); else memset(dst, 0, PAGE_SIZE); set_page_dirty(page); f2fs_put_page(page, 1); } Commit Message: f2fs: fix a panic caused by NULL flush_cmd_control Mount fs with option noflush_merge, boot failed for illegal address fcc in function f2fs_issue_flush: if (!test_opt(sbi, FLUSH_MERGE)) { ret = submit_flush_wait(sbi); atomic_inc(&fcc->issued_flush); -> Here, fcc illegal return ret; } Signed-off-by: Yunlei He <heyunlei@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> CWE ID: CWE-476
0
22,911
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void MessageLoop::AddDestructionObserver( DestructionObserver* destruction_observer) { DCHECK_EQ(this, current()); destruction_observers_.AddObserver(destruction_observer); } Commit Message: Introduce RunLoop::Type::NESTABLE_TASKS_ALLOWED to replace MessageLoop::ScopedNestableTaskAllower. (as well as MessageLoop::SetNestableTasksAllowed()) Surveying usage: the scoped object is always instantiated right before RunLoop().Run(). The intent is really to allow nestable tasks in that RunLoop so it's better to explicitly label that RunLoop as such and it allows us to break the last dependency that forced some RunLoop users to use MessageLoop APIs. There's also the odd case of allowing nestable tasks for loops that are reentrant from a native task (without going through RunLoop), these are the minority but will have to be handled (after cleaning up the majority of cases that are RunLoop induced). As highlighted by robliao@ in https://chromium-review.googlesource.com/c/600517 (which was merged in this CL). R=danakj@chromium.org Bug: 750779 Change-Id: I43d122c93ec903cff3a6fe7b77ec461ea0656448 Reviewed-on: https://chromium-review.googlesource.com/594713 Commit-Queue: Gabriel Charette <gab@chromium.org> Reviewed-by: Robert Liao <robliao@chromium.org> Reviewed-by: danakj <danakj@chromium.org> Cr-Commit-Position: refs/heads/master@{#492263} CWE ID:
0
14,236
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool Downmix_foldGeneric( uint32_t mask, int16_t *pSrc, int16_t*pDst, size_t numFrames, bool accumulate) { if (!Downmix_validChannelMask(mask)) { return false; } const bool hasSides = (mask & kSides) != 0; const bool hasBacks = (mask & kBacks) != 0; const int numChan = audio_channel_count_from_out_mask(mask); const bool hasFC = ((mask & AUDIO_CHANNEL_OUT_FRONT_CENTER) == AUDIO_CHANNEL_OUT_FRONT_CENTER); const bool hasLFE = ((mask & AUDIO_CHANNEL_OUT_LOW_FREQUENCY) == AUDIO_CHANNEL_OUT_LOW_FREQUENCY); const bool hasBC = ((mask & AUDIO_CHANNEL_OUT_BACK_CENTER) == AUDIO_CHANNEL_OUT_BACK_CENTER); const int indexFC = hasFC ? 2 : 1; // front center const int indexLFE = hasLFE ? indexFC + 1 : indexFC; // low frequency const int indexBL = hasBacks ? indexLFE + 1 : indexLFE; // back left const int indexBR = hasBacks ? indexBL + 1 : indexBL; // back right const int indexBC = hasBC ? indexBR + 1 : indexBR; // back center const int indexSL = hasSides ? indexBC + 1 : indexBC; // side left const int indexSR = hasSides ? indexSL + 1 : indexSL; // side right int32_t lt, rt, centersLfeContrib; // samples in Q19.12 format if (accumulate) { while (numFrames) { centersLfeContrib = 0; if (hasFC) { centersLfeContrib += pSrc[indexFC]; } if (hasLFE) { centersLfeContrib += pSrc[indexLFE]; } if (hasBC) { centersLfeContrib += pSrc[indexBC]; } centersLfeContrib *= MINUS_3_DB_IN_Q19_12; lt = (pSrc[0] << 12); rt = (pSrc[1] << 12); if (hasSides) { lt += pSrc[indexSL] << 12; rt += pSrc[indexSR] << 12; } if (hasBacks) { lt += pSrc[indexBL] << 12; rt += pSrc[indexBR] << 12; } lt += centersLfeContrib; rt += centersLfeContrib; pDst[0] = clamp16(pDst[0] + (lt >> 13)); pDst[1] = clamp16(pDst[1] + (rt >> 13)); pSrc += numChan; pDst += 2; numFrames--; } } else { while (numFrames) { centersLfeContrib = 0; if (hasFC) { centersLfeContrib += pSrc[indexFC]; } if (hasLFE) { centersLfeContrib += pSrc[indexLFE]; } if (hasBC) { centersLfeContrib += pSrc[indexBC]; } centersLfeContrib *= MINUS_3_DB_IN_Q19_12; lt = (pSrc[0] << 12); rt = (pSrc[1] << 12); if (hasSides) { lt += pSrc[indexSL] << 12; rt += pSrc[indexSR] << 12; } if (hasBacks) { lt += pSrc[indexBL] << 12; rt += pSrc[indexBR] << 12; } lt += centersLfeContrib; rt += centersLfeContrib; pDst[0] = clamp16(lt >> 13); // differs from when accumulate is true above pDst[1] = clamp16(rt >> 13); // differs from when accumulate is true above pSrc += numChan; pDst += 2; numFrames--; } } return true; } Commit Message: Add EFFECT_CMD_SET_PARAM parameter checking to Downmix and Reverb Bug: 63662938 Bug: 63526567 Test: Added CTS tests Change-Id: I8ed398cd62a9f461b0590e37f593daa3d8e4dbc4 (cherry picked from commit 804632afcdda6e80945bf27c384757bda50560cb) CWE ID: CWE-200
0
456
Analyze the following 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 stringAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) { TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue); imp->setStringAttribute(cppValue); } 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
25,978
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: IDNSpoofChecker::IDNSpoofChecker() { UErrorCode status = U_ZERO_ERROR; checker_ = uspoof_open(&status); if (U_FAILURE(status)) { checker_ = nullptr; return; } uspoof_setRestrictionLevel(checker_, USPOOF_HIGHLY_RESTRICTIVE); SetAllowedUnicodeSet(&status); int32_t checks = uspoof_getChecks(checker_, &status) | USPOOF_AUX_INFO; uspoof_setChecks(checker_, checks, &status); deviation_characters_ = icu::UnicodeSet( UNICODE_STRING_SIMPLE("[\\u00df\\u03c2\\u200c\\u200d]"), status); deviation_characters_.freeze(); non_ascii_latin_letters_ = icu::UnicodeSet(UNICODE_STRING_SIMPLE("[[:Latin:] - [a-zA-Z]]"), status); non_ascii_latin_letters_.freeze(); kana_letters_exceptions_ = icu::UnicodeSet( UNICODE_STRING_SIMPLE("[\\u3078-\\u307a\\u30d8-\\u30da\\u30fb-\\u30fe]"), status); kana_letters_exceptions_.freeze(); combining_diacritics_exceptions_ = icu::UnicodeSet(UNICODE_STRING_SIMPLE("[\\u0300-\\u0339]"), status); combining_diacritics_exceptions_.freeze(); cyrillic_letters_latin_alike_ = icu::UnicodeSet( icu::UnicodeString::fromUTF8("[асԁеһіјӏорԛѕԝхуъЬҽпгѵѡ]"), status); cyrillic_letters_latin_alike_.freeze(); cyrillic_letters_ = icu::UnicodeSet(UNICODE_STRING_SIMPLE("[[:Cyrl:]]"), status); cyrillic_letters_.freeze(); DCHECK(U_SUCCESS(status)); lgc_letters_n_ascii_ = icu::UnicodeSet( UNICODE_STRING_SIMPLE("[[:Latin:][:Greek:][:Cyrillic:][0-9\\u002e_" "\\u002d][\\u0300-\\u0339]]"), status); lgc_letters_n_ascii_.freeze(); UParseError parse_error; diacritic_remover_.reset(icu::Transliterator::createFromRules( UNICODE_STRING_SIMPLE("DropAcc"), icu::UnicodeString::fromUTF8("::NFD; ::[:Nonspacing Mark:] Remove; ::NFC;" " ł > l; ø > o; đ > d;"), UTRANS_FORWARD, parse_error, status)); extra_confusable_mapper_.reset(icu::Transliterator::createFromRules( UNICODE_STRING_SIMPLE("ExtraConf"), icu::UnicodeString::fromUTF8( "ӏ > l; [кĸκ] > k; п > n; [ƅь] > b; в > b; м > m; н > h; " "т > t; [шщ] > w; ട > s;"), UTRANS_FORWARD, parse_error, status)); DCHECK(U_SUCCESS(status)) << "Spoofchecker initalization failed due to an error: " << u_errorName(status); } Commit Message: Add more confusable character map entries When comparing domain names with top 10k domain names for confusability, characters with diacritics are decomposed into base + diacritic marks (Unicode Normalization Form D) and diacritics are dropped before calculating the confusability skeleton because two characters with and without a diacritics is NOT regarded as confusable. However, there are a dozen of characters (most of them are Cyrillic) with a diacritic-like mark attached but they are not decomposed into base + diacritics by NFD (e.g. U+049B, қ; Cyrillic Small Letter Ka with Descender). This CL treats them the same way as their "base" characters. For instance, қ (U+049B) is treated as confusable with Latin k because к (U+043A; Cyrillic Small Letter Ka) is. They're curated from the following sets: [:IdentifierStatus=Allowed:] & [:Ll:] & [[:sc=Cyrillic:] - [[\u01cd-\u01dc][\u1c80-\u1c8f][\u1e00-\u1e9b][\u1f00-\u1fff] [\ua640-\ua69f][\ua720-\ua7ff]]] & [:NFD_Inert=Yes:] [:IdentifierStatus=Allowed:] & [:Ll:] & [[:sc=Latin:] - [[\u01cd-\u01dc][\u1e00-\u1e9b][\ua720-\ua7ff]]] & [:NFD_Inert=Yes:] [:IdentifierStatus=Allowed:] & [:Ll:] & [[:sc=Greek:]] & [:NFD_Inert=Yes:] Bug: 793628,798892 Test: components_unittests --gtest_filter=*IDN* Change-Id: I20c6af13defa295f6952f33d75987e87ce1853d0 Reviewed-on: https://chromium-review.googlesource.com/860567 Commit-Queue: Jungshik Shin <jshin@chromium.org> Reviewed-by: Eric Lawrence <elawrence@chromium.org> Reviewed-by: Peter Kasting <pkasting@chromium.org> Cr-Commit-Position: refs/heads/master@{#529129} CWE ID: CWE-20
1
685
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static WORD32 ihevcd_parse_vui_parameters(bitstrm_t *ps_bitstrm, vui_t *ps_vui, WORD32 sps_max_sub_layers_minus1) { WORD32 ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS; BITS_PARSE("aspect_ratio_info_present_flag", ps_vui->u1_aspect_ratio_info_present_flag, ps_bitstrm, 1); ps_vui->u1_aspect_ratio_idc = SAR_UNUSED; ps_vui->u2_sar_width = 0; ps_vui->u2_sar_height = 0; if(ps_vui->u1_aspect_ratio_info_present_flag) { BITS_PARSE("aspect_ratio_idc", ps_vui->u1_aspect_ratio_idc, ps_bitstrm, 8); if(ps_vui->u1_aspect_ratio_idc == EXTENDED_SAR) { BITS_PARSE("sar_width", ps_vui->u2_sar_width, ps_bitstrm, 16); BITS_PARSE("sar_height", ps_vui->u2_sar_height, ps_bitstrm, 16); } } BITS_PARSE("overscan_info_present_flag", ps_vui->u1_overscan_info_present_flag, ps_bitstrm, 1); ps_vui->u1_overscan_appropriate_flag = 0; if(ps_vui->u1_overscan_info_present_flag) BITS_PARSE("overscan_appropriate_flag", ps_vui->u1_overscan_appropriate_flag, ps_bitstrm, 1); BITS_PARSE("video_signal_type_present_flag", ps_vui->u1_video_signal_type_present_flag, ps_bitstrm, 1); ps_vui->u1_video_format = VID_FMT_UNSPECIFIED; ps_vui->u1_video_full_range_flag = 0; ps_vui->u1_colour_description_present_flag = 0; ps_vui->u1_colour_primaries = 2; ps_vui->u1_transfer_characteristics = 2; ps_vui->u1_matrix_coefficients = 2; if(ps_vui->u1_video_signal_type_present_flag) { BITS_PARSE("video_format", ps_vui->u1_video_format, ps_bitstrm, 3); BITS_PARSE("video_full_range_flag", ps_vui->u1_video_full_range_flag, ps_bitstrm, 1); BITS_PARSE("colour_description_present_flag", ps_vui->u1_colour_description_present_flag, ps_bitstrm, 1); if(ps_vui->u1_colour_description_present_flag) { BITS_PARSE("colour_primaries", ps_vui->u1_colour_primaries, ps_bitstrm, 8); BITS_PARSE("transfer_characteristics", ps_vui->u1_transfer_characteristics, ps_bitstrm, 8); BITS_PARSE("matrix_coeffs", ps_vui->u1_matrix_coefficients, ps_bitstrm, 8); } } BITS_PARSE("chroma_loc_info_present_flag", ps_vui->u1_chroma_loc_info_present_flag, ps_bitstrm, 1); ps_vui->u1_chroma_sample_loc_type_top_field = 0; ps_vui->u1_chroma_sample_loc_type_bottom_field = 0; if(ps_vui->u1_chroma_loc_info_present_flag) { UEV_PARSE("chroma_sample_loc_type_top_field", ps_vui->u1_chroma_sample_loc_type_top_field, ps_bitstrm); UEV_PARSE("chroma_sample_loc_type_bottom_field", ps_vui->u1_chroma_sample_loc_type_bottom_field, ps_bitstrm); } BITS_PARSE("neutral_chroma_indication_flag", ps_vui->u1_neutral_chroma_indication_flag, ps_bitstrm, 1); BITS_PARSE("field_seq_flag", ps_vui->u1_field_seq_flag, ps_bitstrm, 1); BITS_PARSE("frame_field_info_present_flag", ps_vui->u1_frame_field_info_present_flag, ps_bitstrm, 1); BITS_PARSE("default_display_window_flag", ps_vui->u1_default_display_window_flag, ps_bitstrm, 1); ps_vui->u4_def_disp_win_left_offset = 0; ps_vui->u4_def_disp_win_right_offset = 0; ps_vui->u4_def_disp_win_top_offset = 0; ps_vui->u4_def_disp_win_bottom_offset = 0; if(ps_vui->u1_default_display_window_flag) { UEV_PARSE("def_disp_win_left_offset", ps_vui->u4_def_disp_win_left_offset, ps_bitstrm); UEV_PARSE("def_disp_win_right_offset", ps_vui->u4_def_disp_win_right_offset, ps_bitstrm); UEV_PARSE("def_disp_win_top_offset", ps_vui->u4_def_disp_win_top_offset, ps_bitstrm); UEV_PARSE("def_disp_win_bottom_offset", ps_vui->u4_def_disp_win_bottom_offset, ps_bitstrm); } BITS_PARSE("vui_timing_info_present_flag", ps_vui->u1_vui_timing_info_present_flag, ps_bitstrm, 1); if(ps_vui->u1_vui_timing_info_present_flag) { BITS_PARSE("vui_num_units_in_tick", ps_vui->u4_vui_num_units_in_tick, ps_bitstrm, 32); BITS_PARSE("vui_time_scale", ps_vui->u4_vui_time_scale, ps_bitstrm, 32); BITS_PARSE("vui_poc_proportional_to_timing_flag", ps_vui->u1_poc_proportional_to_timing_flag, ps_bitstrm, 1); if(ps_vui->u1_poc_proportional_to_timing_flag) UEV_PARSE("vui_num_ticks_poc_diff_one_minus1", ps_vui->u1_num_ticks_poc_diff_one_minus1, ps_bitstrm); BITS_PARSE("vui_hrd_parameters_present_flag", ps_vui->u1_vui_hrd_parameters_present_flag, ps_bitstrm, 1); if(ps_vui->u1_vui_hrd_parameters_present_flag) ihevcd_parse_hrd_parameters(ps_bitstrm, &ps_vui->s_vui_hrd_parameters, 1, sps_max_sub_layers_minus1); } BITS_PARSE("bitstream_restriction_flag", ps_vui->u1_bitstream_restriction_flag, ps_bitstrm, 1); ps_vui->u1_tiles_fixed_structure_flag = 0; ps_vui->u1_motion_vectors_over_pic_boundaries_flag = 1; ps_vui->u1_restricted_ref_pic_lists_flag = 0; ps_vui->u4_min_spatial_segmentation_idc = 0; ps_vui->u1_max_bytes_per_pic_denom = 2; ps_vui->u1_max_bits_per_mincu_denom = 1; ps_vui->u1_log2_max_mv_length_horizontal = 15; ps_vui->u1_log2_max_mv_length_vertical = 15; if(ps_vui->u1_bitstream_restriction_flag) { BITS_PARSE("tiles_fixed_structure_flag", ps_vui->u1_tiles_fixed_structure_flag, ps_bitstrm, 1); BITS_PARSE("motion_vectors_over_pic_boundaries_flag", ps_vui->u1_motion_vectors_over_pic_boundaries_flag, ps_bitstrm, 1); BITS_PARSE("restricted_ref_pic_lists_flag", ps_vui->u1_restricted_ref_pic_lists_flag, ps_bitstrm, 1); UEV_PARSE("min_spatial_segmentation_idc", ps_vui->u4_min_spatial_segmentation_idc, ps_bitstrm); UEV_PARSE("max_bytes_per_pic_denom", ps_vui->u1_max_bytes_per_pic_denom, ps_bitstrm); UEV_PARSE("max_bits_per_min_cu_denom", ps_vui->u1_max_bits_per_mincu_denom, ps_bitstrm); UEV_PARSE("log2_max_mv_length_horizontal", ps_vui->u1_log2_max_mv_length_horizontal, ps_bitstrm); UEV_PARSE("log2_max_mv_length_vertical", ps_vui->u1_log2_max_mv_length_vertical, ps_bitstrm); } return ret; } Commit Message: Correct Tiles rows and cols check Bug: 36231493 Bug: 34064500 Change-Id: Ib17b2c68360685c5a2c019e1497612a130f9f76a (cherry picked from commit 07ef4e7138e0e13d61039530358343a19308b188) CWE ID: CWE-119
0
24,635
Analyze the following 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 IsURLHandledByDefaultLoader(const GURL& url) { return IsURLHandledByNetworkService(url) || url.SchemeIs(url::kDataScheme); } Commit Message: Abort navigations on 304 responses. A recent change (https://chromium-review.googlesource.com/1161479) accidentally resulted in treating 304 responses as downloads. This CL treats them as ERR_ABORTED instead. This doesn't exactly match old behavior, which passed them on to the renderer, which then aborted them. The new code results in correctly restoring the original URL in the omnibox, and has a shiny new test to prevent future regressions. Bug: 882270 Change-Id: Ic73dcce9e9596d43327b13acde03b4ed9bd0c82e Reviewed-on: https://chromium-review.googlesource.com/1252684 Commit-Queue: Matt Menke <mmenke@chromium.org> Reviewed-by: Camille Lamy <clamy@chromium.org> Cr-Commit-Position: refs/heads/master@{#595641} CWE ID: CWE-20
0
16,246
Analyze the following 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 debugfs_evict_inode(struct inode *inode) { truncate_inode_pages_final(&inode->i_data); clear_inode(inode); if (S_ISLNK(inode->i_mode)) kfree(inode->i_link); } Commit Message: dentry name snapshots take_dentry_name_snapshot() takes a safe snapshot of dentry name; if the name is a short one, it gets copied into caller-supplied structure, otherwise an extra reference to external name is grabbed (those are never modified). In either case the pointer to stable string is stored into the same structure. dentry must be held by the caller of take_dentry_name_snapshot(), but may be freely dropped afterwards - the snapshot will stay until destroyed by release_dentry_name_snapshot(). Intended use: struct name_snapshot s; take_dentry_name_snapshot(&s, dentry); ... access s.name ... release_dentry_name_snapshot(&s); Replaces fsnotify_oldname_...(), gets used in fsnotify to obtain the name to pass down with event. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> CWE ID: CWE-362
0
27,517
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ConnectionFilterImpl( const service_manager::Identity& child_identity, std::unique_ptr<service_manager::BinderRegistry> registry) : child_identity_(child_identity), registry_(std::move(registry)), controller_(new ConnectionFilterController(this)), weak_factory_(this) { thread_checker_.DetachFromThread(); } Commit Message: Correct mojo::WrapSharedMemoryHandle usage Fixes some incorrect uses of mojo::WrapSharedMemoryHandle which were assuming that the call actually has any control over the memory protection applied to a handle when mapped. Where fixing usage is infeasible for this CL, TODOs are added to annotate follow-up work. Also updates the API and documentation to (hopefully) improve clarity and avoid similar mistakes from being made in the future. BUG=792900 Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Change-Id: I0578aaa9ca3bfcb01aaf2451315d1ede95458477 Reviewed-on: https://chromium-review.googlesource.com/818282 Reviewed-by: Wei Li <weili@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: John Abd-El-Malek <jam@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org> Reviewed-by: Yuzhu Shen <yzshen@chromium.org> Reviewed-by: Robert Sesek <rsesek@chromium.org> Commit-Queue: Ken Rockot <rockot@chromium.org> Cr-Commit-Position: refs/heads/master@{#530268} CWE ID: CWE-787
0
8,877
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void dumpV8Message(v8::Local<v8::Context> context, v8::Local<v8::Message> message) { if (message.IsEmpty()) return; message->GetScriptOrigin(); v8::Maybe<int> unused = message->GetLineNumber(context); ALLOW_UNUSED_LOCAL(unused); v8::Local<v8::Value> resourceName = message->GetScriptOrigin().ResourceName(); String fileName = "Unknown JavaScript file"; if (!resourceName.IsEmpty() && resourceName->IsString()) fileName = toCoreString(v8::Local<v8::String>::Cast(resourceName)); int lineNumber = 0; v8Call(message->GetLineNumber(context), lineNumber); v8::Local<v8::String> errorMessage = message->Get(); fprintf(stderr, "%s (line %d): %s\n", fileName.utf8().data(), lineNumber, toCoreString(errorMessage).utf8().data()); } Commit Message: Blink-in-JS should not run micro tasks If Blink-in-JS runs micro tasks, there's a risk of causing a UXSS bug (see 645211 for concrete steps). This CL makes Blink-in-JS use callInternalFunction (instead of callFunction) to avoid running micro tasks after Blink-in-JS' callbacks. BUG=645211 Review-Url: https://codereview.chromium.org/2330843002 Cr-Commit-Position: refs/heads/master@{#417874} CWE ID: CWE-79
0
13,368
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *msg, int val) { if ((ctxt != NULL) && (ctxt->disableSAX != 0) && (ctxt->instate == XML_PARSER_EOF)) return; if (ctxt != NULL) ctxt->errNo = error; __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, val, 0, msg, val); if (ctxt != NULL) { ctxt->wellFormed = 0; if (ctxt->recovery == 0) ctxt->disableSAX = 1; } } Commit Message: DO NOT MERGE: Add validation for eternal enities https://bugzilla.gnome.org/show_bug.cgi?id=780691 Bug: 36556310 Change-Id: I9450743e167c3c73af5e4071f3fc85e81d061648 (cherry picked from commit bef9af3d89d241bcb518c20cba6da2a2fd9ba049) CWE ID: CWE-611
0
9,278
Analyze the following 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 WebRuntimeFeatures::EnableVideoFullscreenDetection(bool enable) { RuntimeEnabledFeatures::SetVideoFullscreenDetectionEnabled(enable); } Commit Message: Remove RequireCSSExtensionForFile runtime enabled flag. The feature has long since been stable (since M64) and doesn't seem to be a need for this flag. BUG=788936 Change-Id: I666390b869289c328acb4a2daa5bf4154e1702c0 Reviewed-on: https://chromium-review.googlesource.com/c/1324143 Reviewed-by: Mike West <mkwst@chromium.org> Reviewed-by: Camille Lamy <clamy@chromium.org> Commit-Queue: Dave Tapuska <dtapuska@chromium.org> Cr-Commit-Position: refs/heads/master@{#607329} CWE ID: CWE-254
0
20,991
Analyze the following 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 EVP_PKEY * php_openssl_evp_from_zval(zval ** val, int public_key, char * passphrase, int makeresource, long * resourceval TSRMLS_DC) { EVP_PKEY * key = NULL; X509 * cert = NULL; int free_cert = 0; long cert_res = -1; char * filename = NULL; zval tmp; Z_TYPE(tmp) = IS_NULL; #define TMP_CLEAN \ if (Z_TYPE(tmp) == IS_STRING) {\ zval_dtor(&tmp); \ } \ return NULL; if (resourceval) { *resourceval = -1; } if (Z_TYPE_PP(val) == IS_ARRAY) { zval ** zphrase; /* get passphrase */ if (zend_hash_index_find(HASH_OF(*val), 1, (void **)&zphrase) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "key array must be of the form array(0 => key, 1 => phrase)"); return NULL; } if (Z_TYPE_PP(zphrase) == IS_STRING) { passphrase = Z_STRVAL_PP(zphrase); } else { tmp = **zphrase; zval_copy_ctor(&tmp); convert_to_string(&tmp); passphrase = Z_STRVAL(tmp); } /* now set val to be the key param and continue */ if (zend_hash_index_find(HASH_OF(*val), 0, (void **)&val) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "key array must be of the form array(0 => key, 1 => phrase)"); TMP_CLEAN; } } if (Z_TYPE_PP(val) == IS_RESOURCE) { void * what; int type; what = zend_fetch_resource(val TSRMLS_CC, -1, "OpenSSL X.509/key", &type, 2, le_x509, le_key); if (!what) { TMP_CLEAN; } if (resourceval) { *resourceval = Z_LVAL_PP(val); } if (type == le_x509) { /* extract key from cert, depending on public_key param */ cert = (X509*)what; free_cert = 0; } else if (type == le_key) { int is_priv; is_priv = php_openssl_is_private_key((EVP_PKEY*)what TSRMLS_CC); /* check whether it is actually a private key if requested */ if (!public_key && !is_priv) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "supplied key param is a public key"); TMP_CLEAN; } if (public_key && is_priv) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Don't know how to get public key from this private key"); TMP_CLEAN; } else { if (Z_TYPE(tmp) == IS_STRING) { zval_dtor(&tmp); } /* got the key - return it */ return (EVP_PKEY*)what; } } else { /* other types could be used here - eg: file pointers and read in the data from them */ TMP_CLEAN; } } else { /* force it to be a string and check if it refers to a file */ /* passing non string values leaks, object uses toString, it returns NULL * See bug38255.phpt */ if (!(Z_TYPE_PP(val) == IS_STRING || Z_TYPE_PP(val) == IS_OBJECT)) { TMP_CLEAN; } convert_to_string_ex(val); if (Z_STRLEN_PP(val) > 7 && memcmp(Z_STRVAL_PP(val), "file://", sizeof("file://") - 1) == 0) { filename = Z_STRVAL_PP(val) + (sizeof("file://") - 1); } /* it's an X509 file/cert of some kind, and we need to extract the data from that */ if (public_key) { cert = php_openssl_x509_from_zval(val, 0, &cert_res TSRMLS_CC); free_cert = (cert_res == -1); /* actual extraction done later */ if (!cert) { /* not a X509 certificate, try to retrieve public key */ BIO* in; if (filename) { in = BIO_new_file(filename, "r"); } else { in = BIO_new_mem_buf(Z_STRVAL_PP(val), Z_STRLEN_PP(val)); } if (in == NULL) { TMP_CLEAN; } key = PEM_read_bio_PUBKEY(in, NULL,NULL, NULL); BIO_free(in); } } else { /* we want the private key */ BIO *in; if (filename) { if (php_openssl_safe_mode_chk(filename TSRMLS_CC)) { TMP_CLEAN; } in = BIO_new_file(filename, "r"); } else { in = BIO_new_mem_buf(Z_STRVAL_PP(val), Z_STRLEN_PP(val)); } if (in == NULL) { TMP_CLEAN; } key = PEM_read_bio_PrivateKey(in, NULL,NULL, passphrase); BIO_free(in); } } if (public_key && cert && key == NULL) { /* extract public key from X509 cert */ key = (EVP_PKEY *) X509_get_pubkey(cert); } if (free_cert && cert) { X509_free(cert); } if (key && makeresource && resourceval) { *resourceval = ZEND_REGISTER_RESOURCE(NULL, key, le_key); } if (Z_TYPE(tmp) == IS_STRING) { zval_dtor(&tmp); } return key; } Commit Message: CWE ID: CWE-119
0
17,496
Analyze the following 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 ThreadableBlobRegistry::registerStreamURL(const KURL& url, const String& type) { if (isMainThread()) { blobRegistry().registerStreamURL(url, type); } else { OwnPtr<BlobRegistryContext> context = adoptPtr(new BlobRegistryContext(url, type)); callOnMainThread(&registerStreamURLTask, context.leakPtr()); } } Commit Message: Remove BlobRegistry indirection since there is only one implementation. BUG= Review URL: https://chromiumcodereview.appspot.com/15851008 git-svn-id: svn://svn.chromium.org/blink/trunk@152746 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID:
1
18,862
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList& args) : KParts::ReadWritePart(parent), m_splitter(Q_NULLPTR), m_busy(false), m_jobTracker(Q_NULLPTR) { Q_UNUSED(args) KAboutData aboutData(QStringLiteral("ark"), i18n("ArkPart"), QStringLiteral("3.0")); setComponentData(aboutData, false); new DndExtractAdaptor(this); const QString pathName = QStringLiteral("/DndExtract/%1").arg(s_instanceCounter++); if (!QDBusConnection::sessionBus().registerObject(pathName, this)) { qCCritical(ARK) << "Could not register a D-Bus object for drag'n'drop"; } QWidget *mainWidget = new QWidget; m_vlayout = new QVBoxLayout; m_model = new ArchiveModel(pathName, this); m_splitter = new QSplitter(Qt::Horizontal, parentWidget); m_view = new ArchiveView; m_infoPanel = new InfoPanel(m_model); m_commentView = new QPlainTextEdit(); m_commentView->setReadOnly(true); m_commentView->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); m_commentBox = new QGroupBox(i18n("Comment")); m_commentBox->hide(); QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(m_commentView); m_commentBox->setLayout(vbox); m_messageWidget = new KMessageWidget(parentWidget); m_messageWidget->setWordWrap(true); m_messageWidget->hide(); m_commentMsgWidget = new KMessageWidget(); m_commentMsgWidget->setText(i18n("Comment has been modified.")); m_commentMsgWidget->setMessageType(KMessageWidget::Information); m_commentMsgWidget->setCloseButtonVisible(false); m_commentMsgWidget->hide(); QAction *saveAction = new QAction(i18n("Save"), m_commentMsgWidget); m_commentMsgWidget->addAction(saveAction); connect(saveAction, &QAction::triggered, this, &Part::slotAddComment); m_commentBox->layout()->addWidget(m_commentMsgWidget); connect(m_commentView, &QPlainTextEdit::textChanged, this, &Part::slotCommentChanged); setWidget(mainWidget); mainWidget->setLayout(m_vlayout); m_vlayout->setContentsMargins(0,0,0,0); m_vlayout->addWidget(m_messageWidget); m_vlayout->addWidget(m_splitter); m_commentSplitter = new QSplitter(Qt::Vertical, parentWidget); m_commentSplitter->setOpaqueResize(false); m_commentSplitter->addWidget(m_view); m_commentSplitter->addWidget(m_commentBox); m_commentSplitter->setCollapsible(0, false); m_splitter->addWidget(m_commentSplitter); m_splitter->addWidget(m_infoPanel); if (!ArkSettings::showInfoPanel()) { m_infoPanel->hide(); } else { m_splitter->setSizes(ArkSettings::splitterSizes()); } setupView(); setupActions(); connect(m_view, &ArchiveView::entryChanged, this, &Part::slotRenameFile); connect(m_model, &ArchiveModel::loadingStarted, this, &Part::slotLoadingStarted); connect(m_model, &ArchiveModel::loadingFinished, this, &Part::slotLoadingFinished); connect(m_model, &ArchiveModel::droppedFiles, this, static_cast<void (Part::*)(const QStringList&, const Archive::Entry*, const QString&)>(&Part::slotAddFiles)); connect(m_model, &ArchiveModel::error, this, &Part::slotError); connect(m_model, &ArchiveModel::messageWidget, this, &Part::displayMsgWidget); connect(this, &Part::busy, this, &Part::setBusyGui); connect(this, &Part::ready, this, &Part::setReadyGui); connect(this, static_cast<void (KParts::ReadOnlyPart::*)()>(&KParts::ReadOnlyPart::completed), this, &Part::setFileNameFromArchive); m_statusBarExtension = new KParts::StatusBarExtension(this); setXMLFile(QStringLiteral("ark_part.rc")); } Commit Message: CWE ID: CWE-78
0
26,163
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: std::string GetInputValue(RenderFrameHostImpl* frame) { std::string result; EXPECT_TRUE(ExecuteScriptAndExtractString( frame, "window.domAutomationController.send(input.value);", &result)); return result; } Commit Message: Avoid sharing process for blob URLs with null origin. Previously, when a frame with a unique origin, such as from a data URL, created a blob URL, the blob URL looked like blob:null/guid and resulted in a site URL of "blob:" when navigated to. This incorrectly allowed all such blob URLs to share a process, even if they were created by different sites. This CL changes the site URL assigned in such cases to be the full blob URL, which includes the GUID. This avoids process sharing for all blob URLs with unique origins. This fix is conservative in the sense that it would also isolate different blob URLs created by the same unique origin from each other. This case isn't expected to be common, so it's unlikely to affect process count. There's ongoing work to maintain a GUID for unique origins, so longer-term, we could try using that to track down the creator and potentially use that GUID in the site URL instead of the blob URL's GUID, to avoid unnecessary process isolation in scenarios like this. Note that as part of this, we discovered a bug where data URLs aren't able to script blob URLs that they create: https://crbug.com/865254. This scripting bug should be fixed independently of this CL, and as far as we can tell, this CL doesn't regress scripting cases like this further. Bug: 863623 Change-Id: Ib50407adbba3d5ee0cf6d72d3df7f8d8f24684ee Reviewed-on: https://chromium-review.googlesource.com/1142389 Commit-Queue: Alex Moshchuk <alexmos@chromium.org> Reviewed-by: Charlie Reis <creis@chromium.org> Cr-Commit-Position: refs/heads/master@{#576318} CWE ID: CWE-285
0
23,912
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: size_t ImageProcessorClient::GetErrorCount() const { base::AutoLock auto_lock_(output_lock_); return image_processor_error_count_; } Commit Message: media/gpu/test: ImageProcessorClient: Use bytes for width and height in libyuv::CopyPlane() |width| is in bytes in libyuv::CopyPlane(). We formerly pass width in pixels. This should matter when a pixel format is used whose pixel is composed of more than one bytes. Bug: None Test: image_processor_test Change-Id: I98e90be70c8d0128319172d4d19f3a8017b65d78 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1553129 Commit-Queue: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Cr-Commit-Position: refs/heads/master@{#648117} CWE ID: CWE-20
0
28,971
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void ext4_falloc_update_inode(struct inode *inode, int mode, loff_t new_size, int update_ctime) { struct timespec now; if (update_ctime) { now = current_fs_time(inode->i_sb); if (!timespec_equal(&inode->i_ctime, &now)) inode->i_ctime = now; } /* * Update only when preallocation was requested beyond * the file size. */ if (!(mode & FALLOC_FL_KEEP_SIZE)) { if (new_size > i_size_read(inode)) i_size_write(inode, new_size); if (new_size > EXT4_I(inode)->i_disksize) ext4_update_i_disksize(inode, new_size); } else { /* * Mark that we allocate beyond EOF so the subsequent truncate * can proceed even if the new size is the same as i_size. */ if (new_size > i_size_read(inode)) ext4_set_inode_flag(inode, EXT4_INODE_EOFBLOCKS); } } Commit Message: ext4: race-condition protection for ext4_convert_unwritten_extents_endio We assumed that at the time we call ext4_convert_unwritten_extents_endio() extent in question is fully inside [map.m_lblk, map->m_len] because it was already split during submission. But this may not be true due to a race between writeback vs fallocate. If extent in question is larger than requested we will split it again. Special precautions should being done if zeroout required because [map.m_lblk, map->m_len] already contains valid data. Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: stable@vger.kernel.org CWE ID: CWE-362
0
27,427
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int in_set_format(struct audio_stream *stream, audio_format_t format) { (void)stream; (void)format; return -ENOSYS; } Commit Message: Fix audio record pre-processing proc_buf_out consistently initialized. intermediate scratch buffers consistently initialized. prevent read failure from overwriting memory. Test: POC, CTS, camera record Bug: 62873231 Change-Id: Ie26e12a419a5819c1c5c3a0bcf1876d6d7aca686 (cherry picked from commit 6d7b330c27efba944817e647955da48e54fd74eb) CWE ID: CWE-125
0
20,521
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static inline FDrive *drv0(FDCtrl *fdctrl) { return &fdctrl->drives[(fdctrl->tdr & FD_TDR_BOOTSEL) >> 2]; } Commit Message: CWE ID: CWE-119
0
22,452
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static const char *csv_escape_str(AVBPrint *dst, const char *src, const char sep, void *log_ctx) { char meta_chars[] = { sep, '"', '\n', '\r', '\0' }; int needs_quoting = !!src[strcspn(src, meta_chars)]; if (needs_quoting) av_bprint_chars(dst, '"', 1); for (; *src; src++) { if (*src == '"') av_bprint_chars(dst, '"', 1); av_bprint_chars(dst, *src, 1); } if (needs_quoting) av_bprint_chars(dst, '"', 1); return dst->str; } Commit Message: ffprobe: Fix null pointer dereference with color primaries Found-by: AD-lab of venustech Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> CWE ID: CWE-476
0
3,511
Analyze the following 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 tfdt_dump(GF_Box *a, FILE * trace) { GF_TFBaseMediaDecodeTimeBox *ptr = (GF_TFBaseMediaDecodeTimeBox*) a; if (!a) return GF_BAD_PARAM; gf_isom_box_dump_start(a, "TrackFragmentBaseMediaDecodeTimeBox", trace); fprintf(trace, "baseMediaDecodeTime=\""LLD"\">\n", ptr->baseMediaDecodeTime); gf_isom_box_dump_done("TrackFragmentBaseMediaDecodeTimeBox", a, trace); return GF_OK; } Commit Message: fixed 2 possible heap overflows (inc. #1088) CWE ID: CWE-125
0
10,974
Analyze the following 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 voidMethodDoubleArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { if (UNLIKELY(info.Length() < 1)) { throwTypeError(ExceptionMessages::failedToExecute("voidMethodDoubleArg", "TestObjectPython", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate()); return; } TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); V8TRYCATCH_VOID(double, doubleArg, static_cast<double>(info[0]->NumberValue())); imp->voidMethodDoubleArg(doubleArg); } 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
8,108
Analyze the following 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 PDFiumEngine::OnChar(const pp::KeyboardInputEvent& event) { if (last_page_mouse_down_ == -1) return false; base::string16 str = base::UTF8ToUTF16(event.GetCharacterText().AsString()); return !!FORM_OnChar( form_, pages_[last_page_mouse_down_]->GetPage(), str[0], event.GetModifiers()); } Commit Message: [pdf] Defer page unloading in JS callback. One of the callbacks from PDFium JavaScript into the embedder is to get the current page number. In Chromium, this will trigger a call to CalculateMostVisiblePage that method will determine the visible pages and unload any non-visible pages. But, if the originating JS is on a non-visible page we'll delete the page and annotations associated with that page. This will cause issues as we are currently working with those objects when the JavaScript returns. This Cl defers the page unloading triggered by getting the most visible page until the next event is handled by the Chromium embedder. BUG=chromium:653090 Review-Url: https://codereview.chromium.org/2418533002 Cr-Commit-Position: refs/heads/master@{#424781} CWE ID: CWE-416
0
8,677
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int ssl3_accept(SSL *s) { BUF_MEM *buf; unsigned long alg_k, Time = (unsigned long)time(NULL); void (*cb) (const SSL *ssl, int type, int val) = NULL; int ret = -1; int new_state, state, skip = 0; RAND_add(&Time, sizeof(Time), 0); ERR_clear_error(); clear_sys_error(); if (s->info_callback != NULL) cb = s->info_callback; else if (s->ctx->info_callback != NULL) cb = s->ctx->info_callback; /* init things to blank */ s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); if (s->cert == NULL) { SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_NO_CERTIFICATE_SET); return (-1); } #ifndef OPENSSL_NO_HEARTBEATS /* * If we're awaiting a HeartbeatResponse, pretend we already got and * don't await it anymore, because Heartbeats don't make sense during * handshakes anyway. */ if (s->tlsext_hb_pending) { s->tlsext_hb_pending = 0; s->tlsext_hb_seq++; } #endif for (;;) { state = s->state; switch (s->state) { case SSL_ST_RENEGOTIATE: s->renegotiate = 1; /* s->state=SSL_ST_ACCEPT; */ case SSL_ST_BEFORE: case SSL_ST_ACCEPT: case SSL_ST_BEFORE | SSL_ST_ACCEPT: case SSL_ST_OK | SSL_ST_ACCEPT: s->server = 1; if (cb != NULL) cb(s, SSL_CB_HANDSHAKE_START, 1); if ((s->version >> 8) != 3) { SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); s->state = SSL_ST_ERR; return -1; } s->type = SSL_ST_ACCEPT; if (s->init_buf == NULL) { if ((buf = BUF_MEM_new()) == NULL) { ret = -1; s->state = SSL_ST_ERR; goto end; } if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) { BUF_MEM_free(buf); ret = -1; s->state = SSL_ST_ERR; goto end; } s->init_buf = buf; } if (!ssl3_setup_buffers(s)) { ret = -1; s->state = SSL_ST_ERR; goto end; } s->init_num = 0; s->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY; s->s3->flags &= ~SSL3_FLAGS_CCS_OK; /* * Should have been reset by ssl3_get_finished, too. */ s->s3->change_cipher_spec = 0; if (s->state != SSL_ST_RENEGOTIATE) { /* * Ok, we now need to push on a buffering BIO so that the * output is sent in a way that TCP likes :-) */ if (!ssl_init_wbio_buffer(s, 1)) { ret = -1; s->state = SSL_ST_ERR; goto end; } ssl3_init_finished_mac(s); s->state = SSL3_ST_SR_CLNT_HELLO_A; s->ctx->stats.sess_accept++; } else if (!s->s3->send_connection_binding && !(s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { /* * Server attempting to renegotiate with client that doesn't * support secure renegotiation. */ SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); ret = -1; s->state = SSL_ST_ERR; goto end; } else { /* * s->state == SSL_ST_RENEGOTIATE, we will just send a * HelloRequest */ s->ctx->stats.sess_accept_renegotiate++; s->state = SSL3_ST_SW_HELLO_REQ_A; } break; case SSL3_ST_SW_HELLO_REQ_A: case SSL3_ST_SW_HELLO_REQ_B: s->shutdown = 0; ret = ssl3_send_hello_request(s); if (ret <= 0) goto end; s->s3->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C; s->state = SSL3_ST_SW_FLUSH; s->init_num = 0; ssl3_init_finished_mac(s); break; case SSL3_ST_SW_HELLO_REQ_C: s->state = SSL_ST_OK; break; case SSL3_ST_SR_CLNT_HELLO_A: case SSL3_ST_SR_CLNT_HELLO_B: case SSL3_ST_SR_CLNT_HELLO_C: s->shutdown = 0; ret = ssl3_get_client_hello(s); if (ret <= 0) goto end; #ifndef OPENSSL_NO_SRP s->state = SSL3_ST_SR_CLNT_HELLO_D; case SSL3_ST_SR_CLNT_HELLO_D: { int al; if ((ret = ssl_check_srp_ext_ClientHello(s, &al)) < 0) { /* * callback indicates firther work to be done */ s->rwstate = SSL_X509_LOOKUP; goto end; } if (ret != SSL_ERROR_NONE) { ssl3_send_alert(s, SSL3_AL_FATAL, al); /* * This is not really an error but the only means to for * a client to detect whether srp is supported. */ if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT); ret = SSL_TLSEXT_ERR_ALERT_FATAL; ret = -1; s->state = SSL_ST_ERR; goto end; } } #endif s->renegotiate = 2; s->state = SSL3_ST_SW_SRVR_HELLO_A; s->init_num = 0; break; case SSL3_ST_SW_SRVR_HELLO_A: case SSL3_ST_SW_SRVR_HELLO_B: ret = ssl3_send_server_hello(s); if (ret <= 0) goto end; #ifndef OPENSSL_NO_TLSEXT if (s->hit) { if (s->tlsext_ticket_expected) s->state = SSL3_ST_SW_SESSION_TICKET_A; else s->state = SSL3_ST_SW_CHANGE_A; } #else if (s->hit) s->state = SSL3_ST_SW_CHANGE_A; #endif else s->state = SSL3_ST_SW_CERT_A; s->init_num = 0; break; case SSL3_ST_SW_CERT_A: case SSL3_ST_SW_CERT_B: /* Check if it is anon DH or anon ECDH, */ /* normal PSK or KRB5 or SRP */ if (! (s->s3->tmp. new_cipher->algorithm_auth & (SSL_aNULL | SSL_aKRB5 | SSL_aSRP)) && !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { ret = ssl3_send_server_certificate(s); if (ret <= 0) goto end; #ifndef OPENSSL_NO_TLSEXT if (s->tlsext_status_expected) s->state = SSL3_ST_SW_CERT_STATUS_A; else s->state = SSL3_ST_SW_KEY_EXCH_A; } else { skip = 1; s->state = SSL3_ST_SW_KEY_EXCH_A; } #else } else skip = 1; s->state = SSL3_ST_SW_KEY_EXCH_A; #endif s->init_num = 0; break; case SSL3_ST_SW_KEY_EXCH_A: case SSL3_ST_SW_KEY_EXCH_B: alg_k = s->s3->tmp.new_cipher->algorithm_mkey; /* * clear this, it may get reset by * send_server_key_exchange */ s->s3->tmp.use_rsa_tmp = 0; /* * only send if a DH key exchange, fortezza or RSA but we have a * sign only certificate PSK: may send PSK identity hints For * ECC ciphersuites, we send a serverKeyExchange message only if * the cipher suite is either ECDH-anon or ECDHE. In other cases, * the server certificate contains the server's public key for * key exchange. */ if (0 /* * PSK: send ServerKeyExchange if PSK identity hint if * provided */ #ifndef OPENSSL_NO_PSK || ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint) #endif #ifndef OPENSSL_NO_SRP /* SRP: send ServerKeyExchange */ || (alg_k & SSL_kSRP) #endif || (alg_k & SSL_kEDH) || (alg_k & SSL_kEECDH) || ((alg_k & SSL_kRSA) && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && EVP_PKEY_size(s->cert->pkeys [SSL_PKEY_RSA_ENC].privatekey) * 8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher) ) ) ) ) { ret = ssl3_send_server_key_exchange(s); if (ret <= 0) goto end; } else skip = 1; s->state = SSL3_ST_SW_CERT_REQ_A; s->init_num = 0; break; case SSL3_ST_SW_CERT_REQ_A: case SSL3_ST_SW_CERT_REQ_B: if ( /* don't request cert unless asked for it: */ !(s->verify_mode & SSL_VERIFY_PEER) || /* * if SSL_VERIFY_CLIENT_ONCE is set, don't request cert * during re-negotiation: */ ((s->session->peer != NULL) && (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || /* * never request cert in anonymous ciphersuites (see * section "Certificate request" in SSL 3 drafts and in * RFC 2246): */ ((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) && /* * ... except when the application insists on * verification (against the specs, but s3_clnt.c accepts * this for SSL 3) */ !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) || /* * never request cert in Kerberos ciphersuites */ (s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) || /* don't request certificate for SRP auth */ (s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP) /* * With normal PSK Certificates and Certificate Requests * are omitted */ || (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) { /* no cert request */ skip = 1; s->s3->tmp.cert_request = 0; s->state = SSL3_ST_SW_SRVR_DONE_A; if (s->s3->handshake_buffer) { if (!ssl3_digest_cached_records(s)) { s->state = SSL_ST_ERR; return -1; } } } else { s->s3->tmp.cert_request = 1; ret = ssl3_send_certificate_request(s); if (ret <= 0) goto end; #ifndef NETSCAPE_HANG_BUG s->state = SSL3_ST_SW_SRVR_DONE_A; #else s->state = SSL3_ST_SW_FLUSH; s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; #endif s->init_num = 0; } break; case SSL3_ST_SW_SRVR_DONE_A: case SSL3_ST_SW_SRVR_DONE_B: ret = ssl3_send_server_done(s); if (ret <= 0) goto end; s->s3->tmp.next_state = SSL3_ST_SR_CERT_A; s->state = SSL3_ST_SW_FLUSH; s->init_num = 0; break; case SSL3_ST_SW_FLUSH: /* * This code originally checked to see if any data was pending * using BIO_CTRL_INFO and then flushed. This caused problems as * documented in PR#1939. The proposed fix doesn't completely * resolve this issue as buggy implementations of * BIO_CTRL_PENDING still exist. So instead we just flush * unconditionally. */ s->rwstate = SSL_WRITING; if (BIO_flush(s->wbio) <= 0) { ret = -1; goto end; } s->rwstate = SSL_NOTHING; s->state = s->s3->tmp.next_state; break; case SSL3_ST_SR_CERT_A: case SSL3_ST_SR_CERT_B: if (s->s3->tmp.cert_request) { ret = ssl3_get_client_certificate(s); if (ret <= 0) goto end; } s->init_num = 0; s->state = SSL3_ST_SR_KEY_EXCH_A; break; case SSL3_ST_SR_KEY_EXCH_A: case SSL3_ST_SR_KEY_EXCH_B: ret = ssl3_get_client_key_exchange(s); if (ret <= 0) goto end; if (ret == 2) { /* * For the ECDH ciphersuites when the client sends its ECDH * pub key in a certificate, the CertificateVerify message is * not sent. Also for GOST ciphersuites when the client uses * its key from the certificate for key exchange. */ #if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) s->state = SSL3_ST_SR_FINISHED_A; #else if (s->s3->next_proto_neg_seen) s->state = SSL3_ST_SR_NEXT_PROTO_A; else s->state = SSL3_ST_SR_FINISHED_A; #endif s->init_num = 0; } else if (SSL_USE_SIGALGS(s)) { s->state = SSL3_ST_SR_CERT_VRFY_A; s->init_num = 0; if (!s->session->peer) break; /* * For sigalgs freeze the handshake buffer at this point and * digest cached records. */ if (!s->s3->handshake_buffer) { SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); s->state = SSL_ST_ERR; return -1; } s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE; if (!ssl3_digest_cached_records(s)) { s->state = SSL_ST_ERR; return -1; } } else { int offset = 0; int dgst_num; s->state = SSL3_ST_SR_CERT_VRFY_A; s->init_num = 0; /* * We need to get hashes here so if there is a client cert, * it can be verified FIXME - digest processing for * CertificateVerify should be generalized. But it is next * step */ if (s->s3->handshake_buffer) { if (!ssl3_digest_cached_records(s)) { s->state = SSL_ST_ERR; return -1; } } for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++) if (s->s3->handshake_dgst[dgst_num]) { int dgst_size; s->method->ssl3_enc->cert_verify_mac(s, EVP_MD_CTX_type (s-> s3->handshake_dgst [dgst_num]), &(s->s3-> tmp.cert_verify_md [offset])); dgst_size = EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]); if (dgst_size < 0) { s->state = SSL_ST_ERR; ret = -1; goto end; } offset += dgst_size; } } break; case SSL3_ST_SR_CERT_VRFY_A: case SSL3_ST_SR_CERT_VRFY_B: ret = ssl3_get_cert_verify(s); if (ret <= 0) goto end; #if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) s->state = SSL3_ST_SR_FINISHED_A; #else if (s->s3->next_proto_neg_seen) s->state = SSL3_ST_SR_NEXT_PROTO_A; else s->state = SSL3_ST_SR_FINISHED_A; #endif s->init_num = 0; break; #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) case SSL3_ST_SR_NEXT_PROTO_A: case SSL3_ST_SR_NEXT_PROTO_B: /* * Enable CCS for NPN. Receiving a CCS clears the flag, so make * sure not to re-enable it to ban duplicates. This *should* be the * first time we have received one - but we check anyway to be * cautious. * s->s3->change_cipher_spec is set when a CCS is * processed in s3_pkt.c, and remains set until * the client's Finished message is read. */ if (!s->s3->change_cipher_spec) s->s3->flags |= SSL3_FLAGS_CCS_OK; ret = ssl3_get_next_proto(s); if (ret <= 0) goto end; s->init_num = 0; s->state = SSL3_ST_SR_FINISHED_A; break; #endif case SSL3_ST_SR_FINISHED_A: case SSL3_ST_SR_FINISHED_B: /* * Enable CCS for handshakes without NPN. In NPN the CCS flag has * already been set. Receiving a CCS clears the flag, so make * sure not to re-enable it to ban duplicates. * s->s3->change_cipher_spec is set when a CCS is * processed in s3_pkt.c, and remains set until * the client's Finished message is read. */ if (!s->s3->change_cipher_spec) s->s3->flags |= SSL3_FLAGS_CCS_OK; ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A, SSL3_ST_SR_FINISHED_B); if (ret <= 0) goto end; if (s->hit) s->state = SSL_ST_OK; #ifndef OPENSSL_NO_TLSEXT else if (s->tlsext_ticket_expected) s->state = SSL3_ST_SW_SESSION_TICKET_A; #endif else s->state = SSL3_ST_SW_CHANGE_A; s->init_num = 0; break; #ifndef OPENSSL_NO_TLSEXT case SSL3_ST_SW_SESSION_TICKET_A: case SSL3_ST_SW_SESSION_TICKET_B: ret = ssl3_send_newsession_ticket(s); if (ret <= 0) goto end; s->state = SSL3_ST_SW_CHANGE_A; s->init_num = 0; break; case SSL3_ST_SW_CERT_STATUS_A: case SSL3_ST_SW_CERT_STATUS_B: ret = ssl3_send_cert_status(s); if (ret <= 0) goto end; s->state = SSL3_ST_SW_KEY_EXCH_A; s->init_num = 0; break; #endif case SSL3_ST_SW_CHANGE_A: case SSL3_ST_SW_CHANGE_B: s->session->cipher = s->s3->tmp.new_cipher; if (!s->method->ssl3_enc->setup_key_block(s)) { ret = -1; s->state = SSL_ST_ERR; goto end; } ret = ssl3_send_change_cipher_spec(s, SSL3_ST_SW_CHANGE_A, SSL3_ST_SW_CHANGE_B); if (ret <= 0) goto end; s->state = SSL3_ST_SW_FINISHED_A; s->init_num = 0; if (!s->method->ssl3_enc->change_cipher_state(s, SSL3_CHANGE_CIPHER_SERVER_WRITE)) { ret = -1; s->state = SSL_ST_ERR; goto end; } break; case SSL3_ST_SW_FINISHED_A: case SSL3_ST_SW_FINISHED_B: ret = ssl3_send_finished(s, SSL3_ST_SW_FINISHED_A, SSL3_ST_SW_FINISHED_B, s->method-> ssl3_enc->server_finished_label, s->method-> ssl3_enc->server_finished_label_len); if (ret <= 0) goto end; s->state = SSL3_ST_SW_FLUSH; if (s->hit) { #if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG) s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; #else if (s->s3->next_proto_neg_seen) { s->s3->tmp.next_state = SSL3_ST_SR_NEXT_PROTO_A; } else s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A; #endif } else s->s3->tmp.next_state = SSL_ST_OK; s->init_num = 0; break; case SSL_ST_OK: /* clean a few things up */ ssl3_cleanup_key_block(s); BUF_MEM_free(s->init_buf); s->init_buf = NULL; /* remove buffering on output */ ssl_free_wbio_buffer(s); s->init_num = 0; if (s->renegotiate == 2) { /* skipped if we just sent a * HelloRequest */ s->renegotiate = 0; s->new_session = 0; ssl_update_cache(s, SSL_SESS_CACHE_SERVER); s->ctx->stats.sess_accept_good++; /* s->server=1; */ s->handshake_func = ssl3_accept; if (cb != NULL) cb(s, SSL_CB_HANDSHAKE_DONE, 1); } ret = 1; goto end; /* break; */ case SSL_ST_ERR: default: SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNKNOWN_STATE); ret = -1; goto end; /* break; */ } if (!s->s3->tmp.reuse_message && !skip) { if (s->debug) { if ((ret = BIO_flush(s->wbio)) <= 0) goto end; } if ((cb != NULL) && (s->state != state)) { new_state = s->state; s->state = state; cb(s, SSL_CB_ACCEPT_LOOP, 1); s->state = new_state; } } skip = 0; } Commit Message: CWE ID: CWE-362
0
13,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 udp_v4_early_demux(struct sk_buff *skb) { struct net *net = dev_net(skb->dev); const struct iphdr *iph; const struct udphdr *uh; struct sock *sk; struct dst_entry *dst; int dif = skb->dev->ifindex; /* validate the packet */ if (!pskb_may_pull(skb, skb_transport_offset(skb) + sizeof(struct udphdr))) return; iph = ip_hdr(skb); uh = udp_hdr(skb); if (skb->pkt_type == PACKET_BROADCAST || skb->pkt_type == PACKET_MULTICAST) sk = __udp4_lib_mcast_demux_lookup(net, uh->dest, iph->daddr, uh->source, iph->saddr, dif); else if (skb->pkt_type == PACKET_HOST) sk = __udp4_lib_demux_lookup(net, uh->dest, iph->daddr, uh->source, iph->saddr, dif); else return; if (!sk) return; skb->sk = sk; skb->destructor = sock_efree; dst = sk->sk_rx_dst; if (dst) dst = dst_check(dst, 0); if (dst) skb_dst_set_noref(skb, dst); } Commit Message: udp: fix behavior of wrong checksums We have two problems in UDP stack related to bogus checksums : 1) We return -EAGAIN to application even if receive queue is not empty. This breaks applications using edge trigger epoll() 2) Under UDP flood, we can loop forever without yielding to other processes, potentially hanging the host, especially on non SMP. This patch is an attempt to make things better. We might in the future add extra support for rt applications wanting to better control time spent doing a recv() in a hostile environment. For example we could validate checksums before queuing packets in socket receive queue. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-399
0
2,241
Analyze the following 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 addrconf_cleanup(void) { struct net_device *dev; int i; unregister_netdevice_notifier(&ipv6_dev_notf); unregister_pernet_subsys(&addrconf_ops); ipv6_addr_label_cleanup(); rtnl_lock(); __rtnl_af_unregister(&inet6_ops); /* clean dev list */ for_each_netdev(&init_net, dev) { if (__in6_dev_get(dev) == NULL) continue; addrconf_ifdown(dev, 1); } addrconf_ifdown(init_net.loopback_dev, 2); /* * Check hash table. */ spin_lock_bh(&addrconf_hash_lock); for (i = 0; i < IN6_ADDR_HSIZE; i++) WARN_ON(!hlist_empty(&inet6_addr_lst[i])); spin_unlock_bh(&addrconf_hash_lock); cancel_delayed_work(&addr_chk_work); rtnl_unlock(); destroy_workqueue(addrconf_wq); } Commit Message: ipv6: addrconf: validate new MTU before applying it Currently we don't check if the new MTU is valid or not and this allows one to configure a smaller than minimum allowed by RFCs or even bigger than interface own MTU, which is a problem as it may lead to packet drops. If you have a daemon like NetworkManager running, this may be exploited by remote attackers by forging RA packets with an invalid MTU, possibly leading to a DoS. (NetworkManager currently only validates for values too small, but not for too big ones.) The fix is just to make sure the new value is valid. That is, between IPV6_MIN_MTU and interface's MTU. Note that similar check is already performed at ndisc_router_discovery(), for when kernel itself parses the RA. Signed-off-by: Marcelo Ricardo Leitner <mleitner@redhat.com> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-20
0
12,275
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void ApiTestBase::SetUp() { ModuleSystemTest::SetUp(); test_env_.reset(new ApiTestEnvironment(env())); } Commit Message: [Extensions] Don't allow built-in extensions code to be overridden BUG=546677 Review URL: https://codereview.chromium.org/1417513003 Cr-Commit-Position: refs/heads/master@{#356654} CWE ID: CWE-264
0
21,907
Analyze the following 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 php_wddx_pop_element(void *user_data, const XML_Char *name) { st_entry *ent1, *ent2; wddx_stack *stack = (wddx_stack *)user_data; HashTable *target_hash; zend_class_entry **pce; zval *obj; zval *tmp; TSRMLS_FETCH(); /* OBJECTS_FIXME */ if (stack->top == 0) { return; } if (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) || !strcmp(name, EL_BOOLEAN) || !strcmp(name, EL_NULL) || !strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT) || !strcmp(name, EL_RECORDSET) || !strcmp(name, EL_BINARY) || !strcmp(name, EL_DATETIME)) { wddx_stack_top(stack, (void**)&ent1); if (!ent1->data) { if (stack->top > 1) { stack->top--; efree(ent1); } else { stack->done = 1; } return; } if (!strcmp(name, EL_BINARY)) { int new_len=0; unsigned char *new_str; new_str = php_base64_decode(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data), &new_len); STR_FREE(Z_STRVAL_P(ent1->data)); if (new_str) { Z_STRVAL_P(ent1->data) = new_str; Z_STRLEN_P(ent1->data) = new_len; } else { ZVAL_EMPTY_STRING(ent1->data); } } /* Call __wakeup() method on the object. */ if (Z_TYPE_P(ent1->data) == IS_OBJECT) { zval *fname, *retval = NULL; MAKE_STD_ZVAL(fname); ZVAL_STRING(fname, "__wakeup", 1); call_user_function_ex(NULL, &ent1->data, fname, &retval, 0, 0, 0, NULL TSRMLS_CC); zval_dtor(fname); FREE_ZVAL(fname); if (retval) { zval_ptr_dtor(&retval); } } if (stack->top > 1) { stack->top--; wddx_stack_top(stack, (void**)&ent2); /* if non-existent field */ if (ent2->data == NULL) { zval_ptr_dtor(&ent1->data); efree(ent1); return; } if (Z_TYPE_P(ent2->data) == IS_ARRAY || Z_TYPE_P(ent2->data) == IS_OBJECT) { target_hash = HASH_OF(ent2->data); if (ent1->varname) { if (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) && Z_TYPE_P(ent1->data) == IS_STRING && Z_STRLEN_P(ent1->data) && ent2->type == ST_STRUCT && Z_TYPE_P(ent2->data) == IS_ARRAY) { zend_bool incomplete_class = 0; zend_str_tolower(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data)); if (zend_hash_find(EG(class_table), Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data)+1, (void **) &pce)==FAILURE) { incomplete_class = 1; pce = &PHP_IC_ENTRY; } if (pce != &PHP_IC_ENTRY && ((*pce)->serialize || (*pce)->unserialize)) { zval_ptr_dtor(&ent2->data); ent2->data = NULL; php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class %s can not be unserialized", Z_STRVAL_P(ent1->data)); } else { /* Initialize target object */ MAKE_STD_ZVAL(obj); object_init_ex(obj, *pce); /* Merge current hashtable with object's default properties */ zend_hash_merge(Z_OBJPROP_P(obj), Z_ARRVAL_P(ent2->data), (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0); if (incomplete_class) { php_store_class_name(obj, Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data)); } /* Clean up old array entry */ zval_ptr_dtor(&ent2->data); /* Set stack entry to point to the newly created object */ ent2->data = obj; } /* Clean up class name var entry */ zval_ptr_dtor(&ent1->data); } else if (Z_TYPE_P(ent2->data) == IS_OBJECT) { zend_class_entry *old_scope = EG(scope); EG(scope) = Z_OBJCE_P(ent2->data); Z_DELREF_P(ent1->data); add_property_zval(ent2->data, ent1->varname, ent1->data); EG(scope) = old_scope; } else { zend_symtable_update(target_hash, ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL); } efree(ent1->varname); } else { zend_hash_next_index_insert(target_hash, &ent1->data, sizeof(zval *), NULL); } } efree(ent1); } else { stack->done = 1; } } else if (!strcmp(name, EL_VAR) && stack->varname) { efree(stack->varname); stack->varname = NULL; } else if (!strcmp(name, EL_FIELD)) { st_entry *ent; wddx_stack_top(stack, (void **)&ent); efree(ent); stack->top--; } } Commit Message: Fix bug #73631 - Invalid read when wddx decodes empty boolean element CWE ID: CWE-125
0
14,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: void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( const base::CommandLine& browser_cmd, base::CommandLine* renderer_cmd) { static const char* const kSwitchNames[] = { service_manager::switches::kDisableInProcessStackTraces, service_manager::switches::kDisableSeccompFilterSandbox, switches::kAgcStartupMinVolume, switches::kAecRefinedAdaptiveFilter, switches::kAllowLoopbackInPeerConnection, switches::kAndroidFontsPath, switches::kAudioBufferSize, switches::kAutoplayPolicy, switches::kBlinkSettings, switches::kDefaultTileWidth, switches::kDefaultTileHeight, switches::kDisable2dCanvasImageChromium, switches::kDisableAcceleratedJpegDecoding, switches::kDisableAcceleratedVideoDecode, switches::kDisableBackgroundTimerThrottling, switches::kDisableBreakpad, switches::kDisableCompositorUkmForTests, switches::kDisablePreferCompositingToLCDText, switches::kDisableDatabases, switches::kDisableDistanceFieldText, switches::kDisableFileSystem, switches::kDisableGpuMemoryBufferVideoFrames, switches::kDisableGpuVsync, switches::kDisableLowResTiling, switches::kDisableHistogramCustomizer, switches::kDisableLCDText, switches::kDisableLogging, switches::kDisableMediaSuspend, switches::kDisableNotifications, switches::kDisableOriginTrialControlledBlinkFeatures, switches::kDisablePepper3DImageChromium, switches::kDisablePermissionsAPI, switches::kDisablePresentationAPI, switches::kDisableRGBA4444Textures, switches::kDisableRTCSmoothnessAlgorithm, switches::kDisableSharedWorkers, switches::kDisableSkiaRuntimeOpts, switches::kDisableSpeechAPI, switches::kDisableThreadedCompositing, switches::kDisableThreadedScrolling, switches::kDisableTouchAdjustment, switches::kDisableTouchDragDrop, switches::kDisableV8IdleTasks, switches::kDisableWebGLImageChromium, switches::kDomAutomationController, switches::kEnableAutomation, switches::kEnableDistanceFieldText, switches::kEnableExperimentalCanvasFeatures, switches::kEnableExperimentalWebPlatformFeatures, switches::kEnableHeapProfiling, switches::kEnableGPUClientLogging, switches::kEnableGpuClientTracing, switches::kEnableGpuMemoryBufferVideoFrames, switches::kEnableGPUServiceLogging, switches::kEnableLowResTiling, switches::kEnableMediaSuspend, switches::kEnableInbandTextTracks, switches::kEnableLCDText, switches::kEnableLogging, switches::kEnableNetworkInformationDownlinkMax, switches::kEnableOOPRasterization, switches::kEnablePluginPlaceholderTesting, switches::kEnablePreciseMemoryInfo, switches::kEnablePrintBrowser, switches::kEnablePreferCompositingToLCDText, switches::kEnableRGBA4444Textures, switches::kEnableSkiaBenchmarking, switches::kEnableSlimmingPaintV175, switches::kEnableSlimmingPaintV2, switches::kEnableThreadedCompositing, switches::kEnableTouchDragDrop, switches::kEnableUseZoomForDSF, switches::kEnableViewport, switches::kEnableVtune, switches::kEnableWebGLDraftExtensions, switches::kEnableWebGLImageChromium, switches::kEnableWebVR, switches::kExplicitlyAllowedPorts, switches::kForceColorProfile, switches::kForceDeviceScaleFactor, switches::kForceGpuMemAvailableMb, switches::kForceGpuRasterization, switches::kForceOverlayFullscreenVideo, switches::kForceVideoOverlays, switches::kFullMemoryCrashReport, switches::kIPCConnectionTimeout, switches::kJavaScriptFlags, switches::kLoggingLevel, switches::kMaxUntiledLayerWidth, switches::kMaxUntiledLayerHeight, switches::kDisableMojoLocalStorage, switches::kMSEAudioBufferSizeLimit, switches::kMSEVideoBufferSizeLimit, switches::kNoReferrers, switches::kNoSandbox, switches::kNoZygote, switches::kOverridePluginPowerSaverForTesting, switches::kPassiveListenersDefault, switches::kPpapiInProcess, switches::kReducedReferrerGranularity, switches::kRegisterPepperPlugins, switches::kRendererStartupDialog, switches::kRootLayerScrolls, switches::kShowPaintRects, switches::kStatsCollectionController, switches::kTestType, switches::kTouchEventFeatureDetection, switches::kTouchTextSelectionStrategy, switches::kTraceConfigFile, switches::kTraceToConsole, switches::kUseFakeUIForMediaStream, switches::kUseGL, switches::kUseGpuInTests, switches::kUseMobileUserAgent, switches::kV, switches::kVideoThreads, switches::kVideoUnderflowThresholdMs, switches::kVModule, cc::switches::kDisableCompositedAntialiasing, cc::switches::kDisableThreadedAnimation, cc::switches::kEnableGpuBenchmarking, cc::switches::kEnableLayerLists, cc::switches::kEnableTileCompression, cc::switches::kShowCompositedLayerBorders, cc::switches::kShowFPSCounter, cc::switches::kShowLayerAnimationBounds, cc::switches::kShowPropertyChangedRects, cc::switches::kShowScreenSpaceRects, cc::switches::kShowSurfaceDamageRects, cc::switches::kSlowDownRasterScaleFactor, cc::switches::kBrowserControlsHideThreshold, cc::switches::kBrowserControlsShowThreshold, cc::switches::kRunAllCompositorStagesBeforeDraw, switches::kDisableSurfaceReferences, switches::kEnableSurfaceSynchronization, #if BUILDFLAG(ENABLE_PLUGINS) switches::kEnablePepperTesting, #endif #if BUILDFLAG(ENABLE_RUNTIME_MEDIA_RENDERER_SELECTION) switches::kDisableMojoRenderer, #endif #if BUILDFLAG(ENABLE_WEBRTC) switches::kDisableWebRtcHWDecoding, switches::kDisableWebRtcHWEncoding, switches::kEnableWebRtcSrtpAesGcm, switches::kEnableWebRtcSrtpEncryptedHeaders, switches::kEnableWebRtcStunOrigin, switches::kEnforceWebRtcIPPermissionCheck, switches::kWebRtcMaxCaptureFramerate, #endif switches::kEnableLowEndDeviceMode, switches::kDisableLowEndDeviceMode, switches::kDisallowNonExactResourceReuse, #if defined(OS_ANDROID) switches::kDisableMediaSessionAPI, switches::kMadviseRandomExecutableCode, switches::kRendererWaitForJavaDebugger, #endif #if defined(OS_MACOSX) switches::kEnableSandboxLogging, #endif #if defined(OS_WIN) service_manager::switches::kDisableWin32kLockDown, switches::kEnableWin7WebRtcHWH264Decoding, switches::kTrySupportedChannelLayouts, switches::kTraceExportEventsToETW, #endif #if defined(USE_OZONE) switches::kOzonePlatform, #endif #if defined(ENABLE_IPC_FUZZER) switches::kIpcDumpDirectory, switches::kIpcFuzzerTestcase, #endif #if BUILDFLAG(ENABLE_MUS) switches::kMus, switches::kMusHostingViz, #endif }; renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames, arraysize(kSwitchNames)); BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(renderer_cmd); if (browser_cmd.HasSwitch(switches::kTraceStartup) && BrowserMainLoop::GetInstance()->is_tracing_startup_for_duration()) { renderer_cmd->AppendSwitchASCII( switches::kTraceStartup, browser_cmd.GetSwitchValueASCII(switches::kTraceStartup)); } #if BUILDFLAG(ENABLE_WEBRTC) if (!has_done_stun_trials && browser_cmd.HasSwitch(switches::kWebRtcStunProbeTrialParameter)) { has_done_stun_trials = true; renderer_cmd->AppendSwitchASCII( switches::kWebRtcStunProbeTrialParameter, browser_cmd.GetSwitchValueASCII( switches::kWebRtcStunProbeTrialParameter)); } #endif if (GetBrowserContext()->IsOffTheRecord() && !browser_cmd.HasSwitch(switches::kDisableDatabases)) { renderer_cmd->AppendSwitch(switches::kDisableDatabases); } #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !BUILDFLAG(ENABLE_MUS) if (ImageTransportFactory::GetInstance()->IsGpuCompositingDisabled()) renderer_cmd->AppendSwitch(switches::kDisableGpuCompositing); #else #endif #endif if (browser_cmd.HasSwitch(switches::kWaitForDebuggerChildren)) { std::string value = browser_cmd.GetSwitchValueASCII(switches::kWaitForDebuggerChildren); if (value.empty() || value == switches::kRendererProcess) { renderer_cmd->AppendSwitch(switches::kWaitForDebugger); } } DCHECK(child_connection_); renderer_cmd->AppendSwitchASCII(service_manager::switches::kServicePipeToken, child_connection_->service_token()); #if defined(OS_WIN) && !defined(OFFICIAL_BUILD) if (renderer_cmd->HasSwitch(switches::kRendererStartupDialog) && !renderer_cmd->HasSwitch(switches::kNoSandbox)) { renderer_cmd->AppendSwitch(switches::kNoSandbox); } #endif CopyFeatureSwitch(browser_cmd, renderer_cmd, switches::kEnableBlinkFeatures); CopyFeatureSwitch(browser_cmd, renderer_cmd, switches::kDisableBlinkFeatures); } Commit Message: Correct mojo::WrapSharedMemoryHandle usage Fixes some incorrect uses of mojo::WrapSharedMemoryHandle which were assuming that the call actually has any control over the memory protection applied to a handle when mapped. Where fixing usage is infeasible for this CL, TODOs are added to annotate follow-up work. Also updates the API and documentation to (hopefully) improve clarity and avoid similar mistakes from being made in the future. BUG=792900 Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Change-Id: I0578aaa9ca3bfcb01aaf2451315d1ede95458477 Reviewed-on: https://chromium-review.googlesource.com/818282 Reviewed-by: Wei Li <weili@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: John Abd-El-Malek <jam@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org> Reviewed-by: Yuzhu Shen <yzshen@chromium.org> Reviewed-by: Robert Sesek <rsesek@chromium.org> Commit-Queue: Ken Rockot <rockot@chromium.org> Cr-Commit-Position: refs/heads/master@{#530268} CWE ID: CWE-787
0
7,817
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool PostScript_MetaHandler::ExtractContainsXMPHint(IOBuffer &ioBuf,XMP_Int64 containsXMPStartpos) { XMP_IO* fileRef = this->parent->ioRef; int xmpHint = kPSHint_NoMain; // ! From here on, a failure means "no main", not "no marker". if ( ! CheckFileSpace ( fileRef, &ioBuf, 1 ) ) return false; if ( ! IsSpaceOrTab ( *ioBuf.ptr ) ) return false; if ( ! PostScript_Support::SkipTabsAndSpaces(fileRef,ioBuf) ) return false; if ( IsNewline ( *ioBuf.ptr ) ) return false; // Reached the end of the ContainsXMP comment. if ( ! CheckFileSpace ( fileRef, &ioBuf, 6 ) ) return false ; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("NoMain"), 6 ) ) { ioBuf.ptr += 6; if ( ! PostScript_Support::SkipTabsAndSpaces(fileRef,ioBuf) ) return false; if ( ! IsNewline( *ioBuf.ptr) ) return false; this->psHint = kPSHint_NoMain; setTokenInfo(kPS_ADOContainsXMP,containsXMPStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-containsXMPStartpos); } else if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("MainFi"), 6 ) ) { ioBuf.ptr += 6; if ( ! CheckFileSpace ( fileRef, &ioBuf, 3 ) ) return false; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("rst"), 3 ) ) { ioBuf.ptr += 3; if ( ! PostScript_Support::SkipTabsAndSpaces(fileRef,ioBuf) ) return false; if ( ! IsNewline( *ioBuf.ptr) ) return false; this->psHint = kPSHint_MainFirst; setTokenInfo(kPS_ADOContainsXMP,containsXMPStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-containsXMPStartpos); containsXMPHint=true; } } else if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("MainLa"), 6 ) ) { ioBuf.ptr += 6; if ( ! CheckFileSpace ( fileRef, &ioBuf, 2 ) ) return false; if ( CheckBytes ( ioBuf.ptr, Uns8Ptr("st"), 2 ) ) { ioBuf.ptr += 2; if ( ! PostScript_Support::SkipTabsAndSpaces(fileRef,ioBuf) ) return false; if ( ! IsNewline( *ioBuf.ptr) ) return false; this->psHint = kPSHint_MainLast; setTokenInfo(kPS_ADOContainsXMP,containsXMPStartpos,ioBuf.filePos+ioBuf.ptr-ioBuf.data-containsXMPStartpos); containsXMPHint=true; } } else { if ( ! PostScript_Support::SkipUntilNewline(fileRef,ioBuf) ) return false; } return true; } Commit Message: CWE ID: CWE-125
0
13,964
Analyze the following 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 PrintTime(u64 time) { u32 ms, h, m, s; h = (u32) (time / 1000 / 3600); m = (u32) (time / 1000 / 60 - h*60); s = (u32) (time / 1000 - h*3600 - m*60); ms = (u32) (time - (h*3600 + m*60 + s) * 1000); fprintf(stderr, "%02d:%02d:%02d.%03d", h, m, s, ms); } Commit Message: add some boundary checks on gf_text_get_utf8_line (#1188) CWE ID: CWE-787
0
24,652
Analyze the following 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 load_segment_descriptor(struct x86_emulate_ctxt *ctxt, u16 selector, int seg) { struct desc_struct seg_desc; u8 dpl, rpl, cpl; unsigned err_vec = GP_VECTOR; u32 err_code = 0; bool null_selector = !(selector & ~0x3); /* 0000-0003 are null */ int ret; memset(&seg_desc, 0, sizeof seg_desc); if ((seg <= VCPU_SREG_GS && ctxt->mode == X86EMUL_MODE_VM86) || ctxt->mode == X86EMUL_MODE_REAL) { /* set real mode segment descriptor */ set_desc_base(&seg_desc, selector << 4); set_desc_limit(&seg_desc, 0xffff); seg_desc.type = 3; seg_desc.p = 1; seg_desc.s = 1; goto load; } /* NULL selector is not valid for TR, CS and SS */ if ((seg == VCPU_SREG_CS || seg == VCPU_SREG_SS || seg == VCPU_SREG_TR) && null_selector) goto exception; /* TR should be in GDT only */ if (seg == VCPU_SREG_TR && (selector & (1 << 2))) goto exception; if (null_selector) /* for NULL selector skip all following checks */ goto load; ret = read_segment_descriptor(ctxt, selector, &seg_desc); if (ret != X86EMUL_CONTINUE) return ret; err_code = selector & 0xfffc; err_vec = GP_VECTOR; /* can't load system descriptor into segment selecor */ if (seg <= VCPU_SREG_GS && !seg_desc.s) goto exception; if (!seg_desc.p) { err_vec = (seg == VCPU_SREG_SS) ? SS_VECTOR : NP_VECTOR; goto exception; } rpl = selector & 3; dpl = seg_desc.dpl; cpl = ctxt->ops->cpl(ctxt); switch (seg) { case VCPU_SREG_SS: /* * segment is not a writable data segment or segment * selector's RPL != CPL or segment selector's RPL != CPL */ if (rpl != cpl || (seg_desc.type & 0xa) != 0x2 || dpl != cpl) goto exception; break; case VCPU_SREG_CS: if (!(seg_desc.type & 8)) goto exception; if (seg_desc.type & 4) { /* conforming */ if (dpl > cpl) goto exception; } else { /* nonconforming */ if (rpl > cpl || dpl != cpl) goto exception; } /* CS(RPL) <- CPL */ selector = (selector & 0xfffc) | cpl; break; case VCPU_SREG_TR: if (seg_desc.s || (seg_desc.type != 1 && seg_desc.type != 9)) goto exception; break; case VCPU_SREG_LDTR: if (seg_desc.s || seg_desc.type != 2) goto exception; break; default: /* DS, ES, FS, or GS */ /* * segment is not a data or readable code segment or * ((segment is a data or nonconforming code segment) * and (both RPL and CPL > DPL)) */ if ((seg_desc.type & 0xa) == 0x8 || (((seg_desc.type & 0xc) != 0xc) && (rpl > dpl && cpl > dpl))) goto exception; break; } if (seg_desc.s) { /* mark segment as accessed */ seg_desc.type |= 1; ret = write_segment_descriptor(ctxt, selector, &seg_desc); if (ret != X86EMUL_CONTINUE) return ret; } load: ctxt->ops->set_segment(ctxt, selector, &seg_desc, 0, seg); return X86EMUL_CONTINUE; exception: emulate_exception(ctxt, err_vec, err_code, true); return X86EMUL_PROPAGATE_FAULT; } Commit Message: KVM: x86: fix missing checks in syscall emulation On hosts without this patch, 32bit guests will crash (and 64bit guests may behave in a wrong way) for example by simply executing following nasm-demo-application: [bits 32] global _start SECTION .text _start: syscall (I tested it with winxp and linux - both always crashed) Disassembly of section .text: 00000000 <_start>: 0: 0f 05 syscall The reason seems a missing "invalid opcode"-trap (int6) for the syscall opcode "0f05", which is not available on Intel CPUs within non-longmodes, as also on some AMD CPUs within legacy-mode. (depending on CPU vendor, MSR_EFER and cpuid) Because previous mentioned OSs may not engage corresponding syscall target-registers (STAR, LSTAR, CSTAR), they remain NULL and (non trapping) syscalls are leading to multiple faults and finally crashs. Depending on the architecture (AMD or Intel) pretended by guests, various checks according to vendor's documentation are implemented to overcome the current issue and behave like the CPUs physical counterparts. [mtosatti: cleanup/beautify code] Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> CWE ID:
0
20,767
Analyze the following 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 sas_get_phy_change_count(struct domain_device *dev, int phy_id, int *pcc) { int res; struct smp_resp *disc_resp; disc_resp = alloc_smp_resp(DISCOVER_RESP_SIZE); if (!disc_resp) return -ENOMEM; res = sas_get_phy_discover(dev, phy_id, disc_resp); if (!res) *pcc = disc_resp->disc.change_count; kfree(disc_resp); return res; } 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
9,785
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static inline int big_key_gen_enckey(u8 *key) { return crypto_rng_get_bytes(big_key_rng, key, ENC_KEY_SIZE); } Commit Message: KEYS: Sort out big_key initialisation big_key has two separate initialisation functions, one that registers the key type and one that registers the crypto. If the key type fails to register, there's no problem if the crypto registers successfully because there's no way to reach the crypto except through the key type. However, if the key type registers successfully but the crypto does not, big_key_rng and big_key_blkcipher may end up set to NULL - but the code neither checks for this nor unregisters the big key key type. Furthermore, since the key type is registered before the crypto, it is theoretically possible for the kernel to try adding a big_key before the crypto is set up, leading to the same effect. Fix this by merging big_key_crypto_init() and big_key_init() and calling the resulting function late. If they're going to be encrypted, we shouldn't be creating big_keys before we have the facilities to do the encryption available. The key type registration is also moved after the crypto initialisation. The fix also includes message printing on failure. If the big_key type isn't correctly set up, simply doing: dd if=/dev/zero bs=4096 count=1 | keyctl padd big_key a @s ought to cause an oops. Fixes: 13100a72f40f5748a04017e0ab3df4cf27c809ef ('Security: Keys: Big keys stored encrypted') Signed-off-by: David Howells <dhowells@redhat.com> cc: Peter Hlavaty <zer0mem@yahoo.com> cc: Kirill Marinushkin <k.marinushkin@gmail.com> cc: Artem Savkov <asavkov@redhat.com> cc: stable@vger.kernel.org Signed-off-by: James Morris <james.l.morris@oracle.com> CWE ID: CWE-476
0
7,575
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void nfc_llcp_unregister_device(struct nfc_dev *dev) { struct nfc_llcp_local *local = nfc_llcp_find_local(dev); if (local == NULL) { pr_debug("No such device\n"); return; } local_cleanup(local); nfc_llcp_local_put(local); } Commit Message: net: nfc: Fix NULL dereference on nfc_llcp_build_tlv fails KASAN report this: BUG: KASAN: null-ptr-deref in nfc_llcp_build_gb+0x37f/0x540 [nfc] Read of size 3 at addr 0000000000000000 by task syz-executor.0/5401 CPU: 0 PID: 5401 Comm: syz-executor.0 Not tainted 5.0.0-rc7+ #45 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xfa/0x1ce lib/dump_stack.c:113 kasan_report+0x171/0x18d mm/kasan/report.c:321 memcpy+0x1f/0x50 mm/kasan/common.c:130 nfc_llcp_build_gb+0x37f/0x540 [nfc] nfc_llcp_register_device+0x6eb/0xb50 [nfc] nfc_register_device+0x50/0x1d0 [nfc] nfcsim_device_new+0x394/0x67d [nfcsim] ? 0xffffffffc1080000 nfcsim_init+0x6b/0x1000 [nfcsim] do_one_initcall+0xfa/0x5ca init/main.c:887 do_init_module+0x204/0x5f6 kernel/module.c:3460 load_module+0x66b2/0x8570 kernel/module.c:3808 __do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902 do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x462e99 Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f9cb79dcc58 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 RAX: ffffffffffffffda RBX: 000000000073bf00 RCX: 0000000000462e99 RDX: 0000000000000000 RSI: 0000000020000280 RDI: 0000000000000003 RBP: 00007f9cb79dcc70 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f9cb79dd6bc R13: 00000000004bcefb R14: 00000000006f7030 R15: 0000000000000004 nfc_llcp_build_tlv will return NULL on fails, caller should check it, otherwise will trigger a NULL dereference. Reported-by: Hulk Robot <hulkci@huawei.com> Fixes: eda21f16a5ed ("NFC: Set MIU and RW values from CONNECT and CC LLCP frames") Fixes: d646960f7986 ("NFC: Initial LLCP support") Signed-off-by: YueHaibing <yuehaibing@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-476
0
13,614
Analyze the following 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 InputDispatcher::doNotifyANRLockedInterruptible( CommandEntry* commandEntry) { mLock.unlock(); nsecs_t newTimeout = mPolicy->notifyANR( commandEntry->inputApplicationHandle, commandEntry->inputWindowHandle, commandEntry->reason); mLock.lock(); resumeAfterTargetsNotReadyTimeoutLocked(newTimeout, commandEntry->inputWindowHandle != NULL ? commandEntry->inputWindowHandle->getInputChannel() : NULL); } Commit Message: Add new MotionEvent flag for partially obscured windows. Due to more complex window layouts resulting in lots of overlapping windows, the policy around FLAG_WINDOW_IS_OBSCURED has changed to only be set when the point at which the window was touched is obscured. Unfortunately, this doesn't prevent tapjacking attacks that overlay the dialog's text, making a potentially dangerous operation seem innocuous. To avoid this on particularly sensitive dialogs, introduce a new flag that really does tell you when your window is being even partially overlapped. We aren't exposing this as API since we plan on making the original flag more robust. This is really a workaround for system dialogs since we generally know their layout and screen position, and that they're unlikely to be overlapped by other applications. Bug: 26677796 Change-Id: I9e336afe90f262ba22015876769a9c510048fd47 CWE ID: CWE-264
0
26,852
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: SPL_METHOD(SplDoublyLinkedList, push) { zval *value; spl_dllist_object *intern; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &value) == FAILURE) { return; } intern = Z_SPLDLLIST_P(getThis()); spl_ptr_llist_push(intern->llist, value); RETURN_TRUE; } Commit Message: Fix bug #71735: Double-free in SplDoublyLinkedList::offsetSet CWE ID: CWE-415
0
13,683
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void brcmf_link_down(struct brcmf_cfg80211_vif *vif, u16 reason) { struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(vif->wdev.wiphy); s32 err = 0; brcmf_dbg(TRACE, "Enter\n"); if (test_and_clear_bit(BRCMF_VIF_STATUS_CONNECTED, &vif->sme_state)) { brcmf_dbg(INFO, "Call WLC_DISASSOC to stop excess roaming\n "); err = brcmf_fil_cmd_data_set(vif->ifp, BRCMF_C_DISASSOC, NULL, 0); if (err) { brcmf_err("WLC_DISASSOC failed (%d)\n", err); } if ((vif->wdev.iftype == NL80211_IFTYPE_STATION) || (vif->wdev.iftype == NL80211_IFTYPE_P2P_CLIENT)) cfg80211_disconnected(vif->wdev.netdev, reason, NULL, 0, true, GFP_KERNEL); } clear_bit(BRCMF_VIF_STATUS_CONNECTING, &vif->sme_state); clear_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status); brcmf_btcoex_set_mode(vif, BRCMF_BTCOEX_ENABLED, 0); if (vif->profile.use_fwsup != BRCMF_PROFILE_FWSUP_NONE) { brcmf_set_pmk(vif->ifp, NULL, 0); vif->profile.use_fwsup = BRCMF_PROFILE_FWSUP_NONE; } brcmf_dbg(TRACE, "Exit\n"); } Commit Message: brcmfmac: fix possible buffer overflow in brcmf_cfg80211_mgmt_tx() The lower level nl80211 code in cfg80211 ensures that "len" is between 25 and NL80211_ATTR_FRAME (2304). We subtract DOT11_MGMT_HDR_LEN (24) from "len" so thats's max of 2280. However, the action_frame->data[] buffer is only BRCMF_FIL_ACTION_FRAME_SIZE (1800) bytes long so this memcpy() can overflow. memcpy(action_frame->data, &buf[DOT11_MGMT_HDR_LEN], le16_to_cpu(action_frame->len)); Cc: stable@vger.kernel.org # 3.9.x Fixes: 18e2f61db3b70 ("brcmfmac: P2P action frame tx.") Reported-by: "freenerguo(郭大兴)" <freenerguo@tencent.com> Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-119
0
1,813
Analyze the following 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(pg_get_notify) { zval *pgsql_link; int id = -1; long result_type = PGSQL_ASSOC; PGconn *pgsql; PGnotify *pgsql_notify; if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &pgsql_link, &result_type) == FAILURE) { RETURN_FALSE; } ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); if (!(result_type & PGSQL_BOTH)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid result type"); RETURN_FALSE; } PQconsumeInput(pgsql); pgsql_notify = PQnotifies(pgsql); if (!pgsql_notify) { /* no notify message */ RETURN_FALSE; } array_init(return_value); if (result_type & PGSQL_NUM) { add_index_string(return_value, 0, pgsql_notify->relname, 1); add_index_long(return_value, 1, pgsql_notify->be_pid); #if HAVE_PQPROTOCOLVERSION && HAVE_PQPARAMETERSTATUS if (PQprotocolVersion(pgsql) >= 3 && atof(PQparameterStatus(pgsql, "server_version")) >= 9.0) { #else if (atof(PG_VERSION) >= 9.0) { #endif #if HAVE_PQPARAMETERSTATUS add_index_string(return_value, 2, pgsql_notify->extra, 1); #endif } } if (result_type & PGSQL_ASSOC) { add_assoc_string(return_value, "message", pgsql_notify->relname, 1); add_assoc_long(return_value, "pid", pgsql_notify->be_pid); #if HAVE_PQPROTOCOLVERSION && HAVE_PQPARAMETERSTATUS if (PQprotocolVersion(pgsql) >= 3 && atof(PQparameterStatus(pgsql, "server_version")) >= 9.0) { #else if (atof(PG_VERSION) >= 9.0) { #endif #if HAVE_PQPARAMETERSTATUS add_assoc_string(return_value, "payload", pgsql_notify->extra, 1); #endif } } PQfreemem(pgsql_notify); } /* }}} */ /* {{{ proto int pg_get_pid([resource connection) Get backend(server) pid */ PHP_FUNCTION(pg_get_pid) { zval *pgsql_link; int id = -1; PGconn *pgsql; if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "r", &pgsql_link) == FAILURE) { RETURN_FALSE; } ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); RETURN_LONG(PQbackendPID(pgsql)); } /* }}} */ /* {{{ php_pgsql_meta_data * TODO: Add meta_data cache for better performance */ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, zval *meta TSRMLS_DC) { PGresult *pg_result; char *src, *tmp_name, *tmp_name2 = NULL; char *escaped; smart_str querystr = {0}; size_t new_len; int i, num_rows; zval *elem; if (!*table_name) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The table name must be specified"); return FAILURE; } src = estrdup(table_name); tmp_name = php_strtok_r(src, ".", &tmp_name2); if (!tmp_name2 || !*tmp_name2) { /* Default schema */ tmp_name2 = tmp_name; "SELECT a.attname, a.attnum, t.typname, a.attlen, a.attnotnull, a.atthasdef, a.attndims, t.typtype = 'e' " "FROM pg_class as c, pg_attribute a, pg_type t, pg_namespace n " "WHERE a.attnum > 0 AND a.attrelid = c.oid AND c.relname = '"); escaped = (char *)safe_emalloc(strlen(tmp_name2), 2, 1); new_len = PQescapeStringConn(pg_link, escaped, tmp_name2, strlen(tmp_name2), NULL); if (new_len) { smart_str_appendl(&querystr, escaped, new_len); } efree(escaped); smart_str_appends(&querystr, "' AND c.relnamespace = n.oid AND n.nspname = '"); escaped = (char *)safe_emalloc(strlen(tmp_name), 2, 1); new_len = PQescapeStringConn(pg_link, escaped, tmp_name, strlen(tmp_name), NULL); if (new_len) { smart_str_appendl(&querystr, escaped, new_len); } efree(escaped); smart_str_appends(&querystr, "' AND a.atttypid = t.oid ORDER BY a.attnum;"); smart_str_0(&querystr); efree(src); pg_result = PQexec(pg_link, querystr.c); if (PQresultStatus(pg_result) != PGRES_TUPLES_OK || (num_rows = PQntuples(pg_result)) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Table '%s' doesn't exists", table_name); smart_str_free(&querystr); PQclear(pg_result); return FAILURE; } smart_str_free(&querystr); for (i = 0; i < num_rows; i++) { char *name; MAKE_STD_ZVAL(elem); array_init(elem); add_assoc_long(elem, "num", atoi(PQgetvalue(pg_result,i,1))); add_assoc_string(elem, "type", PQgetvalue(pg_result,i,2), 1); add_assoc_long(elem, "len", atoi(PQgetvalue(pg_result,i,3))); if (!strcmp(PQgetvalue(pg_result,i,4), "t")) { add_assoc_bool(elem, "not null", 1); } else { add_assoc_bool(elem, "not null", 0); } if (!strcmp(PQgetvalue(pg_result,i,5), "t")) { add_assoc_bool(elem, "has default", 1); } else { add_assoc_bool(elem, "has default", 0); } add_assoc_long(elem, "array dims", atoi(PQgetvalue(pg_result,i,6))); if (!strcmp(PQgetvalue(pg_result,i,7), "t")) { add_assoc_bool(elem, "is enum", 1); } else { add_assoc_bool(elem, "is enum", 0); } name = PQgetvalue(pg_result,i,0); add_assoc_zval(meta, name, elem); } PQclear(pg_result); return SUCCESS; } /* }}} */ Commit Message: CWE ID:
1
4,068
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: status_t MyOggExtractor::init() { mMeta = new MetaData; mMeta->setCString(kKeyMIMEType, mMimeType); status_t err; MediaBuffer *packet; for (size_t i = 0; i < mNumHeaders; ++i) { if ((err = _readNextPacket(&packet, /* calcVorbisTimestamp = */ false)) != OK) { return err; } ALOGV("read packet of size %zu\n", packet->range_length()); err = verifyHeader(packet, /* type = */ i * 2 + 1); packet->release(); packet = NULL; if (err != OK) { return err; } } mFirstDataOffset = mOffset + mCurrentPageSize; off64_t size; uint64_t lastGranulePosition; if (!(mSource->flags() & DataSource::kIsCachingDataSource) && mSource->getSize(&size) == OK && findPrevGranulePosition(size, &lastGranulePosition) == OK) { int64_t durationUs = getTimeUsOfGranule(lastGranulePosition); mMeta->setInt64(kKeyDuration, durationUs); buildTableOfContents(); } return OK; } Commit Message: Fix memory leak in OggExtractor Test: added a temporal log and run poc Bug: 63581671 Change-Id: I436a08e54d5e831f9fbdb33c26d15397ce1fbeba (cherry picked from commit 63079e7c8e12cda4eb124fbe565213d30b9ea34c) CWE ID: CWE-772
0
20,008
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Document::prepareForDestruction() { disconnectDescendantFrames(); if (!confusingAndOftenMisusedAttached()) return; if (DOMWindow* window = this->domWindow()) window->willDetachDocumentFromFrame(); detach(); } Commit Message: Refactoring: Move m_mayDisplaySeamlesslyWithParent down to Document The member is used only in Document, thus no reason to stay in SecurityContext. TEST=none BUG=none R=haraken@chromium.org, abarth, haraken, hayato Review URL: https://codereview.chromium.org/27615003 git-svn-id: svn://svn.chromium.org/blink/trunk@159829 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-20
0
10,173
Analyze the following 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 key *find_keyring_by_name(const char *name, bool uid_keyring) { struct key *keyring; int bucket; if (!name) return ERR_PTR(-EINVAL); bucket = keyring_hash(name); read_lock(&keyring_name_lock); if (keyring_name_hash[bucket].next) { /* search this hash bucket for a keyring with a matching name * that's readable and that hasn't been revoked */ list_for_each_entry(keyring, &keyring_name_hash[bucket], name_link ) { if (!kuid_has_mapping(current_user_ns(), keyring->user->uid)) continue; if (test_bit(KEY_FLAG_REVOKED, &keyring->flags)) continue; if (strcmp(keyring->description, name) != 0) continue; if (uid_keyring) { if (!test_bit(KEY_FLAG_UID_KEYRING, &keyring->flags)) continue; } else { if (key_permission(make_key_ref(keyring, 0), KEY_NEED_SEARCH) < 0) continue; } /* we've got a match but we might end up racing with * key_cleanup() if the keyring is currently 'dead' * (ie. it has a zero usage count) */ if (!refcount_inc_not_zero(&keyring->usage)) continue; keyring->last_used_at = current_kernel_time().tv_sec; goto out; } } keyring = ERR_PTR(-ENOKEY); out: read_unlock(&keyring_name_lock); return keyring; } Commit Message: KEYS: Fix race between updating and finding a negative key Consolidate KEY_FLAG_INSTANTIATED, KEY_FLAG_NEGATIVE and the rejection error into one field such that: (1) The instantiation state can be modified/read atomically. (2) The error can be accessed atomically with the state. (3) The error isn't stored unioned with the payload pointers. This deals with the problem that the state is spread over three different objects (two bits and a separate variable) and reading or updating them atomically isn't practical, given that not only can uninstantiated keys change into instantiated or rejected keys, but rejected keys can also turn into instantiated keys - and someone accessing the key might not be using any locking. The main side effect of this problem is that what was held in the payload may change, depending on the state. For instance, you might observe the key to be in the rejected state. You then read the cached error, but if the key semaphore wasn't locked, the key might've become instantiated between the two reads - and you might now have something in hand that isn't actually an error code. The state is now KEY_IS_UNINSTANTIATED, KEY_IS_POSITIVE or a negative error code if the key is negatively instantiated. The key_is_instantiated() function is replaced with key_is_positive() to avoid confusion as negative keys are also 'instantiated'. Additionally, barriering is included: (1) Order payload-set before state-set during instantiation. (2) Order state-read before payload-read when using the key. Further separate barriering is necessary if RCU is being used to access the payload content after reading the payload pointers. Fixes: 146aa8b1453b ("KEYS: Merge the type-specific data with the payload data") Cc: stable@vger.kernel.org # v4.4+ Reported-by: Eric Biggers <ebiggers@google.com> Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Eric Biggers <ebiggers@google.com> CWE ID: CWE-20
0
14,195
Analyze the following 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 proc_maps_open(struct inode *inode, struct file *file, const struct seq_operations *ops, int psize) { struct proc_maps_private *priv = __seq_open_private(file, ops, psize); if (!priv) return -ENOMEM; priv->inode = inode; priv->mm = proc_mem_open(inode, PTRACE_MODE_READ); if (IS_ERR(priv->mm)) { int err = PTR_ERR(priv->mm); seq_release_private(inode, file); return err; } return 0; } Commit Message: pagemap: do not leak physical addresses to non-privileged userspace As pointed by recent post[1] on exploiting DRAM physical imperfection, /proc/PID/pagemap exposes sensitive information which can be used to do attacks. This disallows anybody without CAP_SYS_ADMIN to read the pagemap. [1] http://googleprojectzero.blogspot.com/2015/03/exploiting-dram-rowhammer-bug-to-gain.html [ Eventually we might want to do anything more finegrained, but for now this is the simple model. - Linus ] Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Konstantin Khlebnikov <khlebnikov@openvz.org> Acked-by: Andy Lutomirski <luto@amacapital.net> Cc: Pavel Emelyanov <xemul@parallels.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Mark Seaborn <mseaborn@chromium.org> Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID: CWE-200
0
19,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: void radeon_restore_bios_scratch_regs(struct radeon_device *rdev) { uint32_t scratch_reg; int i; if (rdev->family >= CHIP_R600) scratch_reg = R600_BIOS_0_SCRATCH; else scratch_reg = RADEON_BIOS_0_SCRATCH; for (i = 0; i < RADEON_BIOS_NUM_SCRATCH; i++) WREG32(scratch_reg + (i * 4), rdev->bios_scratch[i]); } Commit Message: drivers/gpu/drm/radeon/radeon_atombios.c: range check issues This change makes the array larger, "MAX_SUPPORTED_TV_TIMING_V1_2" is 3 and the original size "MAX_SUPPORTED_TV_TIMING" is 2. Also there were checks that were off by one. Signed-off-by: Dan Carpenter <error27@gmail.com> Acked-by: Alex Deucher <alexdeucher@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Dave Airlie <airlied@redhat.com> CWE ID: CWE-119
0
16,807
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: send_smtp_trap(const char *node, const char *rsc, const char *task, int target_rc, int rc, int status, const char *desc) { #if ENABLE_ESMTP smtp_session_t session; smtp_message_t message; auth_context_t authctx; struct sigaction sa; int len = 20; int noauth = 1; int smtp_debug = LOG_DEBUG; char crm_mail_body[BODY_MAX]; char *crm_mail_subject = NULL; memset(&sa, 0, sizeof(struct sigaction)); if (node == NULL) { node = "-"; } if (rsc == NULL) { rsc = "-"; } if (desc == NULL) { desc = "-"; } if (crm_mail_to == NULL) { return 1; } if (crm_mail_host == NULL) { crm_mail_host = "localhost:25"; } if (crm_mail_prefix == NULL) { crm_mail_prefix = "Cluster notification"; } crm_debug("Sending '%s' mail to %s via %s", crm_mail_prefix, crm_mail_to, crm_mail_host); len += strlen(crm_mail_prefix); len += strlen(task); len += strlen(rsc); len += strlen(node); len += strlen(desc); len++; crm_mail_subject = calloc(1, len); snprintf(crm_mail_subject, len, "%s - %s event for %s on %s: %s\r\n", crm_mail_prefix, task, rsc, node, desc); len = 0; len += snprintf(crm_mail_body + len, BODY_MAX - len, "\r\n%s\r\n", crm_mail_prefix); len += snprintf(crm_mail_body + len, BODY_MAX - len, "====\r\n\r\n"); if (rc == target_rc) { len += snprintf(crm_mail_body + len, BODY_MAX - len, "Completed operation %s for resource %s on %s\r\n", task, rsc, node); } else { len += snprintf(crm_mail_body + len, BODY_MAX - len, "Operation %s for resource %s on %s failed: %s\r\n", task, rsc, node, desc); } len += snprintf(crm_mail_body + len, BODY_MAX - len, "\r\nDetails:\r\n"); len += snprintf(crm_mail_body + len, BODY_MAX - len, "\toperation status: (%d) %s\r\n", status, services_lrm_status_str(status)); if (status == PCMK_LRM_OP_DONE) { len += snprintf(crm_mail_body + len, BODY_MAX - len, "\tscript returned: (%d) %s\r\n", rc, lrmd_event_rc2str(rc)); len += snprintf(crm_mail_body + len, BODY_MAX - len, "\texpected return value: (%d) %s\r\n", target_rc, lrmd_event_rc2str(target_rc)); } auth_client_init(); session = smtp_create_session(); message = smtp_add_message(session); smtp_starttls_enable(session, Starttls_ENABLED); sa.sa_handler = SIG_IGN; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGPIPE, &sa, NULL); smtp_set_server(session, crm_mail_host); authctx = auth_create_context(); auth_set_mechanism_flags(authctx, AUTH_PLUGIN_PLAIN, 0); smtp_set_eventcb(session, event_cb, NULL); /* Now tell libESMTP it can use the SMTP AUTH extension. */ if (!noauth) { crm_debug("Adding authentication context"); smtp_auth_set_context(session, authctx); } if (crm_mail_from == NULL) { struct utsname us; char auto_from[BODY_MAX]; CRM_ASSERT(uname(&us) == 0); snprintf(auto_from, BODY_MAX, "crm_mon@%s", us.nodename); smtp_set_reverse_path(message, auto_from); } else { /* NULL is ok */ smtp_set_reverse_path(message, crm_mail_from); } smtp_set_header(message, "To", NULL /*phrase */ , NULL /*addr */ ); /* "Phrase" <addr> */ smtp_add_recipient(message, crm_mail_to); /* Set the Subject: header and override any subject line in the message headers. */ smtp_set_header(message, "Subject", crm_mail_subject); smtp_set_header_option(message, "Subject", Hdr_OVERRIDE, 1); smtp_set_message_str(message, crm_mail_body); smtp_set_monitorcb(session, crm_smtp_debug, &smtp_debug, 1); if (smtp_start_session(session)) { char buf[128]; int rc = smtp_errno(); crm_err("SMTP server problem: %s (%d)", smtp_strerror(rc, buf, sizeof buf), rc); } else { char buf[128]; int rc = smtp_errno(); const smtp_status_t *smtp_status = smtp_message_transfer_status(message); if (rc != 0) { crm_err("SMTP server problem: %s (%d)", smtp_strerror(rc, buf, sizeof buf), rc); } crm_info("Send status: %d %s", smtp_status->code, crm_str(smtp_status->text)); smtp_enumerate_recipients(message, print_recipient_status, NULL); } smtp_destroy_session(session); auth_destroy_context(authctx); auth_client_exit(); #endif return 0; } Commit Message: High: core: Internal tls api improvements for reuse with future LRMD tls backend. CWE ID: CWE-399
0
20,548
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: pfn_t gfn_to_pfn_memslot_atomic(struct kvm_memory_slot *slot, gfn_t gfn) { return __gfn_to_pfn_memslot(slot, gfn, true, NULL, true, NULL); } Commit Message: KVM: perform an invalid memslot step for gpa base change PPC must flush all translations before the new memory slot is visible. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com> CWE ID: CWE-399
0
10,176
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Browser::TabDetachedAtImpl(content::WebContents* contents, int index, DetachType type) { if (type == DETACH_TYPE_DETACH) { if (contents == tab_strip_model_->GetActiveWebContents()) { LocationBar* location_bar = window()->GetLocationBar(); if (location_bar) location_bar->SaveStateToContents(contents); } if (!tab_strip_model_->closing_all()) SyncHistoryWithTabs(0); } SetAsDelegate(contents, false); RemoveScheduledUpdatesFor(contents); if (find_bar_controller_.get() && index == tab_strip_model_->active_index()) { find_bar_controller_->ChangeWebContents(NULL); } search_delegate_->OnTabDetached(contents); for (size_t i = 0; i < interstitial_observers_.size(); i++) { if (interstitial_observers_[i]->web_contents() != contents) continue; delete interstitial_observers_[i]; interstitial_observers_.erase(interstitial_observers_.begin() + i); return; } } Commit Message: Don't focus the location bar for NTP navigations in non-selected tabs. BUG=677716 TEST=See bug for repro steps. Review-Url: https://codereview.chromium.org/2624373002 Cr-Commit-Position: refs/heads/master@{#443338} CWE ID:
0
29,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: int skcipher_walk_aead(struct skcipher_walk *walk, struct aead_request *req, bool atomic) { walk->total = req->cryptlen; return skcipher_walk_aead_common(walk, req, atomic); } Commit Message: crypto: skcipher - Add missing API setkey checks The API setkey checks for key sizes and alignment went AWOL during the skcipher conversion. This patch restores them. Cc: <stable@vger.kernel.org> Fixes: 4e6c3df4d729 ("crypto: skcipher - Add low-level skcipher...") Reported-by: Baozeng <sploving1@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> CWE ID: CWE-476
0
12,677
Analyze the following 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_get_wrappers) { HashTable *url_stream_wrappers_hash; char *stream_protocol; int key_flags; uint stream_protocol_len = 0; ulong num_key; if (zend_parse_parameters_none() == FAILURE) { return; } if ((url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash())) { HashPosition pos; array_init(return_value); for (zend_hash_internal_pointer_reset_ex(url_stream_wrappers_hash, &pos); (key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTANT; zend_hash_move_forward_ex(url_stream_wrappers_hash, &pos)) { if (key_flags == HASH_KEY_IS_STRING) { add_next_index_stringl(return_value, stream_protocol, stream_protocol_len - 1, 1); } } } else { RETURN_FALSE; } } Commit Message: CWE ID: CWE-254
0
16,661
Analyze the following 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 __init postgresql_init(void) { dissect_add("postgresql", APP_LAYER_TCP, 5432, dissector_postgresql); } Commit Message: Fixed heap overflow caused by length CWE ID: CWE-119
0
14,418
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void ServiceWorkerContainer::dispatchMessageEvent(WebPassOwnPtr<WebServiceWorker::Handle> handle, const WebString& message, const WebMessagePortChannelArray& webChannels) { if (!getExecutionContext() || !getExecutionContext()->executingWindow()) return; MessagePortArray* ports = MessagePort::toMessagePortArray(getExecutionContext(), webChannels); RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance().createFromWire(message); ServiceWorker* source = ServiceWorker::from(getExecutionContext(), handle.release()); dispatchEvent(ServiceWorkerMessageEvent::create(ports, value, source, getExecutionContext()->getSecurityOrigin()->toString())); } Commit Message: Check CSP before registering ServiceWorkers Service Worker registrations should be subject to the same CSP checks as other workers. The spec doesn't say this explicitly (https://www.w3.org/TR/CSP2/#directive-child-src-workers says "Worker or SharedWorker constructors"), but it seems to be in the spirit of things, and it matches Firefox's behavior. BUG=579801 Review URL: https://codereview.chromium.org/1861253004 Cr-Commit-Position: refs/heads/master@{#385775} CWE ID: CWE-284
0
26,312
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: trash_files (CommonJob *job, GList *files, int *files_skipped) { GList *l; GFile *file; GList *to_delete; SourceInfo source_info; TransferInfo transfer_info; gboolean skipped_file; if (job_aborted (job)) { return; } scan_sources (files, &source_info, job, OP_KIND_TRASH); if (job_aborted (job)) { return; } g_timer_start (job->time); memset (&transfer_info, 0, sizeof (transfer_info)); report_trash_progress (job, &source_info, &transfer_info); to_delete = NULL; for (l = files; l != NULL && !job_aborted (job); l = l->next) { file = l->data; skipped_file = FALSE; trash_file (job, file, &skipped_file, &source_info, &transfer_info, TRUE, &to_delete); if (skipped_file) { (*files_skipped)++; transfer_add_file_to_count (file, job, &transfer_info); report_trash_progress (job, &source_info, &transfer_info); } } if (to_delete) { to_delete = g_list_reverse (to_delete); delete_files (job, to_delete, files_skipped); g_list_free (to_delete); } } Commit Message: mime-actions: use file metadata for trusting desktop files Currently we only trust desktop files that have the executable bit set, and don't replace the displayed icon or the displayed name until it's trusted, which prevents for running random programs by a malicious desktop file. However, the executable permission is preserved if the desktop file comes from a compressed file. To prevent this, add a metadata::trusted metadata to the file once the user acknowledges the file as trusted. This adds metadata to the file, which cannot be added unless it has access to the computer. Also remove the SHEBANG "trusted" content we were putting inside the desktop file, since that doesn't add more security since it can come with the file itself. https://bugzilla.gnome.org/show_bug.cgi?id=777991 CWE ID: CWE-20
0
146
Analyze the following 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 stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples) { float **outputs; int n=0; int z = f->channels; if (z > channels) z = channels; while (n < num_samples) { int i; int k = f->channel_buffer_end - f->channel_buffer_start; if (n+k >= num_samples) k = num_samples - n; if (k) { for (i=0; i < z; ++i) memcpy(buffer[i]+n, f->channel_buffers[i]+f->channel_buffer_start, sizeof(float)*k); for ( ; i < channels; ++i) memset(buffer[i]+n, 0, sizeof(float) * k); } n += k; f->channel_buffer_start += k; if (n == num_samples) break; if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; } return n; } Commit Message: fix unchecked length in stb_vorbis that could crash on corrupt/invalid files CWE ID: CWE-119
0
1,758
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: gfx::Rect BrowserWindowGtk::GetBounds() const { return bounds_; } 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
5,896
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { auto it = binding_sets_.find(interface_name); if (it != binding_sets_.end()) binding_sets_.erase(it); } Commit Message: If JavaScript shows a dialog, cause the page to lose fullscreen. BUG=670135, 550017, 726761, 728276 Review-Url: https://codereview.chromium.org/2906133004 Cr-Commit-Position: refs/heads/master@{#478884} CWE ID: CWE-20
0
21,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: int hns_rcb_common_init_hw(struct rcb_common_cb *rcb_common) { u32 reg_val; int i; int port_num = hns_rcb_common_get_port_num(rcb_common); hns_rcb_comm_exc_irq_en(rcb_common, 0); reg_val = dsaf_read_dev(rcb_common, RCB_COM_CFG_INIT_FLAG_REG); if (0x1 != (reg_val & 0x1)) { dev_err(rcb_common->dsaf_dev->dev, "RCB_COM_CFG_INIT_FLAG_REG reg = 0x%x\n", reg_val); return -EBUSY; } for (i = 0; i < port_num; i++) { hns_rcb_set_port_desc_cnt(rcb_common, i, rcb_common->desc_num); hns_rcb_set_rx_coalesced_frames( rcb_common, i, HNS_RCB_DEF_RX_COALESCED_FRAMES); if (!AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver) && !HNS_DSAF_IS_DEBUG(rcb_common->dsaf_dev)) hns_rcb_set_tx_coalesced_frames( rcb_common, i, HNS_RCB_DEF_TX_COALESCED_FRAMES); hns_rcb_set_port_timeout( rcb_common, i, HNS_RCB_DEF_COALESCED_USECS); } dsaf_write_dev(rcb_common, RCB_COM_CFG_ENDIAN_REG, HNS_RCB_COMMON_ENDIAN); if (AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver)) { dsaf_write_dev(rcb_common, RCB_COM_CFG_FNA_REG, 0x0); dsaf_write_dev(rcb_common, RCB_COM_CFG_FA_REG, 0x1); } else { dsaf_set_dev_bit(rcb_common, RCBV2_COM_CFG_USER_REG, RCB_COM_CFG_FNA_B, false); dsaf_set_dev_bit(rcb_common, RCBV2_COM_CFG_USER_REG, RCB_COM_CFG_FA_B, true); dsaf_set_dev_bit(rcb_common, RCBV2_COM_CFG_TSO_MODE_REG, RCB_COM_TSO_MODE_B, HNS_TSO_MODE_8BD_32K); } return 0; } Commit Message: net: hns: fix ethtool_get_strings overflow in hns driver hns_get_sset_count() returns HNS_NET_STATS_CNT and the data space allocated is not enough for ethtool_get_strings(), which will cause random memory corruption. When SLAB and DEBUG_SLAB are both enabled, memory corruptions like the the following can be observed without this patch: [ 43.115200] Slab corruption (Not tainted): Acpi-ParseExt start=ffff801fb0b69030, len=80 [ 43.115206] Redzone: 0x9f911029d006462/0x5f78745f31657070. [ 43.115208] Last user: [<5f7272655f746b70>](0x5f7272655f746b70) [ 43.115214] 010: 70 70 65 31 5f 74 78 5f 70 6b 74 00 6b 6b 6b 6b ppe1_tx_pkt.kkkk [ 43.115217] 030: 70 70 65 31 5f 74 78 5f 70 6b 74 5f 6f 6b 00 6b ppe1_tx_pkt_ok.k [ 43.115218] Next obj: start=ffff801fb0b69098, len=80 [ 43.115220] Redzone: 0x706d655f6f666966/0x9f911029d74e35b. [ 43.115229] Last user: [<ffff0000084b11b0>](acpi_os_release_object+0x28/0x38) [ 43.115231] 000: 74 79 00 6b 6b 6b 6b 6b 70 70 65 31 5f 74 78 5f ty.kkkkkppe1_tx_ [ 43.115232] 010: 70 6b 74 5f 65 72 72 5f 63 73 75 6d 5f 66 61 69 pkt_err_csum_fai Signed-off-by: Timmy Li <lixiaoping3@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-119
0
5,895
Analyze the following 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_msgq_add_buffer (struct t_irc_server *server, const char *buffer) { char *pos_cr, *pos_lf; while (buffer[0]) { pos_cr = strchr (buffer, '\r'); pos_lf = strchr (buffer, '\n'); if (!pos_cr && !pos_lf) { /* no CR/LF found => add to unterminated and return */ irc_server_msgq_add_unterminated (server, buffer); return; } if (pos_cr && ((!pos_lf) || (pos_lf > pos_cr))) { /* found '\r' first => ignore this char */ pos_cr[0] = '\0'; irc_server_msgq_add_unterminated (server, buffer); buffer = pos_cr + 1; } else { /* found: '\n' first => terminate message */ pos_lf[0] = '\0'; irc_server_msgq_add_msg (server, buffer); buffer = pos_lf + 1; } } } Commit Message: CWE ID: CWE-20
0
6,983
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: epass2003_hook_file(struct sc_file *file, int inc) { int fidl = file->id & 0xff; int fidh = file->id & 0xff00; if (epass2003_hook_path(&file->path, inc)) { if (inc) file->id = fidh + fidl * FID_STEP; else file->id = fidh + fidl / FID_STEP; } } 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
19,597
Analyze the following 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::JSOutOfMemory(TabContents* tab) { JSOutOfMemoryHelper(tab); } Commit Message: Implement a bubble that appears at the top of the screen when a tab enters fullscreen mode via webkitRequestFullScreen(), telling the user how to exit fullscreen. This is implemented as an NSView rather than an NSWindow because the floating chrome that appears in presentation mode should overlap the bubble. Content-initiated fullscreen mode makes use of 'presentation mode' on the Mac: the mode in which the UI is hidden, accessible by moving the cursor to the top of the screen. On Snow Leopard, this mode is synonymous with fullscreen mode. On Lion, however, fullscreen mode does not imply presentation mode: in non-presentation fullscreen mode, the chrome is permanently shown. It is possible to switch between presentation mode and fullscreen mode using the presentation mode UI control. When a tab initiates fullscreen mode on Lion, we enter presentation mode if not in presentation mode already. When the user exits fullscreen mode using Chrome UI (i.e. keyboard shortcuts, menu items, buttons, switching tabs, etc.) we return the user to the mode they were in before the tab entered fullscreen. BUG=14471 TEST=Enter fullscreen mode using webkitRequestFullScreen. You should see a bubble pop down from the top of the screen. Need to test the Lion logic somehow, with no Lion trybots. BUG=96883 Original review http://codereview.chromium.org/7890056/ TBR=thakis Review URL: http://codereview.chromium.org/7920024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101624 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-119
0
22,783
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void kvm_vcpu_reset(struct kvm_vcpu *vcpu) { atomic_set(&vcpu->arch.nmi_queued, 0); vcpu->arch.nmi_pending = 0; vcpu->arch.nmi_injected = false; memset(vcpu->arch.db, 0, sizeof(vcpu->arch.db)); vcpu->arch.dr6 = DR6_FIXED_1; vcpu->arch.dr7 = DR7_FIXED_1; kvm_update_dr7(vcpu); kvm_make_request(KVM_REQ_EVENT, vcpu); vcpu->arch.apf.msr_val = 0; vcpu->arch.st.msr_val = 0; kvmclock_reset(vcpu); kvm_clear_async_pf_completion_queue(vcpu); kvm_async_pf_hash_reset(vcpu); vcpu->arch.apf.halted = false; kvm_pmu_reset(vcpu); memset(vcpu->arch.regs, 0, sizeof(vcpu->arch.regs)); vcpu->arch.regs_avail = ~0; vcpu->arch.regs_dirty = ~0; kvm_x86_ops->vcpu_reset(vcpu); } Commit Message: KVM: x86: Convert vapic synchronization to _cached functions (CVE-2013-6368) In kvm_lapic_sync_from_vapic and kvm_lapic_sync_to_vapic there is the potential to corrupt kernel memory if userspace provides an address that is at the end of a page. This patches concerts those functions to use kvm_write_guest_cached and kvm_read_guest_cached. It also checks the vapic_address specified by userspace during ioctl processing and returns an error to userspace if the address is not a valid GPA. This is generally not guest triggerable, because the required write is done by firmware that runs before the guest. Also, it only affects AMD processors and oldish Intel that do not have the FlexPriority feature (unless you disable FlexPriority, of course; then newer processors are also affected). Fixes: b93463aa59d6 ('KVM: Accelerated apic support') Reported-by: Andrew Honig <ahonig@google.com> Cc: stable@vger.kernel.org Signed-off-by: Andrew Honig <ahonig@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> CWE ID: CWE-20
0
13,156
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static struct page *new_page_node(struct page *p, unsigned long private, int **result) { struct page_to_node *pm = (struct page_to_node *)private; while (pm->node != MAX_NUMNODES && pm->page != p) pm++; if (pm->node == MAX_NUMNODES) return NULL; *result = &pm->status; if (PageHuge(p)) return alloc_huge_page_node(page_hstate(compound_head(p)), pm->node); else return __alloc_pages_node(pm->node, GFP_HIGHUSER_MOVABLE | __GFP_THISNODE, 0); } Commit Message: mm: migrate dirty page without clear_page_dirty_for_io etc clear_page_dirty_for_io() has accumulated writeback and memcg subtleties since v2.6.16 first introduced page migration; and the set_page_dirty() which completed its migration of PageDirty, later had to be moderated to __set_page_dirty_nobuffers(); then PageSwapBacked had to skip that too. No actual problems seen with this procedure recently, but if you look into what the clear_page_dirty_for_io(page)+set_page_dirty(newpage) is actually achieving, it turns out to be nothing more than moving the PageDirty flag, and its NR_FILE_DIRTY stat from one zone to another. It would be good to avoid a pile of irrelevant decrementations and incrementations, and improper event counting, and unnecessary descent of the radix_tree under tree_lock (to set the PAGECACHE_TAG_DIRTY which radix_tree_replace_slot() left in place anyway). Do the NR_FILE_DIRTY movement, like the other stats movements, while interrupts still disabled in migrate_page_move_mapping(); and don't even bother if the zone is the same. Do the PageDirty movement there under tree_lock too, where old page is frozen and newpage not yet visible: bearing in mind that as soon as newpage becomes visible in radix_tree, an un-page-locked set_page_dirty() might interfere (or perhaps that's just not possible: anything doing so should already hold an additional reference to the old page, preventing its migration; but play safe). But we do still need to transfer PageDirty in migrate_page_copy(), for those who don't go the mapping route through migrate_page_move_mapping(). Signed-off-by: Hugh Dickins <hughd@google.com> Cc: Christoph Lameter <cl@linux.com> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Rik van Riel <riel@redhat.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Sasha Levin <sasha.levin@oracle.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID: CWE-476
0
1,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: bool PluginObserver::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(PluginObserver, message) IPC_MESSAGE_HANDLER(ViewHostMsg_MissingPluginStatus, OnMissingPluginStatus) IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) IPC_MESSAGE_HANDLER(ViewHostMsg_BlockedOutdatedPlugin, OnBlockedOutdatedPlugin) IPC_MESSAGE_UNHANDLED(return false) IPC_END_MESSAGE_MAP() return true; } Commit Message: Infobar Windows Media Player plug-in by default. BUG=51464 Review URL: http://codereview.chromium.org/7080048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87500 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-264
0
4,070
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: iakerb_make_token(iakerb_ctx_id_t ctx, krb5_data *realm, krb5_data *cookie, krb5_data *request, int initialContextToken, gss_buffer_t token) { krb5_error_code code; krb5_iakerb_header iah; krb5_data *data = NULL; char *p; unsigned int tokenSize; unsigned char *q; token->value = NULL; token->length = 0; /* * Assemble the IAKERB-HEADER from the realm and cookie */ memset(&iah, 0, sizeof(iah)); iah.target_realm = *realm; iah.cookie = cookie; code = encode_krb5_iakerb_header(&iah, &data); if (code != 0) goto cleanup; /* * Concatenate Kerberos request. */ p = realloc(data->data, data->length + request->length); if (p == NULL) { code = ENOMEM; goto cleanup; } data->data = p; if (request->length > 0) memcpy(data->data + data->length, request->data, request->length); data->length += request->length; if (initialContextToken) tokenSize = g_token_size(gss_mech_iakerb, data->length); else tokenSize = 2 + data->length; token->value = q = gssalloc_malloc(tokenSize); if (q == NULL) { code = ENOMEM; goto cleanup; } token->length = tokenSize; if (initialContextToken) { g_make_token_header(gss_mech_iakerb, data->length, &q, IAKERB_TOK_PROXY); } else { store_16_be(IAKERB_TOK_PROXY, q); q += 2; } memcpy(q, data->data, data->length); q += data->length; assert(q == (unsigned char *)token->value + token->length); cleanup: krb5_free_data(ctx->k5c, data); return code; } Commit Message: Fix IAKERB context export/import [CVE-2015-2698] The patches for CVE-2015-2696 contained a regression in the newly added IAKERB iakerb_gss_export_sec_context() function, which could cause it to corrupt memory. Fix the regression by properly dereferencing the context_handle pointer before casting it. Also, the patches did not implement an IAKERB gss_import_sec_context() function, under the erroneous belief that an exported IAKERB context would be tagged as a krb5 context. Implement it now to allow IAKERB contexts to be successfully exported and imported after establishment. CVE-2015-2698: In any MIT krb5 release with the patches for CVE-2015-2696 applied, an application which calls gss_export_sec_context() may experience memory corruption if the context was established using the IAKERB mechanism. Historically, some vulnerabilities of this nature can be translated into remote code execution, though the necessary exploits must be tailored to the individual application and are usually quite complicated. CVSSv2 Vector: AV:N/AC:H/Au:S/C:C/I:C/A:C/E:POC/RL:OF/RC:C ticket: 8273 (new) target_version: 1.14 tags: pullup CWE ID: CWE-119
0
27,506
Analyze the following 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 pdf_run_gs_SMask(fz_context *ctx, pdf_processor *proc, pdf_xobject *smask, pdf_obj *page_resources, float *bc, int luminosity) { pdf_run_processor *pr = (pdf_run_processor *)proc; pdf_gstate *gstate = pdf_flush_text(ctx, pr); int i; if (gstate->softmask) { pdf_drop_xobject(ctx, gstate->softmask); gstate->softmask = NULL; pdf_drop_obj(ctx, gstate->softmask_resources); gstate->softmask_resources = NULL; } if (smask) { fz_colorspace *cs = pdf_xobject_colorspace(ctx, smask); int cs_n = 1; if (cs) cs_n = fz_colorspace_n(ctx, cs); gstate->softmask_ctm = gstate->ctm; gstate->softmask = pdf_keep_xobject(ctx, smask); gstate->softmask_resources = pdf_keep_obj(ctx, page_resources); for (i = 0; i < cs_n; ++i) gstate->softmask_bc[i] = bc[i]; gstate->luminosity = luminosity; fz_drop_colorspace(ctx, cs); } } Commit Message: CWE ID: CWE-416
0
14,927
Analyze the following 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 HTMLFormControlElement::NameForAutofill() const { String full_name = GetName(); String trimmed_name = full_name.StripWhiteSpace(); if (!trimmed_name.IsEmpty()) return trimmed_name; full_name = GetIdAttribute(); trimmed_name = full_name.StripWhiteSpace(); return trimmed_name; } Commit Message: autofocus: Fix a crash with an autofocus element in a document without browsing context. ShouldAutofocus() should check existence of the browsing context. Otherwise, doc.TopFrameOrigin() returns null. Before crrev.com/695830, ShouldAutofocus() was called only for rendered elements. That is to say, the document always had browsing context. Bug: 1003228 Change-Id: I2a941c34e9707d44869a6d7585dc7fb9f06e3bf4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1800902 Commit-Queue: Kent Tamura <tkent@chromium.org> Reviewed-by: Keishi Hattori <keishi@chromium.org> Cr-Commit-Position: refs/heads/master@{#696291} CWE ID: CWE-704
0
13,370
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void Document::setDesignMode(InheritedBool value) { m_designMode = value; for (Frame* frame = m_frame; frame && frame->document(); frame = frame->tree()->traverseNext(m_frame)) frame->document()->setNeedsStyleRecalc(); } Commit Message: Refactoring: Move m_mayDisplaySeamlesslyWithParent down to Document The member is used only in Document, thus no reason to stay in SecurityContext. TEST=none BUG=none R=haraken@chromium.org, abarth, haraken, hayato Review URL: https://codereview.chromium.org/27615003 git-svn-id: svn://svn.chromium.org/blink/trunk@159829 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-20
0
20,140