instruction
stringclasses
1 value
input
stringlengths
56
241k
output
int64
0
1
__index_level_0__
int64
0
175k
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void CorePageLoadMetricsObserver::OnDomContentLoadedEventStart( const page_load_metrics::PageLoadTiming& timing, const page_load_metrics::PageLoadExtraInfo& info) { if (WasStartedInForegroundOptionalEventInForeground( timing.dom_content_loaded_event_start, info)) { PAGE_LOAD_HISTOGRAM(internal::kHistogramDomContentLoadedImmediate, timing.dom_content_loaded_event_start.value()); } else { PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramDomContentLoadedImmediate, timing.dom_content_loaded_event_start.value()); } } Commit Message: Remove clock resolution page load histograms. These were temporary metrics intended to understand whether high/low resolution clocks adversely impact page load metrics. After collecting a few months of data it was determined that clock resolution doesn't adversely impact our metrics, and it that these histograms were no longer needed. BUG=394757 Review-Url: https://codereview.chromium.org/2155143003 Cr-Commit-Position: refs/heads/master@{#406143} CWE ID:
0
121,093
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void coroutine_fn v9fs_symlink(void *opaque) { V9fsPDU *pdu = opaque; V9fsString name; V9fsString symname; V9fsFidState *dfidp; V9fsQID qid; struct stat stbuf; int32_t dfid; int err = 0; gid_t gid; size_t offset = 7; v9fs_string_init(&name); v9fs_string_init(&symname); err = pdu_unmarshal(pdu, offset, "dssd", &dfid, &name, &symname, &gid); if (err < 0) { goto out_nofid; } trace_v9fs_symlink(pdu->tag, pdu->id, dfid, name.data, symname.data, gid); if (name_is_illegal(name.data)) { err = -ENOENT; goto out_nofid; } if (!strcmp(".", name.data) || !strcmp("..", name.data)) { err = -EEXIST; goto out_nofid; } dfidp = get_fid(pdu, dfid); if (dfidp == NULL) { err = -EINVAL; goto out_nofid; } err = v9fs_co_symlink(pdu, dfidp, &name, symname.data, gid, &stbuf); if (err < 0) { goto out; } stat_to_qid(&stbuf, &qid); err = pdu_marshal(pdu, offset, "Q", &qid); if (err < 0) { goto out; } err += offset; trace_v9fs_symlink_return(pdu->tag, pdu->id, qid.type, qid.version, qid.path); out: put_fid(pdu, dfidp); out_nofid: pdu_complete(pdu, err); v9fs_string_free(&name); v9fs_string_free(&symname); } Commit Message: CWE ID: CWE-362
0
1,513
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int __init ux500_cryp_mod_init(void) { pr_debug("[%s] is called!", __func__); klist_init(&driver_data.device_list, NULL, NULL); /* Initialize the semaphore to 0 devices (locked state) */ sema_init(&driver_data.device_allocation, 0); return platform_driver_register(&cryp_driver); } Commit Message: crypto: prefix module autoloading with "crypto-" This prefixes all crypto module loading with "crypto-" so we never run the risk of exposing module auto-loading to userspace via a crypto API, as demonstrated by Mathias Krause: https://lkml.org/lkml/2013/3/4/70 Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> CWE ID: CWE-264
0
47,512
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void InputHandlerProxy::ScrollEndForSnapFling() { cc::ScrollState scroll_state = CreateScrollStateForInertialEnd(); input_handler_->ScrollEnd(&scroll_state, false); } Commit Message: Revert "Add explicit flag for compositor scrollbar injected gestures" This reverts commit d9a56afcbdf9850bc39bb3edb56d07d11a1eb2b2. Reason for revert: Findit (https://goo.gl/kROfz5) identified CL at revision 669086 as the culprit for flakes in the build cycles as shown on: https://analysis.chromium.org/p/chromium/flake-portal/analysis/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyQwsSDEZsYWtlQ3VscHJpdCIxY2hyb21pdW0vZDlhNTZhZmNiZGY5ODUwYmMzOWJiM2VkYjU2ZDA3ZDExYTFlYjJiMgw Sample Failed Build: https://ci.chromium.org/buildbot/chromium.chromiumos/linux-chromeos-rel/25818 Sample Failed Step: content_browsertests on Ubuntu-16.04 Sample Flaky Test: ScrollLatencyScrollbarBrowserTest.ScrollbarThumbDragLatency Original change's description: > Add explicit flag for compositor scrollbar injected gestures > > The original change to enable scrollbar latency for the composited > scrollbars incorrectly used an existing member to try and determine > whether a GestureScrollUpdate was the first one in an injected sequence > or not. is_first_gesture_scroll_update_ was incorrect because it is only > updated when input is actually dispatched to InputHandlerProxy, and the > flag is cleared for all GSUs before the location where it was being > read. > > This bug was missed because of incorrect tests. The > VerifyRecordedSamplesForHistogram method doesn't actually assert or > expect anything - the return value must be inspected. > > As part of fixing up the tests, I made a few other changes to get them > passing consistently across all platforms: > - turn on main thread scrollbar injection feature (in case it's ever > turned off we don't want the tests to start failing) > - enable mock scrollbars > - disable smooth scrolling > - don't run scrollbar tests on Android > > The composited scrollbar button test is disabled due to a bug in how > the mock theme reports its button sizes, which throws off the region > detection in ScrollbarLayerImplBase::IdentifyScrollbarPart (filed > crbug.com/974063 for this issue). > > Change-Id: Ie1a762a5f6ecc264d22f0256db68f141fc76b950 > > Bug: 954007 > Change-Id: Ib258e08e083e79da90ba2e4e4216e4879cf00cf7 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1652741 > Commit-Queue: Daniel Libby <dlibby@microsoft.com> > Reviewed-by: David Bokan <bokan@chromium.org> > Cr-Commit-Position: refs/heads/master@{#669086} Change-Id: Icc743e48fa740fe27f0cb0cfa21b209a696f518c No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 954007 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1660114 Cr-Commit-Position: refs/heads/master@{#669150} CWE ID: CWE-281
0
137,984
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void BrowserRenderProcessHost::OnRevealFolderInOS(const FilePath& path) { if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(id(), path)) content::GetContentClient()->browser()->RevealFolderInOS(path); } Commit Message: DevTools: move DevToolsAgent/Client into content. BUG=84078 TEST= Review URL: http://codereview.chromium.org/7461019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93596 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
98,802
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void limitedWithInvalidMissingDefaultAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) { TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); TestObjectPythonV8Internal::limitedWithInvalidMissingDefaultAttributeAttributeGetter(info); TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); } Commit Message: document.location bindings fix BUG=352374 R=jochen@chromium.org Review URL: https://codereview.chromium.org/196343011 git-svn-id: svn://svn.chromium.org/blink/trunk@169176 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-399
0
122,359
Analyze the following 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 WebRuntimeFeatures::IsOriginTrialsEnabled() { return RuntimeEnabledFeatures::OriginTrialsEnabled(); } 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
154,714
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: dhcp6opt_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) { const struct dhcp6opt *dh6o; const u_char *tp; size_t i; uint16_t opttype; size_t optlen; uint8_t auth_proto; u_int authinfolen, authrealmlen; int remain_len; /* Length of remaining options */ int label_len; /* Label length */ uint16_t subopt_code; uint16_t subopt_len; if (cp == ep) return; while (cp < ep) { if (ep < cp + sizeof(*dh6o)) goto trunc; dh6o = (const struct dhcp6opt *)cp; ND_TCHECK(*dh6o); optlen = EXTRACT_16BITS(&dh6o->dh6opt_len); if (ep < cp + sizeof(*dh6o) + optlen) goto trunc; opttype = EXTRACT_16BITS(&dh6o->dh6opt_type); ND_PRINT((ndo, " (%s", tok2str(dh6opt_str, "opt_%u", opttype))); ND_TCHECK2(*(cp + sizeof(*dh6o)), optlen); switch (opttype) { case DH6OPT_CLIENTID: case DH6OPT_SERVERID: if (optlen < 2) { /*(*/ ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); switch (EXTRACT_16BITS(tp)) { case 1: if (optlen >= 2 + 6) { ND_PRINT((ndo, " hwaddr/time type %u time %u ", EXTRACT_16BITS(&tp[2]), EXTRACT_32BITS(&tp[4]))); for (i = 8; i < optlen; i++) ND_PRINT((ndo, "%02x", tp[i])); /*(*/ ND_PRINT((ndo, ")")); } else { /*(*/ ND_PRINT((ndo, " ?)")); } break; case 2: if (optlen >= 2 + 8) { ND_PRINT((ndo, " vid ")); for (i = 2; i < 2 + 8; i++) ND_PRINT((ndo, "%02x", tp[i])); /*(*/ ND_PRINT((ndo, ")")); } else { /*(*/ ND_PRINT((ndo, " ?)")); } break; case 3: if (optlen >= 2 + 2) { ND_PRINT((ndo, " hwaddr type %u ", EXTRACT_16BITS(&tp[2]))); for (i = 4; i < optlen; i++) ND_PRINT((ndo, "%02x", tp[i])); /*(*/ ND_PRINT((ndo, ")")); } else { /*(*/ ND_PRINT((ndo, " ?)")); } break; default: ND_PRINT((ndo, " type %d)", EXTRACT_16BITS(tp))); break; } break; case DH6OPT_IA_ADDR: if (optlen < 24) { /*(*/ ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[0]))); ND_PRINT((ndo, " pltime:%u vltime:%u", EXTRACT_32BITS(&tp[16]), EXTRACT_32BITS(&tp[20]))); if (optlen > 24) { /* there are sub-options */ dhcp6opt_print(ndo, tp + 24, tp + optlen); } ND_PRINT((ndo, ")")); break; case DH6OPT_ORO: case DH6OPT_ERO: if (optlen % 2) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); for (i = 0; i < optlen; i += 2) { ND_PRINT((ndo, " %s", tok2str(dh6opt_str, "opt_%u", EXTRACT_16BITS(&tp[i])))); } ND_PRINT((ndo, ")")); break; case DH6OPT_PREFERENCE: if (optlen != 1) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); ND_PRINT((ndo, " %d)", *tp)); break; case DH6OPT_ELAPSED_TIME: if (optlen != 2) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); ND_PRINT((ndo, " %d)", EXTRACT_16BITS(tp))); break; case DH6OPT_RELAY_MSG: ND_PRINT((ndo, " (")); tp = (const u_char *)(dh6o + 1); dhcp6_print(ndo, tp, optlen); ND_PRINT((ndo, ")")); break; case DH6OPT_AUTH: if (optlen < 11) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); auth_proto = *tp; switch (auth_proto) { case DH6OPT_AUTHPROTO_DELAYED: ND_PRINT((ndo, " proto: delayed")); break; case DH6OPT_AUTHPROTO_RECONFIG: ND_PRINT((ndo, " proto: reconfigure")); break; default: ND_PRINT((ndo, " proto: %d", auth_proto)); break; } tp++; switch (*tp) { case DH6OPT_AUTHALG_HMACMD5: /* XXX: may depend on the protocol */ ND_PRINT((ndo, ", alg: HMAC-MD5")); break; default: ND_PRINT((ndo, ", alg: %d", *tp)); break; } tp++; switch (*tp) { case DH6OPT_AUTHRDM_MONOCOUNTER: ND_PRINT((ndo, ", RDM: mono")); break; default: ND_PRINT((ndo, ", RDM: %d", *tp)); break; } tp++; ND_PRINT((ndo, ", RD:")); for (i = 0; i < 4; i++, tp += 2) ND_PRINT((ndo, " %04x", EXTRACT_16BITS(tp))); /* protocol dependent part */ authinfolen = optlen - 11; switch (auth_proto) { case DH6OPT_AUTHPROTO_DELAYED: if (authinfolen == 0) break; if (authinfolen < 20) { ND_PRINT((ndo, " ??")); break; } authrealmlen = authinfolen - 20; if (authrealmlen > 0) { ND_PRINT((ndo, ", realm: ")); } for (i = 0; i < authrealmlen; i++, tp++) ND_PRINT((ndo, "%02x", *tp)); ND_PRINT((ndo, ", key ID: %08x", EXTRACT_32BITS(tp))); tp += 4; ND_PRINT((ndo, ", HMAC-MD5:")); for (i = 0; i < 4; i++, tp+= 4) ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tp))); break; case DH6OPT_AUTHPROTO_RECONFIG: if (authinfolen != 17) { ND_PRINT((ndo, " ??")); break; } switch (*tp++) { case DH6OPT_AUTHRECONFIG_KEY: ND_PRINT((ndo, " reconfig-key")); break; case DH6OPT_AUTHRECONFIG_HMACMD5: ND_PRINT((ndo, " type: HMAC-MD5")); break; default: ND_PRINT((ndo, " type: ??")); break; } ND_PRINT((ndo, " value:")); for (i = 0; i < 4; i++, tp+= 4) ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tp))); break; default: ND_PRINT((ndo, " ??")); break; } ND_PRINT((ndo, ")")); break; case DH6OPT_RAPID_COMMIT: /* nothing todo */ ND_PRINT((ndo, ")")); break; case DH6OPT_INTERFACE_ID: case DH6OPT_SUBSCRIBER_ID: /* * Since we cannot predict the encoding, print hex dump * at most 10 characters. */ tp = (const u_char *)(dh6o + 1); ND_PRINT((ndo, " ")); for (i = 0; i < optlen && i < 10; i++) ND_PRINT((ndo, "%02x", tp[i])); ND_PRINT((ndo, "...)")); break; case DH6OPT_RECONF_MSG: tp = (const u_char *)(dh6o + 1); switch (*tp) { case DH6_RENEW: ND_PRINT((ndo, " for renew)")); break; case DH6_INFORM_REQ: ND_PRINT((ndo, " for inf-req)")); break; default: ND_PRINT((ndo, " for ?\?\?(%02x))", *tp)); break; } break; case DH6OPT_RECONF_ACCEPT: /* nothing todo */ ND_PRINT((ndo, ")")); break; case DH6OPT_SIP_SERVER_A: case DH6OPT_DNS_SERVERS: case DH6OPT_SNTP_SERVERS: case DH6OPT_NIS_SERVERS: case DH6OPT_NISP_SERVERS: case DH6OPT_BCMCS_SERVER_A: case DH6OPT_PANA_AGENT: case DH6OPT_LQ_CLIENT_LINK: if (optlen % 16) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); for (i = 0; i < optlen; i += 16) ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[i]))); ND_PRINT((ndo, ")")); break; case DH6OPT_SIP_SERVER_D: case DH6OPT_DOMAIN_LIST: tp = (const u_char *)(dh6o + 1); while (tp < cp + sizeof(*dh6o) + optlen) { ND_PRINT((ndo, " ")); if ((tp = ns_nprint(ndo, tp, cp + sizeof(*dh6o) + optlen)) == NULL) goto trunc; } ND_PRINT((ndo, ")")); break; case DH6OPT_STATUS_CODE: if (optlen < 2) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); ND_PRINT((ndo, " %s)", dhcp6stcode(EXTRACT_16BITS(&tp[0])))); break; case DH6OPT_IA_NA: case DH6OPT_IA_PD: if (optlen < 12) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); ND_PRINT((ndo, " IAID:%u T1:%u T2:%u", EXTRACT_32BITS(&tp[0]), EXTRACT_32BITS(&tp[4]), EXTRACT_32BITS(&tp[8]))); if (optlen > 12) { /* there are sub-options */ dhcp6opt_print(ndo, tp + 12, tp + optlen); } ND_PRINT((ndo, ")")); break; case DH6OPT_IA_TA: if (optlen < 4) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); ND_PRINT((ndo, " IAID:%u", EXTRACT_32BITS(tp))); if (optlen > 4) { /* there are sub-options */ dhcp6opt_print(ndo, tp + 4, tp + optlen); } ND_PRINT((ndo, ")")); break; case DH6OPT_IA_PD_PREFIX: if (optlen < 25) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); ND_PRINT((ndo, " %s/%d", ip6addr_string(ndo, &tp[9]), tp[8])); ND_PRINT((ndo, " pltime:%u vltime:%u", EXTRACT_32BITS(&tp[0]), EXTRACT_32BITS(&tp[4]))); if (optlen > 25) { /* there are sub-options */ dhcp6opt_print(ndo, tp + 25, tp + optlen); } ND_PRINT((ndo, ")")); break; case DH6OPT_LIFETIME: case DH6OPT_CLT_TIME: if (optlen != 4) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); ND_PRINT((ndo, " %d)", EXTRACT_32BITS(tp))); break; case DH6OPT_REMOTE_ID: if (optlen < 4) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); ND_PRINT((ndo, " %d ", EXTRACT_32BITS(tp))); /* * Print hex dump first 10 characters. */ for (i = 4; i < optlen && i < 14; i++) ND_PRINT((ndo, "%02x", tp[i])); ND_PRINT((ndo, "...)")); break; case DH6OPT_LQ_QUERY: if (optlen < 17) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); switch (*tp) { case 1: ND_PRINT((ndo, " by-address")); break; case 2: ND_PRINT((ndo, " by-clientID")); break; default: ND_PRINT((ndo, " type_%d", (int)*tp)); break; } ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[1]))); if (optlen > 17) { /* there are query-options */ dhcp6opt_print(ndo, tp + 17, tp + optlen); } ND_PRINT((ndo, ")")); break; case DH6OPT_CLIENT_DATA: tp = (const u_char *)(dh6o + 1); if (optlen > 0) { /* there are encapsulated options */ dhcp6opt_print(ndo, tp, tp + optlen); } ND_PRINT((ndo, ")")); break; case DH6OPT_LQ_RELAY_DATA: if (optlen < 16) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); ND_PRINT((ndo, " %s ", ip6addr_string(ndo, &tp[0]))); /* * Print hex dump first 10 characters. */ for (i = 16; i < optlen && i < 26; i++) ND_PRINT((ndo, "%02x", tp[i])); ND_PRINT((ndo, "...)")); break; case DH6OPT_NTP_SERVER: if (optlen < 4) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); while (tp < cp + sizeof(*dh6o) + optlen - 4) { subopt_code = EXTRACT_16BITS(tp); tp += 2; subopt_len = EXTRACT_16BITS(tp); tp += 2; if (tp + subopt_len > cp + sizeof(*dh6o) + optlen) goto trunc; ND_PRINT((ndo, " subopt:%d", subopt_code)); switch (subopt_code) { case DH6OPT_NTP_SUBOPTION_SRV_ADDR: case DH6OPT_NTP_SUBOPTION_MC_ADDR: if (subopt_len != 16) { ND_PRINT((ndo, " ?")); break; } ND_PRINT((ndo, " %s", ip6addr_string(ndo, &tp[0]))); break; case DH6OPT_NTP_SUBOPTION_SRV_FQDN: ND_PRINT((ndo, " ")); if (ns_nprint(ndo, tp, tp + subopt_len) == NULL) goto trunc; break; default: ND_PRINT((ndo, " ?")); break; } tp += subopt_len; } ND_PRINT((ndo, ")")); break; case DH6OPT_AFTR_NAME: if (optlen < 3) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); remain_len = optlen; ND_PRINT((ndo, " ")); /* Encoding is described in section 3.1 of RFC 1035 */ while (remain_len && *tp) { label_len = *tp++; if (label_len < remain_len - 1) { (void)fn_printn(ndo, tp, label_len, NULL); tp += label_len; remain_len -= (label_len + 1); if(*tp) ND_PRINT((ndo, ".")); } else { ND_PRINT((ndo, " ?")); break; } } ND_PRINT((ndo, ")")); break; case DH6OPT_NEW_POSIX_TIMEZONE: /* all three of these options */ case DH6OPT_NEW_TZDB_TIMEZONE: /* are encoded similarly */ case DH6OPT_MUDURL: /* although GMT might not work */ if (optlen < 5) { ND_PRINT((ndo, " ?)")); break; } tp = (const u_char *)(dh6o + 1); ND_PRINT((ndo, "=")); (void)fn_printn(ndo, tp, (u_int)optlen, NULL); ND_PRINT((ndo, ")")); break; default: ND_PRINT((ndo, ")")); break; } cp += sizeof(*dh6o) + optlen; } return; trunc: ND_PRINT((ndo, "[|dhcp6ext]")); } Commit Message: CVE-2017-13017/DHCPv6: Add a missing option length check. This fixes a buffer over-read discovered by Bhargava Shastry, SecT/TU Berlin. Add a test using the capture file supplied by the reporter(s), modified so the capture file won't be rejected as an invalid capture. CWE ID: CWE-125
1
167,875
Analyze the following 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 tracing_clock_show(struct seq_file *m, void *v) { struct trace_array *tr = m->private; int i; for (i = 0; i < ARRAY_SIZE(trace_clocks); i++) seq_printf(m, "%s%s%s%s", i ? " " : "", i == tr->clock_id ? "[" : "", trace_clocks[i].name, i == tr->clock_id ? "]" : ""); seq_putc(m, '\n'); return 0; } Commit Message: Merge tag 'trace-v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace Pull tracing fixes from Steven Rostedt: "This contains a few fixes and a clean up. - a bad merge caused an "endif" to go in the wrong place in scripts/Makefile.build - softirq tracing fix for tracing that corrupts lockdep and causes a false splat - histogram documentation typo fixes - fix a bad memory reference when passing in no filter to the filter code - simplify code by using the swap macro instead of open coding the swap" * tag 'trace-v4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Fix SKIP_STACK_VALIDATION=1 build due to bad merge with -mrecord-mcount tracing: Fix some errors in histogram documentation tracing: Use swap macro in update_max_tr softirq: Reorder trace_softirqs_on to prevent lockdep splat tracing: Check for no filter when processing event filters CWE ID: CWE-787
0
81,460
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: DOMWindow* V8Proxy::retrieveWindow(v8::Handle<v8::Context> context) { v8::Handle<v8::Object> global = context->Global(); ASSERT(!global.IsEmpty()); global = V8DOMWrapper::lookupDOMWrapper(V8DOMWindow::GetTemplate(), global); ASSERT(!global.IsEmpty()); return V8DOMWindow::toNative(global); } Commit Message: [V8] Pass Isolate to throwNotEnoughArgumentsError() https://bugs.webkit.org/show_bug.cgi?id=86983 Reviewed by Adam Barth. The objective is to pass Isolate around in V8 bindings. This patch passes Isolate to throwNotEnoughArgumentsError(). No tests. No change in behavior. * bindings/scripts/CodeGeneratorV8.pm: (GenerateArgumentsCountCheck): (GenerateEventConstructorCallback): * bindings/scripts/test/V8/V8Float64Array.cpp: (WebCore::Float64ArrayV8Internal::fooCallback): * bindings/scripts/test/V8/V8TestActiveDOMObject.cpp: (WebCore::TestActiveDOMObjectV8Internal::excitingFunctionCallback): (WebCore::TestActiveDOMObjectV8Internal::postMessageCallback): * bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp: (WebCore::TestCustomNamedGetterV8Internal::anotherFunctionCallback): * bindings/scripts/test/V8/V8TestEventConstructor.cpp: (WebCore::V8TestEventConstructor::constructorCallback): * bindings/scripts/test/V8/V8TestEventTarget.cpp: (WebCore::TestEventTargetV8Internal::itemCallback): (WebCore::TestEventTargetV8Internal::dispatchEventCallback): * bindings/scripts/test/V8/V8TestInterface.cpp: (WebCore::TestInterfaceV8Internal::supplementalMethod2Callback): (WebCore::V8TestInterface::constructorCallback): * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp: (WebCore::TestMediaQueryListListenerV8Internal::methodCallback): * bindings/scripts/test/V8/V8TestNamedConstructor.cpp: (WebCore::V8TestNamedConstructorConstructorCallback): * bindings/scripts/test/V8/V8TestObj.cpp: (WebCore::TestObjV8Internal::voidMethodWithArgsCallback): (WebCore::TestObjV8Internal::intMethodWithArgsCallback): (WebCore::TestObjV8Internal::objMethodWithArgsCallback): (WebCore::TestObjV8Internal::methodWithSequenceArgCallback): (WebCore::TestObjV8Internal::methodReturningSequenceCallback): (WebCore::TestObjV8Internal::methodThatRequiresAllArgsAndThrowsCallback): (WebCore::TestObjV8Internal::serializedValueCallback): (WebCore::TestObjV8Internal::idbKeyCallback): (WebCore::TestObjV8Internal::optionsObjectCallback): (WebCore::TestObjV8Internal::methodWithNonOptionalArgAndOptionalArgCallback): (WebCore::TestObjV8Internal::methodWithNonOptionalArgAndTwoOptionalArgsCallback): (WebCore::TestObjV8Internal::methodWithCallbackArgCallback): (WebCore::TestObjV8Internal::methodWithNonCallbackArgAndCallbackArgCallback): (WebCore::TestObjV8Internal::overloadedMethod1Callback): (WebCore::TestObjV8Internal::overloadedMethod2Callback): (WebCore::TestObjV8Internal::overloadedMethod3Callback): (WebCore::TestObjV8Internal::overloadedMethod4Callback): (WebCore::TestObjV8Internal::overloadedMethod5Callback): (WebCore::TestObjV8Internal::overloadedMethod6Callback): (WebCore::TestObjV8Internal::overloadedMethod7Callback): (WebCore::TestObjV8Internal::overloadedMethod11Callback): (WebCore::TestObjV8Internal::overloadedMethod12Callback): (WebCore::TestObjV8Internal::enabledAtRuntimeMethod1Callback): (WebCore::TestObjV8Internal::enabledAtRuntimeMethod2Callback): (WebCore::TestObjV8Internal::convert1Callback): (WebCore::TestObjV8Internal::convert2Callback): (WebCore::TestObjV8Internal::convert3Callback): (WebCore::TestObjV8Internal::convert4Callback): (WebCore::TestObjV8Internal::convert5Callback): (WebCore::TestObjV8Internal::strictFunctionCallback): (WebCore::V8TestObj::constructorCallback): * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp: (WebCore::TestSerializedScriptValueInterfaceV8Internal::acceptTransferListCallback): (WebCore::V8TestSerializedScriptValueInterface::constructorCallback): * bindings/v8/ScriptController.cpp: (WebCore::setValueAndClosePopupCallback): * bindings/v8/V8Proxy.cpp: (WebCore::V8Proxy::throwNotEnoughArgumentsError): * bindings/v8/V8Proxy.h: (V8Proxy): * bindings/v8/custom/V8AudioContextCustom.cpp: (WebCore::V8AudioContext::constructorCallback): * bindings/v8/custom/V8DataViewCustom.cpp: (WebCore::V8DataView::getInt8Callback): (WebCore::V8DataView::getUint8Callback): (WebCore::V8DataView::setInt8Callback): (WebCore::V8DataView::setUint8Callback): * bindings/v8/custom/V8DirectoryEntryCustom.cpp: (WebCore::V8DirectoryEntry::getDirectoryCallback): (WebCore::V8DirectoryEntry::getFileCallback): * bindings/v8/custom/V8IntentConstructor.cpp: (WebCore::V8Intent::constructorCallback): * bindings/v8/custom/V8SVGLengthCustom.cpp: (WebCore::V8SVGLength::convertToSpecifiedUnitsCallback): * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp: (WebCore::getObjectParameter): (WebCore::V8WebGLRenderingContext::getAttachedShadersCallback): (WebCore::V8WebGLRenderingContext::getExtensionCallback): (WebCore::V8WebGLRenderingContext::getFramebufferAttachmentParameterCallback): (WebCore::V8WebGLRenderingContext::getParameterCallback): (WebCore::V8WebGLRenderingContext::getProgramParameterCallback): (WebCore::V8WebGLRenderingContext::getShaderParameterCallback): (WebCore::V8WebGLRenderingContext::getUniformCallback): (WebCore::vertexAttribAndUniformHelperf): (WebCore::uniformHelperi): (WebCore::uniformMatrixHelper): * bindings/v8/custom/V8WebKitMutationObserverCustom.cpp: (WebCore::V8WebKitMutationObserver::constructorCallback): (WebCore::V8WebKitMutationObserver::observeCallback): * bindings/v8/custom/V8WebSocketCustom.cpp: (WebCore::V8WebSocket::constructorCallback): (WebCore::V8WebSocket::sendCallback): * bindings/v8/custom/V8XMLHttpRequestCustom.cpp: (WebCore::V8XMLHttpRequest::openCallback): git-svn-id: svn://svn.chromium.org/blink/trunk@117736 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID:
0
109,759
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: gs_currentdevice(const gs_gstate * pgs) { return pgs->device; } Commit Message: CWE ID: CWE-78
0
2,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: _gcry_cipher_gcm_encrypt (gcry_cipher_hd_t c, byte *outbuf, size_t outbuflen, const byte *inbuf, size_t inbuflen) { static const unsigned char zerobuf[MAX_BLOCKSIZE]; gcry_err_code_t err; if (c->spec->blocksize != GCRY_GCM_BLOCK_LEN) return GPG_ERR_CIPHER_ALGO; if (outbuflen < inbuflen) return GPG_ERR_BUFFER_TOO_SHORT; if (c->u_mode.gcm.datalen_over_limits) return GPG_ERR_INV_LENGTH; if (c->marks.tag || c->u_mode.gcm.ghash_data_finalized || !c->u_mode.gcm.ghash_fn) return GPG_ERR_INV_STATE; if (!c->marks.iv) _gcry_cipher_gcm_setiv (c, zerobuf, GCRY_GCM_BLOCK_LEN); if (c->u_mode.gcm.disallow_encryption_because_of_setiv_in_fips_mode) return GPG_ERR_INV_STATE; if (!c->u_mode.gcm.ghash_aad_finalized) { /* Start of encryption marks end of AAD stream. */ do_ghash_buf(c, c->u_mode.gcm.u_tag.tag, NULL, 0, 1); c->u_mode.gcm.ghash_aad_finalized = 1; } gcm_bytecounter_add(c->u_mode.gcm.datalen, inbuflen); if (!gcm_check_datalen(c->u_mode.gcm.datalen)) { c->u_mode.gcm.datalen_over_limits = 1; return GPG_ERR_INV_LENGTH; } while (inbuflen) { size_t currlen = inbuflen; /* Since checksumming is done after encryption, process input in 24KiB * chunks to keep data loaded in L1 cache for checksumming. */ if (currlen > 24 * 1024) currlen = 24 * 1024; err = gcm_ctr_encrypt(c, outbuf, outbuflen, inbuf, currlen); if (err != 0) return err; do_ghash_buf(c, c->u_mode.gcm.u_tag.tag, outbuf, currlen, 0); outbuf += currlen; inbuf += currlen; outbuflen -= currlen; inbuflen -= currlen; } return 0; } Commit Message: GCM: move look-up table to .data section and unshare between processes * cipher/cipher-gcm.c (ATTR_ALIGNED_64): New. (gcmR): Move to 'gcm_table' structure. (gcm_table): New structure for look-up table with counters before and after. (gcmR): New macro. (prefetch_table): Handle input with length not multiple of 256. (do_prefetch_tables): Modify pre- and post-table counters to unshare look-up table pages between processes. -- GnuPG-bug-id: 4541 Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi> CWE ID: CWE-310
0
89,604
Analyze the following 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 *Type_UcrBg_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag) { cmsUcrBg* n = (cmsUcrBg*) _cmsMallocZero(self ->ContextID, sizeof(cmsUcrBg)); cmsUInt32Number CountUcr, CountBg; char* ASCIIString; *nItems = 0; if (n == NULL) return NULL; if (!_cmsReadUInt32Number(io, &CountUcr)) return NULL; if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL; SizeOfTag -= sizeof(cmsUInt32Number); n ->Ucr = cmsBuildTabulatedToneCurve16(self ->ContextID, CountUcr, NULL); if (n ->Ucr == NULL) return NULL; if (!_cmsReadUInt16Array(io, CountUcr, n ->Ucr->Table16)) return NULL; if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL; SizeOfTag -= CountUcr * sizeof(cmsUInt16Number); if (!_cmsReadUInt32Number(io, &CountBg)) return NULL; if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL; SizeOfTag -= sizeof(cmsUInt32Number); n ->Bg = cmsBuildTabulatedToneCurve16(self ->ContextID, CountBg, NULL); if (n ->Bg == NULL) return NULL; if (!_cmsReadUInt16Array(io, CountBg, n ->Bg->Table16)) return NULL; if (SizeOfTag < CountBg * sizeof(cmsUInt16Number)) return NULL; SizeOfTag -= CountBg * sizeof(cmsUInt16Number); if (SizeOfTag == UINT_MAX) return NULL; n ->Desc = cmsMLUalloc(self ->ContextID, 1); if (n ->Desc == NULL) return NULL; ASCIIString = (char*) _cmsMalloc(self ->ContextID, SizeOfTag + 1); if (io ->Read(io, ASCIIString, sizeof(char), SizeOfTag) != SizeOfTag) return NULL; ASCIIString[SizeOfTag] = 0; cmsMLUsetASCII(n ->Desc, cmsNoLanguage, cmsNoCountry, ASCIIString); _cmsFree(self ->ContextID, ASCIIString); *nItems = 1; return (void*) n; } Commit Message: Added an extra check to MLU bounds Thanks to Ibrahim el-sayed for spotting the bug CWE ID: CWE-125
0
71,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: static struct net_device *netdev_next_lower_dev(struct net_device *dev, struct list_head **iter) { struct netdev_adjacent *lower; lower = list_entry((*iter)->next, struct netdev_adjacent, list); if (&lower->list == &dev->adj_list.lower) return NULL; *iter = &lower->list; return lower->dev; } Commit Message: tun: call dev_get_valid_name() before register_netdevice() register_netdevice() could fail early when we have an invalid dev name, in which case ->ndo_uninit() is not called. For tun device, this is a problem because a timer etc. are already initialized and it expects ->ndo_uninit() to clean them up. We could move these initializations into a ->ndo_init() so that register_netdevice() knows better, however this is still complicated due to the logic in tun_detach(). Therefore, I choose to just call dev_get_valid_name() before register_netdevice(), which is quicker and much easier to audit. And for this specific case, it is already enough. Fixes: 96442e42429e ("tuntap: choose the txq based on rxq") Reported-by: Dmitry Alexeev <avekceeb@gmail.com> Cc: Jason Wang <jasowang@redhat.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-476
0
93,423
Analyze the following 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 id_create(void *ptr) { static int id = 0; id_link(++id, ptr); return id; } Commit Message: Support all the new variables added CWE ID: CWE-264
0
27,194
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static unsigned int fanout_demux_cpu(struct packet_fanout *f, struct sk_buff *skb, unsigned int num) { return smp_processor_id() % num; } Commit Message: net: rework recvmsg handler msg_name and msg_namelen logic This patch now always passes msg->msg_namelen as 0. recvmsg handlers must set msg_namelen to the proper size <= sizeof(struct sockaddr_storage) to return msg_name to the user. This prevents numerous uninitialized memory leaks we had in the recvmsg handlers and makes it harder for new code to accidentally leak uninitialized memory. Optimize for the case recvfrom is called with NULL as address. We don't need to copy the address at all, so set it to NULL before invoking the recvmsg handler. We can do so, because all the recvmsg handlers must cope with the case a plain read() is called on them. read() also sets msg_name to NULL. Also document these changes in include/linux/net.h as suggested by David Miller. Changes since RFC: Set msg->msg_name = NULL if user specified a NULL in msg_name but had a non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't affect sendto as it would bail out earlier while trying to copy-in the address. It also more naturally reflects the logic by the callers of verify_iovec. With this change in place I could remove " if (!uaddr || msg_sys->msg_namelen == 0) msg->msg_name = NULL ". This change does not alter the user visible error logic as we ignore msg_namelen as long as msg_name is NULL. Also remove two unnecessary curly brackets in ___sys_recvmsg and change comments to netdev style. Cc: David Miller <davem@davemloft.net> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-20
0
40,609
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: md5_digest_clear (struct md5_digest *digest) { CLEAR (*digest); } Commit Message: Use constant time memcmp when comparing HMACs in openvpn_decrypt. Signed-off-by: Steffan Karger <steffan.karger@fox-it.com> Acked-by: Gert Doering <gert@greenie.muc.de> Signed-off-by: Gert Doering <gert@greenie.muc.de> CWE ID: CWE-200
0
32,019
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: map_remove_zone(int zone_index) { vector_remove(s_map->zones, zone_index); } Commit Message: Fix integer overflow in layer_resize in map_engine.c (#268) * Fix integer overflow in layer_resize in map_engine.c There's a buffer overflow bug in the function layer_resize. It allocates a buffer `tilemap` with size `x_size * y_size * sizeof(struct map_tile)`. But it didn't check for integer overflow, so if x_size and y_size are very large, it's possible that the buffer size is smaller than needed, causing a buffer overflow later. PoC: `SetLayerSize(0, 0x7FFFFFFF, 0x7FFFFFFF);` * move malloc to a separate line CWE ID: CWE-190
0
75,058
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int audit_compare_uid(kuid_t uid, struct audit_names *name, struct audit_field *f, struct audit_context *ctx) { struct audit_names *n; int rc; if (name) { rc = audit_uid_comparator(uid, f->op, name->uid); if (rc) return rc; } if (ctx) { list_for_each_entry(n, &ctx->names_list, list) { rc = audit_uid_comparator(uid, f->op, n->uid); if (rc) return rc; } } return 0; } Commit Message: audit: fix a double fetch in audit_log_single_execve_arg() There is a double fetch problem in audit_log_single_execve_arg() where we first check the execve(2) argumnets for any "bad" characters which would require hex encoding and then re-fetch the arguments for logging in the audit record[1]. Of course this leaves a window of opportunity for an unsavory application to munge with the data. This patch reworks things by only fetching the argument data once[2] into a buffer where it is scanned and logged into the audit records(s). In addition to fixing the double fetch, this patch improves on the original code in a few other ways: better handling of large arguments which require encoding, stricter record length checking, and some performance improvements (completely unverified, but we got rid of some strlen() calls, that's got to be a good thing). As part of the development of this patch, I've also created a basic regression test for the audit-testsuite, the test can be tracked on GitHub at the following link: * https://github.com/linux-audit/audit-testsuite/issues/25 [1] If you pay careful attention, there is actually a triple fetch problem due to a strnlen_user() call at the top of the function. [2] This is a tiny white lie, we do make a call to strnlen_user() prior to fetching the argument data. I don't like it, but due to the way the audit record is structured we really have no choice unless we copy the entire argument at once (which would require a rather wasteful allocation). The good news is that with this patch the kernel no longer relies on this strnlen_user() value for anything beyond recording it in the log, we also update it with a trustworthy value whenever possible. Reported-by: Pengfei Wang <wpengfeinudt@gmail.com> Cc: <stable@vger.kernel.org> Signed-off-by: Paul Moore <paul@paul-moore.com> CWE ID: CWE-362
0
51,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: static bool bdrv_start_throttled_reqs(BlockDriverState *bs) { bool drained = false; bool enabled = bs->io_limits_enabled; int i; bs->io_limits_enabled = false; for (i = 0; i < 2; i++) { while (qemu_co_enter_next(&bs->throttled_reqs[i])) { drained = true; } } bs->io_limits_enabled = enabled; return drained; } Commit Message: CWE ID: CWE-190
0
16,900
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: cid_get_offset( FT_Byte* *start, FT_Byte offsize ) { FT_ULong result; FT_Byte* p = *start; for ( result = 0; offsize > 0; offsize-- ) { result <<= 8; result |= *p++; } *start = p; return (FT_Long)result; } Commit Message: CWE ID: CWE-20
0
15,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: TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp) { static const char module[] = "TIFFFetchStripThing"; enum TIFFReadDirEntryErr err; uint64* data; err=TIFFReadDirEntryLong8Array(tif,dir,&data); if (err!=TIFFReadDirEntryErrOk) { const TIFFField* fip = TIFFFieldWithTag(tif,dir->tdir_tag); TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0); return(0); } if (dir->tdir_count!=(uint64)nstrips) { uint64* resizeddata; resizeddata=(uint64*)_TIFFCheckMalloc(tif,nstrips,sizeof(uint64),"for strip array"); if (resizeddata==0) { _TIFFfree(data); return(0); } if (dir->tdir_count<(uint64)nstrips) { _TIFFmemcpy(resizeddata,data,(uint32)dir->tdir_count*sizeof(uint64)); _TIFFmemset(resizeddata+(uint32)dir->tdir_count,0,(nstrips-(uint32)dir->tdir_count)*sizeof(uint64)); } else _TIFFmemcpy(resizeddata,data,nstrips*sizeof(uint64)); _TIFFfree(data); data=resizeddata; } *lpp=data; return(1); } Commit Message: * libtiff/tif_dirread.c: modify ChopUpSingleUncompressedStrip() to instanciate compute ntrips as TIFFhowmany_32(td->td_imagelength, rowsperstrip), instead of a logic based on the total size of data. Which is faulty is the total size of data is not sufficient to fill the whole image, and thus results in reading outside of the StripByCounts/StripOffsets arrays when using TIFFReadScanline(). Reported by Agostino Sarubbo. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2608. * libtiff/tif_strip.c: revert the change in TIFFNumberOfStrips() done for http://bugzilla.maptools.org/show_bug.cgi?id=2587 / CVE-2016-9273 since the above change is a better fix that makes it unnecessary. CWE ID: CWE-125
0
70,128
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void fsl_emb_pmu_disable(struct pmu *pmu) { struct cpu_hw_events *cpuhw; unsigned long flags; local_irq_save(flags); cpuhw = &__get_cpu_var(cpu_hw_events); if (!cpuhw->disabled) { cpuhw->disabled = 1; /* * Check if we ever enabled the PMU on this cpu. */ if (!cpuhw->pmcs_enabled) { ppc_enable_pmcs(); cpuhw->pmcs_enabled = 1; } if (atomic_read(&num_events)) { /* * Set the 'freeze all counters' bit, and disable * interrupts. The barrier is to make sure the * mtpmr has been executed and the PMU has frozen * the events before we return. */ mtpmr(PMRN_PMGC0, PMGC0_FAC); isync(); } } local_irq_restore(flags); } Commit Message: perf: Remove the nmi parameter from the swevent and overflow interface The nmi parameter indicated if we could do wakeups from the current context, if not, we would set some state and self-IPI and let the resulting interrupt do the wakeup. For the various event classes: - hardware: nmi=0; PMI is in fact an NMI or we run irq_work_run from the PMI-tail (ARM etc.) - tracepoint: nmi=0; since tracepoint could be from NMI context. - software: nmi=[0,1]; some, like the schedule thing cannot perform wakeups, and hence need 0. As one can see, there is very little nmi=1 usage, and the down-side of not using it is that on some platforms some software events can have a jiffy delay in wakeup (when arch_irq_work_raise isn't implemented). The up-side however is that we can remove the nmi parameter and save a bunch of conditionals in fast paths. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Michael Cree <mcree@orcon.net.nz> Cc: Will Deacon <will.deacon@arm.com> Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com> Cc: Anton Blanchard <anton@samba.org> Cc: Eric B Munson <emunson@mgebm.net> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Paul Mundt <lethal@linux-sh.org> Cc: David S. Miller <davem@davemloft.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jason Wessel <jason.wessel@windriver.com> Cc: Don Zickus <dzickus@redhat.com> Link: http://lkml.kernel.org/n/tip-agjev8eu666tvknpb3iaj0fg@git.kernel.org Signed-off-by: Ingo Molnar <mingo@elte.hu> CWE ID: CWE-399
0
25,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: bool WebPagePrivate::commitRootLayerIfNeeded() { #if DEBUG_AC_COMMIT BBLOG(Platform::LogLevelCritical, "%s: m_suspendRootLayerCommit = %d, m_needsCommit = %d, m_frameLayers = 0x%x, m_frameLayers->hasLayer() = %d, needsLayoutRecursive() = %d", WTF_PRETTY_FUNCTION, m_suspendRootLayerCommit, m_needsCommit, m_frameLayers.get(), m_frameLayers && m_frameLayers->hasLayer(), m_mainFrame && m_mainFrame->view() && needsLayoutRecursive(m_mainFrame->view())); #endif if (m_suspendRootLayerCommit) return false; if (!m_needsCommit) return false; if (!(m_frameLayers && m_frameLayers->hasLayer()) && !m_overlayLayer && !m_needsOneShotDrawingSynchronization) return false; FrameView* view = m_mainFrame->view(); if (!view) return false; updateDelegatedOverlays(); if (needsLayoutRecursive(view)) { ASSERT(!needsOneShotDrawingSynchronization()); return false; } willComposite(); m_needsCommit = false; m_needsOneShotDrawingSynchronization = false; if (m_rootLayerCommitTimer->isActive()) m_rootLayerCommitTimer->stop(); double scale = currentScale(); if (m_frameLayers && m_frameLayers->hasLayer()) m_frameLayers->commitOnWebKitThread(scale); if (m_overlayLayer) m_overlayLayer->platformLayer()->commitOnWebKitThread(scale); IntRect layoutRectForCompositing(scrollPosition(), actualVisibleSize()); IntSize contentsSizeForCompositing = contentsSize(); bool drawsRootLayer = compositorDrawsRootLayer(); Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage( Platform::createMethodCallMessage( &WebPagePrivate::commitRootLayer, this, layoutRectForCompositing, contentsSizeForCompositing, drawsRootLayer)); didComposite(); return true; } Commit Message: [BlackBerry] Adapt to new BlackBerry::Platform::TouchPoint API https://bugs.webkit.org/show_bug.cgi?id=105143 RIM PR 171941 Reviewed by Rob Buis. Internally reviewed by George Staikos. Source/WebCore: TouchPoint instances now provide document coordinates for the viewport and content position of the touch event. The pixel coordinates stored in the TouchPoint should no longer be needed in WebKit. Also adapt to new method names and encapsulation of TouchPoint data members. No change in behavior, no new tests. * platform/blackberry/PlatformTouchPointBlackBerry.cpp: (WebCore::PlatformTouchPoint::PlatformTouchPoint): Source/WebKit/blackberry: TouchPoint instances now provide document coordinates for the viewport and content position of the touch event. The pixel coordinates stored in the TouchPoint should no longer be needed in WebKit. One exception is when passing events to a full screen plugin. Also adapt to new method names and encapsulation of TouchPoint data members. * Api/WebPage.cpp: (BlackBerry::WebKit::WebPage::touchEvent): (BlackBerry::WebKit::WebPage::touchPointAsMouseEvent): (BlackBerry::WebKit::WebPagePrivate::dispatchTouchEventToFullScreenPlugin): (BlackBerry::WebKit::WebPagePrivate::dispatchTouchPointAsMouseEventToFullScreenPlugin): * WebKitSupport/InputHandler.cpp: (BlackBerry::WebKit::InputHandler::shouldRequestSpellCheckingOptionsForPoint): * WebKitSupport/InputHandler.h: (InputHandler): * WebKitSupport/TouchEventHandler.cpp: (BlackBerry::WebKit::TouchEventHandler::doFatFingers): (BlackBerry::WebKit::TouchEventHandler::handleTouchPoint): * WebKitSupport/TouchEventHandler.h: (TouchEventHandler): Tools: Adapt to new method names and encapsulation of TouchPoint data members. * DumpRenderTree/blackberry/EventSender.cpp: (addTouchPointCallback): (updateTouchPointCallback): (touchEndCallback): (releaseTouchPointCallback): (sendTouchEvent): git-svn-id: svn://svn.chromium.org/blink/trunk@137880 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID:
0
104,149
Analyze the following 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 CanDownloadFor(WebContents* web_contents) { download_request_limiter_->CanDownloadImpl( web_contents, "GET", // request method base::Bind(&DownloadRequestLimiterTest::ContinueDownload, base::Unretained(this))); base::RunLoop().RunUntilIdle(); } Commit Message: Don't reset TabDownloadState on history back/forward Currently performing forward/backward on a tab will reset the TabDownloadState. Which allows javascript code to do trigger multiple downloads. This CL disables that behavior by not resetting the TabDownloadState on forward/back. It is still possible to reset the TabDownloadState through user gesture or using browser initiated download. BUG=848535 Change-Id: I7f9bf6e8fb759b4dcddf5ac0c214e8c6c9f48863 Reviewed-on: https://chromium-review.googlesource.com/1108959 Commit-Queue: Min Qin <qinmin@chromium.org> Reviewed-by: Xing Liu <xingliu@chromium.org> Cr-Commit-Position: refs/heads/master@{#574437} CWE ID:
0
154,745
Analyze the following 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 RenderViewHostImpl::IsRenderViewLive() const { return GetProcess()->HasConnection() && renderer_initialized_; } Commit Message: Filter more incoming URLs in the CreateWindow path. BUG=170532 Review URL: https://chromiumcodereview.appspot.com/12036002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178728 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID:
0
117,211
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int iscsi_check_numerical_range_value(struct iscsi_param *param, char *value) { char *left_val_ptr = NULL, *right_val_ptr = NULL; char *tilde_ptr = NULL; u32 left_val, right_val, local_left_val; if (strcmp(param->name, IFMARKINT) && strcmp(param->name, OFMARKINT)) { pr_err("Only parameters \"%s\" or \"%s\" may contain a" " numerical range value.\n", IFMARKINT, OFMARKINT); return -1; } if (IS_PSTATE_PROPOSER(param)) return 0; tilde_ptr = strchr(value, '~'); if (!tilde_ptr) { pr_err("Unable to locate numerical range indicator" " \"~\" for \"%s\".\n", param->name); return -1; } *tilde_ptr = '\0'; left_val_ptr = value; right_val_ptr = value + strlen(left_val_ptr) + 1; if (iscsi_check_numerical_value(param, left_val_ptr) < 0) return -1; if (iscsi_check_numerical_value(param, right_val_ptr) < 0) return -1; left_val = simple_strtoul(left_val_ptr, NULL, 0); right_val = simple_strtoul(right_val_ptr, NULL, 0); *tilde_ptr = '~'; if (right_val < left_val) { pr_err("Numerical range for parameter \"%s\" contains" " a right value which is less than the left.\n", param->name); return -1; } /* * For now, enforce reasonable defaults for [I,O]FMarkInt. */ tilde_ptr = strchr(param->value, '~'); if (!tilde_ptr) { pr_err("Unable to locate numerical range indicator" " \"~\" for \"%s\".\n", param->name); return -1; } *tilde_ptr = '\0'; left_val_ptr = param->value; right_val_ptr = param->value + strlen(left_val_ptr) + 1; local_left_val = simple_strtoul(left_val_ptr, NULL, 0); *tilde_ptr = '~'; if (param->set_param) { if ((left_val < local_left_val) || (right_val < local_left_val)) { pr_err("Passed value range \"%u~%u\" is below" " minimum left value \"%u\" for key \"%s\"," " rejecting.\n", left_val, right_val, local_left_val, param->name); return -1; } } else { if ((left_val < local_left_val) && (right_val < local_left_val)) { pr_err("Received value range \"%u~%u\" is" " below minimum left value \"%u\" for key" " \"%s\", rejecting.\n", left_val, right_val, local_left_val, param->name); SET_PSTATE_REJECT(param); if (iscsi_update_param_value(param, REJECT) < 0) return -1; } } return 0; } Commit Message: iscsi-target: fix heap buffer overflow on error If a key was larger than 64 bytes, as checked by iscsi_check_key(), the error response packet, generated by iscsi_add_notunderstood_response(), would still attempt to copy the entire key into the packet, overflowing the structure on the heap. Remote preauthentication kernel memory corruption was possible if a target was configured and listening on the network. CVE-2013-2850 Signed-off-by: Kees Cook <keescook@chromium.org> Cc: stable@vger.kernel.org Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> CWE ID: CWE-119
0
30,967
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: SPR_IDToName(struct rx_call *call, idlist *aid, namelist *aname) { afs_int32 code; code = idToName(call, aid, aname); osi_auditU(call, PTS_IdToNmEvent, code, AUD_END); ViceLog(125, ("PTS_IDToName: code %d\n", code)); return code; } Commit Message: CWE ID: CWE-284
0
12,513
Analyze the following 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 IsAutofillUpstreamEditableCardholderNameExperimentEnabled() { return base::FeatureList::IsEnabled(kAutofillUpstreamEditableCardholderName); } Commit Message: [Autofill] Remove AutofillPopupViewViews and associated feature. Bug: 906135,831603 Change-Id: I3c982f8b3ffb4928c7c878e74e10113999106499 Reviewed-on: https://chromium-review.googlesource.com/c/1387124 Reviewed-by: Robert Kaplow <rkaplow@chromium.org> Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org> Reviewed-by: Fabio Tirelo <ftirelo@chromium.org> Reviewed-by: Tommy Martino <tmartino@chromium.org> Commit-Queue: Mathieu Perreault <mathp@chromium.org> Cr-Commit-Position: refs/heads/master@{#621360} CWE ID: CWE-416
0
130,644
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: IW_IMPL(int) iw_detect_fmt_of_file(const iw_byte *buf, size_t n) { int fmt = IW_FORMAT_UNKNOWN; if(n<2) return fmt; if(buf[0]==0x89 && buf[1]==0x50) { fmt=IW_FORMAT_PNG; } else if(n>=3 && buf[0]=='G' && buf[1]=='I' && buf[2]=='F') { fmt=IW_FORMAT_GIF; } else if(buf[0]==0xff && buf[1]==0xd8) { fmt=IW_FORMAT_JPEG; } else if(buf[0]=='B' && buf[1]=='M') { fmt=IW_FORMAT_BMP; } else if(buf[0]=='B' && buf[1]=='A') { fmt=IW_FORMAT_BMP; } else if((buf[0]==0x49 || buf[0]==0x4d) && buf[1]==buf[0]) { fmt=IW_FORMAT_TIFF; } else if(buf[0]==0x69 && buf[1]==0x64) { fmt=IW_FORMAT_MIFF; } else if(n>=12 && buf[0]==0x52 && buf[1]==0x49 && buf[2]==0x46 && buf[3]==0x46 && buf[8]==0x57 && buf[9]==0x45 && buf[10]==0x42 && buf[11]==0x50) { fmt=IW_FORMAT_WEBP; } else if(buf[0]=='P' && (buf[1]>='1' && buf[1]<='6')) { return IW_FORMAT_PNM; } else if(buf[0]=='P' && (buf[1]=='7' && buf[2]==0x0a)) { return IW_FORMAT_PAM; } return fmt; } Commit Message: Trying to fix some invalid left shift operations Fixes issue #16 CWE ID: CWE-682
0
66,267
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, long value TSRMLS_DC) /* {{{ */ { zval *tmp; ALLOC_ZVAL(tmp); Z_UNSET_ISREF_P(tmp); Z_SET_REFCOUNT_P(tmp, 0); ZVAL_BOOL(tmp, value); return zend_update_static_property(scope, name, name_length, tmp TSRMLS_CC); } /* }}} */ Commit Message: CWE ID: CWE-416
0
13,849
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void __flush_signals(struct task_struct *t) { clear_tsk_thread_flag(t, TIF_SIGPENDING); flush_sigqueue(&t->pending); flush_sigqueue(&t->signal->shared_pending); } Commit Message: kernel/signal.c: stop info leak via the tkill and the tgkill syscalls This fixes a kernel memory contents leak via the tkill and tgkill syscalls for compat processes. This is visible in the siginfo_t->_sifields._rt.si_sigval.sival_ptr field when handling signals delivered from tkill. The place of the infoleak: int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from) { ... put_user_ex(ptr_to_compat(from->si_ptr), &to->si_ptr); ... } Signed-off-by: Emese Revfy <re.emese@gmail.com> Reviewed-by: PaX Team <pageexec@freemail.hu> Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Oleg Nesterov <oleg@redhat.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Serge Hallyn <serge.hallyn@canonical.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-399
0
31,724
Analyze the following 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 ssize_t ui_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) { struct hfi1_devdata *dd = filp->private_data; void __iomem *base = dd->kregbase; unsigned long total, csr_off, barlen = (dd->kregend - dd->kregbase); u64 data; /* only read 8 byte quantities */ if ((count % 8) != 0) return -EINVAL; /* offset must be 8-byte aligned */ if ((*f_pos % 8) != 0) return -EINVAL; /* destination buffer must be 8-byte aligned */ if ((unsigned long)buf % 8 != 0) return -EINVAL; /* must be in range */ if (*f_pos + count > (barlen + DC8051_DATA_MEM_SIZE)) return -EINVAL; /* only set the base if we are not starting past the BAR */ if (*f_pos < barlen) base += *f_pos; csr_off = *f_pos; for (total = 0; total < count; total += 8, csr_off += 8) { /* accessing LCB CSRs requires more checks */ if (is_lcb_offset(csr_off)) { if (read_lcb_csr(dd, csr_off, (u64 *)&data)) break; /* failed */ } /* * Cannot read ASIC GPIO/QSFP* clear and force CSRs without a * false parity error. Avoid the whole issue by not reading * them. These registers are defined as having a read value * of 0. */ else if (csr_off == ASIC_GPIO_CLEAR || csr_off == ASIC_GPIO_FORCE || csr_off == ASIC_QSFP1_CLEAR || csr_off == ASIC_QSFP1_FORCE || csr_off == ASIC_QSFP2_CLEAR || csr_off == ASIC_QSFP2_FORCE) data = 0; else if (csr_off >= barlen) { /* * read_8051_data can read more than just 8 bytes at * a time. However, folding this into the loop and * handling the reads in 8 byte increments allows us * to smoothly transition from chip memory to 8051 * memory. */ if (read_8051_data(dd, (u32)(csr_off - barlen), sizeof(data), &data)) break; /* failed */ } else data = readq(base + total); if (put_user(data, (unsigned long __user *)(buf + total))) break; } *f_pos += total; return total; } Commit Message: IB/security: Restrict use of the write() interface The drivers/infiniband stack uses write() as a replacement for bi-directional ioctl(). This is not safe. There are ways to trigger write calls that result in the return structure that is normally written to user space being shunted off to user specified kernel memory instead. For the immediate repair, detect and deny suspicious accesses to the write API. For long term, update the user space libraries and the kernel API to something that doesn't present the same security vulnerabilities (likely a structured ioctl() interface). The impacted uAPI interfaces are generally only available if hardware from drivers/infiniband is installed in the system. Reported-by: Jann Horn <jann@thejh.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> [ Expanded check to all known write() entry points ] Cc: stable@vger.kernel.org Signed-off-by: Doug Ledford <dledford@redhat.com> CWE ID: CWE-264
0
52,982
Analyze the following 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 pdf_xref_is_incremental(fz_context *ctx, pdf_document *doc, int num) { pdf_xref *xref = &doc->xref_sections[doc->xref_base]; pdf_xref_subsec *sub = xref->subsec; assert(sub != NULL && sub->next == NULL && sub->len == xref->num_objects && sub->start == 0); return num < xref->num_objects && sub->table[num].type; } Commit Message: CWE ID: CWE-119
0
16,728
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: e1000e_intmgr_collect_delayed_causes(E1000ECore *core) { uint32_t res; if (msix_enabled(core->owner)) { assert(core->delayed_causes == 0); return 0; } res = core->delayed_causes; core->delayed_causes = 0; e1000e_intrmgr_stop_delay_timers(core); return res; } Commit Message: CWE ID: CWE-835
0
5,979
Analyze the following 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 AllowFingerprintForUser(const user_manager::User* user) { if (!user->is_logged_in()) return false; quick_unlock::QuickUnlockStorage* quick_unlock_storage = quick_unlock::QuickUnlockFactory::GetForUser(user); if (!quick_unlock_storage) return false; return quick_unlock_storage->IsFingerprintAuthenticationAvailable(); } Commit Message: cros: Check initial auth type when showing views login. Bug: 859611 Change-Id: I0298db9bbf4aed6bd40600aef2e1c5794e8cd058 Reviewed-on: https://chromium-review.googlesource.com/1123056 Reviewed-by: Xiaoyin Hu <xiaoyinh@chromium.org> Commit-Queue: Jacob Dufault <jdufault@chromium.org> Cr-Commit-Position: refs/heads/master@{#572224} CWE ID:
0
131,562
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: PHP_FUNCTION(strtoupper) { zend_string *arg; #ifndef FAST_ZPP if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &arg) == FAILURE) { return; } #else ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(arg) ZEND_PARSE_PARAMETERS_END(); #endif RETURN_STR(php_string_toupper(arg)); } Commit Message: CWE ID: CWE-17
0
14,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: static MagickBooleanType WritePSDImage(const ImageInfo *image_info, Image *image,ExceptionInfo *exception) { const StringInfo *icc_profile; MagickBooleanType status; PSDInfo psd_info; register ssize_t i; size_t length, num_channels, packet_size; StringInfo *bim_profile; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickCoreSignature); status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); if (status == MagickFalse) return(status); packet_size=(size_t) (image->depth > 8 ? 6 : 3); if (image->alpha_trait != UndefinedPixelTrait) packet_size+=image->depth > 8 ? 2 : 1; psd_info.version=1; if ((LocaleCompare(image_info->magick,"PSB") == 0) || (image->columns > 30000) || (image->rows > 30000)) psd_info.version=2; (void) WriteBlob(image,4,(const unsigned char *) "8BPS"); (void) WriteBlobMSBShort(image,psd_info.version); /* version */ for (i=1; i <= 6; i++) (void) WriteBlobByte(image, 0); /* 6 bytes of reserved */ /* When the image has a color profile it won't be converted to gray scale */ if ((GetImageProfile(image,"icc") == (StringInfo *) NULL) && (SetImageGray(image,exception) != MagickFalse)) num_channels=(image->alpha_trait != UndefinedPixelTrait ? 2UL : 1UL); else if ((image_info->type != TrueColorType) && (image_info->type != TrueColorAlphaType) && (image->storage_class == PseudoClass)) num_channels=(image->alpha_trait != UndefinedPixelTrait ? 2UL : 1UL); else { if (image->storage_class == PseudoClass) (void) SetImageStorageClass(image,DirectClass,exception); if (image->colorspace != CMYKColorspace) num_channels=(image->alpha_trait != UndefinedPixelTrait ? 4UL : 3UL); else num_channels=(image->alpha_trait != UndefinedPixelTrait ? 5UL : 4UL); } (void) WriteBlobMSBShort(image,(unsigned short) num_channels); (void) WriteBlobMSBLong(image,(unsigned int) image->rows); (void) WriteBlobMSBLong(image,(unsigned int) image->columns); if (IsImageGray(image) != MagickFalse) { MagickBooleanType monochrome; /* Write depth & mode. */ monochrome=IsImageMonochrome(image) && (image->depth == 1) ? MagickTrue : MagickFalse; (void) WriteBlobMSBShort(image,(unsigned short) (monochrome != MagickFalse ? 1 : image->depth > 8 ? 16 : 8)); (void) WriteBlobMSBShort(image,(unsigned short) (monochrome != MagickFalse ? BitmapMode : GrayscaleMode)); } else { (void) WriteBlobMSBShort(image,(unsigned short) (image->storage_class == PseudoClass ? 8 : image->depth > 8 ? 16 : 8)); if (((image_info->colorspace != UndefinedColorspace) || (image->colorspace != CMYKColorspace)) && (image_info->colorspace != CMYKColorspace)) { (void) TransformImageColorspace(image,sRGBColorspace,exception); (void) WriteBlobMSBShort(image,(unsigned short) (image->storage_class == PseudoClass ? IndexedMode : RGBMode)); } else { if (image->colorspace != CMYKColorspace) (void) TransformImageColorspace(image,CMYKColorspace,exception); (void) WriteBlobMSBShort(image,CMYKMode); } } if ((IsImageGray(image) != MagickFalse) || (image->storage_class == DirectClass) || (image->colors > 256)) (void) WriteBlobMSBLong(image,0); else { /* Write PSD raster colormap. */ (void) WriteBlobMSBLong(image,768); for (i=0; i < (ssize_t) image->colors; i++) (void) WriteBlobByte(image,ScaleQuantumToChar(ClampToQuantum( image->colormap[i].red))); for ( ; i < 256; i++) (void) WriteBlobByte(image,0); for (i=0; i < (ssize_t) image->colors; i++) (void) WriteBlobByte(image,ScaleQuantumToChar(ClampToQuantum( image->colormap[i].green))); for ( ; i < 256; i++) (void) WriteBlobByte(image,0); for (i=0; i < (ssize_t) image->colors; i++) (void) WriteBlobByte(image,ScaleQuantumToChar(ClampToQuantum( image->colormap[i].blue))); for ( ; i < 256; i++) (void) WriteBlobByte(image,0); } /* Image resource block. */ length=28; /* 0x03EB */ bim_profile=(StringInfo *) GetImageProfile(image,"8bim"); icc_profile=GetImageProfile(image,"icc"); if (bim_profile != (StringInfo *) NULL) { bim_profile=CloneStringInfo(bim_profile); if (icc_profile != (StringInfo *) NULL) RemoveICCProfileFromResourceBlock(bim_profile); RemoveResolutionFromResourceBlock(bim_profile); length+=PSDQuantum(GetStringInfoLength(bim_profile)); } if (icc_profile != (const StringInfo *) NULL) length+=PSDQuantum(GetStringInfoLength(icc_profile))+12; (void) WriteBlobMSBLong(image,(unsigned int) length); WriteResolutionResourceBlock(image); if (bim_profile != (StringInfo *) NULL) { (void) WriteBlob(image,GetStringInfoLength(bim_profile), GetStringInfoDatum(bim_profile)); bim_profile=DestroyStringInfo(bim_profile); } if (icc_profile != (StringInfo *) NULL) { (void) WriteBlob(image,4,(const unsigned char *) "8BIM"); (void) WriteBlobMSBShort(image,0x0000040F); (void) WriteBlobMSBShort(image,0); (void) WriteBlobMSBLong(image,(unsigned int) GetStringInfoLength( icc_profile)); (void) WriteBlob(image,GetStringInfoLength(icc_profile), GetStringInfoDatum(icc_profile)); if ((ssize_t) GetStringInfoLength(icc_profile) != PSDQuantum(GetStringInfoLength(icc_profile))) (void) WriteBlobByte(image,0); } if (status != MagickFalse) { MagickOffsetType size_offset; size_t size; size_offset=TellBlob(image); (void) SetPSDSize(&psd_info,image,0); status=WritePSDLayersInternal(image,image_info,&psd_info,&size, exception); size_offset+=WritePSDSize(&psd_info,image,size+ (psd_info.version == 1 ? 8 : 12),size_offset); } (void) WriteBlobMSBLong(image,0); /* user mask data */ /* Write composite image. */ if (status != MagickFalse) { CompressionType compression; compression=image->compression; if (image->compression == ZipCompression) image->compression=RLECompression; if (image_info->compression != UndefinedCompression) image->compression=image_info->compression; if (WritePSDChannels(&psd_info,image_info,image,image,0,MagickFalse, exception) == 0) status=MagickFalse; image->compression=compression; } (void) CloseBlob(image); return(status); } Commit Message: https://github.com/ImageMagick/ImageMagick/issues/1451 CWE ID: CWE-399
0
91,383
Analyze the following 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 crypto_instance *crypto_ccm_alloc(struct rtattr **tb) { const char *cipher_name; char ctr_name[CRYPTO_MAX_ALG_NAME]; char full_name[CRYPTO_MAX_ALG_NAME]; cipher_name = crypto_attr_alg_name(tb[1]); if (IS_ERR(cipher_name)) return ERR_CAST(cipher_name); if (snprintf(ctr_name, CRYPTO_MAX_ALG_NAME, "ctr(%s)", cipher_name) >= CRYPTO_MAX_ALG_NAME) return ERR_PTR(-ENAMETOOLONG); if (snprintf(full_name, CRYPTO_MAX_ALG_NAME, "ccm(%s)", cipher_name) >= CRYPTO_MAX_ALG_NAME) return ERR_PTR(-ENAMETOOLONG); return crypto_ccm_alloc_common(tb, full_name, ctr_name, cipher_name); } Commit Message: crypto: include crypto- module prefix in template This adds the module loading prefix "crypto-" to the template lookup as well. For example, attempting to load 'vfat(blowfish)' via AF_ALG now correctly includes the "crypto-" prefix at every level, correctly rejecting "vfat": net-pf-38 algif-hash crypto-vfat(blowfish) crypto-vfat(blowfish)-all crypto-vfat Reported-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> CWE ID: CWE-264
0
45,570
Analyze the following 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(dom_document_create_processing_instruction) { zval *id; xmlNode *node; xmlDocPtr docp; int ret, value_len, name_len = 0; dom_object *intern; char *name, *value = NULL; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|s", &id, dom_document_class_entry, &name, &name_len, &value, &value_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); if (xmlValidateName((xmlChar *) name, 0) != 0) { php_dom_throw_error(INVALID_CHARACTER_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); RETURN_FALSE; } node = xmlNewPI((xmlChar *) name, (xmlChar *) value); if (!node) { RETURN_FALSE; } node->doc = docp; DOM_RET_OBJ(node, &ret, intern); } Commit Message: CWE ID: CWE-254
0
15,042
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static inline int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) { __u32 i; /* zero the reserved fields */ c->reserved[0] = c->reserved[1] = 0; for (i = 0; i < c->count; i++) c->controls[i].reserved2[0] = 0; /* V4L2_CID_PRIVATE_BASE cannot be used as control class when using extended controls. Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL is it allowed for backwards compatibility. */ if (!allow_priv && c->ctrl_class == V4L2_CID_PRIVATE_BASE) return 0; /* Check that all controls are from the same control class. */ for (i = 0; i < c->count; i++) { if (V4L2_CTRL_ID2CLASS(c->controls[i].id) != c->ctrl_class) { c->error_idx = i; return 0; } } return 1; } Commit Message: [media] v4l: Share code between video_usercopy and video_ioctl2 The two functions are mostly identical. They handle the copy_from_user and copy_to_user operations related with V4L2 ioctls and call the real ioctl handler. Create a __video_usercopy function that implements the core of video_usercopy and video_ioctl2, and call that function from both. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com> CWE ID: CWE-399
0
74,690
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void set_linv_umr_seg(struct mlx5_wqe_umr_ctrl_seg *umr) { memset(umr, 0, sizeof(*umr)); umr->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_FREE); umr->flags = MLX5_UMR_INLINE; } Commit Message: IB/mlx5: Fix leaking stack memory to userspace mlx5_ib_create_qp_resp was never initialized and only the first 4 bytes were written. Fixes: 41d902cb7c32 ("RDMA/mlx5: Fix definition of mlx5_ib_create_qp_resp") Cc: <stable@vger.kernel.org> Acked-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> CWE ID: CWE-119
0
92,185
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int kvm_vm_ioctl_set_tss_addr(struct kvm *kvm, unsigned long addr) { int ret; if (addr > (unsigned int)(-3 * PAGE_SIZE)) return -EINVAL; ret = kvm_x86_ops->set_tss_addr(kvm, addr); return ret; } 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
28,908
Analyze the following 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 ResourceDispatcherHostImpl::UpdateRequestForTransfer( int child_id, int route_id, int request_id, const ResourceHostMsg_Request& request_data, LoaderMap::iterator iter) { ResourceRequestInfoImpl* info = iter->second->GetRequestInfo(); GlobalRoutingID old_routing_id( request_data.transferred_request_child_id, info->GetRouteID()); GlobalRequestID old_request_id(request_data.transferred_request_child_id, request_data.transferred_request_request_id); GlobalRoutingID new_routing_id(child_id, route_id); GlobalRequestID new_request_id(child_id, request_id); IncrementOutstandingRequestsMemory(-1, *info); bool should_update_count = info->counted_as_in_flight_request(); if (should_update_count) IncrementOutstandingRequestsCount(-1, info); DCHECK(pending_loaders_.find(old_request_id) == iter); scoped_ptr<ResourceLoader> loader = std::move(iter->second); ResourceLoader* loader_ptr = loader.get(); pending_loaders_.erase(iter); info->UpdateForTransfer(child_id, route_id, request_data.render_frame_id, request_data.origin_pid, request_id, filter_->GetWeakPtr()); pending_loaders_[new_request_id] = std::move(loader); IncrementOutstandingRequestsMemory(1, *info); if (should_update_count) IncrementOutstandingRequestsCount(1, info); if (old_routing_id != new_routing_id) { if (blocked_loaders_map_.find(old_routing_id) != blocked_loaders_map_.end()) { blocked_loaders_map_[new_routing_id] = std::move(blocked_loaders_map_[old_routing_id]); blocked_loaders_map_.erase(old_routing_id); } } if (old_request_id != new_request_id) { DelegateMap::iterator it = delegate_map_.find(old_request_id); if (it != delegate_map_.end()) { base::ObserverList<ResourceMessageDelegate>::Iterator del_it(it->second); ResourceMessageDelegate* delegate; while ((delegate = del_it.GetNext()) != NULL) { delegate->set_request_id(new_request_id); } delegate_map_[new_request_id] = delegate_map_[old_request_id]; delegate_map_.erase(old_request_id); } } AppCacheInterceptor::CompleteCrossSiteTransfer( loader_ptr->request(), child_id, request_data.appcache_host_id, filter_); ServiceWorkerRequestHandler* handler = ServiceWorkerRequestHandler::GetHandler(loader_ptr->request()); if (handler) { if (!handler->SanityCheckIsSameContext(filter_->service_worker_context())) { bad_message::ReceivedBadMessage( filter_, bad_message::RDHI_WRONG_STORAGE_PARTITION); } else { handler->CompleteCrossSiteTransfer( child_id, request_data.service_worker_provider_id); } } DCHECK(info->cross_site_handler()); } Commit Message: Block a compromised renderer from reusing request ids. BUG=578882 Review URL: https://codereview.chromium.org/1608573002 Cr-Commit-Position: refs/heads/master@{#372547} CWE ID: CWE-362
0
132,858
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: dcinit() { strsize = 1; // We start with empty string, i.e. \0 strmaxsize=DCSTRSIZE; dcstr=calloc(DCSTRSIZE,1); dcptr=dcstr; } Commit Message: decompileAction: Prevent heap buffer overflow and underflow with using OpCode CWE ID: CWE-119
0
89,478
Analyze the following 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 AddInternalName(const Experiment& e, std::set<std::string>* names) { if (e.type == Experiment::SINGLE_VALUE) { names->insert(e.internal_name); } else { DCHECK(e.type == Experiment::MULTI_VALUE || e.type == Experiment::ENABLE_DISABLE_VALUE); for (int i = 0; i < e.num_choices; ++i) names->insert(e.NameForChoice(i)); } } Commit Message: Remove --disable-app-shims. App shims have been enabled by default for 3 milestones (since r242711). BUG=350161 Review URL: https://codereview.chromium.org/298953002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272786 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
110,295
Analyze the following 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 sig_cb(const char *elem, int len, void *arg) { sig_cb_st *sarg = arg; size_t i; char etmp[20], *p; int sig_alg = NID_undef, hash_alg = NID_undef; if (elem == NULL) return 0; if (sarg->sigalgcnt == MAX_SIGALGLEN) return 0; if (len > (int)(sizeof(etmp) - 1)) return 0; memcpy(etmp, elem, len); etmp[len] = 0; p = strchr(etmp, '+'); if (!p) return 0; *p = 0; p++; if (!*p) return 0; get_sigorhash(&sig_alg, &hash_alg, etmp); get_sigorhash(&sig_alg, &hash_alg, p); if (sig_alg == NID_undef || hash_alg == NID_undef) return 0; for (i = 0; i < sarg->sigalgcnt; i += 2) { if (sarg->sigalgs[i] == sig_alg && sarg->sigalgs[i + 1] == hash_alg) return 0; } sarg->sigalgs[sarg->sigalgcnt++] = hash_alg; sarg->sigalgs[sarg->sigalgcnt++] = sig_alg; return 1; } Commit Message: CWE ID: CWE-20
0
9,418
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static long ffs_ep0_ioctl(struct file *file, unsigned code, unsigned long value) { struct ffs_data *ffs = file->private_data; struct usb_gadget *gadget = ffs->gadget; long ret; ENTER(); if (code == FUNCTIONFS_INTERFACE_REVMAP) { struct ffs_function *func = ffs->func; ret = func ? ffs_func_revmap_intf(func, value) : -ENODEV; } else if (gadget && gadget->ops->ioctl) { ret = gadget->ops->ioctl(gadget, code, value); } else { ret = -ENOTTY; } return ret; } Commit Message: usb: gadget: f_fs: Fix use-after-free When using asynchronous read or write operations on the USB endpoints the issuer of the IO request is notified by calling the ki_complete() callback of the submitted kiocb when the URB has been completed. Calling this ki_complete() callback will free kiocb. Make sure that the structure is no longer accessed beyond that point, otherwise undefined behaviour might occur. Fixes: 2e4c7553cd6f ("usb: gadget: f_fs: add aio support") Cc: <stable@vger.kernel.org> # v3.15+ Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> CWE ID: CWE-416
0
49,593
Analyze the following 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 ssize_t qib_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct qib_filedata *fp = iocb->ki_filp->private_data; struct qib_ctxtdata *rcd = ctxt_fp(iocb->ki_filp); struct qib_user_sdma_queue *pq = fp->pq; if (!iter_is_iovec(from) || !from->nr_segs || !pq) return -EINVAL; return qib_user_sdma_writev(rcd, pq, from->iov, from->nr_segs); } Commit Message: IB/security: Restrict use of the write() interface The drivers/infiniband stack uses write() as a replacement for bi-directional ioctl(). This is not safe. There are ways to trigger write calls that result in the return structure that is normally written to user space being shunted off to user specified kernel memory instead. For the immediate repair, detect and deny suspicious accesses to the write API. For long term, update the user space libraries and the kernel API to something that doesn't present the same security vulnerabilities (likely a structured ioctl() interface). The impacted uAPI interfaces are generally only available if hardware from drivers/infiniband is installed in the system. Reported-by: Jann Horn <jann@thejh.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> [ Expanded check to all known write() entry points ] Cc: stable@vger.kernel.org Signed-off-by: Doug Ledford <dledford@redhat.com> CWE ID: CWE-264
0
52,954
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static MagickBooleanType WriteHDRImage(const ImageInfo *image_info,Image *image) { char header[MaxTextExtent]; const char *property; MagickBooleanType status; register const PixelPacket *p; register ssize_t i, x; size_t length; ssize_t count, y; unsigned char pixel[4], *pixels; /* Open output image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); if (status == MagickFalse) return(status); if (IsRGBColorspace(image->colorspace) == MagickFalse) (void) TransformImageColorspace(image,sRGBColorspace); /* Write header. */ (void) ResetMagickMemory(header,' ',MaxTextExtent); length=CopyMagickString(header,"#?RGBE\n",MaxTextExtent); (void) WriteBlob(image,length,(unsigned char *) header); property=GetImageProperty(image,"comment"); if ((property != (const char *) NULL) && (strchr(property,'\n') == (char *) NULL)) { count=FormatLocaleString(header,MaxTextExtent,"#%s\n",property); (void) WriteBlob(image,(size_t) count,(unsigned char *) header); } property=GetImageProperty(image,"hdr:exposure"); if (property != (const char *) NULL) { count=FormatLocaleString(header,MaxTextExtent,"EXPOSURE=%g\n", atof(property)); (void) WriteBlob(image,(size_t) count,(unsigned char *) header); } if (image->gamma != 0.0) { count=FormatLocaleString(header,MaxTextExtent,"GAMMA=%g\n",image->gamma); (void) WriteBlob(image,(size_t) count,(unsigned char *) header); } count=FormatLocaleString(header,MaxTextExtent, "PRIMARIES=%g %g %g %g %g %g %g %g\n", image->chromaticity.red_primary.x,image->chromaticity.red_primary.y, image->chromaticity.green_primary.x,image->chromaticity.green_primary.y, image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y, image->chromaticity.white_point.x,image->chromaticity.white_point.y); (void) WriteBlob(image,(size_t) count,(unsigned char *) header); length=CopyMagickString(header,"FORMAT=32-bit_rle_rgbe\n\n",MaxTextExtent); (void) WriteBlob(image,length,(unsigned char *) header); count=FormatLocaleString(header,MaxTextExtent,"-Y %.20g +X %.20g\n", (double) image->rows,(double) image->columns); (void) WriteBlob(image,(size_t) count,(unsigned char *) header); /* Write HDR pixels. */ pixels=(unsigned char *) AcquireQuantumMemory(image->columns,4* sizeof(*pixels)); if (pixels == (unsigned char *) NULL) ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception); if (p == (const PixelPacket *) NULL) break; if ((image->columns >= 8) && (image->columns <= 0x7ffff)) { pixel[0]=2; pixel[1]=2; pixel[2]=(unsigned char) (image->columns >> 8); pixel[3]=(unsigned char) (image->columns & 0xff); count=WriteBlob(image,4*sizeof(*pixel),pixel); if (count != (ssize_t) (4*sizeof(*pixel))) break; } i=0; for (x=0; x < (ssize_t) image->columns; x++) { double gamma; pixel[0]=0; pixel[1]=0; pixel[2]=0; pixel[3]=0; gamma=QuantumScale*GetPixelRed(p); if ((QuantumScale*GetPixelGreen(p)) > gamma) gamma=QuantumScale*GetPixelGreen(p); if ((QuantumScale*GetPixelBlue(p)) > gamma) gamma=QuantumScale*GetPixelBlue(p); if (gamma > MagickEpsilon) { int exponent; gamma=frexp(gamma,&exponent)*256.0/gamma; pixel[0]=(unsigned char) (gamma*QuantumScale*GetPixelRed(p)); pixel[1]=(unsigned char) (gamma*QuantumScale*GetPixelGreen(p)); pixel[2]=(unsigned char) (gamma*QuantumScale*GetPixelBlue(p)); pixel[3]=(unsigned char) (exponent+128); } if ((image->columns >= 8) && (image->columns <= 0x7ffff)) { pixels[x]=pixel[0]; pixels[x+image->columns]=pixel[1]; pixels[x+2*image->columns]=pixel[2]; pixels[x+3*image->columns]=pixel[3]; } else { pixels[i++]=pixel[0]; pixels[i++]=pixel[1]; pixels[i++]=pixel[2]; pixels[i++]=pixel[3]; } p++; } if ((image->columns >= 8) && (image->columns <= 0x7ffff)) { for (i=0; i < 4; i++) length=HDRWriteRunlengthPixels(image,&pixels[i*image->columns]); } else { count=WriteBlob(image,4*image->columns*sizeof(*pixels),pixels); if (count != (ssize_t) (4*image->columns*sizeof(*pixels))) break; } status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } pixels=(unsigned char *) RelinquishMagickMemory(pixels); (void) CloseBlob(image); return(MagickTrue); } Commit Message: CWE ID: CWE-119
0
71,569
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: Gif_FullReadFile(FILE *f, int read_flags, const char* landmark, Gif_ReadErrorHandler h) { Gif_Reader grr; if (!f) return 0; grr.f = f; grr.pos = 0; grr.is_record = 0; grr.byte_getter = file_byte_getter; grr.block_getter = file_block_getter; grr.eofer = file_eofer; return read_gif(&grr, read_flags, landmark, h); } Commit Message: gif_read: Set last_name = NULL unconditionally. With a non-malicious GIF, last_name is set to NULL when a name extension is followed by an image. Reported in #117, via Debian, via a KAIST fuzzing program. CWE ID: CWE-415
0
86,175
Analyze the following 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 netbk_fatal_tx_err(struct xenvif *vif) { netdev_err(vif->dev, "fatal error; disabling device\n"); xenvif_carrier_off(vif); xenvif_put(vif); } Commit Message: xen/netback: don't leak pages on failure in xen_netbk_tx_check_gop. Signed-off-by: Matthew Daley <mattjd@gmail.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Jan Beulich <JBeulich@suse.com> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-399
0
33,986
Analyze the following 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 amd_pinconf_group_get(struct pinctrl_dev *pctldev, unsigned int group, unsigned long *config) { const unsigned *pins; unsigned npins; int ret; ret = amd_get_group_pins(pctldev, group, &pins, &npins); if (ret) return ret; if (amd_pinconf_get(pctldev, pins[0], config)) return -ENOTSUPP; return 0; } Commit Message: pinctrl/amd: Drop pinctrl_unregister for devm_ registered device It's not necessary to unregister pin controller device registered with devm_pinctrl_register() and using pinctrl_unregister() leads to a double free. Fixes: 3bfd44306c65 ("pinctrl: amd: Add support for additional GPIO") Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> CWE ID: CWE-415
0
86,172
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void LoginDisplayHostWebUI::CreateExistingUserController() { existing_user_controller_.reset(); existing_user_controller_.reset(new ExistingUserController(this)); login_display_->set_delegate(existing_user_controller_.get()); } Commit Message: cros: Check initial auth type when showing views login. Bug: 859611 Change-Id: I0298db9bbf4aed6bd40600aef2e1c5794e8cd058 Reviewed-on: https://chromium-review.googlesource.com/1123056 Reviewed-by: Xiaoyin Hu <xiaoyinh@chromium.org> Commit-Queue: Jacob Dufault <jdufault@chromium.org> Cr-Commit-Position: refs/heads/master@{#572224} CWE ID:
0
131,611
Analyze the following 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 MediaStreamManager::CancelRequest(int render_process_id, int render_frame_id, int page_request_id) { DCHECK_CURRENTLY_ON(BrowserThread::IO); for (const LabeledDeviceRequest& labeled_request : requests_) { DeviceRequest* const request = labeled_request.second; if (request->requesting_process_id == render_process_id && request->requesting_frame_id == render_frame_id && request->page_request_id == page_request_id) { CancelRequest(labeled_request.first); return; } } } Commit Message: Make MediaStreamDispatcherHost per-request instead of per-frame. Instead of having RenderFrameHost own a single MSDH to handle all requests from a frame, MSDH objects will be owned by a strong binding. A consequence of this is that an additional requester ID is added to requests to MediaStreamManager, so that an MSDH is able to cancel only requests generated by it. In practice, MSDH will continue to be per frame in most cases since each frame normally makes a single request for an MSDH object. This fixes a lifetime issue caused by the IO thread executing tasks after the RenderFrameHost dies. Drive-by: Fix some minor lint issues. Bug: 912520 Change-Id: I52742ffc98b9fc57ce8e6f5093a61aed86d3e516 Reviewed-on: https://chromium-review.googlesource.com/c/1369799 Reviewed-by: Emircan Uysaler <emircan@chromium.org> Reviewed-by: Ken Buchanan <kenrb@chromium.org> Reviewed-by: Olga Sharonova <olka@chromium.org> Commit-Queue: Guido Urdaneta <guidou@chromium.org> Cr-Commit-Position: refs/heads/master@{#616347} CWE ID: CWE-189
1
173,101
Analyze the following 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 kill_pid_info(int sig, struct siginfo *info, struct pid *pid) { int error = -ESRCH; struct task_struct *p; rcu_read_lock(); retry: p = pid_task(pid, PIDTYPE_PID); if (p) { error = group_send_sig_info(sig, info, p); if (unlikely(error == -ESRCH)) /* * The task was unhashed in between, try again. * If it is dead, pid_task() will return NULL, * if we race with de_thread() it will find the * new leader. */ goto retry; } rcu_read_unlock(); return error; } Commit Message: kernel/signal.c: stop info leak via the tkill and the tgkill syscalls This fixes a kernel memory contents leak via the tkill and tgkill syscalls for compat processes. This is visible in the siginfo_t->_sifields._rt.si_sigval.sival_ptr field when handling signals delivered from tkill. The place of the infoleak: int copy_siginfo_to_user32(compat_siginfo_t __user *to, siginfo_t *from) { ... put_user_ex(ptr_to_compat(from->si_ptr), &to->si_ptr); ... } Signed-off-by: Emese Revfy <re.emese@gmail.com> Reviewed-by: PaX Team <pageexec@freemail.hu> Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Oleg Nesterov <oleg@redhat.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Serge Hallyn <serge.hallyn@canonical.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-399
0
31,771
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: bool TaskService::BindInstance() { base::AutoLock lock(lock_); if (bound_instance_id_ != kInvalidInstanceId) return false; bound_instance_id_ = next_instance_id_++; DCHECK(!default_task_runner_); default_task_runner_ = base::ThreadTaskRunnerHandle::Get(); return true; } Commit Message: Change ReadWriteLock to Lock+ConditionVariable in TaskService There are non-trivial performance implications of using shared SRWLocking on Windows as more state has to be checked. Since there are only two uses of the ReadWriteLock in Chromium after over 1 year, the decision is to remove it. BUG=758721 Change-Id: I84d1987d7b624a89e896eb37184ee50845c39d80 Reviewed-on: https://chromium-review.googlesource.com/634423 Commit-Queue: Robert Liao <robliao@chromium.org> Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org> Reviewed-by: Francois Doray <fdoray@chromium.org> Cr-Commit-Position: refs/heads/master@{#497632} CWE ID: CWE-20
0
132,037
Analyze the following 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 addRange(vector<uint32_t> &coverage, uint32_t start, uint32_t end) { #ifdef PRINTF_DEBUG printf("adding range %d-%d\n", start, end); #endif if (coverage.empty() || coverage.back() < start) { coverage.push_back(start); coverage.push_back(end); } else { coverage.back() = end; } } Commit Message: Reject fonts with invalid ranges in cmap A corrupt or malicious font may have a negative size in its cmap range, which in turn could lead to memory corruption. This patch detects the case and rejects the font, and also includes an assertion in the sparse bit set implementation if we missed any such case. External issue: https://code.google.com/p/android/issues/detail?id=192618 Bug: 26413177 Change-Id: Icc0c80e4ef389abba0964495b89aa0fae3e9f4b2 CWE ID: CWE-20
0
164,325
Analyze the following 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 SVGElement::RemovedFrom(ContainerNode& root_parent) { bool was_in_document = root_parent.isConnected(); if (was_in_document && HasRelativeLengths()) { if (root_parent.IsSVGElement() && !parentNode()) { DCHECK(ToSVGElement(root_parent) .elements_with_relative_lengths_.Contains(this)); ToSVGElement(root_parent).UpdateRelativeLengthsInformation(false, this); } elements_with_relative_lengths_.clear(); } SECURITY_DCHECK(!root_parent.IsSVGElement() || !ToSVGElement(root_parent) .elements_with_relative_lengths_.Contains(this)); Element::RemovedFrom(root_parent); if (was_in_document) { RebuildAllIncomingReferences(); RemoveAllIncomingReferences(); } InvalidateInstances(); } Commit Message: Fix SVG crash for v0 distribution into foreignObject. We require a parent element to be an SVG element for non-svg-root elements in order to create a LayoutObject for them. However, we checked the light tree parent element, not the flat tree one which is the parent for the layout tree construction. Note that this is just an issue in Shadow DOM v0 since v1 does not allow shadow roots on SVG elements. Bug: 915469 Change-Id: Id81843abad08814fae747b5bc81c09666583f130 Reviewed-on: https://chromium-review.googlesource.com/c/1382494 Reviewed-by: Fredrik Söderquist <fs@opera.com> Commit-Queue: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/master@{#617487} CWE ID: CWE-704
0
152,789
Analyze the following 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 may_ptrace_stop(void) { if (!likely(current->ptrace)) return 0; /* * Are we in the middle of do_coredump? * If so and our tracer is also part of the coredump stopping * is a deadlock situation, and pointless because our tracer * is dead so don't allow us to stop. * If SIGKILL was already sent before the caller unlocked * ->siglock we must see ->core_state != NULL. Otherwise it * is safe to enter schedule(). */ if (unlikely(current->mm->core_state) && unlikely(current->mm == current->parent->mm)) return 0; return 1; } Commit Message: ptrace: ensure arch_ptrace/ptrace_request can never race with SIGKILL putreg() assumes that the tracee is not running and pt_regs_access() can safely play with its stack. However a killed tracee can return from ptrace_stop() to the low-level asm code and do RESTORE_REST, this means that debugger can actually read/modify the kernel stack until the tracee does SAVE_REST again. set_task_blockstep() can race with SIGKILL too and in some sense this race is even worse, the very fact the tracee can be woken up breaks the logic. As Linus suggested we can clear TASK_WAKEKILL around the arch_ptrace() call, this ensures that nobody can ever wakeup the tracee while the debugger looks at it. Not only this fixes the mentioned problems, we can do some cleanups/simplifications in arch_ptrace() paths. Probably ptrace_unfreeze_traced() needs more callers, for example it makes sense to make the tracee killable for oom-killer before access_process_vm(). While at it, add the comment into may_ptrace_stop() to explain why ptrace_stop() still can't rely on SIGKILL and signal_pending_state(). Reported-by: Salman Qazi <sqazi@google.com> Reported-by: Suleiman Souhlal <suleiman@google.com> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> CWE ID: CWE-362
1
166,139
Analyze the following 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 BrowserView::GetSavedWindowPlacement( gfx::Rect* bounds, ui::WindowShowState* show_state) const { if (!ShouldSaveOrRestoreWindowPos()) return false; chrome::GetSavedWindowBoundsAndShowState(browser_.get(), bounds, show_state); #if defined(USE_ASH) if (browser_->is_type_popup() || browser_->is_type_panel()) { if (bounds->x() == 0 && bounds->y() == 0) { *bounds = ChromeShellDelegate::instance()->window_positioner()-> GetPopupPosition(*bounds); } } #endif if ((browser_->is_type_popup() && !browser_->is_devtools() && !browser_->is_app()) || (browser_->is_type_panel())) { if (IsToolbarVisible()) { bounds->set_height( bounds->height() + toolbar_->GetPreferredSize().height()); } gfx::Rect window_rect = frame_->non_client_view()-> GetWindowBoundsForClientBounds(*bounds); window_rect.set_origin(bounds->origin()); if (window_rect.x() == 0 && window_rect.y() == 0) { gfx::Size size = window_rect.size(); window_rect.set_origin( WindowSizer::GetDefaultPopupOrigin(size, browser_->host_desktop_type())); } *bounds = window_rect; *show_state = ui::SHOW_STATE_NORMAL; } return true; } 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
118,367
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void RenderWidgetHostViewGtk::CreatePluginContainer( gfx::PluginWindowHandle id) { plugin_container_manager_.CreatePluginContainer(id); } Commit Message: Implement TextureImageTransportSurface using texture mailbox This has a couple of advantages: - allow tearing down and recreating the UI parent context without losing the renderer contexts - do not require a context to be able to generate textures when creating the GLSurfaceHandle - clearer ownership semantics that potentially allows for more robust and easier lost context handling/thumbnailing/etc., since a texture is at any given time owned by either: UI parent, mailbox, or TextureImageTransportSurface - simplify frontbuffer protection logic; the frontbuffer textures are now owned by RWHV where they are refcounted The TextureImageTransportSurface informs RenderWidgetHostView of the mailbox names for the front- and backbuffer textures by associating them with a surface_handle (1 or 2) in the AcceleratedSurfaceNew message. During SwapBuffers() or PostSubBuffer() cycles, it then uses produceTextureCHROMIUM() and consumeTextureCHROMIUM() to transfer ownership between renderer and browser compositor. RWHV sends back the surface_handle of the buffer being returned with the Swap ACK (or 0 if no buffer is being returned in which case TextureImageTransportSurface will allocate a new texture - note that this could be used to simply keep textures for thumbnailing). BUG=154815,139616 TBR=sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/11194042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171569 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID:
0
114,930
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn) { enum direction dir; if(!(current->thread.flags & SPARC_FLAG_UNALIGNED) || (((insn >> 30) & 3) != 3)) goto kill_user; dir = decode_direction(insn); if(!ok_for_user(regs, insn, dir)) { goto kill_user; } else { int err, size = decode_access_size(insn); unsigned long addr; if(floating_point_load_or_store_p(insn)) { printk("User FPU load/store unaligned unsupported.\n"); goto kill_user; } addr = compute_effective_address(regs, insn); perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr); switch(dir) { case load: err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f), regs), size, (unsigned long *) addr, decode_signedness(insn)); break; case store: err = do_int_store(((insn>>25)&0x1f), size, (unsigned long *) addr, regs); break; case both: /* * This was supported in 2.4. However, we question * the value of SWAP instruction across word boundaries. */ printk("Unaligned SWAP unsupported.\n"); err = -EFAULT; break; default: unaligned_panic("Impossible user unaligned trap."); goto out; } if (err) goto kill_user; else advance(regs); goto out; } kill_user: user_mna_trap_fault(regs, insn); out: ; } Commit Message: perf: Remove the nmi parameter from the swevent and overflow interface The nmi parameter indicated if we could do wakeups from the current context, if not, we would set some state and self-IPI and let the resulting interrupt do the wakeup. For the various event classes: - hardware: nmi=0; PMI is in fact an NMI or we run irq_work_run from the PMI-tail (ARM etc.) - tracepoint: nmi=0; since tracepoint could be from NMI context. - software: nmi=[0,1]; some, like the schedule thing cannot perform wakeups, and hence need 0. As one can see, there is very little nmi=1 usage, and the down-side of not using it is that on some platforms some software events can have a jiffy delay in wakeup (when arch_irq_work_raise isn't implemented). The up-side however is that we can remove the nmi parameter and save a bunch of conditionals in fast paths. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Michael Cree <mcree@orcon.net.nz> Cc: Will Deacon <will.deacon@arm.com> Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com> Cc: Anton Blanchard <anton@samba.org> Cc: Eric B Munson <emunson@mgebm.net> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Paul Mundt <lethal@linux-sh.org> Cc: David S. Miller <davem@davemloft.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jason Wessel <jason.wessel@windriver.com> Cc: Don Zickus <dzickus@redhat.com> Link: http://lkml.kernel.org/n/tip-agjev8eu666tvknpb3iaj0fg@git.kernel.org Signed-off-by: Ingo Molnar <mingo@elte.hu> CWE ID: CWE-399
1
165,806
Analyze the following 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 unix_release_sock(struct sock *sk, int embrion) { struct unix_sock *u = unix_sk(sk); struct path path; struct sock *skpair; struct sk_buff *skb; int state; unix_remove_socket(sk); /* Clear state */ unix_state_lock(sk); sock_orphan(sk); sk->sk_shutdown = SHUTDOWN_MASK; path = u->path; u->path.dentry = NULL; u->path.mnt = NULL; state = sk->sk_state; sk->sk_state = TCP_CLOSE; unix_state_unlock(sk); wake_up_interruptible_all(&u->peer_wait); skpair = unix_peer(sk); if (skpair != NULL) { if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) { unix_state_lock(skpair); /* No more writes */ skpair->sk_shutdown = SHUTDOWN_MASK; if (!skb_queue_empty(&sk->sk_receive_queue) || embrion) skpair->sk_err = ECONNRESET; unix_state_unlock(skpair); skpair->sk_state_change(skpair); sk_wake_async(skpair, SOCK_WAKE_WAITD, POLL_HUP); } sock_put(skpair); /* It may now die */ unix_peer(sk) = NULL; } /* Try to flush out this socket. Throw out buffers at least */ while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { if (state == TCP_LISTEN) unix_release_sock(skb->sk, 1); /* passed fds are erased in the kfree_skb hook */ kfree_skb(skb); } if (path.dentry) path_put(&path); sock_put(sk); /* ---- Socket is dead now and most probably destroyed ---- */ /* * Fixme: BSD difference: In BSD all sockets connected to us get * ECONNRESET and we die on the spot. In Linux we behave * like files and pipes do and wait for the last * dereference. * * Can't we simply set sock->err? * * What the above comment does talk about? --ANK(980817) */ if (unix_tot_inflight) unix_gc(); /* Garbage collect fds */ } Commit Message: net: rework recvmsg handler msg_name and msg_namelen logic This patch now always passes msg->msg_namelen as 0. recvmsg handlers must set msg_namelen to the proper size <= sizeof(struct sockaddr_storage) to return msg_name to the user. This prevents numerous uninitialized memory leaks we had in the recvmsg handlers and makes it harder for new code to accidentally leak uninitialized memory. Optimize for the case recvfrom is called with NULL as address. We don't need to copy the address at all, so set it to NULL before invoking the recvmsg handler. We can do so, because all the recvmsg handlers must cope with the case a plain read() is called on them. read() also sets msg_name to NULL. Also document these changes in include/linux/net.h as suggested by David Miller. Changes since RFC: Set msg->msg_name = NULL if user specified a NULL in msg_name but had a non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't affect sendto as it would bail out earlier while trying to copy-in the address. It also more naturally reflects the logic by the callers of verify_iovec. With this change in place I could remove " if (!uaddr || msg_sys->msg_namelen == 0) msg->msg_name = NULL ". This change does not alter the user visible error logic as we ignore msg_namelen as long as msg_name is NULL. Also remove two unnecessary curly brackets in ___sys_recvmsg and change comments to netdev style. Cc: David Miller <davem@davemloft.net> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID: CWE-20
0
40,742
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd, splice_actor *actor) { int ret; while (pipe->nrbufs) { struct pipe_buffer *buf = pipe->bufs + pipe->curbuf; const struct pipe_buf_operations *ops = buf->ops; sd->len = buf->len; if (sd->len > sd->total_len) sd->len = sd->total_len; ret = buf->ops->confirm(pipe, buf); if (unlikely(ret)) { if (ret == -ENODATA) ret = 0; return ret; } ret = actor(pipe, buf, sd); if (ret <= 0) return ret; buf->offset += ret; buf->len -= ret; sd->num_spliced += ret; sd->len -= ret; sd->pos += ret; sd->total_len -= ret; if (!buf->len) { buf->ops = NULL; ops->release(pipe, buf); pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1); pipe->nrbufs--; if (pipe->files) sd->need_wakeup = true; } if (!sd->total_len) return 0; } return 1; } Commit Message: ->splice_write() via ->write_iter() iter_file_splice_write() - a ->splice_write() instance that gathers the pipe buffers, builds a bio_vec-based iov_iter covering those and feeds it to ->write_iter(). A bunch of simple cases coverted to that... [AV: fixed the braino spotted by Cyrill] Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> CWE ID: CWE-264
0
46,391
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: ScriptedAnimationController& Document::EnsureScriptedAnimationController() { if (!scripted_animation_controller_) { scripted_animation_controller_ = ScriptedAnimationController::Create(this); if (!GetPage()) scripted_animation_controller_->Suspend(); } return *scripted_animation_controller_; } Commit Message: Inherit CSP when we inherit the security origin This prevents attacks that use main window navigation to get out of the existing csp constraints such as the related bug Bug: 747847 Change-Id: I1e57b50da17f65d38088205b0a3c7c49ef2ae4d8 Reviewed-on: https://chromium-review.googlesource.com/592027 Reviewed-by: Mike West <mkwst@chromium.org> Commit-Queue: Andy Paicu <andypaicu@chromium.org> Cr-Commit-Position: refs/heads/master@{#492333} CWE ID: CWE-732
0
134,065
Analyze the following 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 TopSitesImpl::ShutdownOnUIThread() { history_service_ = nullptr; history_service_observer_.RemoveAll(); cancelable_task_tracker_.TryCancelAll(); if (backend_) backend_->Shutdown(); } Commit Message: TopSites: Clear thumbnails from the cache when their URLs get removed We already cleared the thumbnails from persistent storage, but they remained in the in-memory cache, so they remained accessible (until the next Chrome restart) even after all browsing data was cleared. Bug: 758169 Change-Id: Id916d22358430a82e6d5043ac04fa463a32f824f Reviewed-on: https://chromium-review.googlesource.com/758640 Commit-Queue: Marc Treib <treib@chromium.org> Reviewed-by: Sylvain Defresne <sdefresne@chromium.org> Cr-Commit-Position: refs/heads/master@{#514861} CWE ID: CWE-200
0
147,093
Analyze the following 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 decode_mb_coeffs(VP8Context *s, VP8ThreadData *td, VP56RangeCoder *c, VP8Macroblock *mb, uint8_t t_nnz[9], uint8_t l_nnz[9], int is_vp7) { int i, x, y, luma_start = 0, luma_ctx = 3; int nnz_pred, nnz, nnz_total = 0; int segment = mb->segment; int block_dc = 0; if (mb->mode != MODE_I4x4 && (is_vp7 || mb->mode != VP8_MVMODE_SPLIT)) { nnz_pred = t_nnz[8] + l_nnz[8]; nnz = decode_block_coeffs(c, td->block_dc, s->prob->token[1], 0, nnz_pred, s->qmat[segment].luma_dc_qmul, ff_zigzag_scan, is_vp7); l_nnz[8] = t_nnz[8] = !!nnz; if (is_vp7 && mb->mode > MODE_I4x4) { nnz |= inter_predict_dc(td->block_dc, s->inter_dc_pred[mb->ref_frame - 1]); } if (nnz) { nnz_total += nnz; block_dc = 1; if (nnz == 1) s->vp8dsp.vp8_luma_dc_wht_dc(td->block, td->block_dc); else s->vp8dsp.vp8_luma_dc_wht(td->block, td->block_dc); } luma_start = 1; luma_ctx = 0; } for (y = 0; y < 4; y++) for (x = 0; x < 4; x++) { nnz_pred = l_nnz[y] + t_nnz[x]; nnz = decode_block_coeffs(c, td->block[y][x], s->prob->token[luma_ctx], luma_start, nnz_pred, s->qmat[segment].luma_qmul, s->prob[0].scan, is_vp7); /* nnz+block_dc may be one more than the actual last index, * but we don't care */ td->non_zero_count_cache[y][x] = nnz + block_dc; t_nnz[x] = l_nnz[y] = !!nnz; nnz_total += nnz; } for (i = 4; i < 6; i++) for (y = 0; y < 2; y++) for (x = 0; x < 2; x++) { nnz_pred = l_nnz[i + 2 * y] + t_nnz[i + 2 * x]; nnz = decode_block_coeffs(c, td->block[i][(y << 1) + x], s->prob->token[2], 0, nnz_pred, s->qmat[segment].chroma_qmul, s->prob[0].scan, is_vp7); td->non_zero_count_cache[i][(y << 1) + x] = nnz; t_nnz[i + 2 * x] = l_nnz[i + 2 * y] = !!nnz; nnz_total += nnz; } if (!nnz_total) mb->skip = 1; } Commit Message: avcodec/webp: Always set pix_fmt Fixes: out of array access Fixes: 1434/clusterfuzz-testcase-minimized-6314998085189632 Fixes: 1435/clusterfuzz-testcase-minimized-6483783723253760 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Reviewed-by: "Ronald S. Bultje" <rsbultje@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> CWE ID: CWE-119
0
63,955
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: MagickExport void SetImageInfoBlob(ImageInfo *image_info,const void *blob, const size_t length) { assert(image_info != (ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); image_info->blob=(void *) blob; image_info->length=length; } Commit Message: Set pixel cache to undefined if any resource limit is exceeded CWE ID: CWE-119
0
94,853
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: HeapCache::~HeapCache() { } Commit Message: Sanity check IMemory access versus underlying mmap Bug 26877992 Change-Id: Ibbf4b1061e4675e4e96bc944a865b53eaf6984fe CWE ID: CWE-264
0
161,500
Analyze the following 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 TabCloseableStateWatcher::CanCloseTab(const Browser* browser) const { return true; } Commit Message: chromeos: fix bug where "aw snap" page replaces first tab if it was a NTP when closing window with > 1 tab. BUG=chromium-os:12088 TEST=verify bug per bug report. Review URL: http://codereview.chromium.org/6882058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83031 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-20
0
98,034
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: metalink_from_http (const struct response *resp, const struct http_stat *hs, const struct url *u) { metalink_t *metalink = NULL; metalink_file_t *mfile = xnew0 (metalink_file_t); const char *val_beg, *val_end; int res_count = 0, meta_count = 0, hash_count = 0, sig_count = 0, i; DEBUGP (("Checking for Metalink in HTTP response\n")); /* Initialize metalink file for our simple use case. */ if (hs->local_file) mfile->name = xstrdup (hs->local_file); else mfile->name = url_file_name (u, NULL); /* Begin with 1-element array (for 0-termination). */ mfile->checksums = xnew0 (metalink_checksum_t *); mfile->resources = xnew0 (metalink_resource_t *); mfile->metaurls = xnew0 (metalink_metaurl_t *); /* Process the Content-Type header. */ if (resp_header_locate (resp, "Content-Type", 0, &val_beg, &val_end) != -1) { metalink_metaurl_t murl = {0}; const char *type_beg, *type_end; char *typestr = NULL; char *namestr = NULL; size_t type_len; DEBUGP (("Processing Content-Type header...\n")); /* Find beginning of type. */ type_beg = val_beg; while (type_beg < val_end && c_isspace (*type_beg)) type_beg++; /* Find end of type. */ type_end = type_beg + 1; while (type_end < val_end && *type_end != ';' && *type_end != ' ' && *type_end != '\r' && *type_end != '\n') type_end++; if (type_beg >= val_end || type_end > val_end) { DEBUGP (("Invalid Content-Type header. Ignoring.\n")); goto skip_content_type; } type_len = type_end - type_beg; typestr = xstrndup (type_beg, type_len); DEBUGP (("Content-Type: %s\n", typestr)); if (strcmp (typestr, "application/metalink4+xml")) { xfree (typestr); goto skip_content_type; } /* Valid ranges for the "pri" attribute are from 1 to 999999. Mirror servers with a lower value of the "pri" attribute have a higher priority, while mirrors with an undefined "pri" attribute are considered to have a value of 999999, which is the lowest priority. rfc6249 section 3.1 */ murl.priority = DEFAULT_PRI; murl.mediatype = typestr; typestr = NULL; if (opt.content_disposition && resp_header_locate (resp, "Content-Disposition", 0, &val_beg, &val_end) != -1) { find_key_value (val_beg, val_end, "filename", &namestr); murl.name = namestr; namestr = NULL; } murl.url = xstrdup (u->url); DEBUGP (("URL=%s\n", murl.url)); DEBUGP (("MEDIATYPE=%s\n", murl.mediatype)); DEBUGP (("NAME=%s\n", murl.name ? murl.name : "")); DEBUGP (("PRIORITY=%d\n", murl.priority)); /* 1 slot from new resource, 1 slot for null-termination. */ mfile->metaurls = xrealloc (mfile->metaurls, sizeof (metalink_metaurl_t *) * (meta_count + 2)); mfile->metaurls[meta_count] = xnew0 (metalink_metaurl_t); *mfile->metaurls[meta_count] = murl; meta_count++; } skip_content_type: /* Find all Link headers. */ for (i = 0; (i = resp_header_locate (resp, "Link", i, &val_beg, &val_end)) != -1; i++) { char *rel = NULL, *reltype = NULL; char *urlstr = NULL; const char *url_beg, *url_end, *attrs_beg; size_t url_len; /* Sample Metalink Link headers: Link: <http://www2.example.com/dir1/dir2/dir3/dir4/dir5/example.ext>; rel=duplicate; pri=1; pref; geo=gb; depth=4 Link: <http://example.com/example.ext.asc>; rel=describedby; type="application/pgp-signature" */ /* Find beginning of URL. */ url_beg = val_beg; while (url_beg < val_end - 1 && c_isspace (*url_beg)) url_beg++; /* Find end of URL. */ /* The convention here is that end ptr points to one element after end of string. In this case, it should be pointing to the '>', which is one element after end of actual URL. Therefore, it should never point to val_end, which is one element after entire header value string. */ url_end = url_beg + 1; while (url_end < val_end - 1 && *url_end != '>') url_end++; if (url_beg >= val_end || url_end >= val_end || *url_beg != '<' || *url_end != '>') { DEBUGP (("This is not a valid Link header. Ignoring.\n")); continue; } /* Skip <. */ url_beg++; url_len = url_end - url_beg; /* URL found. Now handle the attributes. */ attrs_beg = url_end + 1; /* First we need to find out what type of link it is. Currently, we support rel=duplicate and rel=describedby. */ if (!find_key_value (attrs_beg, val_end, "rel", &rel)) { DEBUGP (("No rel value in Link header, skipping.\n")); continue; } urlstr = xstrndup (url_beg, url_len); DEBUGP (("URL=%s\n", urlstr)); DEBUGP (("rel=%s\n", rel)); if (!strcmp (rel, "describedby")) find_key_value (attrs_beg, val_end, "type", &reltype); /* Handle signatures. Libmetalink only supports one signature per file. Therefore we stop as soon as we successfully get first supported signature. */ if (sig_count == 0 && reltype && !strcmp (reltype, "application/pgp-signature")) { /* Download the signature to a temporary file. */ FILE *_output_stream = output_stream; bool _output_stream_regular = output_stream_regular; output_stream = tmpfile (); if (output_stream) { struct iri *iri = iri_new (); struct url *url; int url_err; set_uri_encoding (iri, opt.locale, true); url = url_parse (urlstr, &url_err, iri, false); if (!url) { char *error = url_error (urlstr, url_err); logprintf (LOG_NOTQUIET, _("When downloading signature:\n" "%s: %s.\n"), urlstr, error); xfree (error); iri_free (iri); } else { /* Avoid recursive Metalink from HTTP headers. */ bool _metalink_http = opt.metalink_over_http; uerr_t retr_err; opt.metalink_over_http = false; retr_err = retrieve_url (url, urlstr, NULL, NULL, NULL, NULL, false, iri, false); opt.metalink_over_http = _metalink_http; url_free (url); iri_free (iri); if (retr_err == RETROK) { /* Signature is in the temporary file. Read it into metalink resource structure. */ metalink_signature_t msig; size_t siglen; fseek (output_stream, 0, SEEK_END); siglen = ftell (output_stream); fseek (output_stream, 0, SEEK_SET); DEBUGP (("siglen=%lu\n", siglen)); msig.signature = xmalloc (siglen + 1); if (fread (msig.signature, siglen, 1, output_stream) != 1) { logputs (LOG_NOTQUIET, _("Unable to read signature content from " "temporary file. Skipping.\n")); xfree (msig.signature); } else { msig.signature[siglen] = '\0'; /* Just in case. */ msig.mediatype = xstrdup ("application/pgp-signature"); DEBUGP (("Signature (%s):\n%s\n", msig.mediatype, msig.signature)); mfile->signature = xnew (metalink_signature_t); *mfile->signature = msig; sig_count++; } } } fclose (output_stream); } else { logputs (LOG_NOTQUIET, _("Could not create temporary file. " "Skipping signature download.\n")); } output_stream_regular = _output_stream_regular; output_stream = _output_stream; } /* Iterate over signatures. */ /* Handle Metalink resources. */ else if (!strcmp (rel, "duplicate")) { metalink_resource_t mres = {0}; char *pristr; /* Valid ranges for the "pri" attribute are from 1 to 999999. Mirror servers with a lower value of the "pri" attribute have a higher priority, while mirrors with an undefined "pri" attribute are considered to have a value of 999999, which is the lowest priority. rfc6249 section 3.1 */ mres.priority = DEFAULT_PRI; if (find_key_value (url_end, val_end, "pri", &pristr)) { long pri; char *end_pristr; /* Do not care for errno since 0 is error in this case. */ pri = strtol (pristr, &end_pristr, 10); if (end_pristr != pristr + strlen (pristr) || !VALID_PRI_RANGE (pri)) { /* This is against the specification, so let's inform the user. */ logprintf (LOG_NOTQUIET, _("Invalid pri value. Assuming %d.\n"), DEFAULT_PRI); } else mres.priority = pri; xfree (pristr); } switch (url_scheme (urlstr)) { case SCHEME_HTTP: mres.type = xstrdup ("http"); break; #ifdef HAVE_SSL case SCHEME_HTTPS: mres.type = xstrdup ("https"); break; case SCHEME_FTPS: mres.type = xstrdup ("ftps"); break; #endif case SCHEME_FTP: mres.type = xstrdup ("ftp"); break; default: DEBUGP (("Unsupported url scheme in %s. Skipping resource.\n", urlstr)); } if (mres.type) { DEBUGP (("TYPE=%s\n", mres.type)); /* At this point we have validated the new resource. */ find_key_value (url_end, val_end, "geo", &mres.location); mres.url = urlstr; urlstr = NULL; mres.preference = 0; if (has_key (url_end, val_end, "pref")) { DEBUGP (("This resource has preference\n")); mres.preference = 1; } /* 1 slot from new resource, 1 slot for null-termination. */ mfile->resources = xrealloc (mfile->resources, sizeof (metalink_resource_t *) * (res_count + 2)); mfile->resources[res_count] = xnew0 (metalink_resource_t); *mfile->resources[res_count] = mres; res_count++; } } /* Handle resource link (rel=duplicate). */ /* Handle Metalink/XML resources. */ else if (reltype && !strcmp (reltype, "application/metalink4+xml")) { metalink_metaurl_t murl = {0}; char *pristr; /* Valid ranges for the "pri" attribute are from 1 to 999999. Mirror servers with a lower value of the "pri" attribute have a higher priority, while mirrors with an undefined "pri" attribute are considered to have a value of 999999, which is the lowest priority. rfc6249 section 3.1 */ murl.priority = DEFAULT_PRI; if (find_key_value (url_end, val_end, "pri", &pristr)) { long pri; char *end_pristr; /* Do not care for errno since 0 is error in this case. */ pri = strtol (pristr, &end_pristr, 10); if (end_pristr != pristr + strlen (pristr) || !VALID_PRI_RANGE (pri)) { /* This is against the specification, so let's inform the user. */ logprintf (LOG_NOTQUIET, _("Invalid pri value. Assuming %d.\n"), DEFAULT_PRI); } else murl.priority = pri; xfree (pristr); } murl.mediatype = xstrdup (reltype); DEBUGP (("MEDIATYPE=%s\n", murl.mediatype)); /* At this point we have validated the new resource. */ find_key_value (url_end, val_end, "name", &murl.name); murl.url = urlstr; urlstr = NULL; /* 1 slot from new resource, 1 slot for null-termination. */ mfile->metaurls = xrealloc (mfile->metaurls, sizeof (metalink_metaurl_t *) * (meta_count + 2)); mfile->metaurls[meta_count] = xnew0 (metalink_metaurl_t); *mfile->metaurls[meta_count] = murl; meta_count++; } /* Handle resource link (rel=describedby). */ else DEBUGP (("This link header was not used for Metalink\n")); xfree (urlstr); xfree (reltype); xfree (rel); } /* Iterate over link headers. */ /* Null-terminate resources array. */ mfile->resources[res_count] = 0; mfile->metaurls[meta_count] = 0; if (res_count == 0 && meta_count == 0) { DEBUGP (("No valid metalink references found.\n")); goto fail; } /* Find all Digest headers. */ for (i = 0; (i = resp_header_locate (resp, "Digest", i, &val_beg, &val_end)) != -1; i++) { const char *dig_pos; char *dig_type, *dig_hash; /* Each Digest header can include multiple hashes. Example: Digest: SHA=thvDyvhfIqlvFe+A9MYgxAfm1q5=,unixsum=30637 Digest: md5=HUXZLQLMuI/KZ5KDcJPcOA== */ for (dig_pos = val_beg; (dig_pos = find_key_values (dig_pos, val_end, &dig_type, &dig_hash)); dig_pos++) { /* The hash here is assumed to be base64. We need the hash in hex. Therefore we convert: base64 -> binary -> hex. */ const size_t dig_hash_str_len = strlen (dig_hash); char *bin_hash = alloca (dig_hash_str_len * 3 / 4 + 1); ssize_t hash_bin_len; hash_bin_len = wget_base64_decode (dig_hash, bin_hash, dig_hash_str_len * 3 / 4 + 1); /* Detect malformed base64 input. */ if (hash_bin_len < 0) { xfree (dig_type); xfree (dig_hash); continue; } /* One slot for me, one for zero-termination. */ mfile->checksums = xrealloc (mfile->checksums, sizeof (metalink_checksum_t *) * (hash_count + 2)); mfile->checksums[hash_count] = xnew (metalink_checksum_t); mfile->checksums[hash_count]->type = dig_type; mfile->checksums[hash_count]->hash = xmalloc ((size_t)hash_bin_len * 2 + 1); wg_hex_to_string (mfile->checksums[hash_count]->hash, bin_hash, (size_t)hash_bin_len); xfree (dig_hash); hash_count++; } } /* Zero-terminate checksums array. */ mfile->checksums[hash_count] = 0; /* If Instance Digests are not provided by the Metalink servers, the Link header fields pertaining to this specification MUST be ignored. rfc6249 section 6 */ if (res_count && hash_count == 0) { logputs (LOG_VERBOSE, _("Could not find acceptable digest for Metalink resources.\n" "Ignoring them.\n")); goto fail; } /* Metalink data is OK. Now we just need to sort the resources based on their priorities, preference, and perhaps location. */ stable_sort (mfile->resources, res_count, sizeof (metalink_resource_t *), metalink_res_cmp); stable_sort (mfile->metaurls, meta_count, sizeof (metalink_metaurl_t *), metalink_meta_cmp); /* Restore sensible preference values (in case someone cares to look). */ for (i = 0; i < res_count; ++i) mfile->resources[i]->preference = 1000000 - mfile->resources[i]->priority; metalink = xnew0 (metalink_t); metalink->files = xmalloc (sizeof (metalink_file_t *) * 2); metalink->files[0] = mfile; metalink->files[1] = 0; metalink->origin = xstrdup (u->url); metalink->version = METALINK_VERSION_4; /* Leave other fields set to 0. */ return metalink; fail: /* Free all allocated memory. */ if (metalink) metalink_delete (metalink); else metalink_file_delete (mfile); return NULL; } Commit Message: CWE ID: CWE-20
0
15,491
Analyze the following 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 nfs_free_unique_id(struct rb_root *root, struct nfs_unique_id *id) { rb_erase(&id->rb_node, root); } Commit Message: NFSv4: Convert the open and close ops to use fmode Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> CWE ID:
0
22,970
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: reduce_timeout(uint16_t max, uint16_t *timeout) { if (max && (!*timeout || *timeout > max)) { *timeout = max; } } Commit Message: ofproto: Fix OVS crash when reverting old flows in bundle commit During bundle commit flows which are added in bundle are applied to ofproto in-order. In case if a flow cannot be added (e.g. flow action is go-to group id which does not exist), OVS tries to revert back all previous flows which were successfully applied from the same bundle. This is possible since OVS maintains list of old flows which were replaced by flows from the bundle. While reinserting old flows ovs asserts due to check on rule state != RULE_INITIALIZED. This will work only for new flows, but for old flow the rule state will be RULE_REMOVED. This is causing an assert and OVS crash. The ovs assert check should be modified to != RULE_INSERTED to prevent any existing rule being re-inserted and allow new rules and old rules (in case of revert) to get inserted. Here is an example to trigger the assert: $ ovs-vsctl add-br br-test -- set Bridge br-test datapath_type=netdev $ cat flows.txt flow add table=1,priority=0,in_port=2,actions=NORMAL flow add table=1,priority=0,in_port=3,actions=NORMAL $ ovs-ofctl dump-flows -OOpenflow13 br-test cookie=0x0, duration=2.465s, table=1, n_packets=0, n_bytes=0, priority=0,in_port=2 actions=NORMAL cookie=0x0, duration=2.465s, table=1, n_packets=0, n_bytes=0, priority=0,in_port=3 actions=NORMAL $ cat flow-modify.txt flow modify table=1,priority=0,in_port=2,actions=drop flow modify table=1,priority=0,in_port=3,actions=group:10 $ ovs-ofctl bundle br-test flow-modify.txt -OOpenflow13 First flow rule will be modified since it is a valid rule. However second rule is invalid since no group with id 10 exists. Bundle commit tries to revert (insert) the first rule to old flow which results in ovs_assert at ofproto_rule_insert__() since old rule->state = RULE_REMOVED. Signed-off-by: Vishal Deep Ajmera <vishal.deep.ajmera@ericsson.com> Signed-off-by: Ben Pfaff <blp@ovn.org> CWE ID: CWE-617
0
77,419
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: AirPDcapDecryptWPABroadcastKey(const EAPOL_RSN_KEY *pEAPKey, guint8 *decryption_key, PAIRPDCAP_SEC_ASSOCIATION sa, guint eapol_len) { guint8 key_version; guint8 *key_data; guint8 *szEncryptedKey; guint16 key_bytes_len = 0; /* Length of the total key data field */ guint16 key_len; /* Actual group key length */ static AIRPDCAP_KEY_ITEM dummy_key; /* needed in case AirPDcapRsnaMng() wants the key structure */ AIRPDCAP_SEC_ASSOCIATION *tmp_sa; /* We skip verifying the MIC of the key. If we were implementing a WPA supplicant we'd want to verify, but for a sniffer it's not needed. */ /* Preparation for decrypting the group key - determine group key data length */ /* depending on whether the pairwise key is TKIP or AES encryption key */ key_version = AIRPDCAP_EAP_KEY_DESCR_VER(pEAPKey->key_information[1]); if (key_version == AIRPDCAP_WPA_KEY_VER_NOT_CCMP){ /* TKIP */ key_bytes_len = pntoh16(pEAPKey->key_length); }else if (key_version == AIRPDCAP_WPA_KEY_VER_AES_CCMP){ /* AES */ key_bytes_len = pntoh16(pEAPKey->key_data_len); /* AES keys must be at least 128 bits = 16 bytes. */ if (key_bytes_len < 16) { return AIRPDCAP_RET_NO_VALID_HANDSHAKE; } } if (key_bytes_len < GROUP_KEY_MIN_LEN || key_bytes_len > eapol_len - sizeof(EAPOL_RSN_KEY)) { return AIRPDCAP_RET_NO_VALID_HANDSHAKE; } /* Encrypted key is in the information element field of the EAPOL key packet */ key_data = (guint8 *)pEAPKey + sizeof(EAPOL_RSN_KEY); szEncryptedKey = (guint8 *)g_memdup(key_data, key_bytes_len); DEBUG_DUMP("Encrypted Broadcast key:", szEncryptedKey, key_bytes_len); DEBUG_DUMP("KeyIV:", pEAPKey->key_iv, 16); DEBUG_DUMP("decryption_key:", decryption_key, 16); /* We are rekeying, save old sa */ tmp_sa=(AIRPDCAP_SEC_ASSOCIATION *)g_malloc(sizeof(AIRPDCAP_SEC_ASSOCIATION)); memcpy(tmp_sa, sa, sizeof(AIRPDCAP_SEC_ASSOCIATION)); sa->next=tmp_sa; /* As we have no concept of the prior association request at this point, we need to deduce the */ /* group key cipher from the length of the key bytes. In WPA this is straightforward as the */ /* keybytes just contain the GTK, and the GTK is only in the group handshake, NOT the M3. */ /* In WPA2 its a little more tricky as the M3 keybytes contain an RSN_IE, but the group handshake */ /* does not. Also there are other (variable length) items in the keybytes which we need to account */ /* for to determine the true key length, and thus the group cipher. */ if (key_version == AIRPDCAP_WPA_KEY_VER_NOT_CCMP){ guint8 new_key[32]; guint8 dummy[256]; /* TKIP key */ /* Per 802.11i, Draft 3.0 spec, section 8.5.2, p. 97, line 4-8, */ /* group key is decrypted using RC4. Concatenate the IV with the 16 byte EK (PTK+16) to get the decryption key */ rc4_state_struct rc4_state; /* The WPA group key just contains the GTK bytes so deducing the type is straightforward */ /* Note - WPA M3 doesn't contain a group key so we'll only be here for the group handshake */ sa->wpa.key_ver = (key_bytes_len >=TKIP_GROUP_KEY_LEN)?AIRPDCAP_WPA_KEY_VER_NOT_CCMP:AIRPDCAP_WPA_KEY_VER_AES_CCMP; /* Build the full decryption key based on the IV and part of the pairwise key */ memcpy(new_key, pEAPKey->key_iv, 16); memcpy(new_key+16, decryption_key, 16); DEBUG_DUMP("FullDecrKey:", new_key, 32); crypt_rc4_init(&rc4_state, new_key, sizeof(new_key)); /* Do dummy 256 iterations of the RC4 algorithm (per 802.11i, Draft 3.0, p. 97 line 6) */ crypt_rc4(&rc4_state, dummy, 256); crypt_rc4(&rc4_state, szEncryptedKey, key_bytes_len); } else if (key_version == AIRPDCAP_WPA_KEY_VER_AES_CCMP){ /* AES CCMP key */ guint8 key_found; guint8 key_length; guint16 key_index; guint8 *decrypted_data; /* Unwrap the key; the result is key_bytes_len in length */ decrypted_data = AES_unwrap(decryption_key, 16, szEncryptedKey, key_bytes_len); /* With WPA2 what we get after Broadcast Key decryption is an actual RSN structure. The key itself is stored as a GTK KDE WPA2 IE (1 byte) id = 0xdd, length (1 byte), GTK OUI (4 bytes), key index (1 byte) and 1 reserved byte. Thus we have to pass pointer to the actual key with 8 bytes offset */ key_found = FALSE; key_index = 0; /* Parse Key data until we found GTK KDE */ /* GTK KDE = 00-0F-AC 01 */ while(key_index < (key_bytes_len - 6) && !key_found){ guint8 rsn_id; guint32 type; /* Get RSN ID */ rsn_id = decrypted_data[key_index]; type = ((decrypted_data[key_index + 2] << 24) + (decrypted_data[key_index + 3] << 16) + (decrypted_data[key_index + 4] << 8) + (decrypted_data[key_index + 5])); if (rsn_id == 0xdd && type == 0x000fac01) { key_found = TRUE; } else { key_index += decrypted_data[key_index+1]+2; } } if (key_found){ key_length = decrypted_data[key_index+1] - 6; if (key_index+8 >= key_bytes_len || key_length > key_bytes_len - key_index - 8) { g_free(decrypted_data); g_free(szEncryptedKey); return AIRPDCAP_RET_NO_VALID_HANDSHAKE; } /* Skip over the GTK header info, and don't copy past the end of the encrypted data */ memcpy(szEncryptedKey, decrypted_data+key_index+8, key_length); } else { g_free(decrypted_data); g_free(szEncryptedKey); return AIRPDCAP_RET_NO_VALID_HANDSHAKE; } if (key_length == TKIP_GROUP_KEY_LEN) sa->wpa.key_ver = AIRPDCAP_WPA_KEY_VER_NOT_CCMP; else sa->wpa.key_ver = AIRPDCAP_WPA_KEY_VER_AES_CCMP; g_free(decrypted_data); } key_len = (sa->wpa.key_ver==AIRPDCAP_WPA_KEY_VER_NOT_CCMP)?TKIP_GROUP_KEY_LEN:CCMP_GROUP_KEY_LEN; if (key_len > key_bytes_len) { /* the key required for this protocol is longer than the key that we just calculated */ g_free(szEncryptedKey); return AIRPDCAP_RET_NO_VALID_HANDSHAKE; } /* Decrypted key is now in szEncryptedKey with len of key_len */ DEBUG_DUMP("Broadcast key:", szEncryptedKey, key_len); /* Load the proper key material info into the SA */ sa->key = &dummy_key; /* we just need key to be not null because it is checked in AirPDcapRsnaMng(). The WPA key materials are actually in the .wpa structure */ sa->validKey = TRUE; /* Since this is a GTK and its size is only 32 bytes (vs. the 64 byte size of a PTK), we fake it and put it in at a 32-byte offset so the */ /* AirPDcapRsnaMng() function will extract the right piece of the GTK for decryption. (The first 16 bytes of the GTK are used for decryption.) */ memset(sa->wpa.ptk, 0, sizeof(sa->wpa.ptk)); memcpy(sa->wpa.ptk+32, szEncryptedKey, key_len); g_free(szEncryptedKey); return AIRPDCAP_RET_SUCCESS_HANDSHAKE; } Commit Message: Sanity check eapol_len in AirPDcapDecryptWPABroadcastKey Bug: 12175 Change-Id: Iaf977ba48f8668bf8095800a115ff9a3472dd893 Reviewed-on: https://code.wireshark.org/review/15326 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Peter Wu <peter@lekensteyn.nl> CWE ID: CWE-125
1
167,157
Analyze the following 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 SpeechRecognitionManagerImpl::DispatchEvent(int session_id, FSMEvent event) { DCHECK_CURRENTLY_ON(BrowserThread::IO); if (!SessionExists(session_id)) return; Session* session = GetSession(session_id); FSMState session_state = GetSessionState(session_id); DCHECK_LE(session_state, SESSION_STATE_MAX_VALUE); DCHECK_LE(event, EVENT_MAX_VALUE); DCHECK(!is_dispatching_event_); is_dispatching_event_ = true; ExecuteTransitionAndGetNextState(session, session_state, event); is_dispatching_event_ = false; } Commit Message: Make MediaStreamDispatcherHost per-request instead of per-frame. Instead of having RenderFrameHost own a single MSDH to handle all requests from a frame, MSDH objects will be owned by a strong binding. A consequence of this is that an additional requester ID is added to requests to MediaStreamManager, so that an MSDH is able to cancel only requests generated by it. In practice, MSDH will continue to be per frame in most cases since each frame normally makes a single request for an MSDH object. This fixes a lifetime issue caused by the IO thread executing tasks after the RenderFrameHost dies. Drive-by: Fix some minor lint issues. Bug: 912520 Change-Id: I52742ffc98b9fc57ce8e6f5093a61aed86d3e516 Reviewed-on: https://chromium-review.googlesource.com/c/1369799 Reviewed-by: Emircan Uysaler <emircan@chromium.org> Reviewed-by: Ken Buchanan <kenrb@chromium.org> Reviewed-by: Olga Sharonova <olka@chromium.org> Commit-Queue: Guido Urdaneta <guidou@chromium.org> Cr-Commit-Position: refs/heads/master@{#616347} CWE ID: CWE-189
0
153,290
Analyze the following 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 V8WindowShell::installDOMWindow() { DOMWrapperWorld::setInitializingWindow(true); DOMWindow* window = m_frame->domWindow(); v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(V8PerContextData::from(m_context.newLocal(m_isolate))->constructorForType(&V8Window::info)); if (windowWrapper.IsEmpty()) return false; V8Window::installPerContextEnabledProperties(windowWrapper, window, m_isolate); V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object>::Cast(windowWrapper->GetPrototype()), &V8Window::info, window); v8::Handle<v8::Object> innerGlobalObject = toInnerGlobalObject(m_context.newLocal(m_isolate)); V8DOMWrapper::setNativeInfo(innerGlobalObject, &V8Window::info, window); innerGlobalObject->SetPrototype(windowWrapper); V8DOMWrapper::associateObjectWithWrapper<V8Window>(PassRefPtr<DOMWindow>(window), &V8Window::info, windowWrapper, m_isolate, WrapperConfiguration::Dependent); DOMWrapperWorld::setInitializingWindow(false); return true; } Commit Message: Fix tracking of the id attribute string if it is shared across elements. The patch to remove AtomicStringImpl: http://src.chromium.org/viewvc/blink?view=rev&rev=154790 Exposed a lifetime issue with strings for id attributes. We simply need to use AtomicString. BUG=290566 Review URL: https://codereview.chromium.org/33793004 git-svn-id: svn://svn.chromium.org/blink/trunk@160250 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID: CWE-399
0
110,437
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static ssize_t cdc_ncm_store_rx_max(struct device *d, struct device_attribute *attr, const char *buf, size_t len) { struct usbnet *dev = netdev_priv(to_net_dev(d)); struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0]; unsigned long val; if (kstrtoul(buf, 0, &val) || cdc_ncm_check_rx_max(dev, val) != val) return -EINVAL; cdc_ncm_update_rxtx_max(dev, val, ctx->tx_max); return len; } Commit Message: cdc_ncm: do not call usbnet_link_change from cdc_ncm_bind usbnet_link_change will call schedule_work and should be avoided if bind is failing. Otherwise we will end up with scheduled work referring to a netdev which has gone away. Instead of making the call conditional, we can just defer it to usbnet_probe, using the driver_info flag made for this purpose. Fixes: 8a34b0ae8778 ("usbnet: cdc_ncm: apply usbnet_link_change") Reported-by: Andrey Konovalov <andreyknvl@gmail.com> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: David S. Miller <davem@davemloft.net> CWE ID:
0
53,638
Analyze the following 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 GetNewTabBackgroundCSS(const ui::ThemeProvider* theme_provider, bool bar_attached) { if (!theme_provider->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { return "-64px"; } int alignment = theme_provider->GetDisplayProperty( ThemeProperties::NTP_BACKGROUND_ALIGNMENT); if (bar_attached) return ThemeProperties::AlignmentToString(alignment); if (alignment & ThemeProperties::ALIGN_TOP) { int offset = chrome::kNTPBookmarkBarHeight; if (alignment & ThemeProperties::ALIGN_LEFT) return "left " + base::IntToString(-offset) + "px"; else if (alignment & ThemeProperties::ALIGN_RIGHT) return "right " + base::IntToString(-offset) + "px"; return "center " + base::IntToString(-offset) + "px"; } return ThemeProperties::AlignmentToString(alignment); } Commit Message: Remove --disable-app-shims. App shims have been enabled by default for 3 milestones (since r242711). BUG=350161 Review URL: https://codereview.chromium.org/298953002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272786 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
110,359
Analyze the following 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 ExtensionApiTest::RunExtensionTestWithFlags( const std::string& extension_name, int flags) { return RunExtensionTestImpl(extension_name, std::string(), nullptr, flags); } Commit Message: Hide DevTools frontend from webRequest API Prevent extensions from observing requests for remote DevTools frontends and add regression tests. And update ExtensionTestApi to support initializing the embedded test server and port from SetUpCommandLine (before SetUpOnMainThread). BUG=797497,797500 TEST=browser_test --gtest_filter=DevToolsFrontendInWebRequestApiTest.HiddenRequests Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo Change-Id: Ic8f44b5771f2d5796f8c3de128f0a7ab88a77735 Reviewed-on: https://chromium-review.googlesource.com/844316 Commit-Queue: Rob Wu <rob@robwu.nl> Reviewed-by: Devlin <rdevlin.cronin@chromium.org> Reviewed-by: Dmitry Gozman <dgozman@chromium.org> Cr-Commit-Position: refs/heads/master@{#528187} CWE ID: CWE-200
0
146,578
Analyze the following 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 Label::SetEnabled(bool enabled) { if (enabled == enabled_) return; View::SetEnabled(enabled); SetColor(enabled ? kEnabledColor : kDisabledColor); } Commit Message: wstring: remove wstring version of SplitString Retry of r84336. BUG=23581 Review URL: http://codereview.chromium.org/6930047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84355 0039d316-1c4b-4281-b951-d872f2087c98 CWE ID: CWE-399
0
100,928
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *args) { __be32 *p; RESERVE_SPACE(12+NFS4_STATEID_SIZE+16); WRITE32(OP_LOCKU); WRITE32(nfs4_lock_type(args->fl, 0)); WRITE32(args->seqid->sequence->counter); WRITEMEM(args->stateid->data, NFS4_STATEID_SIZE); WRITE64(args->fl->fl_start); WRITE64(nfs4_lock_length(args->fl)); return 0; } Commit Message: NFSv4: Convert the open and close ops to use fmode Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> CWE ID:
0
23,071
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: std::unique_ptr<service_manager::Service> CreateMediaService() { return std::unique_ptr<service_manager::Service>( new ::media::MediaService(base::MakeUnique<CdmMojoMediaClient>())); } Commit Message: media: Support hosting mojo CDM in a standalone service Currently when mojo CDM is enabled it is hosted in the MediaService running in the process specified by "mojo_media_host". However, on some platforms we need to run mojo CDM and other mojo media services in different processes. For example, on desktop platforms, we want to run mojo video decoder in the GPU process, but run the mojo CDM in the utility process. This CL adds a new build flag "enable_standalone_cdm_service". When enabled, the mojo CDM service will be hosted in a standalone "cdm" service running in the utility process. All other mojo media services will sill be hosted in the "media" servie running in the process specified by "mojo_media_host". BUG=664364 TEST=Encrypted media browser tests using mojo CDM is still working. Change-Id: I95be6e05adc9ebcff966b26958ef1d7becdfb487 Reviewed-on: https://chromium-review.googlesource.com/567172 Commit-Queue: Xiaohan Wang <xhwang@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: John Abd-El-Malek <jam@chromium.org> Reviewed-by: Dan Sanders <sandersd@chromium.org> Cr-Commit-Position: refs/heads/master@{#486947} CWE ID: CWE-119
1
171,941
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h) { int sx = 0, sy = 0; int dx = 0, dy = 0; int depth = 0; int notify = 0; /* make sure to only copy if it's a plain copy ROP */ if (*s->cirrus_rop == cirrus_bitblt_rop_fwd_src || *s->cirrus_rop == cirrus_bitblt_rop_bkwd_src) { int width, height; depth = s->vga.get_bpp(&s->vga) / 8; s->vga.get_resolution(&s->vga, &width, &height); /* extra x, y */ sx = (src % ABS(s->cirrus_blt_srcpitch)) / depth; sy = (src / ABS(s->cirrus_blt_srcpitch)); dx = (dst % ABS(s->cirrus_blt_dstpitch)) / depth; dy = (dst / ABS(s->cirrus_blt_dstpitch)); /* normalize width */ w /= depth; /* if we're doing a backward copy, we have to adjust our x/y to be the upper left corner (instead of the lower right corner) */ if (s->cirrus_blt_dstpitch < 0) { sx -= (s->cirrus_blt_width / depth) - 1; dx -= (s->cirrus_blt_width / depth) - 1; sy -= s->cirrus_blt_height - 1; dy -= s->cirrus_blt_height - 1; } /* are we in the visible portion of memory? */ if (sx >= 0 && sy >= 0 && dx >= 0 && dy >= 0 && (sx + w) <= width && (sy + h) <= height && (dx + w) <= width && (dy + h) <= height) { notify = 1; } } /* we have to flush all pending changes so that the copy is generated at the appropriate moment in time */ if (notify) graphic_hw_update(s->vga.con); (*s->cirrus_rop) (s, s->vga.vram_ptr + (s->cirrus_blt_dstaddr & s->cirrus_addr_mask), s->vga.vram_ptr + (s->cirrus_blt_srcaddr & s->cirrus_addr_mask), s->cirrus_blt_dstpitch, s->cirrus_blt_srcpitch, s->cirrus_blt_width, s->cirrus_blt_height); if (notify) { qemu_console_copy(s->vga.con, sx, sy, dx, dy, s->cirrus_blt_width / depth, s->cirrus_blt_height); } /* we don't have to notify the display that this portion has changed since qemu_console_copy implies this */ cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, s->cirrus_blt_dstpitch, s->cirrus_blt_width, s->cirrus_blt_height); } Commit Message: CWE ID: CWE-119
0
7,578
Analyze the following 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 uuid_Size(GF_Box *s) { GF_UnknownUUIDBox*ptr = (GF_UnknownUUIDBox*)s; ptr->size += ptr->dataSize; return GF_OK; } Commit Message: fixed 2 possible heap overflows (inc. #1088) CWE ID: CWE-125
0
80,657
Analyze the following 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 __cond_resched(void) { add_preempt_count(PREEMPT_ACTIVE); schedule(); sub_preempt_count(PREEMPT_ACTIVE); } Commit Message: Sched: fix skip_clock_update optimization idle_balance() drops/retakes rq->lock, leaving the previous task vulnerable to set_tsk_need_resched(). Clear it after we return from balancing instead, and in setup_thread_stack() as well, so no successfully descheduled or never scheduled task has it set. Need resched confused the skip_clock_update logic, which assumes that the next call to update_rq_clock() will come nearly immediately after being set. Make the optimization robust against the waking a sleeper before it sucessfully deschedules case by checking that the current task has not been dequeued before setting the flag, since it is that useless clock update we're trying to save, and clear unconditionally in schedule() proper instead of conditionally in put_prev_task(). Signed-off-by: Mike Galbraith <efault@gmx.de> Reported-by: Bjoern B. Brandenburg <bbb.lst@gmail.com> Tested-by: Yong Zhang <yong.zhang0@gmail.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: stable@kernel.org LKML-Reference: <1291802742.1417.9.camel@marge.simson.net> Signed-off-by: Ingo Molnar <mingo@elte.hu> CWE ID:
0
22,299
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: OMXCodec::BufferInfo *OMXCodec::findEmptyInputBuffer() { Vector<BufferInfo> *infos = &mPortBuffers[kPortIndexInput]; for (size_t i = 0; i < infos->size(); ++i) { BufferInfo *info = &infos->editItemAt(i); if (info->mStatus == OWNED_BY_US) { return info; } } TRESPASS(); } Commit Message: OMXCodec: check IMemory::pointer() before using allocation Bug: 29421811 Change-Id: I0a73ba12bae4122f1d89fc92e5ea4f6a96cd1ed1 CWE ID: CWE-284
0
158,157
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: static int sched_copy_attr(struct sched_attr __user *uattr, struct sched_attr *attr) { u32 size; int ret; if (!access_ok(VERIFY_WRITE, uattr, SCHED_ATTR_SIZE_VER0)) return -EFAULT; /* * zero the full structure, so that a short copy will be nice. */ memset(attr, 0, sizeof(*attr)); ret = get_user(size, &uattr->size); if (ret) return ret; if (size > PAGE_SIZE) /* silly large */ goto err_size; if (!size) /* abi compat */ size = SCHED_ATTR_SIZE_VER0; if (size < SCHED_ATTR_SIZE_VER0) goto err_size; /* * If we're handed a bigger struct than we know of, * ensure all the unknown bits are 0 - i.e. new * user-space does not rely on any kernel feature * extensions we dont know about yet. */ if (size > sizeof(*attr)) { unsigned char __user *addr; unsigned char __user *end; unsigned char val; addr = (void __user *)uattr + sizeof(*attr); end = (void __user *)uattr + size; for (; addr < end; addr++) { ret = get_user(val, addr); if (ret) return ret; if (val) goto err_size; } size = sizeof(*attr); } ret = copy_from_user(attr, uattr, size); if (ret) return -EFAULT; /* * XXX: do we want to be lenient like existing syscalls; or do we want * to be strict and return an error on out-of-bounds values? */ attr->sched_nice = clamp(attr->sched_nice, -20, 19); out: return ret; err_size: put_user(sizeof(*attr), &uattr->size); ret = -E2BIG; goto out; } Commit Message: sched: Fix information leak in sys_sched_getattr() We're copying the on-stack structure to userspace, but forgot to give the right number of bytes to copy. This allows the calling process to obtain up to PAGE_SIZE bytes from the stack (and possibly adjacent kernel memory). This fix copies only as much as we actually have on the stack (attr->size defaults to the size of the struct) and leaves the rest of the userspace-provided buffer untouched. Found using kmemcheck + trinity. Fixes: d50dde5a10f30 ("sched: Add new scheduler syscalls to support an extended scheduling parameters ABI") Cc: Dario Faggioli <raistlin@linux.it> Cc: Juri Lelli <juri.lelli@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1392585857-10725-1-git-send-email-vegard.nossum@oracle.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de> CWE ID: CWE-200
0
58,181
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: xfs_attr3_leaf_unbalance( struct xfs_da_state *state, struct xfs_da_state_blk *drop_blk, struct xfs_da_state_blk *save_blk) { struct xfs_attr_leafblock *drop_leaf = drop_blk->bp->b_addr; struct xfs_attr_leafblock *save_leaf = save_blk->bp->b_addr; struct xfs_attr3_icleaf_hdr drophdr; struct xfs_attr3_icleaf_hdr savehdr; struct xfs_attr_leaf_entry *entry; struct xfs_mount *mp = state->mp; trace_xfs_attr_leaf_unbalance(state->args); drop_leaf = drop_blk->bp->b_addr; save_leaf = save_blk->bp->b_addr; xfs_attr3_leaf_hdr_from_disk(&drophdr, drop_leaf); xfs_attr3_leaf_hdr_from_disk(&savehdr, save_leaf); entry = xfs_attr3_leaf_entryp(drop_leaf); /* * Save last hashval from dying block for later Btree fixup. */ drop_blk->hashval = be32_to_cpu(entry[drophdr.count - 1].hashval); /* * Check if we need a temp buffer, or can we do it in place. * Note that we don't check "leaf" for holes because we will * always be dropping it, toosmall() decided that for us already. */ if (savehdr.holes == 0) { /* * dest leaf has no holes, so we add there. May need * to make some room in the entry array. */ if (xfs_attr3_leaf_order(save_blk->bp, &savehdr, drop_blk->bp, &drophdr)) { xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, save_leaf, &savehdr, 0, drophdr.count, mp); } else { xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, save_leaf, &savehdr, savehdr.count, drophdr.count, mp); } } else { /* * Destination has holes, so we make a temporary copy * of the leaf and add them both to that. */ struct xfs_attr_leafblock *tmp_leaf; struct xfs_attr3_icleaf_hdr tmphdr; tmp_leaf = kmem_zalloc(state->blocksize, KM_SLEEP); /* * Copy the header into the temp leaf so that all the stuff * not in the incore header is present and gets copied back in * once we've moved all the entries. */ memcpy(tmp_leaf, save_leaf, xfs_attr3_leaf_hdr_size(save_leaf)); memset(&tmphdr, 0, sizeof(tmphdr)); tmphdr.magic = savehdr.magic; tmphdr.forw = savehdr.forw; tmphdr.back = savehdr.back; tmphdr.firstused = state->blocksize; /* write the header to the temp buffer to initialise it */ xfs_attr3_leaf_hdr_to_disk(tmp_leaf, &tmphdr); if (xfs_attr3_leaf_order(save_blk->bp, &savehdr, drop_blk->bp, &drophdr)) { xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, tmp_leaf, &tmphdr, 0, drophdr.count, mp); xfs_attr3_leaf_moveents(save_leaf, &savehdr, 0, tmp_leaf, &tmphdr, tmphdr.count, savehdr.count, mp); } else { xfs_attr3_leaf_moveents(save_leaf, &savehdr, 0, tmp_leaf, &tmphdr, 0, savehdr.count, mp); xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, tmp_leaf, &tmphdr, tmphdr.count, drophdr.count, mp); } memcpy(save_leaf, tmp_leaf, state->blocksize); savehdr = tmphdr; /* struct copy */ kmem_free(tmp_leaf); } xfs_attr3_leaf_hdr_to_disk(save_leaf, &savehdr); xfs_trans_log_buf(state->args->trans, save_blk->bp, 0, state->blocksize - 1); /* * Copy out last hashval in each block for B-tree code. */ entry = xfs_attr3_leaf_entryp(save_leaf); save_blk->hashval = be32_to_cpu(entry[savehdr.count - 1].hashval); } Commit Message: xfs: remote attribute overwrite causes transaction overrun Commit e461fcb ("xfs: remote attribute lookups require the value length") passes the remote attribute length in the xfs_da_args structure on lookup so that CRC calculations and validity checking can be performed correctly by related code. This, unfortunately has the side effect of changing the args->valuelen parameter in cases where it shouldn't. That is, when we replace a remote attribute, the incoming replacement stores the value and length in args->value and args->valuelen, but then the lookup which finds the existing remote attribute overwrites args->valuelen with the length of the remote attribute being replaced. Hence when we go to create the new attribute, we create it of the size of the existing remote attribute, not the size it is supposed to be. When the new attribute is much smaller than the old attribute, this results in a transaction overrun and an ASSERT() failure on a debug kernel: XFS: Assertion failed: tp->t_blk_res_used <= tp->t_blk_res, file: fs/xfs/xfs_trans.c, line: 331 Fix this by keeping the remote attribute value length separate to the attribute value length in the xfs_da_args structure. The enables us to pass the length of the remote attribute to be removed without overwriting the new attribute's length. Also, ensure that when we save remote block contexts for a later rename we zero the original state variables so that we don't confuse the state of the attribute to be removes with the state of the new attribute that we just added. [Spotted by Brain Foster.] Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com> CWE ID: CWE-19
0
44,943
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: OpenGLFunctionTable* openGLFunctionTable() { static OpenGLFunctionTable table; return &table; } Commit Message: OpenGLShims: fix check for ANGLE GLES2 extensions https://bugs.webkit.org/show_bug.cgi?id=111656 Patch by Sergio Correia <sergio.correia@openbossa.org> on 2013-03-07 Reviewed by Simon Hausmann. The check for ANGLE GLES2 extensions is currently being overriden with checks for APPLE extensions in lookupOpenGLFunctionAddress(). No new tests. No user visible behavior changed. * platform/graphics/OpenGLShims.cpp: (WebCore::lookupOpenGLFunctionAddress): git-svn-id: svn://svn.chromium.org/blink/trunk@145079 bbb929c8-8fbe-4397-9dbb-9b2b20218538 CWE ID:
0
104,727
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: rdp_out_ts_bitmap_capabilityset(STREAM s) { logger(Protocol, Debug, "rdp_out_ts_bitmap_capabilityset(), %dx%d", g_session_width, g_session_height); out_uint16_le(s, RDP_CAPSET_BITMAP); out_uint16_le(s, RDP_CAPLEN_BITMAP); out_uint16_le(s, g_server_depth); /* preferredBitsPerPixel */ out_uint16_le(s, 1); /* receive1BitPerPixel (ignored, should be 1) */ out_uint16_le(s, 1); /* receive4BitPerPixel (ignored, should be 1) */ out_uint16_le(s, 1); /* receive8BitPerPixel (ignored, should be 1) */ out_uint16_le(s, g_session_width); /* desktopWidth */ out_uint16_le(s, g_session_height); /* desktopHeight */ out_uint16_le(s, 0); /* pad2Octets */ out_uint16_le(s, 1); /* desktopResizeFlag */ out_uint16_le(s, 1); /* bitmapCompressionFlag (must be 1) */ out_uint8(s, 0); /* highColorFlags (ignored, should be 0) */ out_uint8(s, 0); /* drawingFlags */ out_uint16_le(s, 1); /* multipleRectangleSupport (must be 1) */ out_uint16_le(s, 0); /* pad2OctetsB */ } Commit Message: Malicious RDP server security fixes This commit includes fixes for a set of 21 vulnerabilities in rdesktop when a malicious RDP server is used. All vulnerabilities was identified and reported by Eyal Itkin. * Add rdp_protocol_error function that is used in several fixes * Refactor of process_bitmap_updates * Fix possible integer overflow in s_check_rem() on 32bit arch * Fix memory corruption in process_bitmap_data - CVE-2018-8794 * Fix remote code execution in process_bitmap_data - CVE-2018-8795 * Fix remote code execution in process_plane - CVE-2018-8797 * Fix Denial of Service in mcs_recv_connect_response - CVE-2018-20175 * Fix Denial of Service in mcs_parse_domain_params - CVE-2018-20175 * Fix Denial of Service in sec_parse_crypt_info - CVE-2018-20176 * Fix Denial of Service in sec_recv - CVE-2018-20176 * Fix minor information leak in rdpdr_process - CVE-2018-8791 * Fix Denial of Service in cssp_read_tsrequest - CVE-2018-8792 * Fix remote code execution in cssp_read_tsrequest - CVE-2018-8793 * Fix Denial of Service in process_bitmap_data - CVE-2018-8796 * Fix minor information leak in rdpsnd_process_ping - CVE-2018-8798 * Fix Denial of Service in process_secondary_order - CVE-2018-8799 * Fix remote code execution in in ui_clip_handle_data - CVE-2018-8800 * Fix major information leak in ui_clip_handle_data - CVE-2018-20174 * Fix memory corruption in rdp_in_unistr - CVE-2018-20177 * Fix Denial of Service in process_demand_active - CVE-2018-20178 * Fix remote code execution in lspci_process - CVE-2018-20179 * Fix remote code execution in rdpsnddbg_process - CVE-2018-20180 * Fix remote code execution in seamless_process - CVE-2018-20181 * Fix remote code execution in seamless_process_line - CVE-2018-20182 CWE ID: CWE-119
0
93,015
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: uint32_t bs_close_read (Bitstream *bs) { uint32_t bytes_read; if (bs->bc < sizeof (*(bs->ptr)) * 8) bs->ptr++; bytes_read = (uint32_t)(bs->ptr - bs->buf) * sizeof (*(bs->ptr)); if (!(bytes_read & 1)) ++bytes_read; CLEAR (*bs); return bytes_read; } Commit Message: fixes for 4 fuzz failures posted to SourceForge mailing list CWE ID: CWE-125
0
70,884
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
Code: void WebContentsImpl::AttachToOuterWebContentsFrame( WebContents* outer_web_contents, RenderFrameHost* outer_contents_frame) { CHECK(GuestMode::IsCrossProcessFrameGuest(this)); RenderFrameHostManager* render_manager = GetRenderManager(); render_manager->InitRenderView(GetRenderViewHost(), nullptr); GetMainFrame()->Init(); if (!render_manager->GetRenderWidgetHostView()) CreateRenderWidgetHostViewForRenderManager(GetRenderViewHost()); auto* outer_web_contents_impl = static_cast<WebContentsImpl*>(outer_web_contents); auto* outer_contents_frame_impl = static_cast<RenderFrameHostImpl*>(outer_contents_frame); node_.ConnectToOuterWebContents(outer_web_contents_impl, outer_contents_frame_impl); DCHECK(outer_contents_frame); render_manager->CreateOuterDelegateProxy( outer_contents_frame->GetSiteInstance(), outer_contents_frame_impl); ReattachToOuterWebContentsFrame(); if (outer_web_contents_impl->frame_tree_.GetFocusedFrame() == outer_contents_frame_impl->frame_tree_node()) { SetFocusedFrame(frame_tree_.root(), outer_contents_frame->GetSiteInstance()); } text_input_manager_.reset(nullptr); } Commit Message: If a page calls |window.focus()|, kick it out of fullscreen. BUG=776418, 800056 Change-Id: I1880fe600e4814c073f247c43b1c1ac80c8fc017 Reviewed-on: https://chromium-review.googlesource.com/852378 Reviewed-by: Nasko Oskov <nasko@chromium.org> Reviewed-by: Philip Jägenstedt <foolip@chromium.org> Commit-Queue: Avi Drissman <avi@chromium.org> Cr-Commit-Position: refs/heads/master@{#533790} CWE ID:
0
147,684
Analyze the following 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 ceph_x_validate_tickets(struct ceph_auth_client *ac, int *pneed) { int want = ac->want_keys; struct ceph_x_info *xi = ac->private; int service; *pneed = ac->want_keys & ~(xi->have_keys); for (service = 1; service <= want; service <<= 1) { struct ceph_x_ticket_handler *th; if (!(ac->want_keys & service)) continue; if (*pneed & service) continue; th = get_ticket_handler(ac, service); if (IS_ERR(th)) { *pneed |= service; continue; } if (get_seconds() >= th->renew_after) *pneed |= service; if (get_seconds() >= th->expires) xi->have_keys &= ~service; } } Commit Message: libceph: do not hard code max auth ticket len We hard code cephx auth ticket buffer size to 256 bytes. This isn't enough for any moderate setups and, in case tickets themselves are not encrypted, leads to buffer overflows (ceph_x_decrypt() errors out, but ceph_decode_copy() doesn't - it's just a memcpy() wrapper). Since the buffer is allocated dynamically anyway, allocated it a bit later, at the point where we know how much is going to be needed. Fixes: http://tracker.ceph.com/issues/8979 Cc: stable@vger.kernel.org Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Sage Weil <sage@redhat.com> CWE ID: CWE-399
0
36,032
Analyze the following 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 read_block(decoder_info_t *decoder_info,stream_t *stream,block_info_dec_t *block_info, frame_type_t frame_type) { int width = decoder_info->width; int height = decoder_info->height; int bit_start; int code,tb_split; int pb_part=0; cbp_t cbp; int stat_frame_type = decoder_info->bit_count.stat_frame_type; //TODO: Use only one variable for frame type int size = block_info->block_pos.size; int ypos = block_info->block_pos.ypos; int xpos = block_info->block_pos.xpos; YPOS = ypos; XPOS = xpos; int sizeY = size; int sizeC = size>>block_info->sub; mv_t mv,zerovec; mv_t mvp; mv_t mv_arr[4]; //TODO: Use mv_arr0 instead mv_t mv_arr0[4]; mv_t mv_arr1[4]; block_mode_t mode; intra_mode_t intra_mode = MODE_DC; int16_t *coeff_y = block_info->coeffq_y; int16_t *coeff_u = block_info->coeffq_u; int16_t *coeff_v = block_info->coeffq_v; zerovec.y = zerovec.x = 0; bit_start = stream->bitcnt; mode = decoder_info->mode; int coeff_block_type = (mode == MODE_INTRA)<<1; /* Initialize bit counter for statistical purposes */ bit_start = stream->bitcnt; if (mode == MODE_SKIP){ /* Derive skip vector candidates and number of skip vector candidates from neighbour blocks */ mv_t mv_skip[MAX_NUM_SKIP]; int num_skip_vec,skip_idx; inter_pred_t skip_candidates[MAX_NUM_SKIP]; num_skip_vec = TEMPLATE(get_mv_skip)(ypos, xpos, width, height, size, size, 1 << decoder_info->log2_sb_size, decoder_info->deblock_data, skip_candidates); if (decoder_info->bit_count.stat_frame_type == B_FRAME && decoder_info->interp_ref == 2) { num_skip_vec = TEMPLATE(get_mv_skip_temp)(decoder_info->width, decoder_info->frame_info.phase, decoder_info->num_reorder_pics + 1, &block_info->block_pos, decoder_info->deblock_data, skip_candidates); } for (int idx = 0; idx < num_skip_vec; idx++) { mv_skip[idx] = skip_candidates[idx].mv0; } /* Decode skip index */ if (num_skip_vec == 4) skip_idx = get_flc(2, stream); else if (num_skip_vec == 3){ skip_idx = get_vlc(12, stream); } else if (num_skip_vec == 2){ skip_idx = get_flc(1, stream); } else skip_idx = 0; decoder_info->bit_count.skip_idx[stat_frame_type] += (stream->bitcnt - bit_start); block_info->num_skip_vec = num_skip_vec; block_info->block_param.skip_idx = skip_idx; if (skip_idx == num_skip_vec) mv = mv_skip[0]; else mv = mv_skip[skip_idx]; mv_arr[0] = mv; mv_arr[1] = mv; mv_arr[2] = mv; mv_arr[3] = mv; block_info->block_param.ref_idx0 = skip_candidates[skip_idx].ref_idx0; block_info->block_param.ref_idx1 = skip_candidates[skip_idx].ref_idx1; for (int i = 0; i < 4; i++) { mv_arr0[i] = skip_candidates[skip_idx].mv0; mv_arr1[i] = skip_candidates[skip_idx].mv1; } block_info->block_param.dir = skip_candidates[skip_idx].bipred_flag; } else if (mode == MODE_MERGE){ /* Derive skip vector candidates and number of skip vector candidates from neighbour blocks */ mv_t mv_skip[MAX_NUM_SKIP]; int num_skip_vec,skip_idx; inter_pred_t merge_candidates[MAX_NUM_SKIP]; num_skip_vec = TEMPLATE(get_mv_merge)(ypos, xpos, width, height, size, size, 1 << decoder_info->log2_sb_size, decoder_info->deblock_data, merge_candidates); for (int idx = 0; idx < num_skip_vec; idx++) { mv_skip[idx] = merge_candidates[idx].mv0; } /* Decode skip index */ if (num_skip_vec == 4) skip_idx = get_flc(2, stream); else if (num_skip_vec == 3){ skip_idx = get_vlc(12, stream); } else if (num_skip_vec == 2){ skip_idx = get_flc(1, stream); } else skip_idx = 0; decoder_info->bit_count.skip_idx[stat_frame_type] += (stream->bitcnt - bit_start); block_info->num_skip_vec = num_skip_vec; block_info->block_param.skip_idx = skip_idx; if (skip_idx == num_skip_vec) mv = mv_skip[0]; else mv = mv_skip[skip_idx]; mv_arr[0] = mv; mv_arr[1] = mv; mv_arr[2] = mv; mv_arr[3] = mv; block_info->block_param.ref_idx0 = merge_candidates[skip_idx].ref_idx0; block_info->block_param.ref_idx1 = merge_candidates[skip_idx].ref_idx1; for (int i = 0; i < 4; i++) { mv_arr0[i] = merge_candidates[skip_idx].mv0; mv_arr1[i] = merge_candidates[skip_idx].mv1; } block_info->block_param.dir = merge_candidates[skip_idx].bipred_flag; } else if (mode==MODE_INTER){ int ref_idx; if (decoder_info->pb_split){ /* Decode PU partition */ pb_part = get_vlc(13, stream); } else{ pb_part = 0; } block_info->block_param.pb_part = pb_part; if (decoder_info->frame_info.num_ref > 1){ ref_idx = decoder_info->ref_idx; } else{ ref_idx = 0; } decoder_info->bit_count.size_and_ref_idx[stat_frame_type][log2i(size)-3][ref_idx] += 1; mvp = TEMPLATE(get_mv_pred)(ypos,xpos,width,height,size,size,1<<decoder_info->log2_sb_size,ref_idx,decoder_info->deblock_data); /* Deode motion vectors for each prediction block */ mv_t mvp2 = mvp; if (pb_part==0){ read_mv(stream,&mv_arr[0],&mvp2); mv_arr[1] = mv_arr[0]; mv_arr[2] = mv_arr[0]; mv_arr[3] = mv_arr[0]; } else if(pb_part==1){ //HOR read_mv(stream,&mv_arr[0],&mvp2); mvp2 = mv_arr[0]; read_mv(stream,&mv_arr[2],&mvp2); mv_arr[1] = mv_arr[0]; mv_arr[3] = mv_arr[2]; } else if(pb_part==2){ //VER read_mv(stream,&mv_arr[0],&mvp2); mvp2 = mv_arr[0]; read_mv(stream,&mv_arr[1],&mvp2); mv_arr[2] = mv_arr[0]; mv_arr[3] = mv_arr[1]; } else{ read_mv(stream,&mv_arr[0],&mvp2); mvp2 = mv_arr[0]; read_mv(stream,&mv_arr[1],&mvp2); read_mv(stream,&mv_arr[2],&mvp2); read_mv(stream,&mv_arr[3],&mvp2); } decoder_info->bit_count.mv[stat_frame_type] += (stream->bitcnt - bit_start); block_info->block_param.ref_idx0 = ref_idx; block_info->block_param.ref_idx1 = ref_idx; block_info->block_param.dir = 0; } else if (mode==MODE_BIPRED){ int ref_idx = 0; mvp = TEMPLATE(get_mv_pred)(ypos,xpos,width,height,size,size,1 << decoder_info->log2_sb_size, ref_idx,decoder_info->deblock_data); /* Deode motion vectors */ mv_t mvp2 = mvp; #if BIPRED_PART if (decoder_info->pb_split) { /* Decode PU partition */ pb_part = get_vlc(13, stream); } else { pb_part = 0; } #else pb_part = 0; #endif block_info->block_param.pb_part = pb_part; if (pb_part == 0) { read_mv(stream, &mv_arr0[0], &mvp2); mv_arr0[1] = mv_arr0[0]; mv_arr0[2] = mv_arr0[0]; mv_arr0[3] = mv_arr0[0]; } else { mv_arr0[0] = mvp2; mv_arr0[1] = mvp2; mv_arr0[2] = mvp2; mv_arr0[3] = mvp2; } if (decoder_info->bit_count.stat_frame_type == B_FRAME) mvp2 = mv_arr0[0]; if (pb_part == 0) { read_mv(stream, &mv_arr1[0], &mvp2); mv_arr1[1] = mv_arr1[0]; mv_arr1[2] = mv_arr1[0]; mv_arr1[3] = mv_arr1[0]; } else if (pb_part == 1) { //HOR read_mv(stream, &mv_arr1[0], &mvp2); mvp2 = mv_arr1[0]; read_mv(stream, &mv_arr1[2], &mvp2); mv_arr1[1] = mv_arr1[0]; mv_arr1[3] = mv_arr1[2]; } else if (pb_part == 2) { //VER read_mv(stream, &mv_arr1[0], &mvp2); mvp2 = mv_arr1[0]; read_mv(stream, &mv_arr1[1], &mvp2); mv_arr1[2] = mv_arr1[0]; mv_arr1[3] = mv_arr1[1]; } else { read_mv(stream, &mv_arr1[0], &mvp2); mvp2 = mv_arr1[0]; read_mv(stream, &mv_arr1[1], &mvp2); read_mv(stream, &mv_arr1[2], &mvp2); read_mv(stream, &mv_arr1[3], &mvp2); } if (decoder_info->bit_count.stat_frame_type == B_FRAME) { block_info->block_param.ref_idx0 = 0; block_info->block_param.ref_idx1 = 1; if (decoder_info->frame_info.interp_ref > 0) { block_info->block_param.ref_idx0 += 1; block_info->block_param.ref_idx1 += 1; } } else{ if (decoder_info->frame_info.num_ref == 2) { int code = get_vlc(13, stream); block_info->block_param.ref_idx0 = (code >> 1) & 1; block_info->block_param.ref_idx1 = (code >> 0) & 1; } else { int code = get_vlc(10, stream); block_info->block_param.ref_idx0 = (code >> 2) & 3; block_info->block_param.ref_idx1 = (code >> 0) & 3; } } block_info->block_param.dir = 2; int combined_ref = block_info->block_param.ref_idx0 * decoder_info->frame_info.num_ref + block_info->block_param.ref_idx1; decoder_info->bit_count.bi_ref[stat_frame_type][combined_ref] += 1; decoder_info->bit_count.mv[stat_frame_type] += (stream->bitcnt - bit_start); } else if (mode==MODE_INTRA){ /* Decode intra prediction mode */ if (decoder_info->frame_info.num_intra_modes<=4){ intra_mode = get_flc(2, stream); } else { intra_mode = get_vlc(8, stream); } decoder_info->bit_count.intra_mode[stat_frame_type] += (stream->bitcnt - bit_start); decoder_info->bit_count.size_and_intra_mode[stat_frame_type][log2i(size)-3][intra_mode] += 1; block_info->block_param.intra_mode = intra_mode; for (int i=0;i<4;i++){ mv_arr[i] = zerovec; //Note: This is necessary for derivation of mvp and mv_skip } block_info->block_param.ref_idx0 = 0; block_info->block_param.ref_idx1 = 0; block_info->block_param.dir = -1; } if (mode!=MODE_SKIP){ int tmp; int cbp_table[8] = {1,0,5,2,6,3,7,4}; code = 0; if (decoder_info->subsample == 400) { tb_split = cbp.u = cbp.v = 0; cbp.y = get_flc(1,stream); if (decoder_info->tb_split_enable && cbp.y) { tb_split = get_flc(1,stream); cbp.y &= !tb_split; } } else { bit_start = stream->bitcnt; code = get_vlc(0,stream); int off = (mode == MODE_MERGE) ? 1 : 2; if (decoder_info->tb_split_enable) { tb_split = code == off; if (code > off) code -= 1; if (tb_split) decoder_info->bit_count.cbp2_stat[0][stat_frame_type][mode-1][log2i(size)-3][8] += 1; } else{ tb_split = 0; } } block_info->block_param.tb_split = tb_split; decoder_info->bit_count.cbp[stat_frame_type] += (stream->bitcnt - bit_start); if (tb_split == 0){ if (decoder_info->subsample != 400) { tmp = 0; if (mode==MODE_MERGE){ if (code==7) code = 1; else if (code>0) code = code+1; } else { if (decoder_info->block_context->cbp == 0 && code < 2) { code = 1 - code; } } while (tmp < 8 && code != cbp_table[tmp]) tmp++; decoder_info->bit_count.cbp2_stat[max(0,decoder_info->block_context->cbp)][stat_frame_type][mode-1][log2i(size)-3][tmp] += 1; cbp.y = ((tmp>>0)&1); cbp.u = ((tmp>>1)&1); cbp.v = ((tmp>>2)&1); } block_info->cbp = cbp; if (cbp.y){ bit_start = stream->bitcnt; read_coeff(stream,coeff_y,sizeY,coeff_block_type|0); decoder_info->bit_count.coeff_y[stat_frame_type] += (stream->bitcnt - bit_start); } else memset(coeff_y,0,sizeY*sizeY*sizeof(int16_t)); if (cbp.u){ bit_start = stream->bitcnt; read_coeff(stream,coeff_u,sizeC,coeff_block_type|1); decoder_info->bit_count.coeff_u[stat_frame_type] += (stream->bitcnt - bit_start); } else memset(coeff_u,0,sizeC*sizeC*sizeof(int16_t)); if (cbp.v){ bit_start = stream->bitcnt; read_coeff(stream,coeff_v,sizeC,coeff_block_type|1); decoder_info->bit_count.coeff_v[stat_frame_type] += (stream->bitcnt - bit_start); } else memset(coeff_v,0,sizeC*sizeC*sizeof(int16_t)); } else{ if (sizeC > 4){ int index; int16_t *coeff; /* Loop over 4 TUs */ for (index=0;index<4;index++){ bit_start = stream->bitcnt; code = get_vlc(0,stream); int tmp = 0; while (code != cbp_table[tmp] && tmp < 8) tmp++; if (decoder_info->block_context->cbp==0 && tmp < 2) tmp = 1-tmp; cbp.y = ((tmp>>0)&1); cbp.u = ((tmp>>1)&1); cbp.v = ((tmp>>2)&1); /* Updating statistics for CBP */ decoder_info->bit_count.cbp[stat_frame_type] += (stream->bitcnt - bit_start); decoder_info->bit_count.cbp_stat[stat_frame_type][cbp.y + (cbp.u<<1) + (cbp.v<<2)] += 1; /* Decode coefficients for this TU */ /* Y */ coeff = coeff_y + index*sizeY/2*sizeY/2; if (cbp.y){ bit_start = stream->bitcnt; read_coeff(stream,coeff,sizeY/2,coeff_block_type|0); decoder_info->bit_count.coeff_y[stat_frame_type] += (stream->bitcnt - bit_start); } else{ memset(coeff,0,sizeY/2*sizeY/2*sizeof(int16_t)); } /* U */ coeff = coeff_u + index*sizeC/2*sizeC/2; if (cbp.u){ bit_start = stream->bitcnt; read_coeff(stream,coeff,sizeC/2,coeff_block_type|1); decoder_info->bit_count.coeff_u[stat_frame_type] += (stream->bitcnt - bit_start); } else{ memset(coeff,0,sizeC/2*sizeC/2*sizeof(int16_t)); } /* V */ coeff = coeff_v + index*sizeC/2*sizeC/2; if (cbp.v){ bit_start = stream->bitcnt; read_coeff(stream,coeff,sizeC/2,coeff_block_type|1); decoder_info->bit_count.coeff_v[stat_frame_type] += (stream->bitcnt - bit_start); } else{ memset(coeff,0,sizeC/2*sizeC/2*sizeof(int16_t)); } } block_info->cbp.y = 1; //TODO: Do properly with respect to deblocking filter block_info->cbp.u = 1; block_info->cbp.v = 1; } else{ int index; int16_t *coeff; /* Loop over 4 TUs */ for (index=0;index<4;index++){ bit_start = stream->bitcnt; cbp.y = get_flc(1, stream); decoder_info->bit_count.cbp[stat_frame_type] += (stream->bitcnt - bit_start); /* Y */ coeff = coeff_y + index*sizeY/2*sizeY/2; if (cbp.y){ bit_start = stream->bitcnt; read_coeff(stream,coeff,sizeY/2,coeff_block_type|0); decoder_info->bit_count.coeff_y[stat_frame_type] += (stream->bitcnt - bit_start); } else{ memset(coeff,0,sizeY/2*sizeY/2*sizeof(int16_t)); } } bit_start = stream->bitcnt; if (decoder_info->subsample != 400) { int tmp; tmp = get_vlc(13, stream); cbp.u = tmp & 1; cbp.v = (tmp >> 1) & 1; } else cbp.u = cbp.v = 0; decoder_info->bit_count.cbp[stat_frame_type] += (stream->bitcnt - bit_start); if (cbp.u){ bit_start = stream->bitcnt; read_coeff(stream,coeff_u,sizeC,coeff_block_type|1); decoder_info->bit_count.coeff_u[stat_frame_type] += (stream->bitcnt - bit_start); } else memset(coeff_u,0,sizeC*sizeC*sizeof(int16_t)); if (cbp.v){ bit_start = stream->bitcnt; read_coeff(stream,coeff_v,sizeC,coeff_block_type|1); decoder_info->bit_count.coeff_v[stat_frame_type] += (stream->bitcnt - bit_start); } else memset(coeff_v,0,sizeC*sizeC*sizeof(int16_t)); block_info->cbp.y = 1; //TODO: Do properly with respect to deblocking filter block_info->cbp.u = 1; block_info->cbp.v = 1; } //if (size==8) } //if (tb_split==0) } //if (mode!=MODE_SKIP) else{ tb_split = 0; block_info->cbp.y = 0; block_info->cbp.u = 0; block_info->cbp.v = 0; } /* Store block data */ if (mode==MODE_BIPRED){ memcpy(block_info->block_param.mv_arr0,mv_arr0,4*sizeof(mv_t)); //Used for mv0 coding memcpy(block_info->block_param.mv_arr1,mv_arr1,4*sizeof(mv_t)); //Used for mv1 coding } else if(mode==MODE_SKIP){ memcpy(block_info->block_param.mv_arr0,mv_arr0,4*sizeof(mv_t)); //Used for mv0 coding memcpy(block_info->block_param.mv_arr1,mv_arr1,4*sizeof(mv_t)); //Used for mv1 coding } else if(mode==MODE_MERGE){ memcpy(block_info->block_param.mv_arr0,mv_arr0,4*sizeof(mv_t)); //Used for mv0 coding memcpy(block_info->block_param.mv_arr1,mv_arr1,4*sizeof(mv_t)); //Used for mv1 coding } else{ memcpy(block_info->block_param.mv_arr0,mv_arr,4*sizeof(mv_t)); //Used for mv0 coding memcpy(block_info->block_param.mv_arr1,mv_arr,4*sizeof(mv_t)); //Used for mv1 coding } block_info->block_param.mode = mode; block_info->block_param.tb_split = tb_split; int bwidth = min(size,width - xpos); int bheight = min(size,height - ypos); /* Update mode and block size statistics */ decoder_info->bit_count.mode[stat_frame_type][mode] += (bwidth/MIN_BLOCK_SIZE * bheight/MIN_BLOCK_SIZE); decoder_info->bit_count.size[stat_frame_type][log2i(size)-3] += (bwidth/MIN_BLOCK_SIZE * bheight/MIN_BLOCK_SIZE); decoder_info->bit_count.size_and_mode[stat_frame_type][log2i(size)-3][mode] += (bwidth/MIN_BLOCK_SIZE * bheight/MIN_BLOCK_SIZE); return 0; } Commit Message: Fix possible stack overflows in decoder for illegal bit streams Fixes CVE-2018-0429 A vulnerability in the Thor decoder (available at: https://github.com/cisco/thor) could allow an authenticated, local attacker to cause segmentation faults and stack overflows when using a non-conformant Thor bitstream as input. The vulnerability is due to lack of input validation when parsing the bitstream. A successful exploit could allow the attacker to cause a stack overflow and potentially inject and execute arbitrary code. CWE ID: CWE-119
0
85,083
Analyze the following 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( "[æӕ] > ae; [þϼҏ] > p; [ħнћңҥӈӊԋԧԩ] > h;" "[ĸκкқҝҟҡӄԟ] > k; [ŋпԥ] > n; œ > ce;" "[ŧтҭԏ] > t; [ƅьҍв] > b; [ωшщพฟພຟ] > w;" "[мӎ] > m; [єҽҿၔ] > e; ґ > r; [ғӻ] > f;" "[ҫင] > c; ұ > y; [χҳӽӿ] > x;" "ԃ > d; [ԍဌ] > g; [ടรຣຮ] > s; ၂ > j;" "[зҙӡ] > 3; [บບ] > u"), UTRANS_FORWARD, parse_error, status)); DCHECK(U_SUCCESS(status)) << "Spoofchecker initalization failed due to an error: " << u_errorName(status); } Commit Message: Add confusability mapping entries for Myanmar and Georgian U+10D5 (ვ), U+1012 (ဒ) => 3 Bug: 847242, 849398 Test: components_unittests --gtest_filter=*IDN* Change-Id: I9abb8560cf1c9e8e5e8d89980780b89461f7be52 Reviewed-on: https://chromium-review.googlesource.com/1091430 Reviewed-by: Peter Kasting <pkasting@chromium.org> Commit-Queue: Mustafa Emre Acer <meacer@chromium.org> Cr-Commit-Position: refs/heads/master@{#565709} CWE ID:
1
173,152
Analyze the following 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 mca_ccb_ll_open(tMCA_CCB* p_ccb, tMCA_CCB_EVT* p_data) { tMCA_CTRL evt_data; p_ccb->cong = false; evt_data.connect_ind.mtu = p_data->open.peer_mtu; evt_data.connect_ind.bd_addr = p_ccb->peer_addr; mca_ccb_report_event(p_ccb, MCA_CONNECT_IND_EVT, &evt_data); } Commit Message: Add packet length checks in mca_ccb_hdl_req Bug: 110791536 Test: manual Change-Id: Ica5d8037246682fdb190b2747a86ed8d44c2869a (cherry picked from commit 4de7ccdd914b7a178df9180d15f675b257ea6e02) CWE ID: CWE-125
0
162,893
Analyze the following 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 testUriUserInfoHostPort1() { UriParserStateA stateA; UriUriA uriA; stateA.uri = &uriA; const char * const input = "http" "://" "abc:def" "@" "localhost"; TEST_ASSERT(0 == uriParseUriA(&stateA, input)); TEST_ASSERT(uriA.userInfo.first == input + 4 + 3); TEST_ASSERT(uriA.userInfo.afterLast == input + 4 + 3 + 7); TEST_ASSERT(uriA.hostText.first == input + 4 + 3 + 7 + 1); TEST_ASSERT(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); TEST_ASSERT(uriA.portText.first == NULL); TEST_ASSERT(uriA.portText.afterLast == NULL); uriFreeUriMembersA(&uriA); } Commit Message: UriQuery.c: Fix out-of-bounds-write in ComposeQuery and ...Ex Reported by Google Autofuzz team CWE ID: CWE-787
0
75,774
Analyze the following 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 NodeFilterMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) { TestObject* impl = V8TestObject::ToImpl(info.Holder()); V8SetReturnValue(info, ToV8(impl->nodeFilterMethod(), info.Holder(), info.GetIsolate())); } Commit Message: bindings: Support "attribute FrozenArray<T>?" Adds a quick hack to support a case of "attribute FrozenArray<T>?". Bug: 1028047 Change-Id: Ib3cecc4beb6bcc0fb0dbc667aca595454cc90c86 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1933866 Reviewed-by: Hitoshi Yoshida <peria@chromium.org> Commit-Queue: Yuki Shiino <yukishiino@chromium.org> Cr-Commit-Position: refs/heads/master@{#718676} CWE ID:
0
134,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 int udf_parse_options(char *options, struct udf_options *uopt, bool remount) { char *p; int option; uopt->novrs = 0; uopt->partition = 0xFFFF; uopt->session = 0xFFFFFFFF; uopt->lastblock = 0; uopt->anchor = 0; uopt->volume = 0xFFFFFFFF; uopt->rootdir = 0xFFFFFFFF; uopt->fileset = 0xFFFFFFFF; uopt->nls_map = NULL; if (!options) return 1; while ((p = strsep(&options, ",")) != NULL) { substring_t args[MAX_OPT_ARGS]; int token; if (!*p) continue; token = match_token(p, tokens, args); switch (token) { case Opt_novrs: uopt->novrs = 1; break; case Opt_bs: if (match_int(&args[0], &option)) return 0; uopt->blocksize = option; uopt->flags |= (1 << UDF_FLAG_BLOCKSIZE_SET); break; case Opt_unhide: uopt->flags |= (1 << UDF_FLAG_UNHIDE); break; case Opt_undelete: uopt->flags |= (1 << UDF_FLAG_UNDELETE); break; case Opt_noadinicb: uopt->flags &= ~(1 << UDF_FLAG_USE_AD_IN_ICB); break; case Opt_adinicb: uopt->flags |= (1 << UDF_FLAG_USE_AD_IN_ICB); break; case Opt_shortad: uopt->flags |= (1 << UDF_FLAG_USE_SHORT_AD); break; case Opt_longad: uopt->flags &= ~(1 << UDF_FLAG_USE_SHORT_AD); break; case Opt_gid: if (match_int(args, &option)) return 0; uopt->gid = option; uopt->flags |= (1 << UDF_FLAG_GID_SET); break; case Opt_uid: if (match_int(args, &option)) return 0; uopt->uid = option; uopt->flags |= (1 << UDF_FLAG_UID_SET); break; case Opt_umask: if (match_octal(args, &option)) return 0; uopt->umask = option; break; case Opt_nostrict: uopt->flags &= ~(1 << UDF_FLAG_STRICT); break; case Opt_session: if (match_int(args, &option)) return 0; uopt->session = option; if (!remount) uopt->flags |= (1 << UDF_FLAG_SESSION_SET); break; case Opt_lastblock: if (match_int(args, &option)) return 0; uopt->lastblock = option; if (!remount) uopt->flags |= (1 << UDF_FLAG_LASTBLOCK_SET); break; case Opt_anchor: if (match_int(args, &option)) return 0; uopt->anchor = option; break; case Opt_volume: if (match_int(args, &option)) return 0; uopt->volume = option; break; case Opt_partition: if (match_int(args, &option)) return 0; uopt->partition = option; break; case Opt_fileset: if (match_int(args, &option)) return 0; uopt->fileset = option; break; case Opt_rootdir: if (match_int(args, &option)) return 0; uopt->rootdir = option; break; case Opt_utf8: uopt->flags |= (1 << UDF_FLAG_UTF8); break; #ifdef CONFIG_UDF_NLS case Opt_iocharset: uopt->nls_map = load_nls(args[0].from); uopt->flags |= (1 << UDF_FLAG_NLS_MAP); break; #endif case Opt_uignore: uopt->flags |= (1 << UDF_FLAG_UID_IGNORE); break; case Opt_uforget: uopt->flags |= (1 << UDF_FLAG_UID_FORGET); break; case Opt_gignore: uopt->flags |= (1 << UDF_FLAG_GID_IGNORE); break; case Opt_gforget: uopt->flags |= (1 << UDF_FLAG_GID_FORGET); break; case Opt_fmode: if (match_octal(args, &option)) return 0; uopt->fmode = option & 0777; break; case Opt_dmode: if (match_octal(args, &option)) return 0; uopt->dmode = option & 0777; break; default: pr_err("bad mount option \"%s\" or missing value\n", p); return 0; } } return 1; } Commit Message: udf: Avoid run away loop when partition table length is corrupted Check provided length of partition table so that (possibly maliciously) corrupted partition table cannot cause accessing data beyond current buffer. Signed-off-by: Jan Kara <jack@suse.cz> CWE ID: CWE-119
0
19,538