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 rely_del(GF_Box *s)
{
GF_RelyHintBox *rely = (GF_RelyHintBox *)s;
gf_free(rely);
}
Commit Message: fixed 2 possible heap overflows (inc. #1088)
CWE ID: CWE-125 | 0 | 80,352 |
Analyze the following 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 nested_svm_intercept_ioio(struct vcpu_svm *svm)
{
unsigned port, size, iopm_len;
u16 val, mask;
u8 start_bit;
u64 gpa;
if (!(svm->nested.intercept & (1ULL << INTERCEPT_IOIO_PROT)))
return NESTED_EXIT_HOST;
port = svm->vmcb->control.exit_info_1 >> 16;
size = (svm->vmcb->control.exit_info_1 & SVM_IOIO_SIZE_MASK) >>
SVM_IOIO_SIZE_SHIFT;
gpa = svm->nested.vmcb_iopm + (port / 8);
start_bit = port % 8;
iopm_len = (start_bit + size > 8) ? 2 : 1;
mask = (0xf >> (4 - size)) << start_bit;
val = 0;
if (kvm_read_guest(svm->vcpu.kvm, gpa, &val, iopm_len))
return NESTED_EXIT_DONE;
return (val & mask) ? NESTED_EXIT_DONE : NESTED_EXIT_HOST;
}
Commit Message: KVM: x86: Check non-canonical addresses upon WRMSR
Upon WRMSR, the CPU should inject #GP if a non-canonical value (address) is
written to certain MSRs. The behavior is "almost" identical for AMD and Intel
(ignoring MSRs that are not implemented in either architecture since they would
anyhow #GP). However, IA32_SYSENTER_ESP and IA32_SYSENTER_EIP cause #GP if
non-canonical address is written on Intel but not on AMD (which ignores the top
32-bits).
Accordingly, this patch injects a #GP on the MSRs which behave identically on
Intel and AMD. To eliminate the differences between the architecutres, the
value which is written to IA32_SYSENTER_ESP and IA32_SYSENTER_EIP is turned to
canonical value before writing instead of injecting a #GP.
Some references from Intel and AMD manuals:
According to Intel SDM description of WRMSR instruction #GP is expected on
WRMSR "If the source register contains a non-canonical address and ECX
specifies one of the following MSRs: IA32_DS_AREA, IA32_FS_BASE, IA32_GS_BASE,
IA32_KERNEL_GS_BASE, IA32_LSTAR, IA32_SYSENTER_EIP, IA32_SYSENTER_ESP."
According to AMD manual instruction manual:
LSTAR/CSTAR (SYSCALL): "The WRMSR instruction loads the target RIP into the
LSTAR and CSTAR registers. If an RIP written by WRMSR is not in canonical
form, a general-protection exception (#GP) occurs."
IA32_GS_BASE and IA32_FS_BASE (WRFSBASE/WRGSBASE): "The address written to the
base field must be in canonical form or a #GP fault will occur."
IA32_KERNEL_GS_BASE (SWAPGS): "The address stored in the KernelGSbase MSR must
be in canonical form."
This patch fixes CVE-2014-3610.
Cc: [email protected]
Signed-off-by: Nadav Amit <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
CWE ID: CWE-264 | 0 | 37,788 |
Analyze the following 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::vector<uint32_t> GetPageNumbersFromPrintPageNumberRange(
const PP_PrintPageNumberRange_Dev* page_ranges,
uint32_t page_range_count) {
std::vector<uint32_t> page_numbers;
for (uint32_t index = 0; index < page_range_count; ++index) {
for (uint32_t page_number = page_ranges[index].first_page_number;
page_number <= page_ranges[index].last_page_number; ++page_number) {
page_numbers.push_back(page_number);
}
}
return page_numbers;
}
Commit Message: [pdf] Defer page unloading in JS callback.
One of the callbacks from PDFium JavaScript into the embedder is to get the
current page number. In Chromium, this will trigger a call to
CalculateMostVisiblePage that method will determine the visible pages and unload
any non-visible pages. But, if the originating JS is on a non-visible page
we'll delete the page and annotations associated with that page. This will
cause issues as we are currently working with those objects when the JavaScript
returns.
This Cl defers the page unloading triggered by getting the most visible page
until the next event is handled by the Chromium embedder.
BUG=chromium:653090
Review-Url: https://codereview.chromium.org/2418533002
Cr-Commit-Position: refs/heads/master@{#424781}
CWE ID: CWE-416 | 0 | 140,342 |
Analyze the following 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 PPAPITest::BuildQuery(const std::string& base,
const std::string& test_case){
return StringPrintf("%stestcase=%s", base.c_str(), test_case.c_str());
}
Commit Message: Disable OutOfProcessPPAPITest.VarDeprecated on Mac due to timeouts.
BUG=121107
[email protected],[email protected]
Review URL: https://chromiumcodereview.appspot.com/9950017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129857 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-189 | 0 | 107,235 |
Analyze the following 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 xfrm_netlink_rcv(struct sk_buff *skb)
{
struct net *net = sock_net(skb->sk);
mutex_lock(&net->xfrm.xfrm_cfg_mutex);
netlink_rcv_skb(skb, &xfrm_user_rcv_msg);
mutex_unlock(&net->xfrm.xfrm_cfg_mutex);
}
Commit Message: ipsec: Fix aborted xfrm policy dump crash
An independent security researcher, Mohamed Ghannam, has reported
this vulnerability to Beyond Security's SecuriTeam Secure Disclosure
program.
The xfrm_dump_policy_done function expects xfrm_dump_policy to
have been called at least once or it will crash. This can be
triggered if a dump fails because the target socket's receive
buffer is full.
This patch fixes it by using the cb->start mechanism to ensure that
the initialisation is always done regardless of the buffer situation.
Fixes: 12a169e7d8f4 ("ipsec: Put dumpers on the dump list")
Signed-off-by: Herbert Xu <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>
CWE ID: CWE-416 | 0 | 59,372 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void ncq_err(NCQTransferState *ncq_tfs)
{
IDEState *ide_state = &ncq_tfs->drive->port.ifs[0];
ide_state->error = ABRT_ERR;
ide_state->status = READY_STAT | ERR_STAT;
ncq_tfs->drive->port_regs.scr_err |= (1 << ncq_tfs->tag);
qemu_sglist_destroy(&ncq_tfs->sglist);
ncq_tfs->used = 0;
}
Commit Message:
CWE ID: CWE-772 | 0 | 5,897 |
Analyze the following 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 ServiceWorkerContextCore::UpdateComplete(
ServiceWorkerContextCore::UpdateCallback callback,
blink::ServiceWorkerStatusCode status,
const std::string& status_message,
ServiceWorkerRegistration* registration) {
if (status != blink::ServiceWorkerStatusCode::kOk) {
DCHECK(!registration);
std::move(callback).Run(status, status_message,
blink::mojom::kInvalidServiceWorkerRegistrationId);
return;
}
DCHECK(registration);
std::move(callback).Run(status, status_message, registration->id());
}
Commit Message: Convert FrameHostMsg_DidAddMessageToConsole to Mojo.
Note: Since this required changing the test
RenderViewImplTest.DispatchBeforeUnloadCanDetachFrame, I manually
re-introduced https://crbug.com/666714 locally (the bug the test was
added for), and reran the test to confirm that it still covers the bug.
Bug: 786836
Change-Id: I110668fa6f0f261fd2ac36bb91a8d8b31c99f4f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1526270
Commit-Queue: Lowell Manners <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Camille Lamy <[email protected]>
Cr-Commit-Position: refs/heads/master@{#653137}
CWE ID: CWE-416 | 0 | 139,497 |
Analyze the following 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 add_named_array(const char *val, struct kernel_param *kp)
{
/* val must be "md_*" where * is not all digits.
* We allocate an array with a large free minor number, and
* set the name to val. val must not already be an active name.
*/
int len = strlen(val);
char buf[DISK_NAME_LEN];
while (len && val[len-1] == '\n')
len--;
if (len >= DISK_NAME_LEN)
return -E2BIG;
strlcpy(buf, val, len+1);
if (strncmp(buf, "md_", 3) != 0)
return -EINVAL;
return md_alloc(0, buf);
}
Commit Message: md: use kzalloc() when bitmap is disabled
In drivers/md/md.c get_bitmap_file() uses kmalloc() for creating a
mdu_bitmap_file_t called "file".
5769 file = kmalloc(sizeof(*file), GFP_NOIO);
5770 if (!file)
5771 return -ENOMEM;
This structure is copied to user space at the end of the function.
5786 if (err == 0 &&
5787 copy_to_user(arg, file, sizeof(*file)))
5788 err = -EFAULT
But if bitmap is disabled only the first byte of "file" is initialized
with zero, so it's possible to read some bytes (up to 4095) of kernel
space memory from user space. This is an information leak.
5775 /* bitmap disabled, zero the first byte and copy out */
5776 if (!mddev->bitmap_info.file)
5777 file->pathname[0] = '\0';
Signed-off-by: Benjamin Randazzo <[email protected]>
Signed-off-by: NeilBrown <[email protected]>
CWE ID: CWE-200 | 0 | 42,358 |
Analyze the following 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 CWebServer::DisplayMeterTypesCombo(std::string & content_part)
{
char szTmp[200];
for (int ii = 0; ii < MTYPE_END; ii++)
{
sprintf(szTmp, "<option value=\"%d\">%s</option>\n", ii, Meter_Type_Desc((_eMeterType)ii));
content_part += szTmp;
}
}
Commit Message: Fixed possible SQL Injection Vulnerability (Thanks to Fabio Carretto!)
CWE ID: CWE-89 | 0 | 91,029 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static unsigned long __reverse_ulong(unsigned char *str)
{
unsigned long tmp = 0;
int shift = 24, idx = 0;
#if BITS_PER_LONG == 64
shift = 56;
#endif
while (shift >= 0) {
tmp |= (unsigned long)str[idx++] << shift;
shift -= BITS_PER_BYTE;
}
return tmp;
}
Commit Message: f2fs: fix a panic caused by NULL flush_cmd_control
Mount fs with option noflush_merge, boot failed for illegal address
fcc in function f2fs_issue_flush:
if (!test_opt(sbi, FLUSH_MERGE)) {
ret = submit_flush_wait(sbi);
atomic_inc(&fcc->issued_flush); -> Here, fcc illegal
return ret;
}
Signed-off-by: Yunlei He <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
CWE ID: CWE-476 | 0 | 85,349 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void LoadingStatsCollectorTest::SetUp() {
LoadingPredictorConfig config;
PopulateTestConfig(&config);
profile_ = std::make_unique<TestingProfile>();
content::RunAllTasksUntilIdle();
mock_predictor_ = std::make_unique<StrictMock<MockResourcePrefetchPredictor>>(
config, profile_.get());
stats_collector_ =
std::make_unique<LoadingStatsCollector>(mock_predictor_.get(), config);
histogram_tester_ = std::make_unique<base::HistogramTester>();
content::RunAllTasksUntilIdle();
}
Commit Message: Origins should be represented as url::Origin (not as GURL).
As pointed out in //docs/security/origin-vs-url.md, origins should be
represented as url::Origin (not as GURL). This CL applies this
guideline to predictor-related code and changes the type of the
following fields from GURL to url::Origin:
- OriginRequestSummary::origin
- PreconnectedRequestStats::origin
- PreconnectRequest::origin
The old code did not depend on any non-origin parts of GURL
(like path and/or query). Therefore, this CL has no intended
behavior change.
Bug: 973885
Change-Id: Idd14590b4834cb9d50c74ed747b595fe1a4ba357
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1895167
Commit-Queue: Łukasz Anforowicz <[email protected]>
Reviewed-by: Alex Ilin <[email protected]>
Cr-Commit-Position: refs/heads/master@{#716311}
CWE ID: CWE-125 | 0 | 136,916 |
Analyze the following 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 CommandBufferProxyImpl::GetGpuFence(
uint32_t gpu_fence_id,
base::OnceCallback<void(std::unique_ptr<gfx::GpuFence>)> callback) {
CheckLock();
base::AutoLock lock(last_state_lock_);
if (last_state_.error != gpu::error::kNoError) {
DLOG(ERROR) << "got error=" << last_state_.error;
return;
}
Send(new GpuCommandBufferMsg_GetGpuFenceHandle(route_id_, gpu_fence_id));
get_gpu_fence_tasks_.emplace(gpu_fence_id, std::move(callback));
}
Commit Message: Correct mojo::WrapSharedMemoryHandle usage
Fixes some incorrect uses of mojo::WrapSharedMemoryHandle which
were assuming that the call actually has any control over the memory
protection applied to a handle when mapped.
Where fixing usage is infeasible for this CL, TODOs are added to
annotate follow-up work.
Also updates the API and documentation to (hopefully) improve clarity
and avoid similar mistakes from being made in the future.
BUG=792900
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I0578aaa9ca3bfcb01aaf2451315d1ede95458477
Reviewed-on: https://chromium-review.googlesource.com/818282
Reviewed-by: Wei Li <[email protected]>
Reviewed-by: Lei Zhang <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Sadrul Chowdhury <[email protected]>
Reviewed-by: Yuzhu Shen <[email protected]>
Reviewed-by: Robert Sesek <[email protected]>
Commit-Queue: Ken Rockot <[email protected]>
Cr-Commit-Position: refs/heads/master@{#530268}
CWE ID: CWE-787 | 0 | 149,450 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: v8::Local<v8::Object> AsObjectOrEmpty(v8::Local<v8::Value> value) {
return value->IsObject() ? value.As<v8::Object>() : v8::Local<v8::Object>();
}
Commit Message: [Extensions] Expand bindings access checks
BUG=601149
BUG=601073
Review URL: https://codereview.chromium.org/1866103002
Cr-Commit-Position: refs/heads/master@{#387710}
CWE ID: CWE-284 | 0 | 132,527 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: char EVUTIL_TOUPPER_(char c)
{
return ((char)EVUTIL_TOUPPER_TABLE[(ev_uint8_t)c]);
}
Commit Message: evutil_parse_sockaddr_port(): fix buffer overflow
@asn-the-goblin-slayer:
"Length between '[' and ']' is cast to signed 32 bit integer on line 1815. Is
the length is more than 2<<31 (INT_MAX), len will hold a negative value.
Consequently, it will pass the check at line 1816. Segfault happens at line
1819.
Generate a resolv.conf with generate-resolv.conf, then compile and run
poc.c. See entry-functions.txt for functions in tor that might be
vulnerable.
Please credit 'Guido Vranken' for this discovery through the Tor bug bounty
program."
Reproducer for gdb (https://gist.github.com/azat/be2b0d5e9417ba0dfe2c):
start
p (1ULL<<31)+1ULL
# $1 = 2147483649
p malloc(sizeof(struct sockaddr))
# $2 = (void *) 0x646010
p malloc(sizeof(int))
# $3 = (void *) 0x646030
p malloc($1)
# $4 = (void *) 0x7fff76a2a010
p memset($4, 1, $1)
# $5 = 1990369296
p (char *)$4
# $6 = 0x7fff76a2a010 '\001' <repeats 200 times>...
set $6[0]='['
set $6[$1]=']'
p evutil_parse_sockaddr_port($4, $2, $3)
# $7 = -1
Before:
$ gdb bin/http-connect < gdb
(gdb) $1 = 2147483649
(gdb) (gdb) $2 = (void *) 0x646010
(gdb) (gdb) $3 = (void *) 0x646030
(gdb) (gdb) $4 = (void *) 0x7fff76a2a010
(gdb) (gdb) $5 = 1990369296
(gdb) (gdb) $6 = 0x7fff76a2a010 '\001' <repeats 200 times>...
(gdb) (gdb) (gdb) (gdb)
Program received signal SIGSEGV, Segmentation fault.
__memcpy_sse2_unaligned () at memcpy-sse2-unaligned.S:36
After:
$ gdb bin/http-connect < gdb
(gdb) $1 = 2147483649
(gdb) (gdb) $2 = (void *) 0x646010
(gdb) (gdb) $3 = (void *) 0x646030
(gdb) (gdb) $4 = (void *) 0x7fff76a2a010
(gdb) (gdb) $5 = 1990369296
(gdb) (gdb) $6 = 0x7fff76a2a010 '\001' <repeats 200 times>...
(gdb) (gdb) (gdb) (gdb) $7 = -1
(gdb) (gdb) quit
Fixes: #318
CWE ID: CWE-119 | 0 | 70,707 |
Analyze the following 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 Element::childShouldCreateRenderer(const NodeRenderingContext& childContext) const
{
if (childContext.node()->isSVGElement())
return childContext.node()->hasTagName(SVGNames::svgTag) || isSVGElement();
return ContainerNode::childShouldCreateRenderer(childContext);
}
Commit Message: Set Attr.ownerDocument in Element#setAttributeNode()
Attr objects can move across documents by setAttributeNode().
So It needs to reset ownerDocument through TreeScopeAdoptr::adoptIfNeeded().
BUG=248950
TEST=set-attribute-node-from-iframe.html
Review URL: https://chromiumcodereview.appspot.com/17583003
git-svn-id: svn://svn.chromium.org/blink/trunk@152938 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-399 | 0 | 112,212 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void WebRuntimeFeatures::EnablePortals(bool enable) {
RuntimeEnabledFeatures::SetPortalsEnabled(enable);
}
Commit Message: Remove RequireCSSExtensionForFile runtime enabled flag.
The feature has long since been stable (since M64) and doesn't seem
to be a need for this flag.
BUG=788936
Change-Id: I666390b869289c328acb4a2daa5bf4154e1702c0
Reviewed-on: https://chromium-review.googlesource.com/c/1324143
Reviewed-by: Mike West <[email protected]>
Reviewed-by: Camille Lamy <[email protected]>
Commit-Queue: Dave Tapuska <[email protected]>
Cr-Commit-Position: refs/heads/master@{#607329}
CWE ID: CWE-254 | 0 | 154,663 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: iakerb_verify_finished(krb5_context context,
krb5_key key,
const krb5_data *conv,
const krb5_data *finished)
{
krb5_error_code code;
krb5_iakerb_finished *iaf;
krb5_boolean valid = FALSE;
if (key == NULL)
return KRB5KDC_ERR_NULL_KEY;
code = decode_krb5_iakerb_finished(finished, &iaf);
if (code != 0)
return code;
code = krb5_k_verify_checksum(context, key, KRB5_KEYUSAGE_IAKERB_FINISHED,
conv, &iaf->checksum, &valid);
if (code == 0 && valid == FALSE)
code = KRB5KRB_AP_ERR_BAD_INTEGRITY;
krb5_free_iakerb_finished(context, iaf);
return code;
}
Commit Message: Fix IAKERB context export/import [CVE-2015-2698]
The patches for CVE-2015-2696 contained a regression in the newly
added IAKERB iakerb_gss_export_sec_context() function, which could
cause it to corrupt memory. Fix the regression by properly
dereferencing the context_handle pointer before casting it.
Also, the patches did not implement an IAKERB gss_import_sec_context()
function, under the erroneous belief that an exported IAKERB context
would be tagged as a krb5 context. Implement it now to allow IAKERB
contexts to be successfully exported and imported after establishment.
CVE-2015-2698:
In any MIT krb5 release with the patches for CVE-2015-2696 applied, an
application which calls gss_export_sec_context() may experience memory
corruption if the context was established using the IAKERB mechanism.
Historically, some vulnerabilities of this nature can be translated
into remote code execution, though the necessary exploits must be
tailored to the individual application and are usually quite
complicated.
CVSSv2 Vector: AV:N/AC:H/Au:S/C:C/I:C/A:C/E:POC/RL:OF/RC:C
ticket: 8273 (new)
target_version: 1.14
tags: pullup
CWE ID: CWE-119 | 0 | 43,803 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: daemon_thrdatamain(void *ptr)
{
char errbuf[PCAP_ERRBUF_SIZE + 1]; // error buffer
struct session *session; // pointer to the struct session for this session
int retval; // general variable used to keep the return value of other functions
struct rpcap_pkthdr *net_pkt_header;// header of the packet
struct pcap_pkthdr *pkt_header; // pointer to the buffer that contains the header of the current packet
u_char *pkt_data; // pointer to the buffer that contains the current packet
size_t sendbufsize; // size for the send buffer
char *sendbuf; // temporary buffer in which data to be sent is buffered
int sendbufidx; // index which keeps the number of bytes currently buffered
int status;
#ifndef _WIN32
sigset_t sigusr1; // signal set with just SIGUSR1
#endif
session = (struct session *) ptr;
session->TotCapt = 0; // counter which is incremented each time a packet is received
memset(errbuf, 0, sizeof(errbuf));
if (pcap_snapshot(session->fp) < 0)
{
rpcapd_log(LOGPRIO_ERROR,
"Unable to allocate the buffer for this child thread: snapshot length of %d is negative",
pcap_snapshot(session->fp));
sendbuf = NULL; // we can't allocate a buffer, so nothing to free
goto error;
}
sendbufsize = sizeof(struct rpcap_header) + sizeof(struct rpcap_pkthdr) + pcap_snapshot(session->fp);
sendbuf = (char *) malloc (sendbufsize);
if (sendbuf == NULL)
{
rpcapd_log(LOGPRIO_ERROR,
"Unable to allocate the buffer for this child thread");
goto error;
}
#ifndef _WIN32
sigemptyset(&sigusr1);
sigaddset(&sigusr1, SIGUSR1);
pthread_sigmask(SIG_BLOCK, &sigusr1, NULL);
#endif
for (;;)
{
#ifndef _WIN32
pthread_sigmask(SIG_UNBLOCK, &sigusr1, NULL);
#endif
retval = pcap_next_ex(session->fp, &pkt_header, (const u_char **) &pkt_data); // cast to avoid a compiler warning
#ifndef _WIN32
pthread_sigmask(SIG_BLOCK, &sigusr1, NULL);
#endif
if (retval < 0)
break; // error
if (retval == 0) // Read timeout elapsed
continue;
sendbufidx = 0;
if (sock_bufferize(NULL, sizeof(struct rpcap_header), NULL,
&sendbufidx, sendbufsize, SOCKBUF_CHECKONLY, errbuf,
PCAP_ERRBUF_SIZE) == -1)
{
rpcapd_log(LOGPRIO_ERROR,
"sock_bufferize() error sending packet message: %s",
errbuf);
goto error;
}
rpcap_createhdr((struct rpcap_header *) sendbuf,
session->protocol_version, RPCAP_MSG_PACKET, 0,
(uint16) (sizeof(struct rpcap_pkthdr) + pkt_header->caplen));
net_pkt_header = (struct rpcap_pkthdr *) &sendbuf[sendbufidx];
if (sock_bufferize(NULL, sizeof(struct rpcap_pkthdr), NULL,
&sendbufidx, sendbufsize, SOCKBUF_CHECKONLY, errbuf,
PCAP_ERRBUF_SIZE) == -1)
{
rpcapd_log(LOGPRIO_ERROR,
"sock_bufferize() error sending packet message: %s",
errbuf);
goto error;
}
net_pkt_header->caplen = htonl(pkt_header->caplen);
net_pkt_header->len = htonl(pkt_header->len);
net_pkt_header->npkt = htonl(++(session->TotCapt));
net_pkt_header->timestamp_sec = htonl(pkt_header->ts.tv_sec);
net_pkt_header->timestamp_usec = htonl(pkt_header->ts.tv_usec);
if (sock_bufferize((char *) pkt_data, pkt_header->caplen,
sendbuf, &sendbufidx, sendbufsize, SOCKBUF_BUFFERIZE,
errbuf, PCAP_ERRBUF_SIZE) == -1)
{
rpcapd_log(LOGPRIO_ERROR,
"sock_bufferize() error sending packet message: %s",
errbuf);
goto error;
}
status = sock_send(session->sockdata, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE);
if (status < 0)
{
if (status == -1)
{
rpcapd_log(LOGPRIO_ERROR,
"Send of packet to client failed: %s",
errbuf);
}
goto error;
}
}
if (retval < 0 && retval != PCAP_ERROR_BREAK)
{
pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error reading the packets: %s", pcap_geterr(session->fp));
rpcap_senderror(session->sockctrl, session->protocol_version,
PCAP_ERR_READEX, errbuf, NULL);
}
error:
free(sendbuf);
return 0;
}
Commit Message: In the open request, reject capture sources that are URLs.
You shouldn't be able to ask a server to open a remote device on some
*other* server; just open it yourself.
This addresses Include Security issue F13: [libpcap] Remote Packet
Capture Daemon Allows Opening Capture URLs.
CWE ID: CWE-918 | 0 | 88,417 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void WebPluginProxy::AcceleratedPluginAllocatedIOSurface(int32 width,
int32 height,
uint32 surface_id) {
Send(new PluginHostMsg_AcceleratedPluginAllocatedIOSurface(
route_id_, width, height, surface_id));
}
Commit Message: Convert plugin and GPU process to brokered handle duplication.
BUG=119250
Review URL: https://chromiumcodereview.appspot.com/9958034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132303 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: | 0 | 107,030 |
Analyze the following 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 nr_processes(void)
{
int cpu;
int total = 0;
for_each_online_cpu(cpu)
total += per_cpu(process_counts, cpu);
return total;
}
Commit Message: Move "exit_robust_list" into mm_release()
We don't want to get rid of the futexes just at exit() time, we want to
drop them when doing an execve() too, since that gets rid of the
previous VM image too.
Doing it at mm_release() time means that we automatically always do it
when we disassociate a VM map from the task.
Reported-by: [email protected]
Cc: Andrew Morton <[email protected]>
Cc: Nick Piggin <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Brad Spengler <[email protected]>
Cc: Alex Efros <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
CWE ID: CWE-264 | 0 | 22,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: int kvm_mmu_get_spte_hierarchy(struct kvm_vcpu *vcpu, u64 addr, u64 sptes[4])
{
struct kvm_shadow_walk_iterator iterator;
u64 spte;
int nr_sptes = 0;
walk_shadow_page_lockless_begin(vcpu);
for_each_shadow_entry_lockless(vcpu, addr, iterator, spte) {
sptes[iterator.level-1] = spte;
nr_sptes++;
if (!is_shadow_present_pte(spte))
break;
}
walk_shadow_page_lockless_end(vcpu);
return nr_sptes;
}
Commit Message: nEPT: Nested INVEPT
If we let L1 use EPT, we should probably also support the INVEPT instruction.
In our current nested EPT implementation, when L1 changes its EPT table
for L2 (i.e., EPT12), L0 modifies the shadow EPT table (EPT02), and in
the course of this modification already calls INVEPT. But if last level
of shadow page is unsync not all L1's changes to EPT12 are intercepted,
which means roots need to be synced when L1 calls INVEPT. Global INVEPT
should not be different since roots are synced by kvm_mmu_load() each
time EPTP02 changes.
Reviewed-by: Xiao Guangrong <[email protected]>
Signed-off-by: Nadav Har'El <[email protected]>
Signed-off-by: Jun Nakajima <[email protected]>
Signed-off-by: Xinhao Xu <[email protected]>
Signed-off-by: Yang Zhang <[email protected]>
Signed-off-by: Gleb Natapov <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
CWE ID: CWE-20 | 0 | 37,469 |
Analyze the following 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 http_adjust_conn_mode(struct stream *s, struct http_txn *txn, struct http_msg *msg)
{
struct proxy *fe = strm_fe(s);
int tmp = TX_CON_WANT_KAL;
if (!((fe->options2|s->be->options2) & PR_O2_FAKE_KA)) {
if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_TUN ||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_TUN)
tmp = TX_CON_WANT_TUN;
if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL)
tmp = TX_CON_WANT_TUN;
}
if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_SCL ||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_SCL) {
/* option httpclose + server_close => forceclose */
if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL ||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_PCL)
tmp = TX_CON_WANT_CLO;
else
tmp = TX_CON_WANT_SCL;
}
if ((fe->options & PR_O_HTTP_MODE) == PR_O_HTTP_FCL ||
(s->be->options & PR_O_HTTP_MODE) == PR_O_HTTP_FCL)
tmp = TX_CON_WANT_CLO;
if ((txn->flags & TX_CON_WANT_MSK) < tmp)
txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | tmp;
if (!(txn->flags & TX_HDR_CONN_PRS) &&
(txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_TUN) {
/* parse the Connection header and possibly clean it */
int to_del = 0;
if ((msg->flags & HTTP_MSGF_VER_11) ||
((txn->flags & TX_CON_WANT_MSK) >= TX_CON_WANT_SCL &&
!((fe->options2|s->be->options2) & PR_O2_FAKE_KA)))
to_del |= 2; /* remove "keep-alive" */
if (!(msg->flags & HTTP_MSGF_VER_11))
to_del |= 1; /* remove "close" */
http_parse_connection_header(txn, msg, to_del);
}
/* check if client or config asks for explicit close in KAL/SCL */
if (((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL ||
(txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL) &&
((txn->flags & TX_HDR_CONN_CLO) || /* "connection: close" */
(!(msg->flags & HTTP_MSGF_VER_11) && !(txn->flags & TX_HDR_CONN_KAL)) || /* no "connection: k-a" in 1.0 */
!(msg->flags & HTTP_MSGF_XFER_LEN) || /* no length known => close */
fe->state == PR_STSTOPPED)) /* frontend is stopping */
txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | TX_CON_WANT_CLO;
}
Commit Message:
CWE ID: CWE-200 | 0 | 6,813 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
{
char language[4] = { 0 };
char buf[200], place[100];
uint16_t langcode = 0;
double longitude, latitude, altitude;
const char *key = "location";
if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4) {
av_log(c->fc, AV_LOG_ERROR, "loci too short\n");
return AVERROR_INVALIDDATA;
}
avio_skip(pb, 4); // version+flags
langcode = avio_rb16(pb);
ff_mov_lang_to_iso639(langcode, language);
len -= 6;
len -= avio_get_str(pb, len, place, sizeof(place));
if (len < 1) {
av_log(c->fc, AV_LOG_ERROR, "place name too long\n");
return AVERROR_INVALIDDATA;
}
avio_skip(pb, 1); // role
len -= 1;
if (len < 12) {
av_log(c->fc, AV_LOG_ERROR,
"loci too short (%u bytes left, need at least %d)\n", len, 12);
return AVERROR_INVALIDDATA;
}
longitude = ((int32_t) avio_rb32(pb)) / (float) (1 << 16);
latitude = ((int32_t) avio_rb32(pb)) / (float) (1 << 16);
altitude = ((int32_t) avio_rb32(pb)) / (float) (1 << 16);
snprintf(buf, sizeof(buf), "%+08.4f%+09.4f", latitude, longitude);
if (altitude)
av_strlcatf(buf, sizeof(buf), "%+f", altitude);
av_strlcatf(buf, sizeof(buf), "/%s", place);
if (*language && strcmp(language, "und")) {
char key2[16];
snprintf(key2, sizeof(key2), "%s-%s", key, language);
av_dict_set(&c->fc->metadata, key2, buf, 0);
}
c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
return av_dict_set(&c->fc->metadata, key, buf, 0);
}
Commit Message: avformat/mov: Fix DoS in read_tfra()
Fixes: Missing EOF check in loop
No testcase
Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <[email protected]>
CWE ID: CWE-834 | 0 | 61,397 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int kiocb_cancel(struct aio_kiocb *kiocb)
{
kiocb_cancel_fn *old, *cancel;
/*
* Don't want to set kiocb->ki_cancel = KIOCB_CANCELLED unless it
* actually has a cancel function, hence the cmpxchg()
*/
cancel = ACCESS_ONCE(kiocb->ki_cancel);
do {
if (!cancel || cancel == KIOCB_CANCELLED)
return -EINVAL;
old = cancel;
cancel = cmpxchg(&kiocb->ki_cancel, old, KIOCB_CANCELLED);
} while (cancel != old);
return cancel(&kiocb->common);
}
Commit Message: aio: mark AIO pseudo-fs noexec
This ensures that do_mmap() won't implicitly make AIO memory mappings
executable if the READ_IMPLIES_EXEC personality flag is set. Such
behavior is problematic because the security_mmap_file LSM hook doesn't
catch this case, potentially permitting an attacker to bypass a W^X
policy enforced by SELinux.
I have tested the patch on my machine.
To test the behavior, compile and run this:
#define _GNU_SOURCE
#include <unistd.h>
#include <sys/personality.h>
#include <linux/aio_abi.h>
#include <err.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/syscall.h>
int main(void) {
personality(READ_IMPLIES_EXEC);
aio_context_t ctx = 0;
if (syscall(__NR_io_setup, 1, &ctx))
err(1, "io_setup");
char cmd[1000];
sprintf(cmd, "cat /proc/%d/maps | grep -F '/[aio]'",
(int)getpid());
system(cmd);
return 0;
}
In the output, "rw-s" is good, "rwxs" is bad.
Signed-off-by: Jann Horn <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
CWE ID: CWE-264 | 0 | 72,039 |
Analyze the following 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 SetImeConfig(const std::string& section,
const std::string& config_name,
const ImeConfigValue& value) {
if (!IBusConnectionsAreAlive()) {
LOG(ERROR) << "SetImeConfig: IBus connection is not alive";
return false;
}
bool is_preload_engines = false;
std::vector<std::string> string_list;
if ((value.type == ImeConfigValue::kValueTypeStringList) &&
(section == kGeneralSectionName) &&
(config_name == kPreloadEnginesConfigName)) {
FilterInputMethods(value.string_list_value, &string_list);
is_preload_engines = true;
} else {
string_list = value.string_list_value;
}
GVariant* variant = NULL;
switch (value.type) {
case ImeConfigValue::kValueTypeString:
variant = g_variant_new_string(value.string_value.c_str());
break;
case ImeConfigValue::kValueTypeInt:
variant = g_variant_new_int32(value.int_value);
break;
case ImeConfigValue::kValueTypeBool:
variant = g_variant_new_boolean(value.bool_value);
break;
case ImeConfigValue::kValueTypeStringList:
GVariantBuilder variant_builder;
g_variant_builder_init(&variant_builder, G_VARIANT_TYPE("as"));
const size_t size = string_list.size(); // don't use string_list_value.
for (size_t i = 0; i < size; ++i) {
g_variant_builder_add(&variant_builder, "s", string_list[i].c_str());
}
variant = g_variant_builder_end(&variant_builder);
break;
}
if (!variant) {
LOG(ERROR) << "SetImeConfig: variant is NULL";
return false;
}
DCHECK(g_variant_is_floating(variant));
ibus_config_set_value_async(ibus_config_,
section.c_str(),
config_name.c_str(),
variant,
-1, // use the default ibus timeout
NULL, // cancellable
SetImeConfigCallback,
g_object_ref(ibus_config_));
if (is_preload_engines) {
DLOG(INFO) << "SetImeConfig: " << section << "/" << config_name
<< ": " << value.ToString();
}
return true;
}
Commit Message: Remove use of libcros from InputMethodLibrary.
BUG=chromium-os:16238
TEST==confirm that input methods work as before on the netbook. Also confirm that the chrome builds and works on the desktop as before.
Review URL: http://codereview.chromium.org/7003086
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89142 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-399 | 1 | 170,547 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: cdf_print_elapsed_time(char *buf, size_t bufsiz, cdf_timestamp_t ts)
{
int len = 0;
int days, hours, mins, secs;
ts /= CDF_TIME_PREC;
secs = (int)(ts % 60);
ts /= 60;
mins = (int)(ts % 60);
ts /= 60;
hours = (int)(ts % 24);
ts /= 24;
days = (int)ts;
if (days) {
len += snprintf(buf + len, bufsiz - len, "%dd+", days);
if ((size_t)len >= bufsiz)
return len;
}
if (days || hours) {
len += snprintf(buf + len, bufsiz - len, "%.2d:", hours);
if ((size_t)len >= bufsiz)
return len;
}
len += snprintf(buf + len, bufsiz - len, "%.2d:", mins);
if ((size_t)len >= bufsiz)
return len;
len += snprintf(buf + len, bufsiz - len, "%.2d", secs);
return len;
}
Commit Message: Fix bounds checks again.
CWE ID: CWE-119 | 0 | 20,931 |
Analyze the following 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 IsTappedNodeNull() const { return tapped_node_.IsNull(); }
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 <[email protected]>
Reviewed-by: Philip Jägenstedt <[email protected]>
Commit-Queue: Avi Drissman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#533790}
CWE ID: | 0 | 148,061 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: LayoutUnit LayoutBlockFlow::logicalRightFloatOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedOffset, LayoutUnit logicalHeight) const
{
if (m_floatingObjects && m_floatingObjects->hasRightObjects())
return m_floatingObjects->logicalRightOffset(fixedOffset, logicalTop, logicalHeight);
return fixedOffset;
}
Commit Message: Consistently check if a block can handle pagination strut propagation.
https://codereview.chromium.org/1360753002 got it right for inline child
layout, but did nothing for block child layout.
BUG=329421
[email protected],[email protected]
Review URL: https://codereview.chromium.org/1387553002
Cr-Commit-Position: refs/heads/master@{#352429}
CWE ID: CWE-22 | 0 | 123,012 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void BinaryUploadService::MaybeUploadForDeepScanningCallback(
std::unique_ptr<BinaryUploadService::Request> request,
bool authorized) {
if (!authorized)
return;
UploadForDeepScanning(std::move(request));
}
Commit Message: Migrate download_protection code to new DM token class.
Migrates RetrieveDMToken calls to use the new BrowserDMToken class.
Bug: 1020296
Change-Id: Icef580e243430d73b6c1c42b273a8540277481d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1904234
Commit-Queue: Dominique Fauteux-Chapleau <[email protected]>
Reviewed-by: Tien Mai <[email protected]>
Reviewed-by: Daniel Rubery <[email protected]>
Cr-Commit-Position: refs/heads/master@{#714196}
CWE ID: CWE-20 | 0 | 136,673 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: SimpleGetHelperResult SimpleGetHelperForData(StaticSocketDataProvider* data[],
size_t data_count) {
SimpleGetHelperResult out;
HttpRequestInfo request;
request.method = "GET";
request.url = GURL("http://www.google.com/");
request.load_flags = 0;
CapturingBoundNetLog log;
session_deps_.net_log = log.bound().net_log();
scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
scoped_ptr<HttpTransaction> trans(
new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
for (size_t i = 0; i < data_count; ++i) {
session_deps_.socket_factory->AddSocketDataProvider(data[i]);
}
TestCompletionCallback callback;
EXPECT_TRUE(log.bound().IsLogging());
int rv = trans->Start(&request, callback.callback(), log.bound());
EXPECT_EQ(ERR_IO_PENDING, rv);
out.rv = callback.WaitForResult();
EXPECT_TRUE(trans->GetLoadTimingInfo(&out.load_timing_info));
TestLoadTimingNotReused(out.load_timing_info, CONNECT_TIMING_HAS_DNS_TIMES);
if (out.rv != OK)
return out;
const HttpResponseInfo* response = trans->GetResponseInfo();
if (response == NULL || response->headers.get() == NULL) {
out.rv = ERR_UNEXPECTED;
return out;
}
out.status_line = response->headers->GetStatusLine();
EXPECT_EQ("127.0.0.1", response->socket_address.host());
EXPECT_EQ(80, response->socket_address.port());
rv = ReadTransaction(trans.get(), &out.response_data);
EXPECT_EQ(OK, rv);
net::CapturingNetLog::CapturedEntryList entries;
log.GetEntries(&entries);
size_t pos = ExpectLogContainsSomewhere(
entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS,
NetLog::PHASE_NONE);
ExpectLogContainsSomewhere(
entries, pos,
NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS,
NetLog::PHASE_NONE);
std::string line;
EXPECT_TRUE(entries[pos].GetStringValue("line", &line));
EXPECT_EQ("GET / HTTP/1.1\r\n", line);
HttpRequestHeaders request_headers;
EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers));
std::string value;
EXPECT_TRUE(request_headers.GetHeader("Host", &value));
EXPECT_EQ("www.google.com", value);
EXPECT_TRUE(request_headers.GetHeader("Connection", &value));
EXPECT_EQ("keep-alive", value);
std::string response_headers;
EXPECT_TRUE(GetHeaders(entries[pos].params.get(), &response_headers));
EXPECT_EQ("['Host: www.google.com','Connection: keep-alive']",
response_headers);
out.totalReceivedBytes = trans->GetTotalReceivedBytes();
return out;
}
Commit Message: Sanitize headers in Proxy Authentication Required responses
BUG=431504
Review URL: https://codereview.chromium.org/769043003
Cr-Commit-Position: refs/heads/master@{#310014}
CWE ID: CWE-19 | 0 | 129,291 |
Analyze the following 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 update_pages_handler(struct work_struct *work)
{
struct ring_buffer_per_cpu *cpu_buffer = container_of(work,
struct ring_buffer_per_cpu, update_pages_work);
rb_update_pages(cpu_buffer);
complete(&cpu_buffer->update_done);
}
Commit Message: ring-buffer: Prevent overflow of size in ring_buffer_resize()
If the size passed to ring_buffer_resize() is greater than MAX_LONG - BUF_PAGE_SIZE
then the DIV_ROUND_UP() will return zero.
Here's the details:
# echo 18014398509481980 > /sys/kernel/debug/tracing/buffer_size_kb
tracing_entries_write() processes this and converts kb to bytes.
18014398509481980 << 10 = 18446744073709547520
and this is passed to ring_buffer_resize() as unsigned long size.
size = DIV_ROUND_UP(size, BUF_PAGE_SIZE);
Where DIV_ROUND_UP(a, b) is (a + b - 1)/b
BUF_PAGE_SIZE is 4080 and here
18446744073709547520 + 4080 - 1 = 18446744073709551599
where 18446744073709551599 is still smaller than 2^64
2^64 - 18446744073709551599 = 17
But now 18446744073709551599 / 4080 = 4521260802379792
and size = size * 4080 = 18446744073709551360
This is checked to make sure its still greater than 2 * 4080,
which it is.
Then we convert to the number of buffer pages needed.
nr_page = DIV_ROUND_UP(size, BUF_PAGE_SIZE)
but this time size is 18446744073709551360 and
2^64 - (18446744073709551360 + 4080 - 1) = -3823
Thus it overflows and the resulting number is less than 4080, which makes
3823 / 4080 = 0
an nr_pages is set to this. As we already checked against the minimum that
nr_pages may be, this causes the logic to fail as well, and we crash the
kernel.
There's no reason to have the two DIV_ROUND_UP() (that's just result of
historical code changes), clean up the code and fix this bug.
Cc: [email protected] # 3.5+
Fixes: 83f40318dab00 ("ring-buffer: Make removal of ring buffer pages atomic")
Signed-off-by: Steven Rostedt <[email protected]>
CWE ID: CWE-190 | 0 | 72,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: void FrameView::scrollToAnchor()
{
RefPtrWillBeRawPtr<Node> anchorNode = m_maintainScrollPositionAnchor;
if (!anchorNode)
return;
if (!anchorNode->renderer())
return;
LayoutRect rect;
if (anchorNode != m_frame->document())
rect = anchorNode->boundingBox();
anchorNode->renderer()->scrollRectToVisible(rect, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignTopAlways);
if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache())
cache->handleScrolledToAnchor(anchorNode.get());
m_maintainScrollPositionAnchor = anchorNode;
}
Commit Message: Defer call to updateWidgetPositions() outside of RenderLayerScrollableArea.
updateWidgetPositions() can destroy the render tree, so it should never
be called from inside RenderLayerScrollableArea. Leaving it there allows
for the potential of use-after-free bugs.
BUG=402407
[email protected]
Review URL: https://codereview.chromium.org/490473003
git-svn-id: svn://svn.chromium.org/blink/trunk@180681 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-416 | 0 | 119,914 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void OpenDeviceOnServiceThread(
const std::string& guid,
mojo::InterfaceRequest<Device> device_request,
const DeviceManager::OpenDeviceCallback& callback,
scoped_refptr<base::TaskRunner> callback_task_runner) {
DCHECK(DeviceClient::Get());
UsbService* usb_service = DeviceClient::Get()->GetUsbService();
if (!usb_service) {
callback_task_runner->PostTask(FROM_HERE,
base::Bind(&RunOpenDeviceCallback, callback,
OPEN_DEVICE_ERROR_NOT_FOUND));
return;
}
scoped_refptr<UsbDevice> device = usb_service->GetDevice(guid);
if (!device) {
callback_task_runner->PostTask(FROM_HERE,
base::Bind(&RunOpenDeviceCallback, callback,
OPEN_DEVICE_ERROR_NOT_FOUND));
return;
}
device->Open(base::Bind(&OnOpenDeviceOnServiceThread,
base::Passed(&device_request), callback,
callback_task_runner));
}
Commit Message: Connect WebUSB client interface to the devices app
This provides a basic WebUSB client interface in
content/renderer. Most of the interface is unimplemented,
but this CL hooks up navigator.usb.getDevices() to the
browser's Mojo devices app to enumerate available USB
devices.
BUG=492204
Review URL: https://codereview.chromium.org/1293253002
Cr-Commit-Position: refs/heads/master@{#344881}
CWE ID: CWE-399 | 0 | 123,285 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: isdn_net_force_dial_lp(isdn_net_local * lp)
{
if ((!(lp->flags & ISDN_NET_CONNECTED)) && !lp->dialstate) {
int chi;
if (lp->phone[1]) {
ulong flags;
/* Grab a free ISDN-Channel */
spin_lock_irqsave(&dev->lock, flags);
if ((chi = isdn_get_free_channel(
ISDN_USAGE_NET,
lp->l2_proto,
lp->l3_proto,
lp->pre_device,
lp->pre_channel,
lp->msn)) < 0) {
printk(KERN_WARNING "isdn_net_force_dial: No channel for %s\n",
lp->netdev->dev->name);
spin_unlock_irqrestore(&dev->lock, flags);
return -EAGAIN;
}
lp->dialstate = 1;
/* Connect interface with channel */
isdn_net_bind_channel(lp, chi);
#ifdef CONFIG_ISDN_PPP
if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP)
if (isdn_ppp_bind(lp) < 0) {
isdn_net_unbind_channel(lp);
spin_unlock_irqrestore(&dev->lock, flags);
return -EAGAIN;
}
#endif
/* Initiate dialing */
spin_unlock_irqrestore(&dev->lock, flags);
isdn_net_dial();
return 0;
} else
return -EINVAL;
} else
return -EBUSY;
}
Commit Message: net: Audit drivers to identify those needing IFF_TX_SKB_SHARING cleared
After the last patch, We are left in a state in which only drivers calling
ether_setup have IFF_TX_SKB_SHARING set (we assume that drivers touching real
hardware call ether_setup for their net_devices and don't hold any state in
their skbs. There are a handful of drivers that violate this assumption of
course, and need to be fixed up. This patch identifies those drivers, and marks
them as not being able to support the safe transmission of skbs by clearning the
IFF_TX_SKB_SHARING flag in priv_flags
Signed-off-by: Neil Horman <[email protected]>
CC: Karsten Keil <[email protected]>
CC: "David S. Miller" <[email protected]>
CC: Jay Vosburgh <[email protected]>
CC: Andy Gospodarek <[email protected]>
CC: Patrick McHardy <[email protected]>
CC: Krzysztof Halasa <[email protected]>
CC: "John W. Linville" <[email protected]>
CC: Greg Kroah-Hartman <[email protected]>
CC: Marcel Holtmann <[email protected]>
CC: Johannes Berg <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
CWE ID: CWE-264 | 0 | 23,642 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: isdn_net_ciscohdlck_slarp_in(isdn_net_local *lp, struct sk_buff *skb)
{
unsigned char *p;
int period;
u32 code;
u32 my_seq;
u32 your_seq;
__be32 local;
__be32 *addr, *mask;
if (skb->len < 14)
return;
p = skb->data;
code = be32_to_cpup((__be32 *)p);
p += 4;
switch (code) {
case CISCO_SLARP_REQUEST:
lp->cisco_yourseq = 0;
isdn_net_ciscohdlck_slarp_send_reply(lp);
break;
case CISCO_SLARP_REPLY:
addr = (__be32 *)p;
mask = (__be32 *)(p + 4);
if (*mask != cpu_to_be32(0xfffffffc))
goto slarp_reply_out;
if ((*addr & cpu_to_be32(3)) == cpu_to_be32(0) ||
(*addr & cpu_to_be32(3)) == cpu_to_be32(3))
goto slarp_reply_out;
local = *addr ^ cpu_to_be32(3);
printk(KERN_INFO "%s: got slarp reply: remote ip: %pI4, local ip: %pI4 mask: %pI4\n",
lp->netdev->dev->name, addr, &local, mask);
break;
slarp_reply_out:
printk(KERN_INFO "%s: got invalid slarp reply (%pI4/%pI4) - ignored\n",
lp->netdev->dev->name, addr, mask);
break;
case CISCO_SLARP_KEEPALIVE:
period = (int)((jiffies - lp->cisco_last_slarp_in
+ HZ/2 - 1) / HZ);
if (lp->cisco_debserint &&
(period != lp->cisco_keepalive_period) &&
lp->cisco_last_slarp_in) {
printk(KERN_DEBUG "%s: Keepalive period mismatch - "
"is %d but should be %d.\n",
lp->netdev->dev->name, period,
lp->cisco_keepalive_period);
}
lp->cisco_last_slarp_in = jiffies;
my_seq = be32_to_cpup((__be32 *)(p + 0));
your_seq = be32_to_cpup((__be32 *)(p + 4));
p += 10;
lp->cisco_yourseq = my_seq;
lp->cisco_mineseen = your_seq;
break;
}
}
Commit Message: net: Audit drivers to identify those needing IFF_TX_SKB_SHARING cleared
After the last patch, We are left in a state in which only drivers calling
ether_setup have IFF_TX_SKB_SHARING set (we assume that drivers touching real
hardware call ether_setup for their net_devices and don't hold any state in
their skbs. There are a handful of drivers that violate this assumption of
course, and need to be fixed up. This patch identifies those drivers, and marks
them as not being able to support the safe transmission of skbs by clearning the
IFF_TX_SKB_SHARING flag in priv_flags
Signed-off-by: Neil Horman <[email protected]>
CC: Karsten Keil <[email protected]>
CC: "David S. Miller" <[email protected]>
CC: Jay Vosburgh <[email protected]>
CC: Andy Gospodarek <[email protected]>
CC: Patrick McHardy <[email protected]>
CC: Krzysztof Halasa <[email protected]>
CC: "John W. Linville" <[email protected]>
CC: Greg Kroah-Hartman <[email protected]>
CC: Marcel Holtmann <[email protected]>
CC: Johannes Berg <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
CWE ID: CWE-264 | 0 | 23,626 |
Analyze the following 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 AutocompleteProvider::DeleteMatch(const AutocompleteMatch& match) {
DLOG(WARNING) << "The AutocompleteProvider '" << name()
<< "' has not implemented DeleteMatch.";
}
Commit Message: Adds per-provider information to omnibox UMA logs.
Adds a fairly general structure to omnibox logs that can be used to pass information (that's not per-result information) from providers to the UMA logs. Right now it's only used to pass whether the asynchronous pass of a provider has finished, but it will probably be used for other things in the future.
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/10380007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137288 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: | 0 | 103,784 |
Analyze the following 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 AgcCreate(preproc_effect_t *effect)
{
webrtc::GainControl *agc = effect->session->apm->gain_control();
ALOGV("AgcCreate got agc %p", agc);
if (agc == NULL) {
ALOGW("AgcCreate Error");
return -ENOMEM;
}
effect->engine = static_cast<preproc_fx_handle_t>(agc);
AgcInit(effect);
return 0;
}
Commit Message: audio effects: fix heap overflow
Check consistency of effect command reply sizes before
copying to reply address.
Also add null pointer check on reply size.
Also remove unused parameter warning.
Bug: 21953516.
Change-Id: I4cf00c12eaed696af28f3b7613f7e36f47a160c4
(cherry picked from commit 0f714a464d2425afe00d6450535e763131b40844)
CWE ID: CWE-119 | 0 | 157,463 |
Analyze the following 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 TIFFWritePhotoshopLayers(Image* image,
const ImageInfo *image_info,EndianType endian,ExceptionInfo *exception)
{
BlobInfo
*blob;
CustomStreamInfo
*custom_stream;
Image
*base_image,
*next;
ImageInfo
*clone_info;
MagickBooleanType
status;
PhotoshopProfile
profile;
PSDInfo
info;
StringInfo
*layers;
base_image=CloneImage(image,0,0,MagickFalse,exception);
if (base_image == (Image *) NULL)
return(MagickTrue);
clone_info=CloneImageInfo(image_info);
if (clone_info == (ImageInfo *) NULL)
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
profile.offset=0;
profile.quantum=MagickMinBlobExtent;
layers=AcquireStringInfo(profile.quantum);
if (layers == (StringInfo *) NULL)
{
base_image=DestroyImage(base_image);
clone_info=DestroyImageInfo(clone_info);
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
}
profile.data=layers;
profile.extent=layers->length;
custom_stream=TIFFAcquireCustomStreamForWriting(&profile,exception);
if (custom_stream == (CustomStreamInfo *) NULL)
{
base_image=DestroyImage(base_image);
clone_info=DestroyImageInfo(clone_info);
layers=DestroyStringInfo(layers);
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
}
blob=CloneBlobInfo((BlobInfo *) NULL);
if (blob == (BlobInfo *) NULL)
{
base_image=DestroyImage(base_image);
clone_info=DestroyImageInfo(clone_info);
layers=DestroyStringInfo(layers);
custom_stream=DestroyCustomStreamInfo(custom_stream);
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
}
DestroyBlob(base_image);
base_image->blob=blob;
next=base_image;
while (next != (Image *) NULL)
next=SyncNextImageInList(next);
AttachCustomStream(base_image->blob,custom_stream);
InitPSDInfo(image,&info);
base_image->endian=endian;
WriteBlobString(base_image,"Adobe Photoshop Document Data Block");
WriteBlobByte(base_image,0);
WriteBlobString(base_image,base_image->endian == LSBEndian ? "MIB8ryaL" :
"8BIMLayr");
status=WritePSDLayers(base_image,clone_info,&info,exception);
if (status != MagickFalse)
{
SetStringInfoLength(layers,(size_t) profile.offset);
status=SetImageProfile(image,"tiff:37724",layers,exception);
}
next=base_image;
while (next != (Image *) NULL)
{
CloseBlob(next);
next=next->next;
}
layers=DestroyStringInfo(layers);
clone_info=DestroyImageInfo(clone_info);
custom_stream=DestroyCustomStreamInfo(custom_stream);
return(status);
}
Commit Message: https://github.com/ImageMagick/ImageMagick/issues/1602
CWE ID: CWE-190 | 0 | 89,270 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: LocalSiteCharacteristicsDataImpl::~LocalSiteCharacteristicsDataImpl() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!IsLoaded());
DCHECK_EQ(0U, loaded_tabs_in_background_count_);
DCHECK(delegate_);
delegate_->OnLocalSiteCharacteristicsDataImplDestroyed(this);
if (is_dirty_ && safe_to_write_to_db_) {
DCHECK(site_characteristics_.IsInitialized());
database_->WriteSiteCharacteristicsIntoDB(origin_, site_characteristics_);
}
}
Commit Message: Connect the LocalDB to TabManager.
Bug: 773382
Change-Id: Iec8fe5226ee175105d51f300f30b4865478ac099
Reviewed-on: https://chromium-review.googlesource.com/1118611
Commit-Queue: Sébastien Marchand <[email protected]>
Reviewed-by: François Doray <[email protected]>
Cr-Commit-Position: refs/heads/master@{#572871}
CWE ID: | 0 | 132,068 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: UkmPageLoadMetricsObserver::UkmPageLoadMetricsObserver(
network::NetworkQualityTracker* network_quality_tracker)
: network_quality_tracker_(network_quality_tracker) {
DCHECK(network_quality_tracker_);
}
Commit Message: Add boolean to UserIntiatedInfo noting if an input event led to navigation.
Also refactor UkmPageLoadMetricsObserver to use this new boolean to
report the user initiated metric in RecordPageLoadExtraInfoMetrics, so
that it works correctly in the case when the page load failed.
Bug: 925104
Change-Id: Ie08e7d3912cb1da484190d838005e95e57a209ff
Reviewed-on: https://chromium-review.googlesource.com/c/1450460
Commit-Queue: Annie Sullivan <[email protected]>
Reviewed-by: Bryan McQuade <[email protected]>
Cr-Commit-Position: refs/heads/master@{#630870}
CWE ID: CWE-79 | 0 | 140,180 |
Analyze the following 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_ioc_fsgeometry_v1(
xfs_mount_t *mp,
void __user *arg)
{
xfs_fsop_geom_t fsgeo;
int error;
error = xfs_fs_geometry(mp, &fsgeo, 3);
if (error)
return -error;
/*
* Caller should have passed an argument of type
* xfs_fsop_geom_v1_t. This is a proper subset of the
* xfs_fsop_geom_t that xfs_fs_geometry() fills in.
*/
if (copy_to_user(arg, &fsgeo, sizeof(xfs_fsop_geom_v1_t)))
return -XFS_ERROR(EFAULT);
return 0;
}
Commit Message: fs,userns: Change inode_capable to capable_wrt_inode_uidgid
The kernel has no concept of capabilities with respect to inodes; inodes
exist independently of namespaces. For example, inode_capable(inode,
CAP_LINUX_IMMUTABLE) would be nonsense.
This patch changes inode_capable to check for uid and gid mappings and
renames it to capable_wrt_inode_uidgid, which should make it more
obvious what it does.
Fixes CVE-2014-4014.
Cc: Theodore Ts'o <[email protected]>
Cc: Serge Hallyn <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Dave Chinner <[email protected]>
Cc: [email protected]
Signed-off-by: Andy Lutomirski <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
CWE ID: CWE-264 | 0 | 36,917 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void HTMLInputElement::setValueForUser(const String& value)
{
setValue(value, DispatchChangeEvent);
}
Commit Message: Setting input.x-webkit-speech should not cause focus change
In r150866, we introduced element()->focus() in destroyShadowSubtree()
to retain focus on <input> when its type attribute gets changed.
But when x-webkit-speech attribute is changed, the element is detached
before calling destroyShadowSubtree() and element()->focus() failed
This patch moves detach() after destroyShadowSubtree() to fix the
problem.
BUG=243818
TEST=fast/forms/input-type-change-focusout.html
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/16084005
git-svn-id: svn://svn.chromium.org/blink/trunk@151444 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-20 | 0 | 113,010 |
Analyze the following 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 prstat_to_stat(struct stat *stbuf, ProxyStat *prstat)
{
memset(stbuf, 0, sizeof(*stbuf));
stbuf->st_dev = prstat->st_dev;
stbuf->st_ino = prstat->st_ino;
stbuf->st_nlink = prstat->st_nlink;
stbuf->st_mode = prstat->st_mode;
stbuf->st_uid = prstat->st_uid;
stbuf->st_gid = prstat->st_gid;
stbuf->st_rdev = prstat->st_rdev;
stbuf->st_size = prstat->st_size;
stbuf->st_blksize = prstat->st_blksize;
stbuf->st_blocks = prstat->st_blocks;
stbuf->st_atim.tv_sec = prstat->st_atim_sec;
stbuf->st_atim.tv_nsec = prstat->st_atim_nsec;
stbuf->st_mtime = prstat->st_mtim_sec;
stbuf->st_mtim.tv_nsec = prstat->st_mtim_nsec;
stbuf->st_ctime = prstat->st_ctim_sec;
stbuf->st_ctim.tv_nsec = prstat->st_ctim_nsec;
}
Commit Message:
CWE ID: CWE-400 | 0 | 7,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 int send_halfclose(struct iwch_ep *ep, gfp_t gfp)
{
struct cpl_close_con_req *req;
struct sk_buff *skb;
PDBG("%s ep %p\n", __func__, ep);
skb = get_skb(NULL, sizeof(*req), gfp);
if (!skb) {
printk(KERN_ERR MOD "%s - failed to alloc skb\n", __func__);
return -ENOMEM;
}
skb->priority = CPL_PRIORITY_DATA;
set_arp_failure_handler(skb, arp_failure_discard);
req = (struct cpl_close_con_req *) skb_put(skb, sizeof(*req));
req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_CLOSE_CON));
req->wr.wr_lo = htonl(V_WR_TID(ep->hwtid));
OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_CLOSE_CON_REQ, ep->hwtid));
return iwch_l2t_send(ep->com.tdev, skb, ep->l2t);
}
Commit Message: iw_cxgb3: Fix incorrectly returning error on success
The cxgb3_*_send() functions return NET_XMIT_ values, which are
positive integers values. So don't treat positive return values
as an error.
Signed-off-by: Steve Wise <[email protected]>
Signed-off-by: Hariprasad Shenai <[email protected]>
Signed-off-by: Doug Ledford <[email protected]>
CWE ID: | 0 | 56,896 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int lzh_read_lens(struct kwajd_stream *lzh,
unsigned int type, unsigned int numsyms,
unsigned char *lens)
{
register unsigned int bit_buffer;
register int bits_left;
unsigned char *i_ptr, *i_end;
unsigned int i, c, sel;
int err;
RESTORE_BITS;
switch (type) {
case 0:
i = numsyms; c = (i==16)?4: (i==32)?5: (i==64)?6: (i==256)?8 :0;
for (i = 0; i < numsyms; i++) lens[i] = c;
break;
case 1:
READ_BITS_SAFE(c, 4); lens[0] = c;
for (i = 1; i < numsyms; i++) {
READ_BITS_SAFE(sel, 1); if (sel == 0) lens[i] = c;
else { READ_BITS_SAFE(sel, 1); if (sel == 0) lens[i] = ++c;
else { READ_BITS_SAFE(c, 4); lens[i] = c; }}
}
break;
case 2:
READ_BITS_SAFE(c, 4); lens[0] = c;
for (i = 1; i < numsyms; i++) {
READ_BITS_SAFE(sel, 2);
if (sel == 3) READ_BITS_SAFE(c, 4); else c += (char) sel-1;
lens[i] = c;
}
break;
case 3:
for (i = 0; i < numsyms; i++) {
READ_BITS_SAFE(c, 4); lens[i] = c;
}
break;
}
STORE_BITS;
return MSPACK_ERR_OK;
}
Commit Message: kwaj_read_headers(): fix handling of non-terminated strings
CWE ID: CWE-787 | 0 | 79,166 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void AXObject::scrollToMakeVisibleWithSubFocus(const IntRect& subfocus) const {
const AXObject* scrollParent = parentObject() ? parentObject() : this;
ScrollableArea* scrollableArea = 0;
while (scrollParent) {
scrollableArea = scrollParent->getScrollableAreaIfScrollable();
if (scrollableArea)
break;
scrollParent = scrollParent->parentObject();
}
if (!scrollParent || !scrollableArea)
return;
IntRect objectRect = pixelSnappedIntRect(getBoundsInFrameCoordinates());
IntSize scrollOffset = scrollableArea->scrollOffsetInt();
IntRect scrollVisibleRect = scrollableArea->visibleContentRect();
if (!scrollParent->isWebArea()) {
objectRect.moveBy(IntPoint(scrollOffset));
objectRect.moveBy(
-pixelSnappedIntRect(scrollParent->getBoundsInFrameCoordinates())
.location());
}
int desiredX = computeBestScrollOffset(
scrollOffset.width(), objectRect.x() + subfocus.x(),
objectRect.x() + subfocus.maxX(), objectRect.x(), objectRect.maxX(), 0,
scrollVisibleRect.width());
int desiredY = computeBestScrollOffset(
scrollOffset.height(), objectRect.y() + subfocus.y(),
objectRect.y() + subfocus.maxY(), objectRect.y(), objectRect.maxY(), 0,
scrollVisibleRect.height());
scrollParent->setScrollOffset(IntPoint(desiredX, desiredY));
IntRect newSubfocus = subfocus;
IntRect newElementRect = pixelSnappedIntRect(getBoundsInFrameCoordinates());
IntRect scrollParentRect =
pixelSnappedIntRect(scrollParent->getBoundsInFrameCoordinates());
newSubfocus.move(newElementRect.x(), newElementRect.y());
newSubfocus.move(-scrollParentRect.x(), -scrollParentRect.y());
if (scrollParent->parentObject()) {
scrollParent->scrollToMakeVisibleWithSubFocus(newSubfocus);
} else {
axObjectCache().postNotification(const_cast<AXObject*>(this),
AXObjectCacheImpl::AXLocationChanged);
}
}
Commit Message: Switch to equalIgnoringASCIICase throughout modules/accessibility
BUG=627682
Review-Url: https://codereview.chromium.org/2793913007
Cr-Commit-Position: refs/heads/master@{#461858}
CWE ID: CWE-254 | 0 | 127,298 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int crypto_skcipher_init_tfm(struct crypto_tfm *tfm)
{
struct crypto_skcipher *skcipher = __crypto_skcipher_cast(tfm);
struct skcipher_alg *alg = crypto_skcipher_alg(skcipher);
if (tfm->__crt_alg->cra_type == &crypto_blkcipher_type)
return crypto_init_skcipher_ops_blkcipher(tfm);
if (tfm->__crt_alg->cra_type == &crypto_ablkcipher_type ||
tfm->__crt_alg->cra_type == &crypto_givcipher_type)
return crypto_init_skcipher_ops_ablkcipher(tfm);
skcipher->setkey = alg->setkey;
skcipher->encrypt = alg->encrypt;
skcipher->decrypt = alg->decrypt;
skcipher->ivsize = alg->ivsize;
skcipher->keysize = alg->max_keysize;
if (alg->exit)
skcipher->base.exit = crypto_skcipher_exit_tfm;
if (alg->init)
return alg->init(skcipher);
return 0;
}
Commit Message: crypto: skcipher - Add missing API setkey checks
The API setkey checks for key sizes and alignment went AWOL during the
skcipher conversion. This patch restores them.
Cc: <[email protected]>
Fixes: 4e6c3df4d729 ("crypto: skcipher - Add low-level skcipher...")
Reported-by: Baozeng <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
CWE ID: CWE-476 | 1 | 168,112 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: URI_CHAR URI_FUNC(HexToLetter)(unsigned int value) {
/* Uppercase recommended in section 2.1. of RFC 3986 *
* http://tools.ietf.org/html/rfc3986#section-2.1 */
return URI_FUNC(HexToLetterEx)(value, URI_TRUE);
}
Commit Message: ResetUri: Protect against NULL
CWE ID: CWE-476 | 0 | 75,712 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: WebPlugin* ChromeContentRendererClient::CreatePlugin(
content::RenderView* render_view,
WebFrame* frame,
const WebPluginParams& original_params,
const ChromeViewHostMsg_GetPluginInfo_Status& status,
const webkit::WebPluginInfo& plugin,
const std::string& actual_mime_type) {
ChromeViewHostMsg_GetPluginInfo_Status::Value status_value = status.value;
GURL url(original_params.url);
std::string orig_mime_type = original_params.mimeType.utf8();
PluginPlaceholder* placeholder = NULL;
if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) {
MissingPluginReporter::GetInstance()->ReportPluginMissing(
orig_mime_type, url);
placeholder = PluginPlaceholder::CreateMissingPlugin(
render_view, frame, original_params);
} else {
scoped_ptr<webkit::npapi::PluginGroup> group(
webkit::npapi::PluginList::Singleton()->GetPluginGroup(plugin));
string16 name = group->GetGroupName();
WebPluginParams params(original_params);
for (size_t i = 0; i < plugin.mime_types.size(); ++i) {
if (plugin.mime_types[i].mime_type == actual_mime_type) {
AppendParams(plugin.mime_types[i].additional_param_names,
plugin.mime_types[i].additional_param_values,
¶ms.attributeNames,
¶ms.attributeValues);
break;
}
}
if (params.mimeType.isNull() && (actual_mime_type.size() > 0)) {
params.mimeType = WebString::fromUTF8(actual_mime_type.c_str());
}
ContentSettingsObserver* observer =
ContentSettingsObserver::Get(render_view);
bool is_nacl_plugin =
plugin.name ==
ASCIIToUTF16(chrome::ChromeContentClient::kNaClPluginName);
ContentSettingsType content_type =
is_nacl_plugin ? CONTENT_SETTINGS_TYPE_JAVASCRIPT :
CONTENT_SETTINGS_TYPE_PLUGINS;
if ((status_value ==
ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized ||
status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay ||
status_value == ChromeViewHostMsg_GetPluginInfo_Status::kBlocked) &&
observer->plugins_temporarily_allowed()) {
status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed;
}
switch (status_value) {
case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: {
NOTREACHED();
break;
}
case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: {
if (prerender::PrerenderHelper::IsPrerendering(render_view)) {
placeholder = PluginPlaceholder::CreateBlockedPlugin(
render_view, frame, params, plugin, name,
IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD);
placeholder->set_blocked_for_prerendering(true);
placeholder->set_allow_loading(true);
break;
}
const char* kNaClMimeType = "application/x-nacl";
bool is_nacl_mime_type = actual_mime_type == kNaClMimeType;
bool is_nacl_unrestricted;
if (is_nacl_plugin) {
is_nacl_unrestricted = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableNaCl);
} else {
is_nacl_unrestricted = true;
}
if (is_nacl_plugin || is_nacl_mime_type) {
GURL manifest_url = is_nacl_mime_type ?
url : GetNaClContentHandlerURL(actual_mime_type, plugin);
const Extension* extension =
extension_dispatcher_->extensions()->GetExtensionOrAppByURL(
ExtensionURLInfo(manifest_url));
bool is_extension_from_webstore =
extension && extension->from_webstore();
bool is_extension_unrestricted = extension &&
(extension->location() == Extension::COMPONENT ||
extension->location() == Extension::LOAD);
GURL top_url = frame->top()->document().url();
if (!IsNaClAllowed(manifest_url,
top_url,
is_nacl_unrestricted,
is_extension_unrestricted,
is_extension_from_webstore,
¶ms)) {
frame->addMessageToConsole(
WebConsoleMessage(
WebConsoleMessage::LevelError,
"Only unpacked extensions and apps installed from the "
"Chrome Web Store can load NaCl modules without enabling "
"Native Client in about:flags."));
placeholder = PluginPlaceholder::CreateBlockedPlugin(
render_view, frame, params, plugin, name,
IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED);
break;
}
}
return render_view->CreatePlugin(frame, plugin, params);
}
case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: {
placeholder = PluginPlaceholder::CreateBlockedPlugin(
render_view, frame, params, plugin, name,
IDR_DISABLED_PLUGIN_HTML, IDS_PLUGIN_DISABLED);
break;
}
case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: {
#if defined(ENABLE_PLUGIN_INSTALLATION)
placeholder = PluginPlaceholder::CreateBlockedPlugin(
render_view, frame, params, plugin, name,
IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED);
placeholder->set_allow_loading(true);
render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin(
render_view->GetRoutingID(), placeholder->CreateRoutingId(),
group->identifier()));
#else
NOTREACHED();
#endif
break;
}
case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: {
placeholder = PluginPlaceholder::CreateBlockedPlugin(
render_view, frame, params, plugin, name,
IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED);
break;
}
case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: {
placeholder = PluginPlaceholder::CreateBlockedPlugin(
render_view, frame, params, plugin, name,
IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_NOT_AUTHORIZED);
placeholder->set_allow_loading(true);
render_view->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin(
render_view->GetRoutingID(), group->GetGroupName()));
break;
}
case ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay: {
placeholder = PluginPlaceholder::CreateBlockedPlugin(
render_view, frame, params, plugin, name,
IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD);
placeholder->set_allow_loading(true);
RenderThread::Get()->RecordUserMetrics("Plugin_ClickToPlay");
observer->DidBlockContentType(content_type, group->identifier());
break;
}
case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: {
placeholder = PluginPlaceholder::CreateBlockedPlugin(
render_view, frame, params, plugin, name,
IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED);
placeholder->set_allow_loading(true);
RenderThread::Get()->RecordUserMetrics("Plugin_Blocked");
observer->DidBlockContentType(content_type, group->identifier());
break;
}
}
}
placeholder->SetStatus(status);
return placeholder->plugin();
}
Commit Message: Do not require DevTools extension resources to be white-listed in manifest.
Currently, resources used by DevTools extensions need to be white-listed as web_accessible_resources in manifest. This is quite inconvenitent and appears to be an overkill, given the fact that DevTools front-end is
(a) trusted and
(b) picky on the frames it loads.
This change adds resources that belong to DevTools extensions and are being loaded into a DevTools front-end page to the list of exceptions from web_accessible_resources check.
BUG=none
TEST=DevToolsExtensionTest.*
Review URL: https://chromiumcodereview.appspot.com/9663076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126378 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-119 | 0 | 108,134 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void hns_ppe_get_strings(struct hns_ppe_cb *ppe_cb, int stringset, u8 *data)
{
char *buff = (char *)data;
int index = ppe_cb->index;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_sw_pkt", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_pkt_ok", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_drop_pkt_no_bd", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_alloc_buf_fail", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_alloc_buf_wait", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_pkt_drop_no_buf", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_pkt_err_fifo_full", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_tx_bd", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_tx_pkt", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_tx_pkt_ok", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_tx_pkt_err_fifo_empty", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_tx_pkt_err_csum_fail", index);
}
Commit Message: net: hns: fix ethtool_get_strings overflow in hns driver
hns_get_sset_count() returns HNS_NET_STATS_CNT and the data space allocated
is not enough for ethtool_get_strings(), which will cause random memory
corruption.
When SLAB and DEBUG_SLAB are both enabled, memory corruptions like the
the following can be observed without this patch:
[ 43.115200] Slab corruption (Not tainted): Acpi-ParseExt start=ffff801fb0b69030, len=80
[ 43.115206] Redzone: 0x9f911029d006462/0x5f78745f31657070.
[ 43.115208] Last user: [<5f7272655f746b70>](0x5f7272655f746b70)
[ 43.115214] 010: 70 70 65 31 5f 74 78 5f 70 6b 74 00 6b 6b 6b 6b ppe1_tx_pkt.kkkk
[ 43.115217] 030: 70 70 65 31 5f 74 78 5f 70 6b 74 5f 6f 6b 00 6b ppe1_tx_pkt_ok.k
[ 43.115218] Next obj: start=ffff801fb0b69098, len=80
[ 43.115220] Redzone: 0x706d655f6f666966/0x9f911029d74e35b.
[ 43.115229] Last user: [<ffff0000084b11b0>](acpi_os_release_object+0x28/0x38)
[ 43.115231] 000: 74 79 00 6b 6b 6b 6b 6b 70 70 65 31 5f 74 78 5f ty.kkkkkppe1_tx_
[ 43.115232] 010: 70 6b 74 5f 65 72 72 5f 63 73 75 6d 5f 66 61 69 pkt_err_csum_fai
Signed-off-by: Timmy Li <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
CWE ID: CWE-119 | 0 | 85,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: GF_Err nump_Read(GF_Box *s, GF_BitStream *bs)
{
GF_NUMPBox *ptr = (GF_NUMPBox *)s;
ptr->nbPackets = gf_bs_read_u64(bs);
return GF_OK;
}
Commit Message: fixed 2 possible heap overflows (inc. #1088)
CWE ID: CWE-125 | 0 | 80,297 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: views::Widget* GetCloseButton(WindowSelectorItem* window) {
return window->close_button_->GetWidget();
}
Commit Message: cros: Enable some tests in //ash/wm in ash_unittests --mash
For the ones that fail, disable them via filter file instead of in the
code, per our disablement policy.
Bug: 698085, 695556, 698878, 698888, 698093, 698894
Test: ash_unittests --mash
Change-Id: Ic145ab6a95508968d6884d14fac2a3ca08888d26
Reviewed-on: https://chromium-review.googlesource.com/752423
Commit-Queue: James Cook <[email protected]>
Reviewed-by: Steven Bennetts <[email protected]>
Cr-Commit-Position: refs/heads/master@{#513836}
CWE ID: CWE-119 | 0 | 133,205 |
Analyze the following 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 Ref(::Cursor cursor) {
cache_[cursor]->Ref();
}
Commit Message: Make shared memory segments writable only by their rightful owners.
BUG=143859
TEST=Chrome's UI still works on Linux and Chrome OS
Review URL: https://chromiumcodereview.appspot.com/10854242
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158289 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-264 | 0 | 119,204 |
Analyze the following 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 WebGL2RenderingContextBase::bindVertexArray(
WebGLVertexArrayObject* vertex_array) {
if (isContextLost())
return;
if (vertex_array &&
(vertex_array->IsDeleted() || !vertex_array->Validate(0, this))) {
SynthesizeGLError(GL_INVALID_OPERATION, "bindVertexArray",
"invalid vertexArray");
return;
}
if (vertex_array && !vertex_array->IsDefaultObject() &&
vertex_array->Object()) {
ContextGL()->BindVertexArrayOES(ObjectOrZero(vertex_array));
vertex_array->SetHasEverBeenBound();
SetBoundVertexArrayObject(vertex_array);
} else {
ContextGL()->BindVertexArrayOES(0);
SetBoundVertexArrayObject(nullptr);
}
}
Commit Message: Reset ES3 pixel pack parameters and PIXEL_PACK_BUFFER binding in DrawingBuffer before ReadPixels() and recover them later.
BUG=740603
TEST=new conformance test
[email protected],[email protected]
Change-Id: I3ea54c6cc34f34e249f7c8b9f792d93c5e1958f4
Reviewed-on: https://chromium-review.googlesource.com/570840
Reviewed-by: Antoine Labour <[email protected]>
Reviewed-by: Kenneth Russell <[email protected]>
Commit-Queue: Zhenyao Mo <[email protected]>
Cr-Commit-Position: refs/heads/master@{#486518}
CWE ID: CWE-119 | 0 | 133,372 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static Image *ReadJPEGImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
char
value[MaxTextExtent];
const char
*option;
ErrorManager
error_manager;
Image
*image;
IndexPacket
index;
JSAMPLE
*volatile jpeg_pixels;
JSAMPROW
scanline[1];
MagickBooleanType
debug,
status;
MagickSizeType
number_pixels;
MemoryInfo
*memory_info;
register ssize_t
i;
struct jpeg_decompress_struct
jpeg_info;
struct jpeg_error_mgr
jpeg_error;
register JSAMPLE
*p;
size_t
units;
ssize_t
y;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
debug=IsEventLogging();
(void) debug;
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Initialize JPEG parameters.
*/
(void) ResetMagickMemory(&error_manager,0,sizeof(error_manager));
(void) ResetMagickMemory(&jpeg_info,0,sizeof(jpeg_info));
(void) ResetMagickMemory(&jpeg_error,0,sizeof(jpeg_error));
jpeg_info.err=jpeg_std_error(&jpeg_error);
jpeg_info.err->emit_message=(void (*)(j_common_ptr,int)) JPEGWarningHandler;
jpeg_info.err->error_exit=(void (*)(j_common_ptr)) JPEGErrorHandler;
memory_info=(MemoryInfo *) NULL;
error_manager.image=image;
if (setjmp(error_manager.error_recovery) != 0)
{
jpeg_destroy_decompress(&jpeg_info);
if (error_manager.profile != (StringInfo *) NULL)
error_manager.profile=DestroyStringInfo(error_manager.profile);
(void) CloseBlob(image);
number_pixels=(MagickSizeType) image->columns*image->rows;
if (number_pixels != 0)
return(GetFirstImageInList(image));
InheritException(exception,&image->exception);
return(DestroyImage(image));
}
jpeg_info.client_data=(void *) &error_manager;
jpeg_create_decompress(&jpeg_info);
JPEGSourceManager(&jpeg_info,image);
jpeg_set_marker_processor(&jpeg_info,JPEG_COM,ReadComment);
option=GetImageOption(image_info,"profile:skip");
if (IsOptionMember("ICC",option) == MagickFalse)
jpeg_set_marker_processor(&jpeg_info,ICC_MARKER,ReadICCProfile);
if (IsOptionMember("IPTC",option) == MagickFalse)
jpeg_set_marker_processor(&jpeg_info,IPTC_MARKER,ReadIPTCProfile);
for (i=1; i < 16; i++)
if ((i != 2) && (i != 13) && (i != 14))
if (IsOptionMember("APP",option) == MagickFalse)
jpeg_set_marker_processor(&jpeg_info,(int) (JPEG_APP0+i),ReadProfile);
i=(ssize_t) jpeg_read_header(&jpeg_info,TRUE);
if ((image_info->colorspace == YCbCrColorspace) ||
(image_info->colorspace == Rec601YCbCrColorspace) ||
(image_info->colorspace == Rec709YCbCrColorspace))
jpeg_info.out_color_space=JCS_YCbCr;
/*
Set image resolution.
*/
units=0;
if ((jpeg_info.saw_JFIF_marker != 0) && (jpeg_info.X_density != 1) &&
(jpeg_info.Y_density != 1))
{
image->x_resolution=(double) jpeg_info.X_density;
image->y_resolution=(double) jpeg_info.Y_density;
units=(size_t) jpeg_info.density_unit;
}
if (units == 1)
image->units=PixelsPerInchResolution;
if (units == 2)
image->units=PixelsPerCentimeterResolution;
number_pixels=(MagickSizeType) image->columns*image->rows;
option=GetImageOption(image_info,"jpeg:size");
if ((option != (const char *) NULL) &&
(jpeg_info.out_color_space != JCS_YCbCr))
{
double
scale_factor;
GeometryInfo
geometry_info;
MagickStatusType
flags;
/*
Scale the image.
*/
flags=ParseGeometry(option,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=geometry_info.rho;
jpeg_calc_output_dimensions(&jpeg_info);
image->magick_columns=jpeg_info.output_width;
image->magick_rows=jpeg_info.output_height;
scale_factor=1.0;
if (geometry_info.rho != 0.0)
scale_factor=jpeg_info.output_width/geometry_info.rho;
if ((geometry_info.sigma != 0.0) &&
(scale_factor > (jpeg_info.output_height/geometry_info.sigma)))
scale_factor=jpeg_info.output_height/geometry_info.sigma;
jpeg_info.scale_num=1U;
jpeg_info.scale_denom=(unsigned int) scale_factor;
jpeg_calc_output_dimensions(&jpeg_info);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
"Scale factor: %.20g",(double) scale_factor);
}
#if (JPEG_LIB_VERSION >= 61) && defined(D_PROGRESSIVE_SUPPORTED)
#if defined(D_LOSSLESS_SUPPORTED)
image->interlace=jpeg_info.process == JPROC_PROGRESSIVE ?
JPEGInterlace : NoInterlace;
image->compression=jpeg_info.process == JPROC_LOSSLESS ?
LosslessJPEGCompression : JPEGCompression;
if (jpeg_info.data_precision > 8)
(void) ThrowMagickException(exception,GetMagickModule(),OptionError,
"12-bit JPEG not supported. Reducing pixel data to 8 bits","`%s'",
image->filename);
if (jpeg_info.data_precision == 16)
jpeg_info.data_precision=12;
#else
image->interlace=jpeg_info.progressive_mode != 0 ? JPEGInterlace :
NoInterlace;
image->compression=JPEGCompression;
#endif
#else
image->compression=JPEGCompression;
image->interlace=JPEGInterlace;
#endif
option=GetImageOption(image_info,"jpeg:colors");
if (option != (const char *) NULL)
{
/*
Let the JPEG library quantize for us.
*/
jpeg_info.quantize_colors=TRUE;
jpeg_info.desired_number_of_colors=(int) StringToUnsignedLong(option);
}
option=GetImageOption(image_info,"jpeg:block-smoothing");
if (option != (const char *) NULL)
jpeg_info.do_block_smoothing=IsStringTrue(option) != MagickFalse ? TRUE :
FALSE;
jpeg_info.dct_method=JDCT_FLOAT;
option=GetImageOption(image_info,"jpeg:dct-method");
if (option != (const char *) NULL)
switch (*option)
{
case 'D':
case 'd':
{
if (LocaleCompare(option,"default") == 0)
jpeg_info.dct_method=JDCT_DEFAULT;
break;
}
case 'F':
case 'f':
{
if (LocaleCompare(option,"fastest") == 0)
jpeg_info.dct_method=JDCT_FASTEST;
if (LocaleCompare(option,"float") == 0)
jpeg_info.dct_method=JDCT_FLOAT;
break;
}
case 'I':
case 'i':
{
if (LocaleCompare(option,"ifast") == 0)
jpeg_info.dct_method=JDCT_IFAST;
if (LocaleCompare(option,"islow") == 0)
jpeg_info.dct_method=JDCT_ISLOW;
break;
}
}
option=GetImageOption(image_info,"jpeg:fancy-upsampling");
if (option != (const char *) NULL)
jpeg_info.do_fancy_upsampling=IsStringTrue(option) != MagickFalse ? TRUE :
FALSE;
(void) jpeg_start_decompress(&jpeg_info);
image->columns=jpeg_info.output_width;
image->rows=jpeg_info.output_height;
image->depth=(size_t) jpeg_info.data_precision;
switch (jpeg_info.out_color_space)
{
case JCS_RGB:
default:
{
(void) SetImageColorspace(image,sRGBColorspace);
break;
}
case JCS_GRAYSCALE:
{
(void) SetImageColorspace(image,GRAYColorspace);
break;
}
case JCS_YCbCr:
{
(void) SetImageColorspace(image,YCbCrColorspace);
break;
}
case JCS_CMYK:
{
(void) SetImageColorspace(image,CMYKColorspace);
break;
}
}
if (IsITUFaxImage(image) != MagickFalse)
{
(void) SetImageColorspace(image,LabColorspace);
jpeg_info.out_color_space=JCS_YCbCr;
}
if (option != (const char *) NULL)
if (AcquireImageColormap(image,StringToUnsignedLong(option)) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if ((jpeg_info.output_components == 1) && (jpeg_info.quantize_colors == 0))
{
size_t
colors;
colors=(size_t) GetQuantumRange(image->depth)+1;
if (AcquireImageColormap(image,colors) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
if (image->debug != MagickFalse)
{
if (image->interlace != NoInterlace)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
"Interlace: progressive");
else
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
"Interlace: nonprogressive");
(void) LogMagickEvent(CoderEvent,GetMagickModule(),"Data precision: %d",
(int) jpeg_info.data_precision);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),"Geometry: %dx%d",
(int) jpeg_info.output_width,(int) jpeg_info.output_height);
}
JPEGSetImageQuality(&jpeg_info,image);
JPEGSetImageSamplingFactor(&jpeg_info,image);
(void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
jpeg_info.out_color_space);
(void) SetImageProperty(image,"jpeg:colorspace",value);
if (image_info->ping != MagickFalse)
{
jpeg_destroy_decompress(&jpeg_info);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
status=SetImageExtent(image,image->columns,image->rows);
if (status == MagickFalse)
{
jpeg_destroy_decompress(&jpeg_info);
InheritException(exception,&image->exception);
return(DestroyImageList(image));
}
if ((jpeg_info.output_components != 1) &&
(jpeg_info.output_components != 3) && (jpeg_info.output_components != 4))
{
jpeg_destroy_decompress(&jpeg_info);
ThrowReaderException(CorruptImageError,"ImageTypeNotSupported");
}
memory_info=AcquireVirtualMemory((size_t) image->columns,
jpeg_info.output_components*sizeof(*jpeg_pixels));
if (memory_info == (MemoryInfo *) NULL)
{
jpeg_destroy_decompress(&jpeg_info);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
jpeg_pixels=(JSAMPLE *) GetVirtualMemoryBlob(memory_info);
/*
Convert JPEG pixels to pixel packets.
*/
if (setjmp(error_manager.error_recovery) != 0)
{
if (memory_info != (MemoryInfo *) NULL)
memory_info=RelinquishVirtualMemory(memory_info);
jpeg_destroy_decompress(&jpeg_info);
(void) CloseBlob(image);
number_pixels=(MagickSizeType) image->columns*image->rows;
if (number_pixels != 0)
return(GetFirstImageInList(image));
return(DestroyImage(image));
}
if (jpeg_info.quantize_colors != 0)
{
image->colors=(size_t) jpeg_info.actual_number_of_colors;
if (jpeg_info.out_color_space == JCS_GRAYSCALE)
for (i=0; i < (ssize_t) image->colors; i++)
{
image->colormap[i].red=ScaleCharToQuantum(jpeg_info.colormap[0][i]);
image->colormap[i].green=image->colormap[i].red;
image->colormap[i].blue=image->colormap[i].red;
image->colormap[i].opacity=OpaqueOpacity;
}
else
for (i=0; i < (ssize_t) image->colors; i++)
{
image->colormap[i].red=ScaleCharToQuantum(jpeg_info.colormap[0][i]);
image->colormap[i].green=ScaleCharToQuantum(jpeg_info.colormap[1][i]);
image->colormap[i].blue=ScaleCharToQuantum(jpeg_info.colormap[2][i]);
image->colormap[i].opacity=OpaqueOpacity;
}
}
scanline[0]=(JSAMPROW) jpeg_pixels;
for (y=0; y < (ssize_t) image->rows; y++)
{
register IndexPacket
*magick_restrict indexes;
register ssize_t
x;
register PixelPacket
*magick_restrict q;
if (jpeg_read_scanlines(&jpeg_info,scanline,1) != 1)
{
(void) ThrowMagickException(exception,GetMagickModule(),
CorruptImageWarning,"SkipToSyncByte","`%s'",image->filename);
continue;
}
p=jpeg_pixels;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
if (jpeg_info.data_precision > 8)
{
unsigned short
scale;
scale=65535/(unsigned short) GetQuantumRange((size_t)
jpeg_info.data_precision);
if (jpeg_info.output_components == 1)
for (x=0; x < (ssize_t) image->columns; x++)
{
size_t
pixel;
pixel=(size_t) (scale*GETJSAMPLE(*p));
index=ConstrainColormapIndex(image,pixel);
SetPixelIndex(indexes+x,index);
SetPixelRGBO(q,image->colormap+(ssize_t) index);
p++;
q++;
}
else
if (image->colorspace != CMYKColorspace)
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelRed(q,ScaleShortToQuantum((unsigned short)
(scale*GETJSAMPLE(*p++))));
SetPixelGreen(q,ScaleShortToQuantum((unsigned short)
(scale*GETJSAMPLE(*p++))));
SetPixelBlue(q,ScaleShortToQuantum((unsigned short)
(scale*GETJSAMPLE(*p++))));
SetPixelOpacity(q,OpaqueOpacity);
q++;
}
else
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelCyan(q,QuantumRange-ScaleShortToQuantum(
(unsigned short) (scale*GETJSAMPLE(*p++))));
SetPixelMagenta(q,QuantumRange-ScaleShortToQuantum(
(unsigned short) (scale*GETJSAMPLE(*p++))));
SetPixelYellow(q,QuantumRange-ScaleShortToQuantum(
(unsigned short) (scale*GETJSAMPLE(*p++))));
SetPixelBlack(indexes+x,QuantumRange-ScaleShortToQuantum(
(unsigned short) (scale*GETJSAMPLE(*p++))));
SetPixelOpacity(q,OpaqueOpacity);
q++;
}
}
else
if (jpeg_info.output_components == 1)
for (x=0; x < (ssize_t) image->columns; x++)
{
index=ConstrainColormapIndex(image,(size_t) GETJSAMPLE(*p));
SetPixelIndex(indexes+x,index);
SetPixelRGBO(q,image->colormap+(ssize_t) index);
p++;
q++;
}
else
if (image->colorspace != CMYKColorspace)
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelRed(q,ScaleCharToQuantum((unsigned char)
GETJSAMPLE(*p++)));
SetPixelGreen(q,ScaleCharToQuantum((unsigned char)
GETJSAMPLE(*p++)));
SetPixelBlue(q,ScaleCharToQuantum((unsigned char)
GETJSAMPLE(*p++)));
SetPixelOpacity(q,OpaqueOpacity);
q++;
}
else
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelCyan(q,QuantumRange-ScaleCharToQuantum((unsigned char)
GETJSAMPLE(*p++)));
SetPixelMagenta(q,QuantumRange-ScaleCharToQuantum((unsigned char)
GETJSAMPLE(*p++)));
SetPixelYellow(q,QuantumRange-ScaleCharToQuantum((unsigned char)
GETJSAMPLE(*p++)));
SetPixelBlack(indexes+x,QuantumRange-ScaleCharToQuantum(
(unsigned char) GETJSAMPLE(*p++)));
SetPixelOpacity(q,OpaqueOpacity);
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
{
jpeg_abort_decompress(&jpeg_info);
break;
}
}
if (status != MagickFalse)
{
error_manager.finished=MagickTrue;
if (setjmp(error_manager.error_recovery) == 0)
(void) jpeg_finish_decompress(&jpeg_info);
}
/*
Free jpeg resources.
*/
jpeg_destroy_decompress(&jpeg_info);
memory_info=RelinquishVirtualMemory(memory_info);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
Commit Message: Changed the JPEG writer to raise a warning when the exif profile exceeds 65533 bytes and truncate it.
CWE ID: CWE-119 | 0 | 71,926 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void StubOfflinePageModel::GetPagesRemovedOnCacheReset(
const MultipleOfflinePageItemCallback& callback) {}
Commit Message: Add the method to check if offline archive is in internal dir
Bug: 758690
Change-Id: I8bb4283fc40a87fa7a87df2c7e513e2e16903290
Reviewed-on: https://chromium-review.googlesource.com/828049
Reviewed-by: Filip Gorski <[email protected]>
Commit-Queue: Jian Li <[email protected]>
Cr-Commit-Position: refs/heads/master@{#524232}
CWE ID: CWE-787 | 0 | 155,944 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int md_open(struct block_device *bdev, fmode_t mode)
{
/*
* Succeed if we can lock the mddev, which confirms that
* it isn't being stopped right now.
*/
struct mddev *mddev = mddev_find(bdev->bd_dev);
int err;
if (!mddev)
return -ENODEV;
if (mddev->gendisk != bdev->bd_disk) {
/* we are racing with mddev_put which is discarding this
* bd_disk.
*/
mddev_put(mddev);
/* Wait until bdev->bd_disk is definitely gone */
flush_workqueue(md_misc_wq);
/* Then retry the open from the top */
return -ERESTARTSYS;
}
BUG_ON(mddev != bdev->bd_disk->private_data);
if ((err = mutex_lock_interruptible(&mddev->open_mutex)))
goto out;
err = 0;
atomic_inc(&mddev->openers);
clear_bit(MD_STILL_CLOSED, &mddev->flags);
mutex_unlock(&mddev->open_mutex);
check_disk_change(bdev);
out:
return err;
}
Commit Message: md: use kzalloc() when bitmap is disabled
In drivers/md/md.c get_bitmap_file() uses kmalloc() for creating a
mdu_bitmap_file_t called "file".
5769 file = kmalloc(sizeof(*file), GFP_NOIO);
5770 if (!file)
5771 return -ENOMEM;
This structure is copied to user space at the end of the function.
5786 if (err == 0 &&
5787 copy_to_user(arg, file, sizeof(*file)))
5788 err = -EFAULT
But if bitmap is disabled only the first byte of "file" is initialized
with zero, so it's possible to read some bytes (up to 4095) of kernel
space memory from user space. This is an information leak.
5775 /* bitmap disabled, zero the first byte and copy out */
5776 if (!mddev->bitmap_info.file)
5777 file->pathname[0] = '\0';
Signed-off-by: Benjamin Randazzo <[email protected]>
Signed-off-by: NeilBrown <[email protected]>
CWE ID: CWE-200 | 0 | 42,451 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: ShadowRoot* Element::shadowRoot() const
{
ElementShadow* elementShadow = shadow();
if (!elementShadow)
return 0;
ShadowRoot* shadowRoot = elementShadow->youngestShadowRoot();
if (shadowRoot->type() == ShadowRoot::AuthorShadowRoot)
return shadowRoot;
return 0;
}
Commit Message: Set Attr.ownerDocument in Element#setAttributeNode()
Attr objects can move across documents by setAttributeNode().
So It needs to reset ownerDocument through TreeScopeAdoptr::adoptIfNeeded().
BUG=248950
TEST=set-attribute-node-from-iframe.html
Review URL: https://chromiumcodereview.appspot.com/17583003
git-svn-id: svn://svn.chromium.org/blink/trunk@152938 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-399 | 0 | 112,403 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: MagickExport char *InterpretImageProperties(ImageInfo *image_info,Image *image,
const char *embed_text,ExceptionInfo *exception)
{
#define ExtendInterpretText(string_length) \
DisableMSCWarning(4127) \
{ \
size_t length=(string_length); \
if ((size_t) (q-interpret_text+length+1) >= extent) \
{ \
extent+=length; \
interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
MaxTextExtent,sizeof(*interpret_text)); \
if (interpret_text == (char *) NULL) \
return((char *) NULL); \
q=interpret_text+strlen(interpret_text); \
} \
} \
RestoreMSCWarning
#define AppendKeyValue2Text(key,value)\
DisableMSCWarning(4127) \
{ \
size_t length=strlen(key)+strlen(value)+2; \
if ((size_t) (q-interpret_text+length+1) >= extent) \
{ \
extent+=length; \
interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
MaxTextExtent,sizeof(*interpret_text)); \
if (interpret_text == (char *) NULL) \
return((char *) NULL); \
q=interpret_text+strlen(interpret_text); \
} \
q+=FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
} \
RestoreMSCWarning
#define AppendString2Text(string) \
DisableMSCWarning(4127) \
{ \
size_t length=strlen((string)); \
if ((size_t) (q-interpret_text+length+1) >= extent) \
{ \
extent+=length; \
interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
MaxTextExtent,sizeof(*interpret_text)); \
if (interpret_text == (char *) NULL) \
return((char *) NULL); \
q=interpret_text+strlen(interpret_text); \
} \
(void) CopyMagickString(q,(string),extent); \
q+=length; \
} \
RestoreMSCWarning
char
*interpret_text;
MagickBooleanType
number;
register char
*q; /* current position in interpret_text */
register const char
*p; /* position in embed_text string being expanded */
size_t
extent; /* allocated length of interpret_text */
assert(image == NULL || image->signature == MagickCoreSignature);
assert(image_info == NULL || image_info->signature == MagickCoreSignature);
if ((image != (Image *) NULL) && (image->debug != MagickFalse))
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
else
if ((image_info != (ImageInfo *) NULL) && (image_info->debug != MagickFalse))
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-image");
if (embed_text == (const char *) NULL)
return(ConstantString(""));
p=embed_text;
while ((isspace((int) ((unsigned char) *p)) != 0) && (*p != '\0'))
p++;
if (*p == '\0')
return(ConstantString(""));
if ((*p == '@') && (IsPathAccessible(p+1) != MagickFalse))
{
/*
Handle a '@' replace string from file.
*/
if (IsRightsAuthorized(PathPolicyDomain,ReadPolicyRights,p) == MagickFalse)
{
errno=EPERM;
(void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
"NotAuthorized","`%s'",p);
return(ConstantString(""));
}
interpret_text=FileToString(p+1,~0UL,exception);
if (interpret_text != (char *) NULL)
return(interpret_text);
}
/*
Translate any embedded format characters.
*/
interpret_text=AcquireString(embed_text); /* new string with extra space */
extent=MagickPathExtent; /* allocated space in string */
number=MagickFalse; /* is last char a number? */
for (q=interpret_text; *p!='\0'; number=isdigit(*p) ? MagickTrue : MagickFalse,p++)
{
/*
Look for the various escapes, (and handle other specials)
*/
*q='\0';
ExtendInterpretText(MagickPathExtent);
switch (*p)
{
case '\\':
{
switch (*(p+1))
{
case '\0':
continue;
case 'r': /* convert to RETURN */
{
*q++='\r';
p++;
continue;
}
case 'n': /* convert to NEWLINE */
{
*q++='\n';
p++;
continue;
}
case '\n': /* EOL removal UNIX,MacOSX */
{
p++;
continue;
}
case '\r': /* EOL removal DOS,Windows */
{
p++;
if (*p == '\n') /* return-newline EOL */
p++;
continue;
}
default:
{
p++;
*q++=(*p);
}
}
continue;
}
case '&':
{
if (LocaleNCompare("<",p,4) == 0)
{
*q++='<';
p+=3;
}
else
if (LocaleNCompare(">",p,4) == 0)
{
*q++='>';
p+=3;
}
else
if (LocaleNCompare("&",p,5) == 0)
{
*q++='&';
p+=4;
}
else
*q++=(*p);
continue;
}
case '%':
break; /* continue to next set of handlers */
default:
{
*q++=(*p); /* any thing else is 'as normal' */
continue;
}
}
p++; /* advance beyond the percent */
/*
Doubled Percent - or percent at end of string.
*/
if ((*p == '\0') || (*p == '\'') || (*p == '"'))
p--;
if (*p == '%')
{
*q++='%';
continue;
}
/*
Single letter escapes %c.
*/
if (*p != '[')
{
const char
*string;
if (number != MagickFalse)
{
/*
But only if not preceeded by a number!
*/
*q++='%'; /* do NOT substitute the percent */
p--; /* back up one */
continue;
}
string=GetMagickPropertyLetter(image_info,image,*p, exception);
if (string != (char *) NULL)
{
AppendString2Text(string);
if (image != (Image *) NULL)
(void) DeleteImageArtifact(image,"get-property");
if (image_info != (ImageInfo *) NULL)
(void) DeleteImageOption(image_info,"get-property");
continue;
}
(void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
"UnknownImageProperty","\"%%%c\"",*p);
continue;
}
{
char
pattern[2*MagickPathExtent];
const char
*key,
*string;
register ssize_t
len;
ssize_t
depth;
/*
Braced Percent Escape %[...].
*/
p++; /* advance p to just inside the opening brace */
depth=1;
if (*p == ']')
{
(void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
"UnknownImageProperty","\"%%[]\"");
break;
}
for (len=0; len<(MagickPathExtent-1L) && (*p != '\0');)
{
if ((*p == '\\') && (*(p+1) != '\0'))
{
/*
Skip escaped braces within braced pattern.
*/
pattern[len++]=(*p++);
pattern[len++]=(*p++);
continue;
}
if (*p == '[')
depth++;
if (*p == ']')
depth--;
if (depth <= 0)
break;
pattern[len++]=(*p++);
}
pattern[len]='\0';
if (depth != 0)
{
/*
Check for unmatched final ']' for "%[...]".
*/
if (len >= 64)
{
pattern[61] = '.'; /* truncate string for error message */
pattern[62] = '.';
pattern[63] = '.';
pattern[64] = '\0';
}
(void) ThrowMagickException(exception,GetMagickModule(),OptionError,
"UnbalancedBraces","\"%%[%s\"",pattern);
interpret_text=DestroyString(interpret_text);
return((char *) NULL);
}
/*
Special Lookup Prefixes %[prefix:...].
*/
if (LocaleNCompare("fx:",pattern,3) == 0)
{
double
value;
FxInfo
*fx_info;
MagickBooleanType
status;
/*
FX - value calculator.
*/
if (image == (Image *) NULL )
{
(void) ThrowMagickException(exception,GetMagickModule(),
OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
continue; /* else no image to retrieve artifact */
}
fx_info=AcquireFxInfo(image,pattern+3,exception);
status=FxEvaluateChannelExpression(fx_info,IntensityPixelChannel,0,0,
&value,exception);
fx_info=DestroyFxInfo(fx_info);
if (status != MagickFalse)
{
char
result[MagickPathExtent];
(void) FormatLocaleString(result,MagickPathExtent,"%.*g",
GetMagickPrecision(),(double) value);
AppendString2Text(result);
}
continue;
}
if (LocaleNCompare("pixel:",pattern,6) == 0)
{
FxInfo
*fx_info;
double
value;
MagickStatusType
status;
PixelInfo
pixel;
/*
Pixel - color value calculator.
*/
if (image == (Image *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
continue; /* else no image to retrieve artifact */
}
GetPixelInfo(image,&pixel);
fx_info=AcquireFxInfo(image,pattern+6,exception);
status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
&value,exception);
pixel.red=(double) QuantumRange*value;
status&=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0,
&value,exception);
pixel.green=(double) QuantumRange*value;
status&=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0,
&value,exception);
pixel.blue=(double) QuantumRange*value;
if (image->colorspace == CMYKColorspace)
{
status&=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0,
&value,exception);
pixel.black=(double) QuantumRange*value;
}
status&=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0,
&value,exception);
pixel.alpha=(double) QuantumRange*value;
fx_info=DestroyFxInfo(fx_info);
if (status != MagickFalse)
{
char
name[MagickPathExtent];
(void) QueryColorname(image,&pixel,SVGCompliance,name,
exception);
AppendString2Text(name);
}
continue;
}
if (LocaleNCompare("option:",pattern,7) == 0)
{
/*
Option - direct global option lookup (with globbing).
*/
if (image_info == (ImageInfo *) NULL )
{
(void) ThrowMagickException(exception,GetMagickModule(),
OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
continue; /* else no image to retrieve artifact */
}
if (IsGlob(pattern+7) != MagickFalse)
{
ResetImageOptionIterator(image_info);
while ((key=GetNextImageOption(image_info)) != (const char *) NULL)
if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
{
string=GetImageOption(image_info,key);
if (string != (const char *) NULL)
AppendKeyValue2Text(key,string);
/* else - assertion failure? key found but no string value! */
}
continue;
}
string=GetImageOption(image_info,pattern+7);
if (string == (char *) NULL)
goto PropertyLookupFailure; /* no artifact of this specifc name */
AppendString2Text(string);
continue;
}
if (LocaleNCompare("artifact:",pattern,9) == 0)
{
/*
Artifact - direct image artifact lookup (with glob).
*/
if (image == (Image *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
continue; /* else no image to retrieve artifact */
}
if (IsGlob(pattern+9) != MagickFalse)
{
ResetImageArtifactIterator(image);
while ((key=GetNextImageArtifact(image)) != (const char *) NULL)
if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
{
string=GetImageArtifact(image,key);
if (string != (const char *) NULL)
AppendKeyValue2Text(key,string);
/* else - assertion failure? key found but no string value! */
}
continue;
}
string=GetImageArtifact(image,pattern+9);
if (string == (char *) NULL)
goto PropertyLookupFailure; /* no artifact of this specifc name */
AppendString2Text(string);
continue;
}
if (LocaleNCompare("property:",pattern,9) == 0)
{
/*
Property - direct image property lookup (with glob).
*/
if (image == (Image *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
continue; /* else no image to retrieve artifact */
}
if (IsGlob(pattern+9) != MagickFalse)
{
ResetImagePropertyIterator(image);
while ((key=GetNextImageProperty(image)) != (const char *) NULL)
if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
{
string=GetImageProperty(image,key,exception);
if (string != (const char *) NULL)
AppendKeyValue2Text(key,string);
/* else - assertion failure? */
}
continue;
}
string=GetImageProperty(image,pattern+9,exception);
if (string == (char *) NULL)
goto PropertyLookupFailure; /* no artifact of this specifc name */
AppendString2Text(string);
continue;
}
if (image != (Image *) NULL)
{
/*
Properties without special prefix. This handles attributes,
properties, and profiles such as %[exif:...]. Note the profile
properties may also include a glob expansion pattern.
*/
string=GetImageProperty(image,pattern,exception);
if (string != (const char *) NULL)
{
AppendString2Text(string);
if (image != (Image *) NULL)
(void)DeleteImageArtifact(image,"get-property");
if (image_info != (ImageInfo *) NULL)
(void)DeleteImageOption(image_info,"get-property");
continue;
}
}
if (IsGlob(pattern) != MagickFalse)
{
/*
Handle property 'glob' patterns such as:
%[*] %[user:array_??] %[filename:e*]>
*/
if (image == (Image *) NULL)
continue; /* else no image to retrieve proprty - no list */
ResetImagePropertyIterator(image);
while ((key=GetNextImageProperty(image)) != (const char *) NULL)
if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
{
string=GetImageProperty(image,key,exception);
if (string != (const char *) NULL)
AppendKeyValue2Text(key,string);
/* else - assertion failure? */
}
continue;
}
/*
Look for a known property or image attribute such as
%[basename] %[denisty] %[delay]. Also handles a braced single
letter: %[b] %[G] %[g].
*/
string=GetMagickProperty(image_info,image,pattern,exception);
if (string != (const char *) NULL)
{
AppendString2Text(string);
continue;
}
/*
Look for a per-image artifact. This includes option lookup
(FUTURE: interpreted according to image).
*/
if (image != (Image *) NULL)
{
string=GetImageArtifact(image,pattern);
if (string != (char *) NULL)
{
AppendString2Text(string);
continue;
}
}
else
if (image_info != (ImageInfo *) NULL)
{
/*
No image, so direct 'option' lookup (no delayed percent escapes).
*/
string=GetImageOption(image_info,pattern);
if (string != (char *) NULL)
{
AppendString2Text(string);
continue;
}
}
PropertyLookupFailure:
/*
Failed to find any match anywhere!
*/
if (len >= 64)
{
pattern[61] = '.'; /* truncate string for error message */
pattern[62] = '.';
pattern[63] = '.';
pattern[64] = '\0';
}
(void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
"UnknownImageProperty","\"%%[%s]\"",pattern);
}
}
*q='\0';
return(interpret_text);
}
Commit Message: Prevent buffer overflow (bug report from Ibrahim el-sayed)
CWE ID: CWE-125 | 0 | 50,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: static void WriteProfileShort(const EndianType endian,
const unsigned short value,unsigned char *p)
{
unsigned char
buffer[2];
if (endian == LSBEndian)
{
buffer[0]=(unsigned char) value;
buffer[1]=(unsigned char) (value >> 8);
(void) CopyMagickMemory(p,buffer,2);
return;
}
buffer[0]=(unsigned char) (value >> 8);
buffer[1]=(unsigned char) value;
(void) CopyMagickMemory(p,buffer,2);
}
Commit Message: https://github.com/ImageMagick/ImageMagick/issues/354
CWE ID: CWE-415 | 0 | 69,125 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void RenderViewImpl::PrintPage(WebLocalFrame* frame) {
UMA_HISTOGRAM_BOOLEAN("PrintPreview.InitiatedByScript",
frame->Top() == frame);
UMA_HISTOGRAM_BOOLEAN("PrintPreview.OutOfProcessSubframe",
frame->Top()->IsWebRemoteFrame());
RenderFrameImpl::FromWebFrame(frame)->ScriptedPrint(
GetWidget()->input_handler().handling_input_event());
}
Commit Message: Prevent renderer initiated back navigation to cancel a browser one.
Renderer initiated back/forward navigations must not be able to cancel ongoing
browser initiated navigation if they are not user initiated.
Note: 'normal' renderer initiated navigation uses the
FrameHost::BeginNavigation() path. A code similar to this patch is done
in NavigatorImpl::OnBeginNavigation().
Test:
-----
Added: NavigationBrowserTest.
* HistoryBackInBeforeUnload
* HistoryBackInBeforeUnloadAfterSetTimeout
* HistoryBackCancelPendingNavigationNoUserGesture
* HistoryBackCancelPendingNavigationUserGesture
Fixed:
* (WPT) .../the-history-interface/traverse_the_history_2.html
* (WPT) .../the-history-interface/traverse_the_history_3.html
* (WPT) .../the-history-interface/traverse_the_history_4.html
* (WPT) .../the-history-interface/traverse_the_history_5.html
Bug: 879965
Change-Id: I1a9bfaaea1ffc219e6c32f6e676b660e746c578c
Reviewed-on: https://chromium-review.googlesource.com/1209744
Commit-Queue: Arthur Sonzogni <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Mustaq Ahmed <[email protected]>
Reviewed-by: Camille Lamy <[email protected]>
Reviewed-by: Charlie Reis <[email protected]>
Cr-Commit-Position: refs/heads/master@{#592823}
CWE ID: CWE-254 | 0 | 145,158 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void skb_flow_dissector_init(struct flow_dissector *flow_dissector,
const struct flow_dissector_key *key,
unsigned int key_count)
{
unsigned int i;
memset(flow_dissector, 0, sizeof(*flow_dissector));
for (i = 0; i < key_count; i++, key++) {
/* User should make sure that every key target offset is withing
* boundaries of unsigned short.
*/
BUG_ON(key->offset > USHRT_MAX);
BUG_ON(skb_flow_dissector_uses_key(flow_dissector,
key->key_id));
skb_flow_dissector_set_key(flow_dissector, key->key_id);
flow_dissector->offset[key->key_id] = key->offset;
}
/* Ensure that the dissector always includes control and basic key.
* That way we are able to avoid handling lack of these in fast path.
*/
BUG_ON(!skb_flow_dissector_uses_key(flow_dissector,
FLOW_DISSECTOR_KEY_CONTROL));
BUG_ON(!skb_flow_dissector_uses_key(flow_dissector,
FLOW_DISSECTOR_KEY_BASIC));
}
Commit Message: flow_dissector: Jump to exit code in __skb_flow_dissect
Instead of returning immediately (on a parsing failure for instance) we
jump to cleanup code. This always sets protocol values in key_control
(even on a failure there is still valid information in the key_tags that
was set before the problem was hit).
Signed-off-by: Tom Herbert <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
CWE ID: CWE-20 | 0 | 61,964 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void CL_Snd_Restart_f(void)
{
CL_Snd_Shutdown();
CL_Vid_Restart_f();
}
Commit Message: All: Don't load .pk3s as .dlls, and don't load user config files from .pk3s
CWE ID: CWE-269 | 0 | 95,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: static int keyvalcmp(const void *ap, const void *bp)
{
const struct keyval *a = ap;
const struct keyval *b = bp;
const char *an;
const char *bn;
/* We should never get a->k == NULL or b->k == NULL. If we
* do, then they match. */
if (a->k < PDF_OBJ_NAME__LIMIT)
an = PDF_NAMES[(intptr_t)a->k];
else if (a->k >= PDF_OBJ__LIMIT && a->k->kind == PDF_NAME)
an = NAME(a->k)->n;
else
return 0;
if (b->k < PDF_OBJ_NAME__LIMIT)
bn = PDF_NAMES[(intptr_t)b->k];
else if (b->k >= PDF_OBJ__LIMIT && b->k->kind == PDF_NAME)
bn = NAME(b->k)->n;
else
return 0;
return strcmp(an, bn);
}
Commit Message:
CWE ID: CWE-416 | 0 | 13,869 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: Resource* DocumentLoader::StartPreload(Resource::Type type,
FetchParameters& params,
CSSPreloaderResourceClient* client) {
Resource* resource = nullptr;
DCHECK(!client || type == Resource::kCSSStyleSheet);
switch (type) {
case Resource::kImage:
if (frame_)
frame_->MaybeAllowImagePlaceholder(params);
resource = ImageResource::Fetch(params, Fetcher());
break;
case Resource::kScript:
resource = ScriptResource::Fetch(params, Fetcher(), nullptr);
break;
case Resource::kCSSStyleSheet:
resource = CSSStyleSheetResource::Fetch(params, Fetcher(), client);
break;
case Resource::kFont:
resource = FontResource::Fetch(params, Fetcher(), nullptr);
break;
case Resource::kAudio:
case Resource::kVideo:
resource = RawResource::FetchMedia(params, Fetcher(), nullptr);
break;
case Resource::kTextTrack:
resource = RawResource::FetchTextTrack(params, Fetcher(), nullptr);
break;
case Resource::kImportResource:
resource = RawResource::FetchImport(params, Fetcher(), nullptr);
break;
case Resource::kRaw:
resource = RawResource::Fetch(params, Fetcher(), nullptr);
break;
default:
NOTREACHED();
}
return resource;
}
Commit Message: Fix detach with open()ed document leaving parent loading indefinitely
Change-Id: I26c2a054b9f1e5eb076acd677e1223058825f6d6
Bug: 803416
Test: fast/loader/document-open-iframe-then-detach.html
Change-Id: I26c2a054b9f1e5eb076acd677e1223058825f6d6
Reviewed-on: https://chromium-review.googlesource.com/887298
Reviewed-by: Mike West <[email protected]>
Commit-Queue: Nate Chapin <[email protected]>
Cr-Commit-Position: refs/heads/master@{#532967}
CWE ID: CWE-362 | 0 | 125,768 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void RuntimeCustomBindings::GetExtensionViews(
const v8::FunctionCallbackInfo<v8::Value>& args) {
if (args.Length() != 2)
return;
if (!args[0]->IsInt32() || !args[1]->IsString())
return;
int browser_window_id = args[0]->Int32Value();
std::string view_type_string =
base::ToUpperASCII(*v8::String::Utf8Value(args[1]));
ViewType view_type = VIEW_TYPE_INVALID;
if (view_type_string == kViewTypeBackgroundPage) {
view_type = VIEW_TYPE_EXTENSION_BACKGROUND_PAGE;
} else if (view_type_string == kViewTypeTabContents) {
view_type = VIEW_TYPE_TAB_CONTENTS;
} else if (view_type_string == kViewTypePopup) {
view_type = VIEW_TYPE_EXTENSION_POPUP;
} else if (view_type_string == kViewTypeExtensionDialog) {
view_type = VIEW_TYPE_EXTENSION_DIALOG;
} else if (view_type_string == kViewTypeAppWindow) {
view_type = VIEW_TYPE_APP_WINDOW;
} else if (view_type_string == kViewTypeLauncherPage) {
view_type = VIEW_TYPE_LAUNCHER_PAGE;
} else if (view_type_string == kViewTypePanel) {
view_type = VIEW_TYPE_PANEL;
} else if (view_type_string != kViewTypeAll) {
return;
}
std::string extension_id = context()->GetExtensionID();
if (extension_id.empty())
return;
std::vector<content::RenderFrame*> frames =
ExtensionFrameHelper::GetExtensionFrames(extension_id, browser_window_id,
view_type);
v8::Local<v8::Array> v8_views = v8::Array::New(args.GetIsolate());
int v8_index = 0;
for (content::RenderFrame* frame : frames) {
if (frame->GetWebFrame()->top() != frame->GetWebFrame())
continue;
v8::Local<v8::Context> context =
frame->GetWebFrame()->mainWorldScriptContext();
if (!context.IsEmpty()) {
v8::Local<v8::Value> window = context->Global();
DCHECK(!window.IsEmpty());
v8_views->Set(v8::Integer::New(args.GetIsolate(), v8_index++), window);
}
}
args.GetReturnValue().Set(v8_views);
}
Commit Message: Create array of extension views without side effects
BUG=608104
Review-Url: https://codereview.chromium.org/1935953002
Cr-Commit-Position: refs/heads/master@{#390961}
CWE ID: | 1 | 172,260 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void ext4_set_inode_flags(struct inode *inode)
{
unsigned int flags = EXT4_I(inode)->i_flags;
unsigned int new_fl = 0;
if (flags & EXT4_SYNC_FL)
new_fl |= S_SYNC;
if (flags & EXT4_APPEND_FL)
new_fl |= S_APPEND;
if (flags & EXT4_IMMUTABLE_FL)
new_fl |= S_IMMUTABLE;
if (flags & EXT4_NOATIME_FL)
new_fl |= S_NOATIME;
if (flags & EXT4_DIRSYNC_FL)
new_fl |= S_DIRSYNC;
if (test_opt(inode->i_sb, DAX))
new_fl |= S_DAX;
inode_set_flags(inode, new_fl,
S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_DAX);
}
Commit Message: ext4: fix races between page faults and hole punching
Currently, page faults and hole punching are completely unsynchronized.
This can result in page fault faulting in a page into a range that we
are punching after truncate_pagecache_range() has been called and thus
we can end up with a page mapped to disk blocks that will be shortly
freed. Filesystem corruption will shortly follow. Note that the same
race is avoided for truncate by checking page fault offset against
i_size but there isn't similar mechanism available for punching holes.
Fix the problem by creating new rw semaphore i_mmap_sem in inode and
grab it for writing over truncate, hole punching, and other functions
removing blocks from extent tree and for read over page faults. We
cannot easily use i_data_sem for this since that ranks below transaction
start and we need something ranking above it so that it can be held over
the whole truncate / hole punching operation. Also remove various
workarounds we had in the code to reduce race window when page fault
could have created pages with stale mapping information.
Signed-off-by: Jan Kara <[email protected]>
Signed-off-by: Theodore Ts'o <[email protected]>
CWE ID: CWE-362 | 0 | 56,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: WTF::Optional<unsigned> FrameSelection::LayoutSelectionStart() const {
return layout_selection_->SelectionStart();
}
Commit Message: MacViews: Enable secure text input for password Textfields.
In Cocoa the NSTextInputContext automatically enables secure text input
when activated and it's in the secure text entry mode.
RenderWidgetHostViewMac did the similar thing for ages following the
WebKit example.
views::Textfield needs to do the same thing in a fashion that's
sycnrhonized with RenderWidgetHostViewMac, otherwise the race conditions
are possible when the Textfield gets focus, activates the secure text
input mode and the RWHVM loses focus immediately afterwards and disables
the secure text input instead of leaving it in the enabled state.
BUG=818133,677220
Change-Id: I6db6c4b59e4a1a72cbb7f8c7056f71b04a3df08b
Reviewed-on: https://chromium-review.googlesource.com/943064
Commit-Queue: Michail Pishchagin <[email protected]>
Reviewed-by: Pavel Feldman <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: Peter Kasting <[email protected]>
Cr-Commit-Position: refs/heads/master@{#542517}
CWE ID: | 0 | 125,847 |
Analyze the following 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 ASCII85Encoder::reset() {
str->reset();
bufPtr = bufEnd = buf;
lineLen = 0;
eof = gFalse;
}
Commit Message:
CWE ID: CWE-119 | 0 | 4,043 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: status_t OMXCodec::cancelBufferToNativeWindow(BufferInfo *info) {
CHECK_EQ((int)info->mStatus, (int)OWNED_BY_US);
CODEC_LOGV("Calling cancelBuffer on buffer %u", info->mBuffer);
int err = mNativeWindow->cancelBuffer(
mNativeWindow.get(), info->mMediaBuffer->graphicBuffer().get(), -1);
if (err != 0) {
CODEC_LOGE("cancelBuffer failed w/ error 0x%08x", err);
setState(ERROR);
return err;
}
info->mStatus = OWNED_BY_NATIVE_WINDOW;
return OK;
}
Commit Message: OMXCodec: check IMemory::pointer() before using allocation
Bug: 29421811
Change-Id: I0a73ba12bae4122f1d89fc92e5ea4f6a96cd1ed1
CWE ID: CWE-284 | 0 | 158,142 |
Analyze the following 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 complete_v1_state_transition(struct msg_digest **mdp, stf_status result)
{
struct msg_digest *md = *mdp;
enum state_kind from_state;
struct state *st;
passert(md != NULL);
/* handle oddball/meta results now */
switch (result) {
case STF_SUSPEND:
cur_state = md->st; /* might have changed */
/* FALL THROUGH */
case STF_INLINE: /* all done, including release_any_md */
*mdp = NULL; /* take md away from parent */
/* FALL THROUGH */
case STF_IGNORE:
DBG(DBG_CONTROL,
DBG_log("complete v1 state transition with %s",
enum_show(&stfstatus_name, result)));
return;
default:
break;
}
DBG(DBG_CONTROL,
DBG_log("complete v1 state transition with %s",
result > STF_FAIL ?
enum_name(&ikev1_notify_names, result - STF_FAIL) :
enum_name(&stfstatus_name, result)));
/* safe to refer to *md */
from_state = md->from_state;
cur_state = st = md->st; /* might have changed */
passert(st != NULL);
passert(!st->st_calculating);
switch (result) {
case STF_OK:
{
/* advance the state */
const struct state_microcode *smc = md->smc;
libreswan_log("transition from state %s to state %s",
enum_name(&state_names, from_state),
enum_name(&state_names, smc->next_state));
/* accept info from VID because we accept this message */
/* If state has FRAGMENTATION support, import it */
if (md->fragvid) {
DBG(DBG_CONTROLMORE, DBG_log("peer supports fragmentation"));
st->st_seen_fragvid = TRUE;
}
/* If state has DPD support, import it */
if (md->dpd &&
st->hidden_variables.st_peer_supports_dpd != md->dpd) {
DBG(DBG_DPD, DBG_log("peer supports dpd"));
st->hidden_variables.st_peer_supports_dpd = md->dpd;
if (dpd_active_locally(st)) {
DBG(DBG_DPD, DBG_log("dpd is active locally"));
}
}
/* If state has VID_NORTEL, import it to activate workaround */
if (md->nortel) {
DBG(DBG_CONTROLMORE, DBG_log("peer requires Nortel Contivity workaround"));
st->st_seen_nortel_vid = TRUE;
}
if (!st->st_msgid_reserved &&
IS_CHILD_SA(st) &&
st->st_msgid != v1_MAINMODE_MSGID) {
struct state *p1st = state_with_serialno(
st->st_clonedfrom);
if (p1st != NULL) {
/* do message ID reservation */
reserve_msgid(p1st, st->st_msgid);
}
st->st_msgid_reserved = TRUE;
}
change_state(st, smc->next_state);
/* XAUTH negotiation withOUT modecfg ends in STATE_XAUTH_I1
* which is wrong and creates issues further in several places
* As per libreswan design, it seems every phase 1 negotiation
* including xauth/modecfg must end with STATE_MAIN_I4 to mark
* actual end of phase 1. With modecfg, negotiation ends with
* STATE_MAIN_I4 already.
*/
#if 0 /* ??? what's this code for? */
if (st->st_connection->spd.this.xauth_client
&& st->hidden_variables.st_xauth_client_done
&& !st->st_connection->spd.this.modecfg_client
&& st->st_state == STATE_XAUTH_I1) {
DBG(DBG_CONTROL,
DBG_log("As XAUTH is done and modecfg is not configured, so Phase 1 neogtiation finishes successfully"));
change_state(st, STATE_MAIN_I4);
}
#endif
/* Schedule for whatever timeout is specified */
if (!md->event_already_set) {
/* Delete previous retransmission event.
* New event will be scheduled below.
*/
delete_event(st);
}
/* Delete IKE fragments */
release_fragments(st);
/* update the previous packet history */
remember_received_packet(st, md);
/* free previous transmit packet */
freeanychunk(st->st_tpacket);
/* in aggressive mode, there will be no reply packet in transition
* from STATE_AGGR_R1 to STATE_AGGR_R2
*/
if (nat_traversal_enabled) {
/* adjust our destination port if necessary */
nat_traversal_change_port_lookup(md, st);
}
/* if requested, send the new reply packet */
if (smc->flags & SMF_REPLY) {
DBG(DBG_CONTROL, {
ipstr_buf b;
DBG_log("sending reply packet to %s:%u (from port %u)",
ipstr(&st->st_remoteaddr, &b),
st->st_remoteport,
st->st_interface->port);
});
close_output_pbs(&reply_stream); /* good form, but actually a no-op */
record_and_send_ike_msg(st, &reply_stream,
enum_name(&state_names, from_state));
}
/* Schedule for whatever timeout is specified */
if (!md->event_already_set) {
unsigned long delay_ms; /* delay is in milliseconds here */
enum event_type kind = smc->timeout_event;
bool agreed_time = FALSE;
struct connection *c = st->st_connection;
switch (kind) {
case EVENT_v1_RETRANSMIT: /* Retransmit packet */
delay_ms = c->r_interval;
break;
case EVENT_SA_REPLACE: /* SA replacement event */
if (IS_PHASE1(st->st_state) ||
IS_PHASE15(st->st_state )) {
/* Note: we will defer to the "negotiated" (dictated)
* lifetime if we are POLICY_DONT_REKEY.
* This allows the other side to dictate
* a time we would not otherwise accept
* but it prevents us from having to initiate
* rekeying. The negative consequences seem
* minor.
*/
delay_ms = deltamillisecs(c->sa_ike_life_seconds);
if ((c->policy & POLICY_DONT_REKEY) ||
delay_ms >= deltamillisecs(st->st_oakley.life_seconds))
{
agreed_time = TRUE;
delay_ms = deltamillisecs(st->st_oakley.life_seconds);
}
} else {
/* Delay is min of up to four things:
* each can limit the lifetime.
*/
time_t delay = deltasecs(c->sa_ipsec_life_seconds);
#define clamp_delay(trans) { \
if (st->trans.present && \
delay >= deltasecs(st->trans.attrs.life_seconds)) { \
agreed_time = TRUE; \
delay = deltasecs(st->trans.attrs.life_seconds); \
} \
}
clamp_delay(st_ah);
clamp_delay(st_esp);
clamp_delay(st_ipcomp);
delay_ms = delay * 1000;
#undef clamp_delay
}
/* By default, we plan to rekey.
*
* If there isn't enough time to rekey, plan to
* expire.
*
* If we are --dontrekey, a lot more rules apply.
* If we are the Initiator, use REPLACE_IF_USED.
* If we are the Responder, and the dictated time
* was unacceptable (too large), plan to REPLACE
* (the only way to ratchet down the time).
* If we are the Responder, and the dictated time
* is acceptable, plan to EXPIRE.
*
* Important policy lies buried here.
* For example, we favour the initiator over the
* responder by making the initiator start rekeying
* sooner. Also, fuzz is only added to the
* initiator's margin.
*
* Note: for ISAKMP SA, we let the negotiated
* time stand (implemented by earlier logic).
*/
if (agreed_time &&
(c->policy & POLICY_DONT_REKEY)) {
kind = (smc->flags & SMF_INITIATOR) ?
EVENT_SA_REPLACE_IF_USED :
EVENT_SA_EXPIRE;
}
if (kind != EVENT_SA_EXPIRE) {
time_t marg =
deltasecs(c->sa_rekey_margin);
if (smc->flags & SMF_INITIATOR) {
marg += marg *
c->sa_rekey_fuzz /
100.E0 *
(rand() /
(RAND_MAX + 1.E0));
} else {
marg /= 2;
}
if (delay_ms > (unsigned long)marg * 1000) {
delay_ms -= (unsigned long)marg * 1000;
st->st_margin = deltatime(marg);
} else {
kind = EVENT_SA_EXPIRE;
}
}
break;
default:
bad_case(kind);
}
event_schedule_ms(kind, delay_ms, st);
}
/* tell whack and log of progress */
{
const char *story = enum_name(&state_stories,
st->st_state);
enum rc_type w = RC_NEW_STATE + st->st_state;
char sadetails[512];
passert(st->st_state < STATE_IKE_ROOF);
sadetails[0] = '\0';
/* document IPsec SA details for admin's pleasure */
if (IS_IPSEC_SA_ESTABLISHED(st->st_state)) {
fmt_ipsec_sa_established(st, sadetails,
sizeof(sadetails));
} else if (IS_ISAKMP_SA_ESTABLISHED(st->st_state) &&
!st->hidden_variables.st_logged_p1algos) {
fmt_isakmp_sa_established(st, sadetails,
sizeof(sadetails));
}
if (IS_ISAKMP_SA_ESTABLISHED(st->st_state) ||
IS_IPSEC_SA_ESTABLISHED(st->st_state)) {
/* log our success */
w = RC_SUCCESS;
}
/* tell whack and logs our progress */
loglog(w,
"%s: %s%s",
enum_name(&state_names, st->st_state),
story,
sadetails);
}
/*
* make sure that a DPD event gets created for a new phase 1
* SA.
*/
if (IS_ISAKMP_SA_ESTABLISHED(st->st_state)) {
if (deltasecs(st->st_connection->dpd_delay) > 0 &&
deltasecs(st->st_connection->dpd_timeout) > 0) {
/* don't ignore failure */
/* ??? in fact, we do ignore this:
* result is NEVER used
* (clang 3.4 noticed this)
*/
stf_status s = dpd_init(st);
pexpect(s != STF_FAIL);
if (s == STF_FAIL)
result = STF_FAIL; /* ??? fall through !?! */
}
}
/* Special case for XAUTH server */
if (st->st_connection->spd.this.xauth_server) {
if (st->st_oakley.doing_xauth &&
IS_ISAKMP_SA_ESTABLISHED(st->st_state)) {
DBG(DBG_CONTROL,
DBG_log("XAUTH: "
"Sending XAUTH Login/Password Request"));
event_schedule_ms(EVENT_v1_SEND_XAUTH,
EVENT_v1_SEND_XAUTH_DELAY, st);
break;
}
}
/*
* for XAUTH client, we are also done, because we need to
* stay in this state, and let the server query us
*/
if (!IS_QUICK(st->st_state) &&
st->st_connection->spd.this.xauth_client &&
!st->hidden_variables.st_xauth_client_done) {
DBG(DBG_CONTROL,
DBG_log("XAUTH client is not yet authenticated"));
break;
}
/*
* when talking to some vendors, we need to initiate a mode
* cfg request to get challenged, but there is also an
* override in the form of a policy bit.
*/
DBG(DBG_CONTROL,
DBG_log("modecfg pull: %s policy:%s %s",
(st->quirks.modecfg_pull_mode ?
"quirk-poll" : "noquirk"),
(st->st_connection->policy & POLICY_MODECFG_PULL) ?
"pull" : "push",
(st->st_connection->spd.this.modecfg_client ?
"modecfg-client" : "not-client")));
if (st->st_connection->spd.this.modecfg_client &&
IS_ISAKMP_SA_ESTABLISHED(st->st_state) &&
(st->quirks.modecfg_pull_mode ||
st->st_connection->policy & POLICY_MODECFG_PULL) &&
!st->hidden_variables.st_modecfg_started) {
DBG(DBG_CONTROL,
DBG_log("modecfg client is starting due to %s",
st->quirks.modecfg_pull_mode ? "quirk" :
"policy"));
modecfg_send_request(st);
break;
}
/* Should we set the peer's IP address regardless? */
if (st->st_connection->spd.this.modecfg_server &&
IS_ISAKMP_SA_ESTABLISHED(st->st_state) &&
!st->hidden_variables.st_modecfg_vars_set &&
!(st->st_connection->policy & POLICY_MODECFG_PULL)) {
change_state(st, STATE_MODE_CFG_R1);
set_cur_state(st);
libreswan_log("Sending MODE CONFIG set");
modecfg_start_set(st);
break;
}
/*
* If we are the responder and the client is in "Contivity mode",
* we need to initiate Quick mode
*/
if (!(smc->flags & SMF_INITIATOR) &&
IS_MODE_CFG_ESTABLISHED(st->st_state) &&
(st->st_seen_nortel_vid)) {
libreswan_log("Nortel 'Contivity Mode' detected, starting Quick Mode");
change_state(st, STATE_MAIN_R3); /* ISAKMP is up... */
set_cur_state(st);
quick_outI1(st->st_whack_sock, st, st->st_connection,
st->st_connection->policy, 1, SOS_NOBODY
#ifdef HAVE_LABELED_IPSEC
, NULL /* Setting NULL as this is responder and will not have sec ctx from a flow*/
#endif
);
break;
}
/* wait for modecfg_set */
if (st->st_connection->spd.this.modecfg_client &&
IS_ISAKMP_SA_ESTABLISHED(st->st_state) &&
!st->hidden_variables.st_modecfg_vars_set) {
DBG(DBG_CONTROL,
DBG_log("waiting for modecfg set from server"));
break;
}
if (st->st_rekeytov2) {
DBG(DBG_CONTROL,
DBG_log("waiting for IKEv1 -> IKEv2 rekey"));
break;
}
DBG(DBG_CONTROL,
DBG_log("phase 1 is done, looking for phase 2 to unpend"));
if (smc->flags & SMF_RELEASE_PENDING_P2) {
/* Initiate any Quick Mode negotiations that
* were waiting to piggyback on this Keying Channel.
*
* ??? there is a potential race condition
* if we are the responder: the initial Phase 2
* message might outrun the final Phase 1 message.
*
* so, instead of actually sending the traffic now,
* we schedule an event to do so.
*
* but, in fact, quick_mode will enqueue a cryptographic operation
* anyway, which will get done "later" anyway, so maybe it is just fine
* as it is.
*
*/
unpend(st);
}
if (IS_ISAKMP_SA_ESTABLISHED(st->st_state) ||
IS_IPSEC_SA_ESTABLISHED(st->st_state))
release_whack(st);
if (IS_QUICK(st->st_state))
break;
break;
}
case STF_INTERNAL_ERROR:
/* update the previous packet history */
remember_received_packet(st, md);
whack_log(RC_INTERNALERR + md->note,
"%s: internal error",
enum_name(&state_names, st->st_state));
DBG(DBG_CONTROL,
DBG_log("state transition function for %s had internal error",
enum_name(&state_names, from_state)));
break;
case STF_TOOMUCHCRYPTO:
/* ??? Why is this comment useful:
* well, this should never happen during a whack, since
* a whack will always force crypto.
*/
/* ??? why no call of remember_received_packet? */
unset_suspended(st);
libreswan_log(
"message in state %s ignored due to cryptographic overload",
enum_name(&state_names, from_state));
log_crypto_workers();
/* ??? the ikev2.c version used to FALL THROUGH to STF_FATAL */
break;
case STF_FATAL:
/* update the previous packet history */
remember_received_packet(st, md);
whack_log(RC_FATAL,
"encountered fatal error in state %s",
enum_name(&state_names, st->st_state));
#ifdef HAVE_NM
if (st->st_connection->remotepeertype == CISCO &&
st->st_connection->nmconfigured) {
if (!do_command(st->st_connection,
&st->st_connection->spd,
"disconnectNM", st))
DBG(DBG_CONTROL,
DBG_log("sending disconnect to NM failed, you may need to do it manually"));
}
#endif
release_pending_whacks(st, "fatal error");
delete_state(st);
md->st = st = NULL;
break;
default: /* a shortcut to STF_FAIL, setting md->note */
passert(result > STF_FAIL);
md->note = result - STF_FAIL;
/* FALL THROUGH */
case STF_FAIL:
/* As it is, we act as if this message never happened:
* whatever retrying was in place, remains in place.
*/
/*
* ??? why no call of remember_received_packet?
* Perhaps because the message hasn't been authenticated?
* But then then any duplicate would lose too, I would think.
*/
whack_log(RC_NOTIFICATION + md->note,
"%s: %s", enum_name(&state_names, st->st_state),
enum_name(&ikev1_notify_names, md->note));
if (md->note != NOTHING_WRONG)
SEND_NOTIFICATION(md->note);
DBG(DBG_CONTROL,
DBG_log("state transition function for %s failed: %s",
enum_name(&state_names, from_state),
enum_name(&ikev1_notify_names, md->note)));
#ifdef HAVE_NM
if (st->st_connection->remotepeertype == CISCO &&
st->st_connection->nmconfigured) {
if (!do_command(st->st_connection,
&st->st_connection->spd,
"disconnectNM", st))
DBG(DBG_CONTROL,
DBG_log("sending disconnect to NM failed, you may need to do it manually"));
}
#endif
if (IS_PHASE1_INIT(st->st_state)) {
delete_event(st);
release_whack(st);
}
if (IS_QUICK(st->st_state)) {
delete_state(st);
/* wipe out dangling pointer to st */
md->st = NULL;
}
break;
}
}
Commit Message: IKEv1: packet retransmit fixes for Main/Aggr/Xauth modes
- Do not schedule retransmits for inI1outR1 packets (prevent DDOS)
- Do schedule retransmits for XAUTH packets
CWE ID: CWE-20 | 0 | 51,681 |
Analyze the following 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 double DrawEpsilonReciprocal(const double x)
{
#define DrawEpsilon (1.0e-6)
double sign = x < 0.0 ? -1.0 : 1.0;
return((sign*x) >= DrawEpsilon ? 1.0/x : sign*(1.0/DrawEpsilon));
}
Commit Message: Prevent buffer overflow in magick/draw.c
CWE ID: CWE-119 | 0 | 53,004 |
Analyze the following 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 btrfs_init_locked_inode(struct inode *inode, void *p)
{
struct btrfs_iget_args *args = p;
inode->i_ino = args->location->objectid;
memcpy(&BTRFS_I(inode)->location, args->location,
sizeof(*args->location));
BTRFS_I(inode)->root = args->root;
return 0;
}
Commit Message: Btrfs: fix truncation of compressed and inlined extents
When truncating a file to a smaller size which consists of an inline
extent that is compressed, we did not discard (or made unusable) the
data between the new file size and the old file size, wasting metadata
space and allowing for the truncated data to be leaked and the data
corruption/loss mentioned below.
We were also not correctly decrementing the number of bytes used by the
inode, we were setting it to zero, giving a wrong report for callers of
the stat(2) syscall. The fsck tool also reported an error about a mismatch
between the nbytes of the file versus the real space used by the file.
Now because we weren't discarding the truncated region of the file, it
was possible for a caller of the clone ioctl to actually read the data
that was truncated, allowing for a security breach without requiring root
access to the system, using only standard filesystem operations. The
scenario is the following:
1) User A creates a file which consists of an inline and compressed
extent with a size of 2000 bytes - the file is not accessible to
any other users (no read, write or execution permission for anyone
else);
2) The user truncates the file to a size of 1000 bytes;
3) User A makes the file world readable;
4) User B creates a file consisting of an inline extent of 2000 bytes;
5) User B issues a clone operation from user A's file into its own
file (using a length argument of 0, clone the whole range);
6) User B now gets to see the 1000 bytes that user A truncated from
its file before it made its file world readbale. User B also lost
the bytes in the range [1000, 2000[ bytes from its own file, but
that might be ok if his/her intention was reading stale data from
user A that was never supposed to be public.
Note that this contrasts with the case where we truncate a file from 2000
bytes to 1000 bytes and then truncate it back from 1000 to 2000 bytes. In
this case reading any byte from the range [1000, 2000[ will return a value
of 0x00, instead of the original data.
This problem exists since the clone ioctl was added and happens both with
and without my recent data loss and file corruption fixes for the clone
ioctl (patch "Btrfs: fix file corruption and data loss after cloning
inline extents").
So fix this by truncating the compressed inline extents as we do for the
non-compressed case, which involves decompressing, if the data isn't already
in the page cache, compressing the truncated version of the extent, writing
the compressed content into the inline extent and then truncate it.
The following test case for fstests reproduces the problem. In order for
the test to pass both this fix and my previous fix for the clone ioctl
that forbids cloning a smaller inline extent into a larger one,
which is titled "Btrfs: fix file corruption and data loss after cloning
inline extents", are needed. Without that other fix the test fails in a
different way that does not leak the truncated data, instead part of
destination file gets replaced with zeroes (because the destination file
has a larger inline extent than the source).
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
# real QA test starts here
_need_to_be_root
_supported_fs btrfs
_supported_os Linux
_require_scratch
_require_cloner
rm -f $seqres.full
_scratch_mkfs >>$seqres.full 2>&1
_scratch_mount "-o compress"
# Create our test files. File foo is going to be the source of a clone operation
# and consists of a single inline extent with an uncompressed size of 512 bytes,
# while file bar consists of a single inline extent with an uncompressed size of
# 256 bytes. For our test's purpose, it's important that file bar has an inline
# extent with a size smaller than foo's inline extent.
$XFS_IO_PROG -f -c "pwrite -S 0xa1 0 128" \
-c "pwrite -S 0x2a 128 384" \
$SCRATCH_MNT/foo | _filter_xfs_io
$XFS_IO_PROG -f -c "pwrite -S 0xbb 0 256" $SCRATCH_MNT/bar | _filter_xfs_io
# Now durably persist all metadata and data. We do this to make sure that we get
# on disk an inline extent with a size of 512 bytes for file foo.
sync
# Now truncate our file foo to a smaller size. Because it consists of a
# compressed and inline extent, btrfs did not shrink the inline extent to the
# new size (if the extent was not compressed, btrfs would shrink it to 128
# bytes), it only updates the inode's i_size to 128 bytes.
$XFS_IO_PROG -c "truncate 128" $SCRATCH_MNT/foo
# Now clone foo's inline extent into bar.
# This clone operation should fail with errno EOPNOTSUPP because the source
# file consists only of an inline extent and the file's size is smaller than
# the inline extent of the destination (128 bytes < 256 bytes). However the
# clone ioctl was not prepared to deal with a file that has a size smaller
# than the size of its inline extent (something that happens only for compressed
# inline extents), resulting in copying the full inline extent from the source
# file into the destination file.
#
# Note that btrfs' clone operation for inline extents consists of removing the
# inline extent from the destination inode and copy the inline extent from the
# source inode into the destination inode, meaning that if the destination
# inode's inline extent is larger (N bytes) than the source inode's inline
# extent (M bytes), some bytes (N - M bytes) will be lost from the destination
# file. Btrfs could copy the source inline extent's data into the destination's
# inline extent so that we would not lose any data, but that's currently not
# done due to the complexity that would be needed to deal with such cases
# (specially when one or both extents are compressed), returning EOPNOTSUPP, as
# it's normally not a very common case to clone very small files (only case
# where we get inline extents) and copying inline extents does not save any
# space (unlike for normal, non-inlined extents).
$CLONER_PROG -s 0 -d 0 -l 0 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
# Now because the above clone operation used to succeed, and due to foo's inline
# extent not being shinked by the truncate operation, our file bar got the whole
# inline extent copied from foo, making us lose the last 128 bytes from bar
# which got replaced by the bytes in range [128, 256[ from foo before foo was
# truncated - in other words, data loss from bar and being able to read old and
# stale data from foo that should not be possible to read anymore through normal
# filesystem operations. Contrast with the case where we truncate a file from a
# size N to a smaller size M, truncate it back to size N and then read the range
# [M, N[, we should always get the value 0x00 for all the bytes in that range.
# We expected the clone operation to fail with errno EOPNOTSUPP and therefore
# not modify our file's bar data/metadata. So its content should be 256 bytes
# long with all bytes having the value 0xbb.
#
# Without the btrfs bug fix, the clone operation succeeded and resulted in
# leaking truncated data from foo, the bytes that belonged to its range
# [128, 256[, and losing data from bar in that same range. So reading the
# file gave us the following content:
#
# 0000000 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1 a1
# *
# 0000200 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a
# *
# 0000400
echo "File bar's content after the clone operation:"
od -t x1 $SCRATCH_MNT/bar
# Also because the foo's inline extent was not shrunk by the truncate
# operation, btrfs' fsck, which is run by the fstests framework everytime a
# test completes, failed reporting the following error:
#
# root 5 inode 257 errors 400, nbytes wrong
status=0
exit
Cc: [email protected]
Signed-off-by: Filipe Manana <[email protected]>
CWE ID: CWE-200 | 0 | 41,643 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void capa_response(int flags)
{
const char *sasllist; /* the list of SASL mechanisms */
int mechcount;
int need_space = 0;
int i;
int lminus = config_getswitch(IMAPOPT_LITERALMINUS);
for (i = 0; base_capabilities[i].str; i++) {
const char *capa = base_capabilities[i].str;
/* Filter capabilities if requested */
if (capa_is_disabled(capa))
continue;
/* Don't show "MAILBOX-REFERRALS" if disabled by config */
if (config_getswitch(IMAPOPT_PROXYD_DISABLE_MAILBOX_REFERRALS) &&
!strcmp(capa, "MAILBOX-REFERRALS"))
continue;
/* Don't show if they're not shown at this level of login */
if (!(base_capabilities[i].mask & flags))
continue;
/* cheap and nasty version of LITERAL- support - just say so */
if (lminus && !strcmp(capa, "LITERAL+"))
capa = "LITERAL-";
/* print the capability */
if (need_space) prot_putc(' ', imapd_out);
else need_space = 1;
prot_printf(imapd_out, "%s", base_capabilities[i].str);
}
if (config_mupdate_server) {
prot_printf(imapd_out, " MUPDATE=mupdate://%s/", config_mupdate_server);
}
if (apns_enabled) {
prot_printf(imapd_out, " XAPPLEPUSHSERVICE");
}
if (tls_enabled() && !imapd_starttls_done && !imapd_authstate) {
prot_printf(imapd_out, " STARTTLS");
}
if (imapd_tls_required || imapd_authstate ||
(!imapd_starttls_done && (extprops_ssf < 2) &&
!config_getswitch(IMAPOPT_ALLOWPLAINTEXT))) {
prot_printf(imapd_out, " LOGINDISABLED");
}
/* add the SASL mechs */
if (!imapd_tls_required && (!imapd_authstate || saslprops.ssf) &&
sasl_listmech(imapd_saslconn, NULL,
"AUTH=", " AUTH=",
!imapd_authstate ? " SASL-IR" : "", &sasllist,
NULL, &mechcount) == SASL_OK && mechcount > 0) {
prot_printf(imapd_out, " %s", sasllist);
} else {
/* else don't show anything */
}
if (!(flags & CAPA_POSTAUTH)) return;
if (config_getswitch(IMAPOPT_CONVERSATIONS))
prot_printf(imapd_out, " XCONVERSATIONS");
#ifdef HAVE_ZLIB
if (!imapd_compress_done && !imapd_tls_comp) {
prot_printf(imapd_out, " COMPRESS=DEFLATE");
}
#endif // HAVE_ZLIB
for (i = 0 ; i < QUOTA_NUMRESOURCES ; i++)
prot_printf(imapd_out, " X-QUOTA=%s", quota_names[i]);
if (idle_enabled()) {
prot_printf(imapd_out, " IDLE");
}
}
Commit Message: imapd: check for isadmin BEFORE parsing sync lines
CWE ID: CWE-20 | 0 | 95,126 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd)
{
scmd_printk(KERN_INFO, scmd,
"Doing target reset due to an I/O command timeout.\n");
return pmcraid_reset_device(scmd,
PMCRAID_INTERNAL_TIMEOUT,
RESET_DEVICE_TARGET);
}
Commit Message: [SCSI] pmcraid: reject negative request size
There's a code path in pmcraid that can be reached via device ioctl that
causes all sorts of ugliness, including heap corruption or triggering the
OOM killer due to consecutive allocation of large numbers of pages.
First, the user can call pmcraid_chr_ioctl(), with a type
PMCRAID_PASSTHROUGH_IOCTL. This calls through to
pmcraid_ioctl_passthrough(). Next, a pmcraid_passthrough_ioctl_buffer
is copied in, and the request_size variable is set to
buffer->ioarcb.data_transfer_length, which is an arbitrary 32-bit
signed value provided by the user. If a negative value is provided
here, bad things can happen. For example,
pmcraid_build_passthrough_ioadls() is called with this request_size,
which immediately calls pmcraid_alloc_sglist() with a negative size.
The resulting math on allocating a scatter list can result in an
overflow in the kzalloc() call (if num_elem is 0, the sglist will be
smaller than expected), or if num_elem is unexpectedly large the
subsequent loop will call alloc_pages() repeatedly, a high number of
pages will be allocated and the OOM killer might be invoked.
It looks like preventing this value from being negative in
pmcraid_ioctl_passthrough() would be sufficient.
Signed-off-by: Dan Rosenberg <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: James Bottomley <[email protected]>
CWE ID: CWE-189 | 0 | 26,436 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int asf_read_seek(AVFormatContext *s, int stream_index,
int64_t pts, int flags)
{
ASFContext *asf = s->priv_data;
AVStream *st = s->streams[stream_index];
int ret = 0;
if (s->packet_size <= 0)
return -1;
/* Try using the protocol's read_seek if available */
if (s->pb) {
int64_t ret = avio_seek_time(s->pb, stream_index, pts, flags);
if (ret >= 0)
asf_reset_header(s);
if (ret != AVERROR(ENOSYS))
return ret;
}
/* explicitly handle the case of seeking to 0 */
if (!pts) {
asf_reset_header(s);
avio_seek(s->pb, s->internal->data_offset, SEEK_SET);
return 0;
}
if (!asf->index_read) {
ret = asf_build_simple_index(s, stream_index);
if (ret < 0)
asf->index_read = -1;
}
if (asf->index_read > 0 && st->index_entries) {
int index = av_index_search_timestamp(st, pts, flags);
if (index >= 0) {
/* find the position */
uint64_t pos = st->index_entries[index].pos;
/* do the seek */
av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);
if(avio_seek(s->pb, pos, SEEK_SET) < 0)
return -1;
asf_reset_header(s);
skip_to_key(s);
return 0;
}
}
/* no index or seeking by index failed */
if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0)
return -1;
asf_reset_header(s);
skip_to_key(s);
return 0;
}
Commit Message: avformat/asfdec: Fix DoS in asf_build_simple_index()
Fixes: Missing EOF check in loop
No testcase
Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <[email protected]>
CWE ID: CWE-399 | 0 | 61,362 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: OobeUI::GetAppLaunchSplashScreenActor() {
return app_launch_splash_screen_actor_;
}
Commit Message: One polymer_config.js to rule them all.
[email protected],[email protected],[email protected]
BUG=425626
Review URL: https://codereview.chromium.org/1224783005
Cr-Commit-Position: refs/heads/master@{#337882}
CWE ID: CWE-399 | 0 | 123,659 |
Analyze the following 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 djvu_close_lc(LoadContext* lc)
{
if (lc->document)
ddjvu_document_release(lc->document);
if (lc->context)
ddjvu_context_release(lc->context);
if (lc->page)
ddjvu_page_release(lc->page);
RelinquishMagickMemory(lc);
}
Commit Message:
CWE ID: CWE-119 | 0 | 71,507 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: nfs4_label_release_security(struct nfs4_label *label)
{ return; }
Commit Message: NFS: Fix a NULL pointer dereference of migration recovery ops for v4.2 client
---Steps to Reproduce--
<nfs-server>
# cat /etc/exports
/nfs/referal *(rw,insecure,no_subtree_check,no_root_squash,crossmnt)
/nfs/old *(ro,insecure,subtree_check,root_squash,crossmnt)
<nfs-client>
# mount -t nfs nfs-server:/nfs/ /mnt/
# ll /mnt/*/
<nfs-server>
# cat /etc/exports
/nfs/referal *(rw,insecure,no_subtree_check,no_root_squash,crossmnt,refer=/nfs/old/@nfs-server)
/nfs/old *(ro,insecure,subtree_check,root_squash,crossmnt)
# service nfs restart
<nfs-client>
# ll /mnt/*/ --->>>>> oops here
[ 5123.102925] BUG: unable to handle kernel NULL pointer dereference at (null)
[ 5123.103363] IP: [<ffffffffa03ed38b>] nfs4_proc_get_locations+0x9b/0x120 [nfsv4]
[ 5123.103752] PGD 587b9067 PUD 3cbf5067 PMD 0
[ 5123.104131] Oops: 0000 [#1]
[ 5123.104529] Modules linked in: nfsv4(OE) nfs(OE) fscache(E) nfsd(OE) xfs libcrc32c iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi coretemp crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel ppdev vmw_balloon parport_pc parport i2c_piix4 shpchp auth_rpcgss nfs_acl vmw_vmci lockd grace sunrpc vmwgfx drm_kms_helper ttm drm mptspi serio_raw scsi_transport_spi e1000 mptscsih mptbase ata_generic pata_acpi [last unloaded: nfsd]
[ 5123.105887] CPU: 0 PID: 15853 Comm: ::1-manager Tainted: G OE 4.2.0-rc6+ #214
[ 5123.106358] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/20/2014
[ 5123.106860] task: ffff88007620f300 ti: ffff88005877c000 task.ti: ffff88005877c000
[ 5123.107363] RIP: 0010:[<ffffffffa03ed38b>] [<ffffffffa03ed38b>] nfs4_proc_get_locations+0x9b/0x120 [nfsv4]
[ 5123.107909] RSP: 0018:ffff88005877fdb8 EFLAGS: 00010246
[ 5123.108435] RAX: ffff880053f3bc00 RBX: ffff88006ce6c908 RCX: ffff880053a0d240
[ 5123.108968] RDX: ffffea0000e6d940 RSI: ffff8800399a0000 RDI: ffff88006ce6c908
[ 5123.109503] RBP: ffff88005877fe28 R08: ffffffff81c708a0 R09: 0000000000000000
[ 5123.110045] R10: 00000000000001a2 R11: ffff88003ba7f5c8 R12: ffff880054c55800
[ 5123.110618] R13: 0000000000000000 R14: ffff880053a0d240 R15: ffff880053a0d240
[ 5123.111169] FS: 0000000000000000(0000) GS:ffffffff81c27000(0000) knlGS:0000000000000000
[ 5123.111726] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 5123.112286] CR2: 0000000000000000 CR3: 0000000054cac000 CR4: 00000000001406f0
[ 5123.112888] Stack:
[ 5123.113458] ffffea0000e6d940 ffff8800399a0000 00000000000167d0 0000000000000000
[ 5123.114049] 0000000000000000 0000000000000000 0000000000000000 00000000a7ec82c6
[ 5123.114662] ffff88005877fe18 ffffea0000e6d940 ffff8800399a0000 ffff880054c55800
[ 5123.115264] Call Trace:
[ 5123.115868] [<ffffffffa03fb44b>] nfs4_try_migration+0xbb/0x220 [nfsv4]
[ 5123.116487] [<ffffffffa03fcb3b>] nfs4_run_state_manager+0x4ab/0x7b0 [nfsv4]
[ 5123.117104] [<ffffffffa03fc690>] ? nfs4_do_reclaim+0x510/0x510 [nfsv4]
[ 5123.117813] [<ffffffff810a4527>] kthread+0xd7/0xf0
[ 5123.118456] [<ffffffff810a4450>] ? kthread_worker_fn+0x160/0x160
[ 5123.119108] [<ffffffff816d9cdf>] ret_from_fork+0x3f/0x70
[ 5123.119723] [<ffffffff810a4450>] ? kthread_worker_fn+0x160/0x160
[ 5123.120329] Code: 4c 8b 6a 58 74 17 eb 52 48 8d 55 a8 89 c6 4c 89 e7 e8 4a b5 ff ff 8b 45 b0 85 c0 74 1c 4c 89 f9 48 8b 55 90 48 8b 75 98 48 89 df <41> ff 55 00 3d e8 d8 ff ff 41 89 c6 74 cf 48 8b 4d c8 65 48 33
[ 5123.121643] RIP [<ffffffffa03ed38b>] nfs4_proc_get_locations+0x9b/0x120 [nfsv4]
[ 5123.122308] RSP <ffff88005877fdb8>
[ 5123.122942] CR2: 0000000000000000
Fixes: ec011fe847 ("NFS: Introduce a vector of migration recovery ops")
Cc: [email protected] # v3.13+
Signed-off-by: Kinglong Mee <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
CWE ID: | 0 | 57,144 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: PermissionPromptImpl::PermissionPromptImpl(Browser* browser, Delegate* delegate)
: browser_(browser), delegate_(delegate), bubble_delegate_(nullptr) {
Show();
}
Commit Message: Elide the permission bubble title from the head of the string.
Long URLs can be used to spoof other origins in the permission bubble
title. This CL customises the title to be elided from the head, which
ensures that the maximal amount of the URL host is displayed in the case
where the URL is too long and causes the string to overflow.
Implementing the ellision means that the title cannot be multiline
(where elision is not well supported). Note that in English, the
window title is a string "$ORIGIN wants to", so the non-origin
component will not be elided. In other languages, the non-origin
component may appear fully or partly before the origin (e.g. in
Filipino, "Gusto ng $ORIGIN na"), so it may be elided there if the
URL is sufficiently long. This is not optimal, but the URLs that are
sufficiently long to trigger the elision are probably malicious, and
displaying the most relevant component of the URL is most important
for security purposes.
BUG=774438
Change-Id: I75c2364b10bf69bf337c7f4970481bf1809f6aae
Reviewed-on: https://chromium-review.googlesource.com/768312
Reviewed-by: Ben Wells <[email protected]>
Reviewed-by: Lucas Garron <[email protected]>
Reviewed-by: Matt Giuca <[email protected]>
Commit-Queue: Dominick Ng <[email protected]>
Cr-Commit-Position: refs/heads/master@{#516921}
CWE ID: | 0 | 146,966 |
Analyze the following 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 Cancel() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (fetcher_.get()) {
fetcher_.reset();
}
FinishRequest(UNKNOWN, REASON_REQUEST_CANCELED);
}
Commit Message: Add the SandboxedDMGParser and wire it up to the DownloadProtectionService.
BUG=496898,464083
[email protected], [email protected], [email protected], [email protected]
Review URL: https://codereview.chromium.org/1299223006 .
Cr-Commit-Position: refs/heads/master@{#344876}
CWE ID: | 0 | 123,732 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: WORD32 ih264d_get_buf_info(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op)
{
dec_struct_t * ps_dec;
UWORD8 i = 0; // Default for 420P format
UWORD16 pic_wd, pic_ht;
ivd_ctl_getbufinfo_op_t *ps_ctl_op =
(ivd_ctl_getbufinfo_op_t*)pv_api_op;
UNUSED(pv_api_ip);
ps_ctl_op->u4_error_code = 0;
ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle);
ps_ctl_op->u4_min_num_in_bufs = MIN_IN_BUFS;
if(ps_dec->u1_chroma_format == IV_YUV_420P)
ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_420;
else if(ps_dec->u1_chroma_format == IV_YUV_422ILE)
ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_422ILE;
else if(ps_dec->u1_chroma_format == IV_RGB_565)
ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_RGB565;
else if((ps_dec->u1_chroma_format == IV_YUV_420SP_UV)
|| (ps_dec->u1_chroma_format == IV_YUV_420SP_VU))
ps_ctl_op->u4_min_num_out_bufs = MIN_OUT_BUFS_420SP;
else
{
return IV_FAIL;
}
ps_ctl_op->u4_num_disp_bufs = 1;
pic_wd = 0;
pic_ht = 0;
if(ps_dec->i4_header_decoded == 3)
{
if(0 == ps_dec->u4_share_disp_buf)
{
pic_wd = ps_dec->u2_disp_width;
pic_ht = ps_dec->u2_disp_height;
}
else
{
pic_wd = ps_dec->u2_frm_wd_y;
pic_ht = ps_dec->u2_frm_ht_y;
}
}
for(i = 0; i < ps_ctl_op->u4_min_num_in_bufs; i++)
{
ps_ctl_op->u4_min_in_buf_size[i] = MAX(256000, pic_wd * pic_ht * 3 / 2);
}
if((WORD32)ps_dec->u4_app_disp_width > pic_wd)
pic_wd = ps_dec->u4_app_disp_width;
if(0 == ps_dec->u4_share_disp_buf)
ps_ctl_op->u4_num_disp_bufs = 1;
else
{
if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid)))
{
if((ps_dec->ps_cur_sps->u1_vui_parameters_present_flag == 1) &&
(1 == ps_dec->ps_cur_sps->s_vui.u1_bitstream_restriction_flag))
{
ps_ctl_op->u4_num_disp_bufs =
ps_dec->ps_cur_sps->s_vui.u4_num_reorder_frames + 1;
}
else
{
/*if VUI is not present assume maximum possible refrence frames for the level,
* as max reorder frames*/
ps_ctl_op->u4_num_disp_bufs = ih264d_get_dpb_size(ps_dec->ps_cur_sps);
}
ps_ctl_op->u4_num_disp_bufs +=
ps_dec->ps_cur_sps->u1_num_ref_frames + 1;
}
else
{
ps_ctl_op->u4_num_disp_bufs = 32;
}
ps_ctl_op->u4_num_disp_bufs = MAX(
ps_ctl_op->u4_num_disp_bufs, 6);
ps_ctl_op->u4_num_disp_bufs = MIN(
ps_ctl_op->u4_num_disp_bufs, 32);
}
/*!*/
if(ps_dec->u1_chroma_format == IV_YUV_420P)
{
ps_ctl_op->u4_min_out_buf_size[0] = (pic_wd * pic_ht);
ps_ctl_op->u4_min_out_buf_size[1] = (pic_wd * pic_ht)
>> 2;
ps_ctl_op->u4_min_out_buf_size[2] = (pic_wd * pic_ht)
>> 2;
}
else if(ps_dec->u1_chroma_format == IV_YUV_422ILE)
{
ps_ctl_op->u4_min_out_buf_size[0] = (pic_wd * pic_ht)
* 2;
ps_ctl_op->u4_min_out_buf_size[1] =
ps_ctl_op->u4_min_out_buf_size[2] = 0;
}
else if(ps_dec->u1_chroma_format == IV_RGB_565)
{
ps_ctl_op->u4_min_out_buf_size[0] = (pic_wd * pic_ht)
* 2;
ps_ctl_op->u4_min_out_buf_size[1] =
ps_ctl_op->u4_min_out_buf_size[2] = 0;
}
else if((ps_dec->u1_chroma_format == IV_YUV_420SP_UV)
|| (ps_dec->u1_chroma_format == IV_YUV_420SP_VU))
{
ps_ctl_op->u4_min_out_buf_size[0] = (pic_wd * pic_ht);
ps_ctl_op->u4_min_out_buf_size[1] = (pic_wd * pic_ht)
>> 1;
ps_ctl_op->u4_min_out_buf_size[2] = 0;
}
ps_dec->u4_num_disp_bufs_requested = ps_ctl_op->u4_num_disp_bufs;
return IV_SUCCESS;
}
Commit Message: Fixed error concealment when no MBs are decoded in the current pic
Bug: 29493002
Change-Id: I3fae547ddb0616b4e6579580985232bd3d65881e
CWE ID: CWE-284 | 0 | 158,313 |
Analyze the following 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 BrowserCommandController::IsCommandEnabled(int id) const {
return command_updater_.IsCommandEnabled(id);
}
Commit Message: mac: Do not let synthetic events toggle "Allow JavaScript From AppleEvents"
Bug: 891697
Change-Id: I49eb77963515637df739c9d2ce83530d4e21cf15
Reviewed-on: https://chromium-review.googlesource.com/c/1308771
Reviewed-by: Elly Fong-Jones <[email protected]>
Commit-Queue: Robert Sesek <[email protected]>
Cr-Commit-Position: refs/heads/master@{#604268}
CWE ID: CWE-20 | 0 | 153,512 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static char *list_of_tainted_modules(const char *proc_modules)
{
struct strbuf *result = strbuf_new();
const char *p = proc_modules;
for (;;)
{
const char *end = strchrnul(p, '\n');
const char *paren = strchrnul(p, '(');
/* We look for a line with this format:
* "kvm_intel 126289 0 - Live 0xf829e000 (taint_flags)"
* where taint_flags have letters
* (flags '+' and '-' indicate (un)loading, we must ignore them).
*/
while (++paren < end)
{
if ((unsigned)(toupper(*paren) - 'A') <= 'Z'-'A')
{
strbuf_append_strf(result, result->len == 0 ? "%.*s" : ",%.*s",
(int)(strchrnul(p,' ') - p), p
);
break;
}
if (*paren == ')')
break;
}
if (*end == '\0')
break;
p = end + 1;
}
if (result->len == 0)
{
strbuf_free(result);
return NULL;
}
return strbuf_free_nobuf(result);
}
Commit Message: make the dump directories owned by root by default
It was discovered that the abrt event scripts create a user-readable
copy of a sosreport file in abrt problem directories, and include
excerpts of /var/log/messages selected by the user-controlled process
name, leading to an information disclosure.
This issue was discovered by Florian Weimer of Red Hat Product Security.
Related: #1212868
Signed-off-by: Jakub Filak <[email protected]>
CWE ID: CWE-200 | 0 | 96,406 |
Analyze the following 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 timer_start(Unit *u) {
Timer *t = TIMER(u);
TimerValue *v;
assert(t);
assert(t->state == TIMER_DEAD || t->state == TIMER_FAILED);
if (UNIT_TRIGGER(u)->load_state != UNIT_LOADED)
return -ENOENT;
t->last_trigger = DUAL_TIMESTAMP_NULL;
/* Reenable all timers that depend on unit activation time */
LIST_FOREACH(value, v, t->values)
if (v->base == TIMER_ACTIVE)
v->disabled = false;
if (t->stamp_path) {
struct stat st;
if (stat(t->stamp_path, &st) >= 0)
t->last_trigger.realtime = timespec_load(&st.st_atim);
else if (errno == ENOENT)
/* The timer has never run before,
* make sure a stamp file exists.
*/
touch_file(t->stamp_path, true, USEC_INFINITY, UID_INVALID, GID_INVALID, 0);
}
t->result = TIMER_SUCCESS;
timer_enter_waiting(t, true);
return 1;
}
Commit Message: util-lib: use MODE_INVALID as invalid value for mode_t everywhere
CWE ID: CWE-264 | 1 | 170,107 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: FindAKA()
{
register unsigned char *cp, *line;
register struct win *wp = curr;
register int len = strlen(wp->w_akabuf);
int y;
y = (wp->w_autoaka > 0 && wp->w_autoaka <= wp->w_height) ? wp->w_autoaka - 1 : wp->w_y;
cols = wp->w_width;
try_line:
cp = line = wp->w_mlines[y].image;
if (wp->w_autoaka > 0 && *wp->w_akabuf != '\0')
{
for (;;)
{
if (cp - line >= cols - len)
{
if (++y == wp->w_autoaka && y < rows)
goto try_line;
return;
}
if (strncmp((char *)cp, wp->w_akabuf, len) == 0)
break;
cp++;
}
cp += len;
}
for (len = cols - (cp - line); len && *cp == ' '; len--, cp++)
;
if (len)
{
if (wp->w_autoaka > 0 && (*cp == '!' || *cp == '%' || *cp == '^'))
wp->w_autoaka = -1;
else
wp->w_autoaka = 0;
line = cp;
while (len && *cp != ' ')
{
if (*cp++ == '/')
line = cp;
len--;
}
ChangeAKA(wp, (char *)line, cp - line);
}
else
wp->w_autoaka = 0;
}
Commit Message:
CWE ID: CWE-119 | 0 | 739 |
Analyze the following 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 hash_setkey(void *private, const u8 *key, unsigned int keylen)
{
return crypto_ahash_setkey(private, key, keylen);
}
Commit Message: crypto: algif - suppress sending source address information in recvmsg
The current code does not set the msg_namelen member to 0 and therefore
makes net/socket.c leak the local sockaddr_storage variable to userland
-- 128 bytes of kernel stack memory. Fix that.
Cc: <[email protected]> # 2.6.38
Signed-off-by: Mathias Krause <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
CWE ID: CWE-200 | 0 | 30,842 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: SpeechRecognitionManagerImpl::SpeechRecognitionManagerImpl(
media::AudioSystem* audio_system,
MediaStreamManager* media_stream_manager)
: audio_system_(audio_system),
media_stream_manager_(media_stream_manager),
primary_session_id_(kSessionIDInvalid),
last_session_id_(kSessionIDInvalid),
is_dispatching_event_(false),
delegate_(GetContentClient()
->browser()
->CreateSpeechRecognitionManagerDelegate()),
weak_factory_(this) {
DCHECK(!g_speech_recognition_manager_impl);
g_speech_recognition_manager_impl = this;
frame_deletion_observer_.reset(new FrameDeletionObserver(
base::BindRepeating(&SpeechRecognitionManagerImpl::AbortSessionImpl,
weak_factory_.GetWeakPtr())));
}
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 <[email protected]>
Reviewed-by: Ken Buchanan <[email protected]>
Reviewed-by: Olga Sharonova <[email protected]>
Commit-Queue: Guido Urdaneta <[email protected]>
Cr-Commit-Position: refs/heads/master@{#616347}
CWE ID: CWE-189 | 1 | 173,111 |
Analyze the following 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 php_mysqlnd_auth_free_mem(void * _packet, zend_bool stack_allocation TSRMLS_DC)
{
if (!stack_allocation) {
MYSQLND_PACKET_AUTH * p = (MYSQLND_PACKET_AUTH *) _packet;
mnd_pefree(p, p->header.persistent);
}
}
Commit Message: Fix bug #72293 - Heap overflow in mysqlnd related to BIT fields
CWE ID: CWE-119 | 0 | 49,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: DEFINE_RUN_ONCE_STATIC(ossl_init_engine_devcrypto)
{
# ifdef OPENSSL_INIT_DEBUG
fprintf(stderr, "OPENSSL_INIT: ossl_init_engine_devcrypto: "
"engine_load_devcrypto_int()\n");
# endif
engine_load_devcrypto_int();
return 1;
}
Commit Message:
CWE ID: CWE-330 | 0 | 11,999 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void Browser::OpenPluginsTabAndActivate() {
OpenURL(GURL(chrome::kChromeUIPluginsURL), GURL(),
NEW_FOREGROUND_TAB, PageTransition::LINK);
window_->Activate();
}
Commit Message: Implement a bubble that appears at the top of the screen when a tab enters
fullscreen mode via webkitRequestFullScreen(), telling the user how to exit
fullscreen.
This is implemented as an NSView rather than an NSWindow because the floating
chrome that appears in presentation mode should overlap the bubble.
Content-initiated fullscreen mode makes use of 'presentation mode' on the Mac:
the mode in which the UI is hidden, accessible by moving the cursor to the top
of the screen. On Snow Leopard, this mode is synonymous with fullscreen mode.
On Lion, however, fullscreen mode does not imply presentation mode: in
non-presentation fullscreen mode, the chrome is permanently shown. It is
possible to switch between presentation mode and fullscreen mode using the
presentation mode UI control.
When a tab initiates fullscreen mode on Lion, we enter presentation mode if not
in presentation mode already. When the user exits fullscreen mode using Chrome
UI (i.e. keyboard shortcuts, menu items, buttons, switching tabs, etc.) we
return the user to the mode they were in before the tab entered fullscreen.
BUG=14471
TEST=Enter fullscreen mode using webkitRequestFullScreen. You should see a bubble pop down from the top of the screen.
Need to test the Lion logic somehow, with no Lion trybots.
BUG=96883
Original review http://codereview.chromium.org/7890056/
TBR=thakis
Review URL: http://codereview.chromium.org/7920024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101624 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-119 | 0 | 97,312 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void vmxnet3_class_init(ObjectClass *class, void *data)
{
DeviceClass *dc = DEVICE_CLASS(class);
PCIDeviceClass *c = PCI_DEVICE_CLASS(class);
VMXNET3Class *vc = VMXNET3_DEVICE_CLASS(class);
c->realize = vmxnet3_pci_realize;
c->exit = vmxnet3_pci_uninit;
c->vendor_id = PCI_VENDOR_ID_VMWARE;
c->device_id = PCI_DEVICE_ID_VMWARE_VMXNET3;
c->revision = PCI_DEVICE_ID_VMWARE_VMXNET3_REVISION;
c->romfile = "efi-vmxnet3.rom";
c->class_id = PCI_CLASS_NETWORK_ETHERNET;
c->subsystem_vendor_id = PCI_VENDOR_ID_VMWARE;
c->subsystem_id = PCI_DEVICE_ID_VMWARE_VMXNET3;
vc->parent_dc_realize = dc->realize;
dc->realize = vmxnet3_realize;
dc->desc = "VMWare Paravirtualized Ethernet v3";
dc->reset = vmxnet3_qdev_reset;
dc->vmsd = &vmstate_vmxnet3;
dc->props = vmxnet3_properties;
set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
}
Commit Message:
CWE ID: CWE-200 | 0 | 8,978 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: int NaClIPCAdapter::LockedReceive(char* output_buffer,
size_t output_buffer_size) {
lock_.AssertAcquired();
if (locked_data_.to_be_received_.empty())
return 0;
scoped_refptr<RewrittenMessage> current =
locked_data_.to_be_received_.front();
int retval = current->Read(output_buffer, output_buffer_size);
if (current->is_consumed())
locked_data_.to_be_received_.pop();
return retval;
}
Commit Message: Revert 143656 - Add an IPC channel between the NaCl loader process and the renderer.
BUG=116317
TEST=ppapi, nacl tests, manual testing for experimental IPC proxy.
Review URL: https://chromiumcodereview.appspot.com/10641016
[email protected]
Review URL: https://chromiumcodereview.appspot.com/10625007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143665 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-399 | 0 | 103,293 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: selDisplayInPix(SEL *sel,
l_int32 size,
l_int32 gthick)
{
l_int32 i, j, w, h, sx, sy, cx, cy, type, width;
l_int32 radius1, radius2, shift1, shift2, x0, y0;
PIX *pixd, *pix2, *pixh, *pixm, *pixorig;
PTA *pta1, *pta2, *pta1t, *pta2t;
PROCNAME("selDisplayInPix");
if (!sel)
return (PIX *)ERROR_PTR("sel not defined", procName, NULL);
if (size < 13) {
L_WARNING("size < 13; setting to 13\n", procName);
size = 13;
}
if (size % 2 == 0)
size++;
if (gthick < 2) {
L_WARNING("grid thickness < 2; setting to 2\n", procName);
gthick = 2;
}
selGetParameters(sel, &sy, &sx, &cy, &cx);
w = size * sx + gthick * (sx + 1);
h = size * sy + gthick * (sy + 1);
pixd = pixCreate(w, h, 1);
/* Generate grid lines */
for (i = 0; i <= sy; i++)
pixRenderLine(pixd, 0, gthick / 2 + i * (size + gthick),
w - 1, gthick / 2 + i * (size + gthick),
gthick, L_SET_PIXELS);
for (j = 0; j <= sx; j++)
pixRenderLine(pixd, gthick / 2 + j * (size + gthick), 0,
gthick / 2 + j * (size + gthick), h - 1,
gthick, L_SET_PIXELS);
/* Generate hit and miss patterns */
radius1 = (l_int32)(0.85 * ((size - 1) / 2.0) + 0.5); /* of hit */
radius2 = (l_int32)(0.65 * ((size - 1) / 2.0) + 0.5); /* of inner miss */
pta1 = generatePtaFilledCircle(radius1);
pta2 = generatePtaFilledCircle(radius2);
shift1 = (size - 1) / 2 - radius1; /* center circle in square */
shift2 = (size - 1) / 2 - radius2;
pta1t = ptaTransform(pta1, shift1, shift1, 1.0, 1.0);
pta2t = ptaTransform(pta2, shift2, shift2, 1.0, 1.0);
pixh = pixGenerateFromPta(pta1t, size, size); /* hits */
pix2 = pixGenerateFromPta(pta2t, size, size);
pixm = pixSubtract(NULL, pixh, pix2);
/* Generate crossed lines for origin pattern */
pixorig = pixCreate(size, size, 1);
width = size / 8;
pixRenderLine(pixorig, size / 2, (l_int32)(0.12 * size),
size / 2, (l_int32)(0.88 * size),
width, L_SET_PIXELS);
pixRenderLine(pixorig, (l_int32)(0.15 * size), size / 2,
(l_int32)(0.85 * size), size / 2,
width, L_FLIP_PIXELS);
pixRasterop(pixorig, size / 2 - width, size / 2 - width,
2 * width, 2 * width, PIX_NOT(PIX_DST), NULL, 0, 0);
/* Specialize origin pattern for this sel */
selGetTypeAtOrigin(sel, &type);
if (type == SEL_HIT)
pixXor(pixorig, pixorig, pixh);
else if (type == SEL_MISS)
pixXor(pixorig, pixorig, pixm);
/* Paste the patterns in */
y0 = gthick;
for (i = 0; i < sy; i++) {
x0 = gthick;
for (j = 0; j < sx; j++) {
selGetElement(sel, i, j, &type);
if (i == cy && j == cx) /* origin */
pixRasterop(pixd, x0, y0, size, size, PIX_SRC, pixorig, 0, 0);
else if (type == SEL_HIT)
pixRasterop(pixd, x0, y0, size, size, PIX_SRC, pixh, 0, 0);
else if (type == SEL_MISS)
pixRasterop(pixd, x0, y0, size, size, PIX_SRC, pixm, 0, 0);
x0 += size + gthick;
}
y0 += size + gthick;
}
pixDestroy(&pix2);
pixDestroy(&pixh);
pixDestroy(&pixm);
pixDestroy(&pixorig);
ptaDestroy(&pta1);
ptaDestroy(&pta1t);
ptaDestroy(&pta2);
ptaDestroy(&pta2t);
return pixd;
}
Commit Message: Security fixes: expect final changes for release 1.75.3.
* Fixed a debian security issue with fscanf() reading a string with
possible buffer overflow.
* There were also a few similar situations with sscanf().
CWE ID: CWE-119 | 0 | 84,214 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
struct nlattr **tb, char *ifname, int modified)
{
const struct net_device_ops *ops = dev->netdev_ops;
int err;
if (tb[IFLA_NET_NS_PID] || tb[IFLA_NET_NS_FD]) {
struct net *net = rtnl_link_get_net(dev_net(dev), tb);
if (IS_ERR(net)) {
err = PTR_ERR(net);
goto errout;
}
if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) {
err = -EPERM;
goto errout;
}
err = dev_change_net_namespace(dev, net, ifname);
put_net(net);
if (err)
goto errout;
modified = 1;
}
if (tb[IFLA_MAP]) {
struct rtnl_link_ifmap *u_map;
struct ifmap k_map;
if (!ops->ndo_set_config) {
err = -EOPNOTSUPP;
goto errout;
}
if (!netif_device_present(dev)) {
err = -ENODEV;
goto errout;
}
u_map = nla_data(tb[IFLA_MAP]);
k_map.mem_start = (unsigned long) u_map->mem_start;
k_map.mem_end = (unsigned long) u_map->mem_end;
k_map.base_addr = (unsigned short) u_map->base_addr;
k_map.irq = (unsigned char) u_map->irq;
k_map.dma = (unsigned char) u_map->dma;
k_map.port = (unsigned char) u_map->port;
err = ops->ndo_set_config(dev, &k_map);
if (err < 0)
goto errout;
modified = 1;
}
if (tb[IFLA_ADDRESS]) {
struct sockaddr *sa;
int len;
len = sizeof(sa_family_t) + dev->addr_len;
sa = kmalloc(len, GFP_KERNEL);
if (!sa) {
err = -ENOMEM;
goto errout;
}
sa->sa_family = dev->type;
memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]),
dev->addr_len);
err = dev_set_mac_address(dev, sa);
kfree(sa);
if (err)
goto errout;
modified = 1;
}
if (tb[IFLA_MTU]) {
err = dev_set_mtu(dev, nla_get_u32(tb[IFLA_MTU]));
if (err < 0)
goto errout;
modified = 1;
}
if (tb[IFLA_GROUP]) {
dev_set_group(dev, nla_get_u32(tb[IFLA_GROUP]));
modified = 1;
}
/*
* Interface selected by interface index but interface
* name provided implies that a name change has been
* requested.
*/
if (ifm->ifi_index > 0 && ifname[0]) {
err = dev_change_name(dev, ifname);
if (err < 0)
goto errout;
modified = 1;
}
if (tb[IFLA_IFALIAS]) {
err = dev_set_alias(dev, nla_data(tb[IFLA_IFALIAS]),
nla_len(tb[IFLA_IFALIAS]));
if (err < 0)
goto errout;
modified = 1;
}
if (tb[IFLA_BROADCAST]) {
nla_memcpy(dev->broadcast, tb[IFLA_BROADCAST], dev->addr_len);
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
}
if (ifm->ifi_flags || ifm->ifi_change) {
err = dev_change_flags(dev, rtnl_dev_combine_flags(dev, ifm));
if (err < 0)
goto errout;
}
if (tb[IFLA_MASTER]) {
err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]));
if (err)
goto errout;
modified = 1;
}
if (tb[IFLA_CARRIER]) {
err = dev_change_carrier(dev, nla_get_u8(tb[IFLA_CARRIER]));
if (err)
goto errout;
modified = 1;
}
if (tb[IFLA_TXQLEN])
dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]);
if (tb[IFLA_OPERSTATE])
set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE]));
if (tb[IFLA_LINKMODE]) {
write_lock_bh(&dev_base_lock);
dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]);
write_unlock_bh(&dev_base_lock);
}
if (tb[IFLA_VFINFO_LIST]) {
struct nlattr *attr;
int rem;
nla_for_each_nested(attr, tb[IFLA_VFINFO_LIST], rem) {
if (nla_type(attr) != IFLA_VF_INFO) {
err = -EINVAL;
goto errout;
}
err = do_setvfinfo(dev, attr);
if (err < 0)
goto errout;
modified = 1;
}
}
err = 0;
if (tb[IFLA_VF_PORTS]) {
struct nlattr *port[IFLA_PORT_MAX+1];
struct nlattr *attr;
int vf;
int rem;
err = -EOPNOTSUPP;
if (!ops->ndo_set_vf_port)
goto errout;
nla_for_each_nested(attr, tb[IFLA_VF_PORTS], rem) {
if (nla_type(attr) != IFLA_VF_PORT)
continue;
err = nla_parse_nested(port, IFLA_PORT_MAX,
attr, ifla_port_policy);
if (err < 0)
goto errout;
if (!port[IFLA_PORT_VF]) {
err = -EOPNOTSUPP;
goto errout;
}
vf = nla_get_u32(port[IFLA_PORT_VF]);
err = ops->ndo_set_vf_port(dev, vf, port);
if (err < 0)
goto errout;
modified = 1;
}
}
err = 0;
if (tb[IFLA_PORT_SELF]) {
struct nlattr *port[IFLA_PORT_MAX+1];
err = nla_parse_nested(port, IFLA_PORT_MAX,
tb[IFLA_PORT_SELF], ifla_port_policy);
if (err < 0)
goto errout;
err = -EOPNOTSUPP;
if (ops->ndo_set_vf_port)
err = ops->ndo_set_vf_port(dev, PORT_SELF_VF, port);
if (err < 0)
goto errout;
modified = 1;
}
if (tb[IFLA_AF_SPEC]) {
struct nlattr *af;
int rem;
nla_for_each_nested(af, tb[IFLA_AF_SPEC], rem) {
const struct rtnl_af_ops *af_ops;
if (!(af_ops = rtnl_af_lookup(nla_type(af))))
BUG();
err = af_ops->set_link_af(dev, af);
if (err < 0)
goto errout;
modified = 1;
}
}
err = 0;
errout:
if (err < 0 && modified)
net_warn_ratelimited("A link change request failed with some changes committed already. Interface %s may have been left with an inconsistent configuration, please check.\n",
dev->name);
return err;
}
Commit Message: rtnl: fix info leak on RTM_GETLINK request for VF devices
Initialize the mac address buffer with 0 as the driver specific function
will probably not fill the whole buffer. In fact, all in-kernel drivers
fill only ETH_ALEN of the MAX_ADDR_LEN bytes, i.e. 6 of the 32 possible
bytes. Therefore we currently leak 26 bytes of stack memory to userland
via the netlink interface.
Signed-off-by: Mathias Krause <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
CWE ID: CWE-399 | 0 | 31,008 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: SYSCALL_DEFINE1(setuid, uid_t, uid)
{
const struct cred *old;
struct cred *new;
int retval;
new = prepare_creds();
if (!new)
return -ENOMEM;
old = current_cred();
retval = -EPERM;
if (nsown_capable(CAP_SETUID)) {
new->suid = new->uid = uid;
if (uid != old->uid) {
retval = set_user(new);
if (retval < 0)
goto error;
}
} else if (uid != old->uid && uid != new->suid) {
goto error;
}
new->fsuid = new->euid = uid;
retval = security_task_fix_setuid(new, old, LSM_SETID_ID);
if (retval < 0)
goto error;
return commit_creds(new);
error:
abort_creds(new);
return retval;
}
Commit Message: mm: fix prctl_set_vma_anon_name
prctl_set_vma_anon_name could attempt to set the name across
two vmas at the same time due to a typo, which might corrupt
the vma list. Fix it to use tmp instead of end to limit
the name setting to a single vma at a time.
Change-Id: Ie32d8ddb0fd547efbeedd6528acdab5ca5b308b4
Reported-by: Jed Davis <[email protected]>
Signed-off-by: Colin Cross <[email protected]>
CWE ID: CWE-264 | 0 | 162,016 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: DWORD CreateRestrictedToken(HANDLE *token_handle,
TokenLevel security_level,
IntegrityLevel integrity_level,
TokenType token_type) {
if (!token_handle)
return ERROR_BAD_ARGUMENTS;
RestrictedToken restricted_token;
restricted_token.Init(NULL); // Initialized with the current process token
std::vector<std::wstring> privilege_exceptions;
std::vector<Sid> sid_exceptions;
bool deny_sids = true;
bool remove_privileges = true;
switch (security_level) {
case USER_UNPROTECTED: {
deny_sids = false;
remove_privileges = false;
break;
}
case USER_RESTRICTED_SAME_ACCESS: {
deny_sids = false;
remove_privileges = false;
unsigned err_code = restricted_token.AddRestrictingSidAllSids();
if (ERROR_SUCCESS != err_code)
return err_code;
break;
}
case USER_NON_ADMIN: {
sid_exceptions.push_back(WinBuiltinUsersSid);
sid_exceptions.push_back(WinWorldSid);
sid_exceptions.push_back(WinInteractiveSid);
sid_exceptions.push_back(WinAuthenticatedUserSid);
privilege_exceptions.push_back(SE_CHANGE_NOTIFY_NAME);
break;
}
case USER_INTERACTIVE: {
sid_exceptions.push_back(WinBuiltinUsersSid);
sid_exceptions.push_back(WinWorldSid);
sid_exceptions.push_back(WinInteractiveSid);
sid_exceptions.push_back(WinAuthenticatedUserSid);
privilege_exceptions.push_back(SE_CHANGE_NOTIFY_NAME);
restricted_token.AddRestrictingSid(WinBuiltinUsersSid);
restricted_token.AddRestrictingSid(WinWorldSid);
restricted_token.AddRestrictingSid(WinRestrictedCodeSid);
restricted_token.AddRestrictingSidCurrentUser();
restricted_token.AddRestrictingSidLogonSession();
break;
}
case USER_LIMITED: {
sid_exceptions.push_back(WinBuiltinUsersSid);
sid_exceptions.push_back(WinWorldSid);
sid_exceptions.push_back(WinInteractiveSid);
privilege_exceptions.push_back(SE_CHANGE_NOTIFY_NAME);
restricted_token.AddRestrictingSid(WinBuiltinUsersSid);
restricted_token.AddRestrictingSid(WinWorldSid);
restricted_token.AddRestrictingSid(WinRestrictedCodeSid);
if (base::win::GetVersion() >= base::win::VERSION_VISTA)
restricted_token.AddRestrictingSidLogonSession();
break;
}
case USER_RESTRICTED: {
privilege_exceptions.push_back(SE_CHANGE_NOTIFY_NAME);
restricted_token.AddUserSidForDenyOnly();
restricted_token.AddRestrictingSid(WinRestrictedCodeSid);
break;
}
case USER_LOCKDOWN: {
restricted_token.AddUserSidForDenyOnly();
restricted_token.AddRestrictingSid(WinNullSid);
break;
}
default: {
return ERROR_BAD_ARGUMENTS;
}
}
DWORD err_code = ERROR_SUCCESS;
if (deny_sids) {
err_code = restricted_token.AddAllSidsForDenyOnly(&sid_exceptions);
if (ERROR_SUCCESS != err_code)
return err_code;
}
if (remove_privileges) {
err_code = restricted_token.DeleteAllPrivileges(&privilege_exceptions);
if (ERROR_SUCCESS != err_code)
return err_code;
}
restricted_token.SetIntegrityLevel(integrity_level);
switch (token_type) {
case PRIMARY: {
err_code = restricted_token.GetRestrictedTokenHandle(token_handle);
break;
}
case IMPERSONATION: {
err_code = restricted_token.GetRestrictedTokenHandleForImpersonation(
token_handle);
break;
}
default: {
err_code = ERROR_BAD_ARGUMENTS;
break;
}
}
return err_code;
}
Commit Message: Prevent sandboxed processes from opening each other
TBR=brettw
BUG=117627
BUG=119150
TEST=sbox_validation_tests
Review URL: https://chromiumcodereview.appspot.com/9716027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132477 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: | 0 | 106,648 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: InspectorAgent::InspectorAgent(const String& name)
: m_name(name)
{
}
Commit Message: DevTools: remove references to modules/device_orientation from core
BUG=340221
Review URL: https://codereview.chromium.org/150913003
git-svn-id: svn://svn.chromium.org/blink/trunk@166493 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: | 0 | 115,230 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index)
{
bool need_put = dn->inode_page ? false : true;
int err;
err = get_dnode_of_data(dn, index, ALLOC_NODE);
if (err)
return err;
if (dn->data_blkaddr == NULL_ADDR)
err = reserve_new_block(dn);
if (err || need_put)
f2fs_put_dnode(dn);
return err;
}
Commit Message: f2fs: fix a dead loop in f2fs_fiemap()
A dead loop can be triggered in f2fs_fiemap() using the test case
as below:
...
fd = open();
fallocate(fd, 0, 0, 4294967296);
ioctl(fd, FS_IOC_FIEMAP, fiemap_buf);
...
It's caused by an overflow in __get_data_block():
...
bh->b_size = map.m_len << inode->i_blkbits;
...
map.m_len is an unsigned int, and bh->b_size is a size_t which is 64 bits
on 64 bits archtecture, type conversion from an unsigned int to a size_t
will result in an overflow.
In the above-mentioned case, bh->b_size will be zero, and f2fs_fiemap()
will call get_data_block() at block 0 again an again.
Fix this by adding a force conversion before left shift.
Signed-off-by: Wei Fang <[email protected]>
Acked-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
CWE ID: CWE-190 | 0 | 85,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: virtual void SetUp() {
fwd_txfm_ = GET_PARAM(0);
inv_txfm_ = GET_PARAM(1);
tx_type_ = GET_PARAM(2);
pitch_ = 8;
fwd_txfm_ref = fdct8x8_ref;
}
Commit Message: Merge Conflict Fix CL to lmp-mr1-release for ag/849478
DO NOT MERGE - libvpx: Pull from upstream
Current HEAD: 7105df53d7dc13d5e575bc8df714ec8d1da36b06
BUG=23452792
Change-Id: Ic78176fc369e0bacc71d423e0e2e6075d004aaec
CWE ID: CWE-119 | 1 | 174,562 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.