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 ChildProcessSecurityPolicyImpl::GrantWebUIBindings(int child_id) {
base::AutoLock lock(lock_);
SecurityStateMap::iterator state = security_state_.find(child_id);
if (state == security_state_.end())
return;
state->second->GrantBindings(BINDINGS_POLICY_WEB_UI);
state->second->GrantScheme(kChromeUIScheme);
state->second->GrantScheme(url::kFileScheme);
}
Commit Message: This patch implements a mechanism for more granular link URL permissions (filtering on scheme/host). This fixes the bug that allowed PDFs to have working links to any "chrome://" URLs.
BUG=528505,226927
Review URL: https://codereview.chromium.org/1362433002
Cr-Commit-Position: refs/heads/master@{#351705}
CWE ID: CWE-264 | 0 | 125,164 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: bool omx_vdec::align_pmem_buffers(int pmem_fd, OMX_U32 buffer_size,
OMX_U32 alignment)
{
struct pmem_allocation allocation;
allocation.size = buffer_size;
allocation.align = clip2(alignment);
if (allocation.align < 4096) {
allocation.align = 4096;
}
if (ioctl(pmem_fd, PMEM_ALLOCATE_ALIGNED, &allocation) < 0) {
DEBUG_PRINT_ERROR("Aligment(%u) failed with pmem driver Sz(%lu)",
allocation.align, allocation.size);
return false;
}
return true;
}
Commit Message: DO NOT MERGE mm-video-v4l2: vdec: Avoid processing ETBs/FTBs in invalid states
(per the spec) ETB/FTB should not be handled in states other than
Executing, Paused and Idle. This avoids accessing invalid buffers.
Also add a lock to protect the private-buffers from being deleted
while accessing from another thread.
Bug: 27890802
Security Vulnerability - Heap Use-After-Free and Possible LPE in
MediaServer (libOmxVdec problem #6)
CRs-Fixed: 1008882
Change-Id: Iaac2e383cd53cf9cf8042c9ed93ddc76dba3907e
CWE ID: | 0 | 160,221 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int nfs_can_extend_write(struct file *file, struct page *page, struct inode *inode)
{
if (file->f_flags & O_DSYNC)
return 0;
if (NFS_PROTO(inode)->have_delegation(inode, FMODE_WRITE))
return 1;
if (nfs_write_pageuptodate(page, inode) && (inode->i_flock == NULL ||
(inode->i_flock->fl_start == 0 &&
inode->i_flock->fl_end == OFFSET_MAX &&
inode->i_flock->fl_type != F_RDLCK)))
return 1;
return 0;
}
Commit Message: nfs: always make sure page is up-to-date before extending a write to cover the entire page
We should always make sure the cached page is up-to-date when we're
determining whether we can extend a write to cover the full page -- even
if we've received a write delegation from the server.
Commit c7559663 added logic to skip this check if we have a write
delegation, which can lead to data corruption such as the following
scenario if client B receives a write delegation from the NFS server:
Client A:
# echo 123456789 > /mnt/file
Client B:
# echo abcdefghi >> /mnt/file
# cat /mnt/file
0�D0�abcdefghi
Just because we hold a write delegation doesn't mean that we've read in
the entire page contents.
Cc: <stable@vger.kernel.org> # v3.11+
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
CWE ID: CWE-20 | 1 | 166,424 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: DummyPageHolder& GetDummyPageHolder() const { return *dummy_page_holder_; }
Commit Message: Move SelectionTemplate::is_handle_visible_ to FrameSelection
This patch moves |is_handle_visible_| to |FrameSelection| from |SelectionTemplate|
since handle visibility is used only for setting |FrameSelection|, hence it is
a redundant member variable of |SelectionTemplate|.
Bug: 742093
Change-Id: I3add4da3844fb40be34dcb4d4b46b5fa6fed1d7e
Reviewed-on: https://chromium-review.googlesource.com/595389
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491660}
CWE ID: CWE-119 | 0 | 124,835 |
Analyze the following 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 MPEG4Source::parseChunk(off64_t *offset) {
uint32_t hdr[2];
if (mDataSource->readAt(*offset, hdr, 8) < 8) {
return ERROR_IO;
}
uint64_t chunk_size = ntohl(hdr[0]);
uint32_t chunk_type = ntohl(hdr[1]);
off64_t data_offset = *offset + 8;
if (chunk_size == 1) {
if (mDataSource->readAt(*offset + 8, &chunk_size, 8) < 8) {
return ERROR_IO;
}
chunk_size = ntoh64(chunk_size);
data_offset += 8;
if (chunk_size < 16) {
return ERROR_MALFORMED;
}
} else if (chunk_size < 8) {
return ERROR_MALFORMED;
}
char chunk[5];
MakeFourCCString(chunk_type, chunk);
ALOGV("MPEG4Source chunk %s @ %#llx", chunk, (long long)*offset);
off64_t chunk_data_size = *offset + chunk_size - data_offset;
switch(chunk_type) {
case FOURCC('t', 'r', 'a', 'f'):
case FOURCC('m', 'o', 'o', 'f'): {
off64_t stop_offset = *offset + chunk_size;
*offset = data_offset;
while (*offset < stop_offset) {
status_t err = parseChunk(offset);
if (err != OK) {
return err;
}
}
if (chunk_type == FOURCC('m', 'o', 'o', 'f')) {
while (true) {
if (mDataSource->readAt(*offset, hdr, 8) < 8) {
break;
}
chunk_size = ntohl(hdr[0]);
chunk_type = ntohl(hdr[1]);
if (chunk_size == 1) {
if (mDataSource->readAt(*offset + 8, &chunk_size, 8) < 8) {
return ERROR_IO;
}
chunk_size = ntoh64(chunk_size);
if (chunk_size < 16) {
return ERROR_MALFORMED;
}
} else if (chunk_size == 0) {
} else if (chunk_size < 8) {
return ERROR_MALFORMED;
}
if (chunk_type == FOURCC('m', 'o', 'o', 'f')) {
mNextMoofOffset = *offset;
break;
} else if (chunk_size == 0) {
break;
}
*offset += chunk_size;
}
}
break;
}
case FOURCC('t', 'f', 'h', 'd'): {
status_t err;
if ((err = parseTrackFragmentHeader(data_offset, chunk_data_size)) != OK) {
return err;
}
*offset += chunk_size;
break;
}
case FOURCC('t', 'r', 'u', 'n'): {
status_t err;
if (mLastParsedTrackId == mTrackId) {
if ((err = parseTrackFragmentRun(data_offset, chunk_data_size)) != OK) {
return err;
}
}
*offset += chunk_size;
break;
}
case FOURCC('s', 'a', 'i', 'z'): {
status_t err;
if ((err = parseSampleAuxiliaryInformationSizes(data_offset, chunk_data_size)) != OK) {
return err;
}
*offset += chunk_size;
break;
}
case FOURCC('s', 'a', 'i', 'o'): {
status_t err;
if ((err = parseSampleAuxiliaryInformationOffsets(data_offset, chunk_data_size)) != OK) {
return err;
}
*offset += chunk_size;
break;
}
case FOURCC('m', 'd', 'a', 't'): {
ALOGV("MPEG4Source::parseChunk mdat");
*offset += chunk_size;
break;
}
default: {
*offset += chunk_size;
break;
}
}
return OK;
}
Commit Message: Skip track if verification fails
Bug: 62187433
Test: ran poc, CTS
Change-Id: Ib9b0b6de88d046d8149e9ea5073d6c40ffec7b0c
(cherry picked from commit ef8c7830d838d877e6b37b75b47294b064c79397)
CWE ID: | 0 | 162,152 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void ext4_put_super(struct super_block *sb)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
struct ext4_super_block *es = sbi->s_es;
int i, err;
ext4_unregister_li_request(sb);
dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
flush_workqueue(sbi->dio_unwritten_wq);
destroy_workqueue(sbi->dio_unwritten_wq);
lock_super(sb);
if (sb->s_dirt)
ext4_commit_super(sb, 1);
if (sbi->s_journal) {
err = jbd2_journal_destroy(sbi->s_journal);
sbi->s_journal = NULL;
if (err < 0)
ext4_abort(sb, "Couldn't clean up the journal");
}
del_timer(&sbi->s_err_report);
ext4_release_system_zone(sb);
ext4_mb_release(sb);
ext4_ext_release(sb);
ext4_xattr_put_super(sb);
if (!(sb->s_flags & MS_RDONLY)) {
EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
es->s_state = cpu_to_le16(sbi->s_mount_state);
ext4_commit_super(sb, 1);
}
if (sbi->s_proc) {
remove_proc_entry(sb->s_id, ext4_proc_root);
}
kobject_del(&sbi->s_kobj);
for (i = 0; i < sbi->s_gdb_count; i++)
brelse(sbi->s_group_desc[i]);
kfree(sbi->s_group_desc);
if (is_vmalloc_addr(sbi->s_flex_groups))
vfree(sbi->s_flex_groups);
else
kfree(sbi->s_flex_groups);
percpu_counter_destroy(&sbi->s_freeblocks_counter);
percpu_counter_destroy(&sbi->s_freeinodes_counter);
percpu_counter_destroy(&sbi->s_dirs_counter);
percpu_counter_destroy(&sbi->s_dirtyblocks_counter);
brelse(sbi->s_sbh);
#ifdef CONFIG_QUOTA
for (i = 0; i < MAXQUOTAS; i++)
kfree(sbi->s_qf_names[i]);
#endif
/* Debugging code just in case the in-memory inode orphan list
* isn't empty. The on-disk one can be non-empty if we've
* detected an error and taken the fs readonly, but the
* in-memory list had better be clean by this point. */
if (!list_empty(&sbi->s_orphan))
dump_orphan_list(sb, sbi);
J_ASSERT(list_empty(&sbi->s_orphan));
invalidate_bdev(sb->s_bdev);
if (sbi->journal_bdev && sbi->journal_bdev != sb->s_bdev) {
/*
* Invalidate the journal device's buffers. We don't want them
* floating about in memory - the physical journal device may
* hotswapped, and it breaks the `ro-after' testing code.
*/
sync_blockdev(sbi->journal_bdev);
invalidate_bdev(sbi->journal_bdev);
ext4_blkdev_remove(sbi);
}
sb->s_fs_info = NULL;
/*
* Now that we are completely done shutting down the
* superblock, we need to actually destroy the kobject.
*/
unlock_super(sb);
kobject_put(&sbi->s_kobj);
wait_for_completion(&sbi->s_kobj_unregister);
kfree(sbi->s_blockgroup_lock);
kfree(sbi);
}
Commit Message: ext4: init timer earlier to avoid a kernel panic in __save_error_info
During mount, when we fail to open journal inode or root inode, the
__save_error_info will mod_timer. But actually s_err_report isn't
initialized yet and the kernel oops. The detailed information can
be found https://bugzilla.kernel.org/show_bug.cgi?id=32082.
The best way is to check whether the timer s_err_report is initialized
or not. But it seems that in include/linux/timer.h, we can't find a
good function to check the status of this timer, so this patch just
move the initializtion of s_err_report earlier so that we can avoid
the kernel panic. The corresponding del_timer is also added in the
error path.
Reported-by: Sami Liedes <sliedes@cc.hut.fi>
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
CWE ID: | 0 | 26,948 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: cpu_cgroup_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp)
{
struct task_group *tg = cgroup_tg(cgrp);
sched_destroy_group(tg);
}
Commit Message: Sched: fix skip_clock_update optimization
idle_balance() drops/retakes rq->lock, leaving the previous task
vulnerable to set_tsk_need_resched(). Clear it after we return
from balancing instead, and in setup_thread_stack() as well, so
no successfully descheduled or never scheduled task has it set.
Need resched confused the skip_clock_update logic, which assumes
that the next call to update_rq_clock() will come nearly immediately
after being set. Make the optimization robust against the waking
a sleeper before it sucessfully deschedules case by checking that
the current task has not been dequeued before setting the flag,
since it is that useless clock update we're trying to save, and
clear unconditionally in schedule() proper instead of conditionally
in put_prev_task().
Signed-off-by: Mike Galbraith <efault@gmx.de>
Reported-by: Bjoern B. Brandenburg <bbb.lst@gmail.com>
Tested-by: Yong Zhang <yong.zhang0@gmail.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: stable@kernel.org
LKML-Reference: <1291802742.1417.9.camel@marge.simson.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
CWE ID: | 0 | 22,374 |
Analyze the following 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 CLISimpleOperatorImage(MagickCLI *cli_wand,
const char *option, const char *arg1n, const char *arg2n,
ExceptionInfo *exception)
{
Image *
new_image;
GeometryInfo
geometry_info;
RectangleInfo
geometry;
MagickStatusType
flags;
ssize_t
parse;
const char /* percent escaped versions of the args */
*arg1,
*arg2;
#define _image_info (cli_wand->wand.image_info)
#define _image (cli_wand->wand.images)
#define _exception (cli_wand->wand.exception)
#define _draw_info (cli_wand->draw_info)
#define _quantize_info (cli_wand->quantize_info)
#define _process_flags (cli_wand->process_flags)
#define _option_type ((CommandOptionFlags) cli_wand->command->flags)
#define IfNormalOp (*option=='-')
#define IfPlusOp (*option!='-')
#define IsNormalOp IfNormalOp ? MagickTrue : MagickFalse
#define IsPlusOp IfNormalOp ? MagickFalse : MagickTrue
assert(cli_wand != (MagickCLI *) NULL);
assert(cli_wand->signature == MagickWandSignature);
assert(cli_wand->wand.signature == MagickWandSignature);
assert(_image != (Image *) NULL); /* an image must be present */
if (cli_wand->wand.debug != MagickFalse)
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name);
arg1 = arg1n,
arg2 = arg2n;
/* Interpret Percent Escapes in Arguments - using first image */
if ( (((_process_flags & ProcessInterpretProperities) != 0 )
|| ((_option_type & AlwaysInterpretArgsFlag) != 0)
) && ((_option_type & NeverInterpretArgsFlag) == 0) ) {
/* Interpret Percent escapes in argument 1 */
if (arg1n != (char *) NULL) {
arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception);
if (arg1 == (char *) NULL) {
CLIWandException(OptionWarning,"InterpretPropertyFailure",option);
arg1=arg1n; /* use the given argument as is */
}
}
if (arg2n != (char *) NULL) {
arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception);
if (arg2 == (char *) NULL) {
CLIWandException(OptionWarning,"InterpretPropertyFailure",option);
arg2=arg2n; /* use the given argument as is */
}
}
}
#undef _process_flags
#undef _option_type
#if 0
(void) FormatLocaleFile(stderr,
"CLISimpleOperatorImage: \"%s\" \"%s\" \"%s\"\n",option,arg1,arg2);
#endif
new_image = (Image *) NULL; /* the replacement image, if not null at end */
SetGeometryInfo(&geometry_info);
switch (*(option+1))
{
case 'a':
{
if (LocaleCompare("adaptive-blur",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
new_image=AdaptiveBlurImage(_image,geometry_info.rho,
geometry_info.sigma,_exception);
break;
}
if (LocaleCompare("adaptive-resize",option+1) == 0)
{
/* FUTURE: Roll into a resize special operator */
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
new_image=AdaptiveResizeImage(_image,geometry.width,geometry.height,
_exception);
break;
}
if (LocaleCompare("adaptive-sharpen",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
new_image=AdaptiveSharpenImage(_image,geometry_info.rho,
geometry_info.sigma,_exception);
break;
}
if (LocaleCompare("alpha",option+1) == 0)
{
parse=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,arg1);
if (parse < 0)
CLIWandExceptArgBreak(OptionError,"UnrecognizedAlphaChannelOption",
option,arg1);
(void) SetImageAlphaChannel(_image,(AlphaChannelOption) parse,
_exception);
break;
}
if (LocaleCompare("annotate",option+1) == 0)
{
char
geometry[MagickPathExtent];
SetGeometryInfo(&geometry_info);
flags=ParseGeometry(arg1,&geometry_info);
if (flags == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=geometry_info.rho;
(void) CloneString(&_draw_info->text,arg2);
(void) FormatLocaleString(geometry,MagickPathExtent,"%+f%+f",
geometry_info.xi,geometry_info.psi);
(void) CloneString(&_draw_info->geometry,geometry);
_draw_info->affine.sx=cos(DegreesToRadians(
fmod(geometry_info.rho,360.0)));
_draw_info->affine.rx=sin(DegreesToRadians(
fmod(geometry_info.rho,360.0)));
_draw_info->affine.ry=(-sin(DegreesToRadians(
fmod(geometry_info.sigma,360.0))));
_draw_info->affine.sy=cos(DegreesToRadians(
fmod(geometry_info.sigma,360.0)));
(void) AnnotateImage(_image,_draw_info,_exception);
GetAffineMatrix(&_draw_info->affine);
break;
}
if (LocaleCompare("auto-gamma",option+1) == 0)
{
(void) AutoGammaImage(_image,_exception);
break;
}
if (LocaleCompare("auto-level",option+1) == 0)
{
(void) AutoLevelImage(_image,_exception);
break;
}
if (LocaleCompare("auto-orient",option+1) == 0)
{
new_image=AutoOrientImage(_image,_image->orientation,_exception);
break;
}
if (LocaleCompare("auto-threshold",option+1) == 0)
{
AutoThresholdMethod
method;
method=(AutoThresholdMethod) ParseCommandOption(
MagickAutoThresholdOptions,MagickFalse,arg1);
(void) AutoThresholdImage(_image,method,_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'b':
{
if (LocaleCompare("black-threshold",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) BlackThresholdImage(_image,arg1,_exception);
break;
}
if (LocaleCompare("blue-shift",option+1) == 0)
{
geometry_info.rho=1.5;
if (IfNormalOp) {
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
}
new_image=BlueShiftImage(_image,geometry_info.rho,_exception);
break;
}
if (LocaleCompare("blur",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
new_image=BlurImage(_image,geometry_info.rho,geometry_info.sigma,
_exception);
break;
}
if (LocaleCompare("border",option+1) == 0)
{
CompositeOperator
compose;
const char*
value;
flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
if ((flags & (WidthValue | HeightValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
compose=OverCompositeOp;
value=GetImageOption(_image_info,"compose");
if (value != (const char *) NULL)
compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
MagickFalse,value);
new_image=BorderImage(_image,&geometry,compose,_exception);
break;
}
if (LocaleCompare("brightness-contrast",option+1) == 0)
{
double
brightness,
contrast;
GeometryInfo
geometry_info;
MagickStatusType
flags;
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
brightness=geometry_info.rho;
contrast=0.0;
if ((flags & SigmaValue) != 0)
contrast=geometry_info.sigma;
(void) BrightnessContrastImage(_image,brightness,contrast,
_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'c':
{
if (LocaleCompare("canny",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
if ((flags & XiValue) == 0)
geometry_info.xi=10;
if ((flags & PsiValue) == 0)
geometry_info.psi=30;
if ((flags & PercentValue) != 0)
{
geometry_info.xi/=100.0;
geometry_info.psi/=100.0;
}
new_image=CannyEdgeImage(_image,geometry_info.rho,geometry_info.sigma,
geometry_info.xi,geometry_info.psi,_exception);
break;
}
if (LocaleCompare("cdl",option+1) == 0)
{
char
*color_correction_collection; /* Note: arguments do not have percent escapes expanded */
/*
Color correct with a color decision list.
*/
color_correction_collection=FileToString(arg1,~0UL,_exception);
if (color_correction_collection == (char *) NULL)
break;
(void) ColorDecisionListImage(_image,color_correction_collection,
_exception);
break;
}
if (LocaleCompare("channel",option+1) == 0)
{
if (IfPlusOp)
{
(void) SetPixelChannelMask(_image,DefaultChannels);
break;
}
parse=ParseChannelOption(arg1);
if (parse < 0)
CLIWandExceptArgBreak(OptionError,"UnrecognizedChannelType",option,
arg1);
(void) SetPixelChannelMask(_image,(ChannelType) parse);
break;
}
if (LocaleCompare("charcoal",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
if ((flags & XiValue) == 0)
geometry_info.xi=1.0;
new_image=CharcoalImage(_image,geometry_info.rho,geometry_info.sigma,
_exception);
break;
}
if (LocaleCompare("chop",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) ParseGravityGeometry(_image,arg1,&geometry,_exception);
new_image=ChopImage(_image,&geometry,_exception);
break;
}
if (LocaleCompare("clahe",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
flags=ParseGeometry(arg1,&geometry_info);
flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
(void) CLAHEImage(_image,geometry.width,geometry.height,
(size_t) geometry.x,geometry_info.psi,_exception);
break;
}
if (LocaleCompare("clamp",option+1) == 0)
{
(void) ClampImage(_image,_exception);
break;
}
if (LocaleCompare("clip",option+1) == 0)
{
if (IfNormalOp)
(void) ClipImage(_image,_exception);
else /* "+mask" remove the write mask */
(void) SetImageMask(_image,WritePixelMask,(Image *) NULL,
_exception);
break;
}
if (LocaleCompare("clip-mask",option+1) == 0)
{
Image
*clip_mask;
if (IfPlusOp) {
/* use "+clip-mask" Remove the write mask for -clip-path */
(void) SetImageMask(_image,WritePixelMask,(Image *) NULL,_exception);
break;
}
clip_mask=GetImageCache(_image_info,arg1,_exception);
if (clip_mask == (Image *) NULL)
break;
(void) SetImageMask(_image,WritePixelMask,clip_mask,_exception);
clip_mask=DestroyImage(clip_mask);
break;
}
if (LocaleCompare("clip-path",option+1) == 0)
{
(void) ClipImagePath(_image,arg1,IsNormalOp,_exception);
/* Note: Use "+clip-mask" remove the write mask added */
break;
}
if (LocaleCompare("colorize",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
new_image=ColorizeImage(_image,arg1,&_draw_info->fill,_exception);
break;
}
if (LocaleCompare("color-matrix",option+1) == 0)
{
KernelInfo
*kernel;
kernel=AcquireKernelInfo(arg1,exception);
if (kernel == (KernelInfo *) NULL)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
new_image=ColorMatrixImage(_image,kernel,_exception);
kernel=DestroyKernelInfo(kernel);
break;
}
if (LocaleCompare("colors",option+1) == 0)
{
/* Reduce the number of colors in the image.
FUTURE: also provide 'plus version with image 'color counts'
*/
_quantize_info->number_colors=StringToUnsignedLong(arg1);
if (_quantize_info->number_colors == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((_image->storage_class == DirectClass) ||
_image->colors > _quantize_info->number_colors)
(void) QuantizeImage(_quantize_info,_image,_exception);
else
(void) CompressImageColormap(_image,_exception);
break;
}
if (LocaleCompare("colorspace",option+1) == 0)
{
/* WARNING: this is both a image_info setting (already done)
and a operator to change image colorspace.
FUTURE: default colorspace should be sRGB!
Unless some type of 'linear colorspace' mode is set.
Note that +colorspace sets "undefined" or no effect on
new images, but forces images already in memory back to RGB!
That seems to be a little strange!
*/
(void) TransformImageColorspace(_image,
IfNormalOp ? _image_info->colorspace : sRGBColorspace,
_exception);
break;
}
if (LocaleCompare("connected-components",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
new_image=ConnectedComponentsImage(_image,(size_t)
StringToInteger(arg1),(CCObjectInfo **) NULL,_exception);
break;
}
if (LocaleCompare("contrast",option+1) == 0)
{
CLIWandWarnReplaced(IfNormalOp?"-level":"+level");
(void) ContrastImage(_image,IsNormalOp,_exception);
break;
}
if (LocaleCompare("contrast-stretch",option+1) == 0)
{
double
black_point,
white_point;
MagickStatusType
flags;
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
black_point=geometry_info.rho;
white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
black_point;
if ((flags & PercentValue) != 0) {
black_point*=(double) _image->columns*_image->rows/100.0;
white_point*=(double) _image->columns*_image->rows/100.0;
}
white_point=(double) _image->columns*_image->rows-white_point;
(void) ContrastStretchImage(_image,black_point,white_point,
_exception);
break;
}
if (LocaleCompare("convolve",option+1) == 0)
{
double
gamma;
KernelInfo
*kernel_info;
register ssize_t
j;
kernel_info=AcquireKernelInfo(arg1,exception);
if (kernel_info == (KernelInfo *) NULL)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
gamma=0.0;
for (j=0; j < (ssize_t) (kernel_info->width*kernel_info->height); j++)
gamma+=kernel_info->values[j];
gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma);
for (j=0; j < (ssize_t) (kernel_info->width*kernel_info->height); j++)
kernel_info->values[j]*=gamma;
new_image=MorphologyImage(_image,CorrelateMorphology,1,kernel_info,
_exception);
kernel_info=DestroyKernelInfo(kernel_info);
break;
}
if (LocaleCompare("crop",option+1) == 0)
{
/* WARNING: This can generate multiple images! */
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
new_image=CropImageToTiles(_image,arg1,_exception);
break;
}
if (LocaleCompare("cycle",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) CycleColormapImage(_image,(ssize_t) StringToLong(arg1),
_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'd':
{
if (LocaleCompare("decipher",option+1) == 0)
{
/* Note: arguments do not have percent escapes expanded */
StringInfo
*passkey;
passkey=FileToStringInfo(arg1,~0UL,_exception);
if (passkey == (StringInfo *) NULL)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) PasskeyDecipherImage(_image,passkey,_exception);
passkey=DestroyStringInfo(passkey);
break;
}
if (LocaleCompare("depth",option+1) == 0)
{
/* The _image_info->depth setting has already been set
We just need to apply it to all images in current sequence
WARNING: Depth from 8 to 16 causes 'quantum rounding to images!
That is it really is an operation, not a setting! Arrgghhh
FUTURE: this should not be an operator!!!
*/
(void) SetImageDepth(_image,_image_info->depth,_exception);
break;
}
if (LocaleCompare("deskew",option+1) == 0)
{
double
threshold;
if (IfNormalOp) {
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0);
}
else
threshold=40.0*QuantumRange/100.0;
new_image=DeskewImage(_image,threshold,_exception);
break;
}
if (LocaleCompare("despeckle",option+1) == 0)
{
new_image=DespeckleImage(_image,_exception);
break;
}
if (LocaleCompare("distort",option+1) == 0)
{
double
*args;
ssize_t
count;
parse = ParseCommandOption(MagickDistortOptions,MagickFalse,arg1);
if ( parse < 0 )
CLIWandExceptArgBreak(OptionError,"UnrecognizedDistortMethod",
option,arg1);
if ((DistortMethod) parse == ResizeDistortion)
{
double
resize_args[2];
/* Special Case - Argument is actually a resize geometry!
** Convert that to an appropriate distortion argument array.
** FUTURE: make a separate special resize operator
Roll into a resize special operator */
if (IsGeometry(arg2) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidGeometry",
option,arg2);
(void) ParseRegionGeometry(_image,arg2,&geometry,_exception);
resize_args[0]=(double) geometry.width;
resize_args[1]=(double) geometry.height;
new_image=DistortImage(_image,(DistortMethod) parse,
(size_t)2,resize_args,MagickTrue,_exception);
break;
}
/* convert argument string into an array of doubles */
args = StringToArrayOfDoubles(arg2,&count,_exception);
if (args == (double *) NULL )
CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2);
new_image=DistortImage(_image,(DistortMethod) parse,(size_t)
count,args,IsPlusOp,_exception);
args=(double *) RelinquishMagickMemory(args);
break;
}
if (LocaleCompare("draw",option+1) == 0)
{
(void) CloneString(&_draw_info->primitive,arg1);
(void) DrawImage(_image,_draw_info,_exception);
(void) CloneString(&_draw_info->primitive,(char *) NULL);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'e':
{
if (LocaleCompare("edge",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
new_image=EdgeImage(_image,geometry_info.rho,_exception);
break;
}
if (LocaleCompare("emboss",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
new_image=EmbossImage(_image,geometry_info.rho,
geometry_info.sigma,_exception);
break;
}
if (LocaleCompare("encipher",option+1) == 0)
{
/* Note: arguments do not have percent escapes expanded */
StringInfo
*passkey;
passkey=FileToStringInfo(arg1,~0UL,_exception);
if (passkey != (StringInfo *) NULL)
{
(void) PasskeyEncipherImage(_image,passkey,_exception);
passkey=DestroyStringInfo(passkey);
}
break;
}
if (LocaleCompare("enhance",option+1) == 0)
{
new_image=EnhanceImage(_image,_exception);
break;
}
if (LocaleCompare("equalize",option+1) == 0)
{
(void) EqualizeImage(_image,_exception);
break;
}
if (LocaleCompare("evaluate",option+1) == 0)
{
double
constant;
parse = ParseCommandOption(MagickEvaluateOptions,MagickFalse,arg1);
if ( parse < 0 )
CLIWandExceptArgBreak(OptionError,"UnrecognizedEvaluateOperator",
option,arg1);
if (IsGeometry(arg2) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2);
constant=StringToDoubleInterval(arg2,(double) QuantumRange+1.0);
(void) EvaluateImage(_image,(MagickEvaluateOperator)parse,constant,
_exception);
break;
}
if (LocaleCompare("extent",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
flags=ParseGravityGeometry(_image,arg1,&geometry,_exception);
if (geometry.width == 0)
geometry.width=_image->columns;
if (geometry.height == 0)
geometry.height=_image->rows;
new_image=ExtentImage(_image,&geometry,_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'f':
{
if (LocaleCompare("flip",option+1) == 0)
{
new_image=FlipImage(_image,_exception);
break;
}
if (LocaleCompare("flop",option+1) == 0)
{
new_image=FlopImage(_image,_exception);
break;
}
if (LocaleCompare("floodfill",option+1) == 0)
{
PixelInfo
target;
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) ParsePageGeometry(_image,arg1,&geometry,_exception);
(void) QueryColorCompliance(arg2,AllCompliance,&target,_exception);
(void) FloodfillPaintImage(_image,_draw_info,&target,geometry.x,
geometry.y,IsPlusOp,_exception);
break;
}
if (LocaleCompare("frame",option+1) == 0)
{
FrameInfo
frame_info;
CompositeOperator
compose;
const char*
value;
value=GetImageOption(_image_info,"compose");
compose=OverCompositeOp; /* use Over not _image->compose */
if (value != (const char *) NULL)
compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
MagickFalse,value);
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
frame_info.width=geometry.width;
frame_info.height=geometry.height;
frame_info.outer_bevel=geometry.x;
frame_info.inner_bevel=geometry.y;
frame_info.x=(ssize_t) frame_info.width;
frame_info.y=(ssize_t) frame_info.height;
frame_info.width=_image->columns+2*frame_info.width;
frame_info.height=_image->rows+2*frame_info.height;
new_image=FrameImage(_image,&frame_info,compose,_exception);
break;
}
if (LocaleCompare("function",option+1) == 0)
{
double
*args;
ssize_t
count;
parse=ParseCommandOption(MagickFunctionOptions,MagickFalse,arg1);
if ( parse < 0 )
CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction",
option,arg1);
/* convert argument string into an array of doubles */
args = StringToArrayOfDoubles(arg2,&count,_exception);
if (args == (double *) NULL )
CLIWandExceptArgBreak(OptionError,"InvalidNumberList",option,arg2);
(void) FunctionImage(_image,(MagickFunction)parse,(size_t) count,args,
_exception);
args=(double *) RelinquishMagickMemory(args);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'g':
{
if (LocaleCompare("gamma",option+1) == 0)
{
double
constant;
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
constant=StringToDouble(arg1,(char **) NULL);
#if 0
/* Using Gamma, via a cache */
if (IfPlusOp)
constant=PerceptibleReciprocal(constant);
(void) GammaImage(_image,constant,_exception);
#else
/* Using Evaluate POW, direct update of values - more accurite */
if (IfNormalOp)
constant=PerceptibleReciprocal(constant);
(void) EvaluateImage(_image,PowEvaluateOperator,constant,_exception);
_image->gamma*=StringToDouble(arg1,(char **) NULL);
#endif
/* Set gamma setting -- Old meaning of "+gamma"
* _image->gamma=StringToDouble(arg1,(char **) NULL);
*/
break;
}
if (LocaleCompare("gaussian-blur",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
new_image=GaussianBlurImage(_image,geometry_info.rho,
geometry_info.sigma,_exception);
break;
}
if (LocaleCompare("gaussian",option+1) == 0)
{
CLIWandWarnReplaced("-gaussian-blur");
(void) CLISimpleOperatorImage(cli_wand,"-gaussian-blur",arg1,NULL,exception);
}
if (LocaleCompare("geometry",option+1) == 0)
{
/*
Record Image offset for composition. (A Setting)
Resize last _image. (ListOperator) -- DEPRECIATE
FUTURE: Why if no 'offset' does this resize ALL images?
Also why is the setting recorded in the IMAGE non-sense!
*/
if (IfPlusOp)
{ /* remove the previous composition geometry offset! */
if (_image->geometry != (char *) NULL)
_image->geometry=DestroyString(_image->geometry);
break;
}
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
if (((flags & XValue) != 0) || ((flags & YValue) != 0))
(void) CloneString(&_image->geometry,arg1);
else
new_image=ResizeImage(_image,geometry.width,geometry.height,
_image->filter,_exception);
break;
}
if (LocaleCompare("grayscale",option+1) == 0)
{
parse=ParseCommandOption(MagickPixelIntensityOptions,
MagickFalse,arg1);
if (parse < 0)
CLIWandExceptArgBreak(OptionError,"UnrecognizedIntensityMethod",
option,arg1);
(void) GrayscaleImage(_image,(PixelIntensityMethod) parse,_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'h':
{
if (LocaleCompare("hough-lines",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=geometry_info.rho;
if ((flags & XiValue) == 0)
geometry_info.xi=40;
new_image=HoughLineImage(_image,(size_t) geometry_info.rho,
(size_t) geometry_info.sigma,(size_t) geometry_info.xi,_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'i':
{
if (LocaleCompare("identify",option+1) == 0)
{
const char
*format,
*text;
format=GetImageOption(_image_info,"format");
if (format == (char *) NULL)
{
(void) IdentifyImage(_image,stdout,_image_info->verbose,
_exception);
break;
}
text=InterpretImageProperties(_image_info,_image,format,_exception);
if (text == (char *) NULL)
CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure",
option);
(void) fputs(text,stdout);
text=DestroyString((char *)text);
break;
}
if (LocaleCompare("implode",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
new_image=ImplodeImage(_image,geometry_info.rho,_image->interpolate,
_exception);
break;
}
if (LocaleCompare("interpolative-resize",option+1) == 0)
{
/* FUTURE: New to IMv7
Roll into a resize special operator */
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
new_image=InterpolativeResizeImage(_image,geometry.width,
geometry.height,_image->interpolate,_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'k':
{
if (LocaleCompare("kuwahara",option+1) == 0)
{
/*
Edge preserving blur.
*/
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=geometry_info.rho-0.5;
new_image=KuwaharaImage(_image,geometry_info.rho,geometry_info.sigma,
_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'l':
{
if (LocaleCompare("lat",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
if ((flags & PercentValue) != 0)
geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
new_image=AdaptiveThresholdImage(_image,(size_t) geometry_info.rho,
(size_t) geometry_info.sigma,(double) geometry_info.xi,
_exception);
break;
}
if (LocaleCompare("level",option+1) == 0)
{
double
black_point,
gamma,
white_point;
MagickStatusType
flags;
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
black_point=geometry_info.rho;
white_point=(double) QuantumRange;
if ((flags & SigmaValue) != 0)
white_point=geometry_info.sigma;
gamma=1.0;
if ((flags & XiValue) != 0)
gamma=geometry_info.xi;
if ((flags & PercentValue) != 0)
{
black_point*=(double) (QuantumRange/100.0);
white_point*=(double) (QuantumRange/100.0);
}
if ((flags & SigmaValue) == 0)
white_point=(double) QuantumRange-black_point;
if (IfPlusOp || ((flags & AspectValue) != 0))
(void) LevelizeImage(_image,black_point,white_point,gamma,_exception);
else
(void) LevelImage(_image,black_point,white_point,gamma,_exception);
break;
}
if (LocaleCompare("level-colors",option+1) == 0)
{
char
token[MagickPathExtent];
const char
*p;
PixelInfo
black_point,
white_point;
p=(const char *) arg1;
GetNextToken(p,&p,MagickPathExtent,token); /* get black point color */
if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
(void) QueryColorCompliance(token,AllCompliance,
&black_point,_exception);
else
(void) QueryColorCompliance("#000000",AllCompliance,
&black_point,_exception);
if (isalpha((int) token[0]) || (token[0] == '#'))
GetNextToken(p,&p,MagickPathExtent,token);
if (*token == '\0')
white_point=black_point; /* set everything to that color */
else
{
if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
GetNextToken(p,&p,MagickPathExtent,token); /* Get white point color. */
if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
(void) QueryColorCompliance(token,AllCompliance,
&white_point,_exception);
else
(void) QueryColorCompliance("#ffffff",AllCompliance,
&white_point,_exception);
}
(void) LevelImageColors(_image,&black_point,&white_point,
IsPlusOp,_exception);
break;
}
if (LocaleCompare("linear-stretch",option+1) == 0)
{
double
black_point,
white_point;
MagickStatusType
flags;
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
black_point=geometry_info.rho;
white_point=(double) _image->columns*_image->rows;
if ((flags & SigmaValue) != 0)
white_point=geometry_info.sigma;
if ((flags & PercentValue) != 0)
{
black_point*=(double) _image->columns*_image->rows/100.0;
white_point*=(double) _image->columns*_image->rows/100.0;
}
if ((flags & SigmaValue) == 0)
white_point=(double) _image->columns*_image->rows-
black_point;
(void) LinearStretchImage(_image,black_point,white_point,_exception);
break;
}
if (LocaleCompare("liquid-rescale",option+1) == 0)
{
/* FUTURE: Roll into a resize special operator */
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
flags=ParseRegionGeometry(_image,arg1,&geometry,_exception);
if ((flags & XValue) == 0)
geometry.x=1;
if ((flags & YValue) == 0)
geometry.y=0;
new_image=LiquidRescaleImage(_image,geometry.width,
geometry.height,1.0*geometry.x,1.0*geometry.y,_exception);
break;
}
if (LocaleCompare("local-contrast",option+1) == 0)
{
MagickStatusType
flags;
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
geometry_info.rho=10;
if ((flags & SigmaValue) == 0)
geometry_info.sigma=12.5;
new_image=LocalContrastImage(_image,geometry_info.rho,
geometry_info.sigma,exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'm':
{
if (LocaleCompare("magnify",option+1) == 0)
{
new_image=MagnifyImage(_image,_exception);
break;
}
if (LocaleCompare("map",option+1) == 0)
{
CLIWandWarnReplaced("-remap");
(void) CLISimpleOperatorImage(cli_wand,"-remap",NULL,NULL,exception);
break;
}
if (LocaleCompare("mask",option+1) == 0)
{
Image
*mask;
if (IfPlusOp)
{
/*
Remove a mask.
*/
(void) SetImageMask(_image,WritePixelMask,(Image *) NULL,
_exception);
break;
}
/*
Set the image mask.
*/
mask=GetImageCache(_image_info,arg1,_exception);
if (mask == (Image *) NULL)
break;
(void) SetImageMask(_image,WritePixelMask,mask,_exception);
mask=DestroyImage(mask);
break;
}
if (LocaleCompare("matte",option+1) == 0)
{
CLIWandWarnReplaced(IfNormalOp?"-alpha Set":"-alpha Off");
(void) SetImageAlphaChannel(_image,IfNormalOp ? SetAlphaChannel :
DeactivateAlphaChannel, _exception);
break;
}
if (LocaleCompare("mean-shift",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
if ((flags & XiValue) == 0)
geometry_info.xi=0.10*QuantumRange;
if ((flags & PercentValue) != 0)
geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
new_image=MeanShiftImage(_image,(size_t) geometry_info.rho,
(size_t) geometry_info.sigma,geometry_info.xi,_exception);
break;
}
if (LocaleCompare("median",option+1) == 0)
{
CLIWandWarnReplaced("-statistic Median");
(void) CLISimpleOperatorImage(cli_wand,"-statistic","Median",arg1,exception);
break;
}
if (LocaleCompare("mode",option+1) == 0)
{
/* FUTURE: note this is also a special "montage" option */
CLIWandWarnReplaced("-statistic Mode");
(void) CLISimpleOperatorImage(cli_wand,"-statistic","Mode",arg1,exception);
break;
}
if (LocaleCompare("modulate",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) ModulateImage(_image,arg1,_exception);
break;
}
if (LocaleCompare("monitor",option+1) == 0)
{
(void) SetImageProgressMonitor(_image, IfNormalOp ? MonitorProgress :
(MagickProgressMonitor) NULL,(void *) NULL);
break;
}
if (LocaleCompare("monochrome",option+1) == 0)
{
(void) SetImageType(_image,BilevelType,_exception);
break;
}
if (LocaleCompare("morphology",option+1) == 0)
{
char
token[MagickPathExtent];
const char
*p;
KernelInfo
*kernel;
ssize_t
iterations;
p=arg1;
GetNextToken(p,&p,MagickPathExtent,token);
parse=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token);
if ( parse < 0 )
CLIWandExceptArgBreak(OptionError,"UnrecognizedFunction",option,
arg1);
iterations=1L;
GetNextToken(p,&p,MagickPathExtent,token);
if ((*p == ':') || (*p == ','))
GetNextToken(p,&p,MagickPathExtent,token);
if ((*p != '\0'))
iterations=(ssize_t) StringToLong(p);
kernel=AcquireKernelInfo(arg2,exception);
if (kernel == (KernelInfo *) NULL)
CLIWandExceptArgBreak(OptionError,"UnabletoParseKernel",option,arg2);
new_image=MorphologyImage(_image,(MorphologyMethod)parse,iterations,
kernel,_exception);
kernel=DestroyKernelInfo(kernel);
break;
}
if (LocaleCompare("motion-blur",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
new_image=MotionBlurImage(_image,geometry_info.rho,geometry_info.sigma,
geometry_info.xi,_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'n':
{
if (LocaleCompare("negate",option+1) == 0)
{
(void) NegateImage(_image, IsPlusOp, _exception);
break;
}
if (LocaleCompare("noise",option+1) == 0)
{
double
attenuate;
const char*
value;
if (IfNormalOp)
{
CLIWandWarnReplaced("-statistic NonPeak");
(void) CLISimpleOperatorImage(cli_wand,"-statistic","NonPeak",arg1,exception);
break;
}
parse=ParseCommandOption(MagickNoiseOptions,MagickFalse,arg1);
if ( parse < 0 )
CLIWandExceptArgBreak(OptionError,"UnrecognizedNoiseType",
option,arg1);
attenuate=1.0;
value=GetImageOption(_image_info,"attenuate");
if (value != (const char *) NULL)
attenuate=StringToDouble(value,(char **) NULL);
new_image=AddNoiseImage(_image,(NoiseType)parse,attenuate,
_exception);
break;
}
if (LocaleCompare("normalize",option+1) == 0)
{
(void) NormalizeImage(_image,_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'o':
{
if (LocaleCompare("opaque",option+1) == 0)
{
PixelInfo
target;
(void) QueryColorCompliance(arg1,AllCompliance,&target,_exception);
(void) OpaquePaintImage(_image,&target,&_draw_info->fill,IsPlusOp,
_exception);
break;
}
if (LocaleCompare("ordered-dither",option+1) == 0)
{
(void) OrderedDitherImage(_image,arg1,_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'p':
{
if (LocaleCompare("paint",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
new_image=OilPaintImage(_image,geometry_info.rho,geometry_info.sigma,
_exception);
break;
}
if (LocaleCompare("perceptible",option+1) == 0)
{
(void) PerceptibleImage(_image,StringToDouble(arg1,(char **) NULL),
_exception);
break;
}
if (LocaleCompare("polaroid",option+1) == 0)
{
const char
*caption;
double
angle;
if (IfPlusOp) {
RandomInfo
*random_info;
random_info=AcquireRandomInfo();
angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
random_info=DestroyRandomInfo(random_info);
}
else {
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
angle=geometry_info.rho;
}
caption=GetImageProperty(_image,"caption",_exception);
new_image=PolaroidImage(_image,_draw_info,caption,angle,
_image->interpolate,_exception);
break;
}
if (LocaleCompare("posterize",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) PosterizeImage(_image,(size_t) geometry_info.rho,
_quantize_info->dither_method,_exception);
break;
}
if (LocaleCompare("preview",option+1) == 0)
{
/* FUTURE: should be a 'Genesis' option?
Option however is also in WandSettingOptionInfo()
Why???
*/
parse=ParseCommandOption(MagickPreviewOptions, MagickFalse,arg1);
if ( parse < 0 )
CLIWandExceptArgBreak(OptionError,"UnrecognizedPreviewType",
option,arg1);
new_image=PreviewImage(_image,(PreviewType)parse,_exception);
break;
}
if (LocaleCompare("profile",option+1) == 0)
{
const char
*name;
const StringInfo
*profile;
Image
*profile_image;
ImageInfo
*profile_info;
/* Note: arguments do not have percent escapes expanded */
if (IfPlusOp)
{ /* Remove a profile from the _image. */
(void) ProfileImage(_image,arg1,(const unsigned char *)
NULL,0,_exception);
break;
}
/* Associate a profile with the _image. */
profile_info=CloneImageInfo(_image_info);
profile=GetImageProfile(_image,"iptc");
if (profile != (StringInfo *) NULL)
profile_info->profile=(void *) CloneStringInfo(profile);
profile_image=GetImageCache(profile_info,arg1,_exception);
profile_info=DestroyImageInfo(profile_info);
if (profile_image == (Image *) NULL)
{
StringInfo
*profile;
profile_info=CloneImageInfo(_image_info);
(void) CopyMagickString(profile_info->filename,arg1,
MagickPathExtent);
profile=FileToStringInfo(profile_info->filename,~0UL,_exception);
if (profile != (StringInfo *) NULL)
{
(void) SetImageInfo(profile_info,0,_exception);
(void) ProfileImage(_image,profile_info->magick,
GetStringInfoDatum(profile),(size_t)
GetStringInfoLength(profile),_exception);
profile=DestroyStringInfo(profile);
}
profile_info=DestroyImageInfo(profile_info);
break;
}
ResetImageProfileIterator(profile_image);
name=GetNextImageProfile(profile_image);
while (name != (const char *) NULL)
{
profile=GetImageProfile(profile_image,name);
if (profile != (StringInfo *) NULL)
(void) ProfileImage(_image,name,GetStringInfoDatum(profile),
(size_t) GetStringInfoLength(profile),_exception);
name=GetNextImageProfile(profile_image);
}
profile_image=DestroyImage(profile_image);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'r':
{
if (LocaleCompare("raise",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
(void) RaiseImage(_image,&geometry,IsNormalOp,_exception);
break;
}
if (LocaleCompare("random-threshold",option+1) == 0)
{
double
min_threshold,
max_threshold;
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
min_threshold=0.0;
max_threshold=(double) QuantumRange;
flags=ParseGeometry(arg1,&geometry_info);
min_threshold=geometry_info.rho;
max_threshold=geometry_info.sigma;
if ((flags & SigmaValue) == 0)
max_threshold=min_threshold;
if (strchr(arg1,'%') != (char *) NULL)
{
max_threshold*=(double) (0.01*QuantumRange);
min_threshold*=(double) (0.01*QuantumRange);
}
(void) RandomThresholdImage(_image,min_threshold,max_threshold,
_exception);
break;
}
if (LocaleCompare("range-threshold",option+1) == 0)
{
/*
Range threshold image.
*/
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=geometry_info.rho;
if ((flags & XiValue) == 0)
geometry_info.xi=geometry_info.sigma;
if ((flags & PsiValue) == 0)
geometry_info.psi=geometry_info.xi;
if (strchr(arg1,'%') != (char *) NULL)
{
geometry_info.rho*=(double) (0.01*QuantumRange);
geometry_info.sigma*=(double) (0.01*QuantumRange);
geometry_info.xi*=(double) (0.01*QuantumRange);
geometry_info.psi*=(double) (0.01*QuantumRange);
}
(void) RangeThresholdImage(_image,geometry_info.rho,
geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
break;
}
if (LocaleCompare("read-mask",option+1) == 0)
{
/* Note: arguments do not have percent escapes expanded */
Image
*mask;
if (IfPlusOp)
{ /* Remove a mask. */
(void) SetImageMask(_image,ReadPixelMask,(Image *) NULL,
_exception);
break;
}
/* Set the image mask. */
mask=GetImageCache(_image_info,arg1,_exception);
if (mask == (Image *) NULL)
break;
(void) SetImageMask(_image,ReadPixelMask,mask,_exception);
mask=DestroyImage(mask);
break;
}
if (LocaleCompare("recolor",option+1) == 0)
{
CLIWandWarnReplaced("-color-matrix");
(void) CLISimpleOperatorImage(cli_wand,"-color-matrix",arg1,NULL,
exception);
}
if (LocaleCompare("region",option+1) == 0)
{
if (*option == '+')
{
(void) SetImageRegionMask(_image,WritePixelMask,
(const RectangleInfo *) NULL,_exception);
break;
}
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) ParseGravityGeometry(_image,arg1,&geometry,_exception);
(void) SetImageRegionMask(_image,WritePixelMask,&geometry,_exception);
break;
}
if (LocaleCompare("remap",option+1) == 0)
{
/* Note: arguments do not have percent escapes expanded */
Image
*remap_image;
remap_image=GetImageCache(_image_info,arg1,_exception);
if (remap_image == (Image *) NULL)
break;
(void) RemapImage(_quantize_info,_image,remap_image,_exception);
remap_image=DestroyImage(remap_image);
break;
}
if (LocaleCompare("repage",option+1) == 0)
{
if (IfNormalOp)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,
arg1);
(void) ResetImagePage(_image,arg1);
}
else
(void) ParseAbsoluteGeometry("0x0+0+0",&_image->page);
break;
}
if (LocaleCompare("resample",option+1) == 0)
{
/* FUTURE: Roll into a resize special operation */
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=geometry_info.rho;
new_image=ResampleImage(_image,geometry_info.rho,
geometry_info.sigma,_image->filter,_exception);
break;
}
if (LocaleCompare("resize",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
new_image=ResizeImage(_image,geometry.width,geometry.height,
_image->filter,_exception);
break;
}
if (LocaleCompare("roll",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
if ((flags & PercentValue) != 0)
{
geometry.x*=(double) _image->columns/100.0;
geometry.y*=(double) _image->rows/100.0;
}
new_image=RollImage(_image,geometry.x,geometry.y,_exception);
break;
}
if (LocaleCompare("rotate",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & GreaterValue) != 0 && (_image->columns <= _image->rows))
break;
if ((flags & LessValue) != 0 && (_image->columns >= _image->rows))
break;
new_image=RotateImage(_image,geometry_info.rho,_exception);
break;
}
if (LocaleCompare("rotational-blur",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
new_image=RotationalBlurImage(_image,geometry_info.rho,_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 's':
{
if (LocaleCompare("sample",option+1) == 0)
{
/* FUTURE: Roll into a resize special operator */
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
new_image=SampleImage(_image,geometry.width,geometry.height,
_exception);
break;
}
if (LocaleCompare("scale",option+1) == 0)
{
/* FUTURE: Roll into a resize special operator */
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
new_image=ScaleImage(_image,geometry.width,geometry.height,
_exception);
break;
}
if (LocaleCompare("segment",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
(void) SegmentImage(_image,_image->colorspace,
_image_info->verbose,geometry_info.rho,geometry_info.sigma,
_exception);
break;
}
if (LocaleCompare("selective-blur",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
if ((flags & PercentValue) != 0)
geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
new_image=SelectiveBlurImage(_image,geometry_info.rho,
geometry_info.sigma,geometry_info.xi,_exception);
break;
}
if (LocaleCompare("separate",option+1) == 0)
{
/* WARNING: This can generate multiple images! */
/* FUTURE - this may be replaced by a "-channel" method */
new_image=SeparateImages(_image,_exception);
break;
}
if (LocaleCompare("sepia-tone",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
new_image=SepiaToneImage(_image,StringToDoubleInterval(arg1,
(double) QuantumRange+1.0),_exception);
break;
}
if (LocaleCompare("shade",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if (((flags & RhoValue) == 0) || ((flags & SigmaValue) == 0))
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
new_image=ShadeImage(_image,IsNormalOp,geometry_info.rho,
geometry_info.sigma,_exception);
break;
}
if (LocaleCompare("shadow",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
if ((flags & XiValue) == 0)
geometry_info.xi=4.0;
if ((flags & PsiValue) == 0)
geometry_info.psi=4.0;
new_image=ShadowImage(_image,geometry_info.rho,geometry_info.sigma,
(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
ceil(geometry_info.psi-0.5),_exception);
break;
}
if (LocaleCompare("sharpen",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
if ((flags & XiValue) == 0)
geometry_info.xi=0.0;
new_image=SharpenImage(_image,geometry_info.rho,geometry_info.sigma,
_exception);
break;
}
if (LocaleCompare("shave",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
flags=ParsePageGeometry(_image,arg1,&geometry,_exception);
new_image=ShaveImage(_image,&geometry,_exception);
break;
}
if (LocaleCompare("shear",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=geometry_info.rho;
new_image=ShearImage(_image,geometry_info.rho,geometry_info.sigma,
_exception);
break;
}
if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=(double) QuantumRange/2.0;
if ((flags & PercentValue) != 0)
geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
100.0;
(void) SigmoidalContrastImage(_image,IsNormalOp,geometry_info.rho,
geometry_info.sigma,_exception);
break;
}
if (LocaleCompare("sketch",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
new_image=SketchImage(_image,geometry_info.rho,
geometry_info.sigma,geometry_info.xi,_exception);
break;
}
if (LocaleCompare("solarize",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) SolarizeImage(_image,StringToDoubleInterval(arg1,(double)
QuantumRange+1.0),_exception);
break;
}
if (LocaleCompare("sparse-color",option+1) == 0)
{
parse= ParseCommandOption(MagickSparseColorOptions,MagickFalse,arg1);
if ( parse < 0 )
CLIWandExceptArgBreak(OptionError,"UnrecognizedSparseColorMethod",
option,arg1);
new_image=SparseColorOption(_image,(SparseColorMethod)parse,arg2,
_exception);
break;
}
if (LocaleCompare("splice",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
flags=ParseGravityGeometry(_image,arg1,&geometry,_exception);
new_image=SpliceImage(_image,&geometry,_exception);
break;
}
if (LocaleCompare("spread",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2);
new_image=SpreadImage(_image,_image->interpolate,geometry_info.rho,
_exception);
break;
}
if (LocaleCompare("statistic",option+1) == 0)
{
parse=ParseCommandOption(MagickStatisticOptions,MagickFalse,arg1);
if ( parse < 0 )
CLIWandExceptArgBreak(OptionError,"UnrecognizedStatisticType",
option,arg1);
flags=ParseGeometry(arg2,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg2);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=geometry_info.rho;
new_image=StatisticImage(_image,(StatisticType)parse,
(size_t) geometry_info.rho,(size_t) geometry_info.sigma,
_exception);
break;
}
if (LocaleCompare("strip",option+1) == 0)
{
(void) StripImage(_image,_exception);
break;
}
if (LocaleCompare("swirl",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
new_image=SwirlImage(_image,geometry_info.rho,
_image->interpolate,_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 't':
{
if (LocaleCompare("threshold",option+1) == 0)
{
double
threshold;
threshold=(double) QuantumRange/2;
if (IfNormalOp) {
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
threshold=StringToDoubleInterval(arg1,(double) QuantumRange+1.0);
}
(void) BilevelImage(_image,threshold,_exception);
break;
}
if (LocaleCompare("thumbnail",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) ParseRegionGeometry(_image,arg1,&geometry,_exception);
new_image=ThumbnailImage(_image,geometry.width,geometry.height,
_exception);
break;
}
if (LocaleCompare("tint",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
new_image=TintImage(_image,arg1,&_draw_info->fill,_exception);
break;
}
if (LocaleCompare("transform",option+1) == 0)
{
CLIWandWarnReplaced("+distort AffineProjection");
new_image=AffineTransformImage(_image,&_draw_info->affine,_exception);
break;
}
if (LocaleCompare("transparent",option+1) == 0)
{
PixelInfo
target;
(void) QueryColorCompliance(arg1,AllCompliance,&target,_exception);
(void) TransparentPaintImage(_image,&target,(Quantum)
TransparentAlpha,IsPlusOp,_exception);
break;
}
if (LocaleCompare("transpose",option+1) == 0)
{
new_image=TransposeImage(_image,_exception);
break;
}
if (LocaleCompare("transverse",option+1) == 0)
{
new_image=TransverseImage(_image,_exception);
break;
}
if (LocaleCompare("trim",option+1) == 0)
{
new_image=TrimImage(_image,_exception);
break;
}
if (LocaleCompare("type",option+1) == 0)
{
/* Note that "type" setting should have already been defined */
(void) SetImageType(_image,_image_info->type,_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'u':
{
if (LocaleCompare("unique",option+1) == 0)
{
/* FUTURE: move to SyncImageSettings() and AcqireImage()???
Option is not documented, bt appears to be for "identify".
We may need a identify specific verbose!
*/
if (IsPlusOp) {
(void) DeleteImageArtifact(_image,"identify:unique-colors");
break;
}
(void) SetImageArtifact(_image,"identify:unique-colors","true");
(void) SetImageArtifact(_image,"verbose","true");
break;
}
if (LocaleCompare("unique-colors",option+1) == 0)
{
new_image=UniqueImageColors(_image,_exception);
break;
}
if (LocaleCompare("unsharp",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
if ((flags & XiValue) == 0)
geometry_info.xi=1.0;
if ((flags & PsiValue) == 0)
geometry_info.psi=0.05;
new_image=UnsharpMaskImage(_image,geometry_info.rho,
geometry_info.sigma,geometry_info.xi,geometry_info.psi,_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'v':
{
if (LocaleCompare("verbose",option+1) == 0)
{
/* FUTURE: move to SyncImageSettings() and AcquireImage()???
three places! ImageArtifact ImageOption _image_info->verbose
Some how new images also get this artifact!
*/
(void) SetImageArtifact(_image,option+1,
IfNormalOp ? "true" : "false" );
break;
}
if (LocaleCompare("vignette",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
if ((flags & XiValue) == 0)
geometry_info.xi=0.1*_image->columns;
if ((flags & PsiValue) == 0)
geometry_info.psi=0.1*_image->rows;
if ((flags & PercentValue) != 0)
{
geometry_info.xi*=(double) _image->columns/100.0;
geometry_info.psi*=(double) _image->rows/100.0;
}
new_image=VignetteImage(_image,geometry_info.rho,geometry_info.sigma,
(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
ceil(geometry_info.psi-0.5),_exception);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'w':
{
if (LocaleCompare("wave",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & (RhoValue|SigmaValue)) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & SigmaValue) == 0)
geometry_info.sigma=1.0;
new_image=WaveImage(_image,geometry_info.rho,geometry_info.sigma,
_image->interpolate,_exception);
break;
}
if (LocaleCompare("wavelet-denoise",option+1) == 0)
{
flags=ParseGeometry(arg1,&geometry_info);
if ((flags & RhoValue) == 0)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
if ((flags & PercentValue) != 0)
{
geometry_info.rho=QuantumRange*geometry_info.rho/100.0;
geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
}
if ((flags & SigmaValue) == 0)
geometry_info.sigma=0.0;
new_image=WaveletDenoiseImage(_image,geometry_info.rho,
geometry_info.sigma,_exception);
break;
}
if (LocaleCompare("white-threshold",option+1) == 0)
{
if (IsGeometry(arg1) == MagickFalse)
CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
(void) WhiteThresholdImage(_image,arg1,_exception);
break;
}
if (LocaleCompare("write-mask",option+1) == 0)
{
/* Note: arguments do not have percent escapes expanded */
Image
*mask;
if (IfPlusOp)
{ /* Remove a mask. */
(void) SetImageMask(_image,WritePixelMask,(Image *) NULL,
_exception);
break;
}
/* Set the image mask. */
mask=GetImageCache(_image_info,arg1,_exception);
if (mask == (Image *) NULL)
break;
(void) SetImageMask(_image,WritePixelMask,mask,_exception);
mask=DestroyImage(mask);
break;
}
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
default:
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
/* clean up percent escape interpreted strings */
if (arg1 != arg1n )
arg1=DestroyString((char *)arg1);
if (arg2 != arg2n )
arg2=DestroyString((char *)arg2);
/* Replace current image with any image that was generated
and set image point to last image (so image->next is correct) */
if (new_image != (Image *) NULL)
ReplaceImageInListReturnLast(&_image,new_image);
return(MagickTrue);
#undef _image_info
#undef _draw_info
#undef _quantize_info
#undef _image
#undef _exception
#undef IfNormalOp
#undef IfPlusOp
#undef IsNormalOp
#undef IsPlusOp
}
Commit Message: https://github.com/ImageMagick/ImageMagick/issues/1604
CWE ID: CWE-399 | 0 | 89,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: void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask)
{
struct rq *rq = task_rq(p);
bool queued, running;
lockdep_assert_held(&p->pi_lock);
queued = task_on_rq_queued(p);
running = task_current(rq, p);
if (queued) {
/*
* Because __kthread_bind() calls this on blocked tasks without
* holding rq->lock.
*/
lockdep_assert_held(&rq->lock);
dequeue_task(rq, p, DEQUEUE_SAVE);
}
if (running)
put_prev_task(rq, p);
p->sched_class->set_cpus_allowed(p, new_mask);
if (running)
p->sched_class->set_curr_task(rq);
if (queued)
enqueue_task(rq, p, ENQUEUE_RESTORE);
}
Commit Message: Merge branch 'stacking-fixes' (vfs stacking fixes from Jann)
Merge filesystem stacking fixes from Jann Horn.
* emailed patches from Jann Horn <jannh@google.com>:
sched: panic on corrupted stack end
ecryptfs: forbid opening files without mmap handler
proc: prevent stacking filesystems on top
CWE ID: CWE-119 | 0 | 55,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: void SMIException(struct pt_regs *regs)
{
die("System Management Interrupt", regs, SIGABRT);
}
Commit Message: [POWERPC] Never panic when taking altivec exceptions from userspace
At the moment we rely on a cpu feature bit or a firmware property to
detect altivec. If we dont have either of these and the cpu does in fact
support altivec we can cause a panic from userspace.
It seems safer to always send a signal if we manage to get an 0xf20
exception from userspace.
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
CWE ID: CWE-19 | 0 | 74,715 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: Compute_Point_Displacement( TT_ExecContext exc,
FT_F26Dot6* x,
FT_F26Dot6* y,
TT_GlyphZone zone,
FT_UShort* refp )
{
TT_GlyphZoneRec zp;
FT_UShort p;
FT_F26Dot6 d;
if ( exc->opcode & 1 )
{
zp = exc->zp0;
p = exc->GS.rp1;
}
else
{
zp = exc->zp1;
p = exc->GS.rp2;
}
if ( BOUNDS( p, zp.n_points ) )
{
if ( exc->pedantic_hinting )
exc->error = FT_THROW( Invalid_Reference );
*refp = 0;
return FAILURE;
}
*zone = zp;
*refp = p;
d = PROJECT( zp.cur + p, zp.org + p );
*x = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.x, exc->F_dot_P );
*y = FT_MulDiv( d, (FT_Long)exc->GS.freeVector.y, exc->F_dot_P );
return SUCCESS;
}
Commit Message:
CWE ID: CWE-476 | 0 | 10,562 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void SaveCardBubbleControllerImpl::UpdateIcon() {
Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
LocationBar* location_bar = browser->window()->GetLocationBar();
location_bar->UpdateSaveCreditCardIcon();
}
Commit Message: [autofill] Avoid duplicate instances of the SaveCardBubble.
autofill::SaveCardBubbleControllerImpl::ShowBubble() expects
(via DCHECK) to only be called when the save card bubble is
not already visible. This constraint is violated if the user
clicks multiple times on a submit button.
If the underlying page goes away, the last SaveCardBubbleView
created by the controller will be automatically cleaned up,
but any others are left visible on the screen... holding a
refence to a possibly-deleted controller.
This CL early exits the ShowBubbleFor*** and ReshowBubble logic
if the bubble is already visible.
BUG=708819
Review-Url: https://codereview.chromium.org/2862933002
Cr-Commit-Position: refs/heads/master@{#469768}
CWE ID: CWE-416 | 0 | 137,014 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void RenderWidgetHostImpl::ForwardGestureEvent(
const WebKit::WebGestureEvent& gesture_event) {
TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardGestureEvent");
if (ignore_input_events_ || process_->IgnoreInputEvents())
return;
if (!IsInOverscrollGesture() &&
!gesture_event_filter_->ShouldForward(gesture_event))
return;
ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), false);
}
Commit Message: Implement TextureImageTransportSurface using texture mailbox
This has a couple of advantages:
- allow tearing down and recreating the UI parent context without
losing the renderer contexts
- do not require a context to be able to generate textures when
creating the GLSurfaceHandle
- clearer ownership semantics that potentially allows for more
robust and easier lost context handling/thumbnailing/etc., since a texture is at
any given time owned by either: UI parent, mailbox, or
TextureImageTransportSurface
- simplify frontbuffer protection logic;
the frontbuffer textures are now owned by RWHV where they are refcounted
The TextureImageTransportSurface informs RenderWidgetHostView of the
mailbox names for the front- and backbuffer textures by
associating them with a surface_handle (1 or 2) in the AcceleratedSurfaceNew message.
During SwapBuffers() or PostSubBuffer() cycles, it then uses
produceTextureCHROMIUM() and consumeTextureCHROMIUM()
to transfer ownership between renderer and browser compositor.
RWHV sends back the surface_handle of the buffer being returned with the Swap ACK
(or 0 if no buffer is being returned in which case TextureImageTransportSurface will
allocate a new texture - note that this could be used to
simply keep textures for thumbnailing).
BUG=154815,139616
TBR=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11194042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171569 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: | 0 | 114,610 |
Analyze the following 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 MockNetworkTransaction::StartInternal(const HttpRequestInfo* request,
const CompletionCallback& callback,
const BoundNetLog& net_log) {
const MockTransaction* t = FindMockTransaction(request->url);
if (!t)
return ERR_FAILED;
if (!before_network_start_callback_.is_null()) {
bool defer = false;
before_network_start_callback_.Run(&defer);
if (defer)
return net::ERR_IO_PENDING;
}
test_mode_ = t->test_mode;
if (OK != t->return_code) {
if (test_mode_ & TEST_MODE_SYNC_NET_START)
return t->return_code;
CallbackLater(callback, t->return_code);
return ERR_IO_PENDING;
}
sent_bytes_ = kTotalSentBytes;
received_bytes_ = kTotalReceivedBytes;
std::string resp_status = t->status;
std::string resp_headers = t->response_headers;
std::string resp_data = t->data;
if (t->handler)
(t->handler)(request, &resp_status, &resp_headers, &resp_data);
if (t->read_handler)
read_handler_ = t->read_handler;
std::string header_data = base::StringPrintf(
"%s\n%s\n", resp_status.c_str(), resp_headers.c_str());
std::replace(header_data.begin(), header_data.end(), '\n', '\0');
response_.request_time = transaction_factory_->Now();
if (!t->request_time.is_null())
response_.request_time = t->request_time;
response_.was_cached = false;
response_.network_accessed = true;
response_.response_time = transaction_factory_->Now();
if (!t->response_time.is_null())
response_.response_time = t->response_time;
response_.headers = new HttpResponseHeaders(header_data);
response_.vary_data.Init(*request, *response_.headers.get());
response_.ssl_info.cert = t->cert;
response_.ssl_info.cert_status = t->cert_status;
response_.ssl_info.connection_status = t->ssl_connection_status;
data_ = resp_data;
content_length_ = response_.headers->GetContentLength();
if (net_log.net_log())
socket_log_id_ = net_log.net_log()->NextID();
if (request_->load_flags & LOAD_PREFETCH)
response_.unused_since_prefetch = true;
if (test_mode_ & TEST_MODE_SYNC_NET_START)
return OK;
CallbackLater(callback, OK);
return ERR_IO_PENDING;
}
Commit Message: Replace fixed string uses of AddHeaderFromString
Uses of AddHeaderFromString() with a static string may as well be
replaced with SetHeader(). Do so.
BUG=None
Review-Url: https://codereview.chromium.org/2236933005
Cr-Commit-Position: refs/heads/master@{#418161}
CWE ID: CWE-119 | 0 | 119,353 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: cmsBool HeaderSection(cmsIT8* it8)
{
char VarName[MAXID];
char Buffer[MAXSTR];
KEYVALUE* Key;
while (it8->sy != SEOF &&
it8->sy != SSYNERROR &&
it8->sy != SBEGIN_DATA_FORMAT &&
it8->sy != SBEGIN_DATA) {
switch (it8 -> sy) {
case SKEYWORD:
InSymbol(it8);
if (!GetVal(it8, Buffer, MAXSTR-1, "Keyword expected")) return FALSE;
if (!AddAvailableProperty(it8, Buffer, WRITE_UNCOOKED)) return FALSE;
InSymbol(it8);
break;
case SDATA_FORMAT_ID:
InSymbol(it8);
if (!GetVal(it8, Buffer, MAXSTR-1, "Keyword expected")) return FALSE;
if (!AddAvailableSampleID(it8, Buffer)) return FALSE;
InSymbol(it8);
break;
case SIDENT:
strncpy(VarName, it8->id, MAXID - 1);
VarName[MAXID - 1] = 0;
if (!IsAvailableOnList(it8->ValidKeywords, VarName, NULL, &Key)) {
#ifdef CMS_STRICT_CGATS
return SynError(it8, "Undefined keyword '%s'", VarName);
#else
Key = AddAvailableProperty(it8, VarName, WRITE_UNCOOKED);
if (Key == NULL) return FALSE;
#endif
}
InSymbol(it8);
if (!GetVal(it8, Buffer, MAXSTR - 1, "Property data expected")) return FALSE;
if (Key->WriteAs != WRITE_PAIR) {
AddToList(it8, &GetTable(it8)->HeaderList, VarName, NULL, Buffer,
(it8->sy == SSTRING) ? WRITE_STRINGIFY : WRITE_UNCOOKED);
}
else {
const char *Subkey;
char *Nextkey;
if (it8->sy != SSTRING)
return SynError(it8, "Invalid value '%s' for property '%s'.", Buffer, VarName);
for (Subkey = Buffer; Subkey != NULL; Subkey = Nextkey)
{
char *Value, *temp;
Nextkey = (char*)strchr(Subkey, ';');
if (Nextkey)
*Nextkey++ = '\0';
Value = (char*)strrchr(Subkey, ',');
if (Value == NULL)
return SynError(it8, "Invalid value for property '%s'.", VarName);
temp = Value++;
do *temp-- = '\0'; while (temp >= Subkey && *temp == ' ');
temp = Value + strlen(Value) - 1;
while (*temp == ' ') *temp-- = '\0';
Subkey += strspn(Subkey, " ");
Value += strspn(Value, " ");
if (Subkey[0] == 0 || Value[0] == 0)
return SynError(it8, "Invalid value for property '%s'.", VarName);
AddToList(it8, &GetTable(it8)->HeaderList, VarName, Subkey, Value, WRITE_PAIR);
}
}
InSymbol(it8);
break;
case SEOLN: break;
default:
return SynError(it8, "expected keyword or identifier");
}
SkipEOLN(it8);
}
return TRUE;
}
Commit Message: Upgrade Visual studio 2017 15.8
- Upgrade to 15.8
- Add check on CGATS memory allocation (thanks to Quang Nguyen for
pointing out this)
CWE ID: CWE-190 | 0 | 78,032 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void LocalDOMWindow::setName(const AtomicString& name) {
if (!IsCurrentlyDisplayedInFrame())
return;
GetFrame()->Tree().SetName(name, FrameTree::kReplicate);
}
Commit Message: MacViews: Enable secure text input for password Textfields.
In Cocoa the NSTextInputContext automatically enables secure text input
when activated and it's in the secure text entry mode.
RenderWidgetHostViewMac did the similar thing for ages following the
WebKit example.
views::Textfield needs to do the same thing in a fashion that's
sycnrhonized with RenderWidgetHostViewMac, otherwise the race conditions
are possible when the Textfield gets focus, activates the secure text
input mode and the RWHVM loses focus immediately afterwards and disables
the secure text input instead of leaving it in the enabled state.
BUG=818133,677220
Change-Id: I6db6c4b59e4a1a72cbb7f8c7056f71b04a3df08b
Reviewed-on: https://chromium-review.googlesource.com/943064
Commit-Queue: Michail Pishchagin <mblsha@yandex-team.ru>
Reviewed-by: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542517}
CWE ID: | 0 | 125,976 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: ImageLoader::ImageLoader(Element* element)
: m_element(element)
, m_image(0)
, m_derefElementTimer(this, &ImageLoader::timerFired)
, m_hasPendingBeforeLoadEvent(false)
, m_hasPendingLoadEvent(false)
, m_hasPendingErrorEvent(false)
, m_imageComplete(true)
, m_loadManually(false)
, m_elementIsProtected(false)
{
}
Commit Message: Error event was fired synchronously blowing away the input element from underneath. Remove the FIXME and fire it asynchronously using errorEventSender().
BUG=240124
Review URL: https://chromiumcodereview.appspot.com/14741011
git-svn-id: svn://svn.chromium.org/blink/trunk@150232 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-416 | 0 | 113,472 |
Analyze the following 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 emulator_read_write(struct x86_emulate_ctxt *ctxt, unsigned long addr,
void *val, unsigned int bytes,
struct x86_exception *exception,
const struct read_write_emulator_ops *ops)
{
struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
gpa_t gpa;
int rc;
if (ops->read_write_prepare &&
ops->read_write_prepare(vcpu, val, bytes))
return X86EMUL_CONTINUE;
vcpu->mmio_nr_fragments = 0;
/* Crossing a page boundary? */
if (((addr + bytes - 1) ^ addr) & PAGE_MASK) {
int now;
now = -addr & ~PAGE_MASK;
rc = emulator_read_write_onepage(addr, val, now, exception,
vcpu, ops);
if (rc != X86EMUL_CONTINUE)
return rc;
addr += now;
val += now;
bytes -= now;
}
rc = emulator_read_write_onepage(addr, val, bytes, exception,
vcpu, ops);
if (rc != X86EMUL_CONTINUE)
return rc;
if (!vcpu->mmio_nr_fragments)
return rc;
gpa = vcpu->mmio_fragments[0].gpa;
vcpu->mmio_needed = 1;
vcpu->mmio_cur_fragment = 0;
vcpu->run->mmio.len = min(8u, vcpu->mmio_fragments[0].len);
vcpu->run->mmio.is_write = vcpu->mmio_is_write = ops->write;
vcpu->run->exit_reason = KVM_EXIT_MMIO;
vcpu->run->mmio.phys_addr = gpa;
return ops->read_write_exit_mmio(vcpu, gpa, val, bytes);
}
Commit Message: KVM: x86: Convert vapic synchronization to _cached functions (CVE-2013-6368)
In kvm_lapic_sync_from_vapic and kvm_lapic_sync_to_vapic there is the
potential to corrupt kernel memory if userspace provides an address that
is at the end of a page. This patches concerts those functions to use
kvm_write_guest_cached and kvm_read_guest_cached. It also checks the
vapic_address specified by userspace during ioctl processing and returns
an error to userspace if the address is not a valid GPA.
This is generally not guest triggerable, because the required write is
done by firmware that runs before the guest. Also, it only affects AMD
processors and oldish Intel that do not have the FlexPriority feature
(unless you disable FlexPriority, of course; then newer processors are
also affected).
Fixes: b93463aa59d6 ('KVM: Accelerated apic support')
Reported-by: Andrew Honig <ahonig@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Andrew Honig <ahonig@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
CWE ID: CWE-20 | 0 | 28,817 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: char *vnc_socket_remote_addr(const char *format, int fd) {
struct sockaddr_storage sa;
socklen_t salen;
salen = sizeof(sa);
if (getpeername(fd, (struct sockaddr*)&sa, &salen) < 0)
return NULL;
return addr_to_string(format, &sa, salen);
}
Commit Message:
CWE ID: CWE-264 | 0 | 8,049 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: GLHelper* CmdBufferImageTransportFactory::GetGLHelper() {
if (!gl_helper_.get())
gl_helper_.reset(new GLHelper(GetContext3D(), NULL));
return gl_helper_.get();
}
Commit Message: Implement TextureImageTransportSurface using texture mailbox
This has a couple of advantages:
- allow tearing down and recreating the UI parent context without
losing the renderer contexts
- do not require a context to be able to generate textures when
creating the GLSurfaceHandle
- clearer ownership semantics that potentially allows for more
robust and easier lost context handling/thumbnailing/etc., since a texture is at
any given time owned by either: UI parent, mailbox, or
TextureImageTransportSurface
- simplify frontbuffer protection logic;
the frontbuffer textures are now owned by RWHV where they are refcounted
The TextureImageTransportSurface informs RenderWidgetHostView of the
mailbox names for the front- and backbuffer textures by
associating them with a surface_handle (1 or 2) in the AcceleratedSurfaceNew message.
During SwapBuffers() or PostSubBuffer() cycles, it then uses
produceTextureCHROMIUM() and consumeTextureCHROMIUM()
to transfer ownership between renderer and browser compositor.
RWHV sends back the surface_handle of the buffer being returned with the Swap ACK
(or 0 if no buffer is being returned in which case TextureImageTransportSurface will
allocate a new texture - note that this could be used to
simply keep textures for thumbnailing).
BUG=154815,139616
TBR=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11194042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171569 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: | 0 | 114,499 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: float AudioParam::smoothedValue()
{
return narrowPrecisionToFloat(m_smoothedValue);
}
Commit Message: Initialize value since calculateFinalValues may fail to do so.
Fix threading issue where updateCoefficientsIfNecessary was not always
called from the audio thread. This causes the value not to be
initialized.
Thus,
o Initialize the variable to some value, just in case.
o Split updateCoefficientsIfNecessary into two functions with the code
that sets the coefficients pulled out in to the new function
updateCoefficients.
o Simplify updateCoefficientsIfNecessary since useSmoothing was always
true, and forceUpdate is not longer needed.
o Add process lock to prevent the audio thread from updating the
coefficients while they are being read in the main thread. The audio
thread will update them the next time around.
o Make getFrequencyResponse set the lock while reading the
coefficients of the biquad in preparation for computing the
frequency response.
BUG=389219
Review URL: https://codereview.chromium.org/354213002
git-svn-id: svn://svn.chromium.org/blink/trunk@177250 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-119 | 0 | 121,084 |
Analyze the following 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 V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
DOMWindow* impl = V8Window::toNative(args.Holder());
ExceptionState es(args.GetIsolate());
if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), es)) {
es.throwIfNeeded();
return;
}
String urlString = toWebCoreStringWithUndefinedOrNullCheck(args[0]);
AtomicString frameName = (args[1]->IsUndefined() || args[1]->IsNull()) ? "_blank" : toWebCoreAtomicString(args[1]);
String windowFeaturesString = toWebCoreStringWithUndefinedOrNullCheck(args[2]);
RefPtr<DOMWindow> openedWindow = impl->open(urlString, frameName, windowFeaturesString, activeDOMWindow(), firstDOMWindow());
if (!openedWindow)
return;
v8SetReturnValueFast(args, openedWindow.release(), impl);
}
Commit Message: Fix tracking of the id attribute string if it is shared across elements.
The patch to remove AtomicStringImpl:
http://src.chromium.org/viewvc/blink?view=rev&rev=154790
Exposed a lifetime issue with strings for id attributes. We simply need to use
AtomicString.
BUG=290566
Review URL: https://codereview.chromium.org/33793004
git-svn-id: svn://svn.chromium.org/blink/trunk@160250 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-399 | 0 | 110,452 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: xml_create_patchset(int format, xmlNode *source, xmlNode *target, bool *config_changed, bool manage_version, bool with_digest)
{
int counter = 0;
bool config = FALSE;
xmlNode *patch = NULL;
const char *version = crm_element_value(source, XML_ATTR_CRM_VERSION);
xml_acl_disable(target);
if(xml_document_dirty(target) == FALSE) {
crm_trace("No change %d", format);
return NULL; /* No change */
}
config = is_config_change(target);
if(config_changed) {
*config_changed = config;
}
if(manage_version && config) {
crm_trace("Config changed %d", format);
crm_xml_add(target, XML_ATTR_NUMUPDATES, "0");
crm_element_value_int(target, XML_ATTR_GENERATION, &counter);
crm_xml_add_int(target, XML_ATTR_GENERATION, counter+1);
} else if(manage_version) {
crm_trace("Status changed %d", format);
crm_element_value_int(target, XML_ATTR_NUMUPDATES, &counter);
crm_xml_add_int(target, XML_ATTR_NUMUPDATES, counter+1);
}
if(format == 0) {
if(patch_legacy_mode()) {
format = 1;
} else if(compare_version("3.0.8", version) < 0) {
format = 2;
} else {
format = 1;
}
crm_trace("Using patch format %d for version: %s", format, version);
}
switch(format) {
case 1:
with_digest = TRUE;
patch = xml_create_patchset_v1(source, target, config, with_digest);
break;
case 2:
patch = xml_create_patchset_v2(source, target);
break;
default:
crm_err("Unknown patch format: %d", format);
return NULL;
}
if(patch && with_digest) {
char *digest = calculate_xml_versioned_digest(target, FALSE, TRUE, version);
crm_xml_add(patch, XML_ATTR_DIGEST, digest);
free(digest);
}
return patch;
}
Commit Message: Fix: acl: Do not delay evaluation of added nodes in some situations
It is not appropriate when the node has no children as it is not a
placeholder
CWE ID: CWE-264 | 0 | 44,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: struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name)
{
/*
* Check for a fs-specific hash function. Note that we must
* calculate the standard hash first, as the d_op->d_hash()
* routine may choose to leave the hash value unchanged.
*/
name->hash = full_name_hash(dir, name->name, name->len);
if (dir->d_flags & DCACHE_OP_HASH) {
int err = dir->d_op->d_hash(dir, name);
if (unlikely(err < 0))
return ERR_PTR(err);
}
return d_lookup(dir, name);
}
Commit Message: dentry name snapshots
take_dentry_name_snapshot() takes a safe snapshot of dentry name;
if the name is a short one, it gets copied into caller-supplied
structure, otherwise an extra reference to external name is grabbed
(those are never modified). In either case the pointer to stable
string is stored into the same structure.
dentry must be held by the caller of take_dentry_name_snapshot(),
but may be freely dropped afterwards - the snapshot will stay
until destroyed by release_dentry_name_snapshot().
Intended use:
struct name_snapshot s;
take_dentry_name_snapshot(&s, dentry);
...
access s.name
...
release_dentry_name_snapshot(&s);
Replaces fsnotify_oldname_...(), gets used in fsnotify to obtain the name
to pass down with event.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
CWE ID: CWE-362 | 0 | 67,305 |
Analyze the following 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 __ext4_ext_check(const char *function, unsigned int line,
struct inode *inode, struct ext4_extent_header *eh,
int depth)
{
const char *error_msg;
int max = 0;
if (unlikely(eh->eh_magic != EXT4_EXT_MAGIC)) {
error_msg = "invalid magic";
goto corrupted;
}
if (unlikely(le16_to_cpu(eh->eh_depth) != depth)) {
error_msg = "unexpected eh_depth";
goto corrupted;
}
if (unlikely(eh->eh_max == 0)) {
error_msg = "invalid eh_max";
goto corrupted;
}
max = ext4_ext_max_entries(inode, depth);
if (unlikely(le16_to_cpu(eh->eh_max) > max)) {
error_msg = "too large eh_max";
goto corrupted;
}
if (unlikely(le16_to_cpu(eh->eh_entries) > le16_to_cpu(eh->eh_max))) {
error_msg = "invalid eh_entries";
goto corrupted;
}
if (!ext4_valid_extent_entries(inode, eh, depth)) {
error_msg = "invalid extent entries";
goto corrupted;
}
return 0;
corrupted:
ext4_error_inode(inode, function, line, 0,
"bad header/extent: %s - magic %x, "
"entries %u, max %u(%u), depth %u(%u)",
error_msg, le16_to_cpu(eh->eh_magic),
le16_to_cpu(eh->eh_entries), le16_to_cpu(eh->eh_max),
max, le16_to_cpu(eh->eh_depth), depth);
return -EIO;
}
Commit Message: ext4: reimplement convert and split_unwritten
Reimplement ext4_ext_convert_to_initialized() and
ext4_split_unwritten_extents() using ext4_split_extent()
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Tested-by: Allison Henderson <achender@linux.vnet.ibm.com>
CWE ID: | 0 | 34,735 |
Analyze the following 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 mailimf_subject_parse(const char * message, size_t length,
size_t * indx,
struct mailimf_subject ** result)
{
struct mailimf_subject * subject;
char * value;
size_t cur_token;
int r;
int res;
cur_token = * indx;
r = mailimf_token_case_insensitive_parse(message, length,
&cur_token, "Subject");
if (r != MAILIMF_NO_ERROR) {
res = r;
goto err;
}
r = mailimf_colon_parse(message, length, &cur_token);
if (r != MAILIMF_NO_ERROR) {
res = r;
goto err;
}
r = mailimf_unstructured_parse(message, length, &cur_token, &value);
if (r != MAILIMF_NO_ERROR) {
res = r;
goto err;
}
r = mailimf_unstrict_crlf_parse(message, length, &cur_token);
if (r != MAILIMF_NO_ERROR) {
res = r;
goto free_value;
}
subject = mailimf_subject_new(value);
if (subject == NULL) {
res = MAILIMF_ERROR_MEMORY;
goto free_value;
}
* result = subject;
* indx = cur_token;
return MAILIMF_NO_ERROR;
free_value:
mailimf_unstructured_free(value);
err:
return res;
}
Commit Message: Fixed crash #274
CWE ID: CWE-476 | 0 | 66,240 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static bool regsafe(struct bpf_reg_state *rold, struct bpf_reg_state *rcur,
struct idpair *idmap)
{
if (!(rold->live & REG_LIVE_READ))
/* explored state didn't use this */
return true;
if (memcmp(rold, rcur, offsetof(struct bpf_reg_state, live)) == 0)
return true;
if (rold->type == NOT_INIT)
/* explored state can't have used this */
return true;
if (rcur->type == NOT_INIT)
return false;
switch (rold->type) {
case SCALAR_VALUE:
if (rcur->type == SCALAR_VALUE) {
/* new val must satisfy old val knowledge */
return range_within(rold, rcur) &&
tnum_in(rold->var_off, rcur->var_off);
} else {
/* if we knew anything about the old value, we're not
* equal, because we can't know anything about the
* scalar value of the pointer in the new value.
*/
return rold->umin_value == 0 &&
rold->umax_value == U64_MAX &&
rold->smin_value == S64_MIN &&
rold->smax_value == S64_MAX &&
tnum_is_unknown(rold->var_off);
}
case PTR_TO_MAP_VALUE:
/* If the new min/max/var_off satisfy the old ones and
* everything else matches, we are OK.
* We don't care about the 'id' value, because nothing
* uses it for PTR_TO_MAP_VALUE (only for ..._OR_NULL)
*/
return memcmp(rold, rcur, offsetof(struct bpf_reg_state, id)) == 0 &&
range_within(rold, rcur) &&
tnum_in(rold->var_off, rcur->var_off);
case PTR_TO_MAP_VALUE_OR_NULL:
/* a PTR_TO_MAP_VALUE could be safe to use as a
* PTR_TO_MAP_VALUE_OR_NULL into the same map.
* However, if the old PTR_TO_MAP_VALUE_OR_NULL then got NULL-
* checked, doing so could have affected others with the same
* id, and we can't check for that because we lost the id when
* we converted to a PTR_TO_MAP_VALUE.
*/
if (rcur->type != PTR_TO_MAP_VALUE_OR_NULL)
return false;
if (memcmp(rold, rcur, offsetof(struct bpf_reg_state, id)))
return false;
/* Check our ids match any regs they're supposed to */
return check_ids(rold->id, rcur->id, idmap);
case PTR_TO_PACKET_META:
case PTR_TO_PACKET:
if (rcur->type != rold->type)
return false;
/* We must have at least as much range as the old ptr
* did, so that any accesses which were safe before are
* still safe. This is true even if old range < old off,
* since someone could have accessed through (ptr - k), or
* even done ptr -= k in a register, to get a safe access.
*/
if (rold->range > rcur->range)
return false;
/* If the offsets don't match, we can't trust our alignment;
* nor can we be sure that we won't fall out of range.
*/
if (rold->off != rcur->off)
return false;
/* id relations must be preserved */
if (rold->id && !check_ids(rold->id, rcur->id, idmap))
return false;
/* new val must satisfy old val knowledge */
return range_within(rold, rcur) &&
tnum_in(rold->var_off, rcur->var_off);
case PTR_TO_CTX:
case CONST_PTR_TO_MAP:
case PTR_TO_STACK:
case PTR_TO_PACKET_END:
/* Only valid matches are exact, which memcmp() above
* would have accepted
*/
default:
/* Don't know what's going on, just say it's not safe */
return false;
}
/* Shouldn't get here; if we do, say it's not safe */
WARN_ON_ONCE(1);
return false;
}
Commit Message: bpf: don't prune branches when a scalar is replaced with a pointer
This could be made safe by passing through a reference to env and checking
for env->allow_ptr_leaks, but it would only work one way and is probably
not worth the hassle - not doing it will not directly lead to program
rejection.
Fixes: f1174f77b50c ("bpf/verifier: rework value tracking")
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
CWE ID: CWE-119 | 1 | 167,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: TabContents* Browser::AddTab(TabContentsWrapper* tab_contents,
PageTransition::Type type) {
tab_handler_->GetTabStripModel()->AddTabContents(
tab_contents, -1, type, TabStripModel::ADD_ACTIVE);
return tab_contents->tab_contents();
}
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,131 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: PluginProcessHost* host() const { return host_; }
Commit Message: Follow-on fixes and naming changes for https://codereview.chromium.org/12086077/
BUG=172573
Review URL: https://codereview.chromium.org/12177018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180600 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-287 | 0 | 116,823 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: ref_param_write_name_value(const gs_memory_t *mem, ref * pref, const gs_param_string * pvalue)
{
return name_ref(mem, pvalue->data, pvalue->size, pref,
(pvalue->persistent ? 0 : 1));
}
Commit Message:
CWE ID: CWE-704 | 0 | 3,284 |
Analyze the following 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 ion_handle_get(struct ion_handle *handle)
{
kref_get(&handle->ref);
}
Commit Message: staging/android/ion : fix a race condition in the ion driver
There is a use-after-free problem in the ion driver.
This is caused by a race condition in the ion_ioctl()
function.
A handle has ref count of 1 and two tasks on different
cpus calls ION_IOC_FREE simultaneously.
cpu 0 cpu 1
-------------------------------------------------------
ion_handle_get_by_id()
(ref == 2)
ion_handle_get_by_id()
(ref == 3)
ion_free()
(ref == 2)
ion_handle_put()
(ref == 1)
ion_free()
(ref == 0 so ion_handle_destroy() is
called
and the handle is freed.)
ion_handle_put() is called and it
decreases the slub's next free pointer
The problem is detected as an unaligned access in the
spin lock functions since it uses load exclusive
instruction. In some cases it corrupts the slub's
free pointer which causes a mis-aligned access to the
next free pointer.(kmalloc returns a pointer like
ffffc0745b4580aa). And it causes lots of other
hard-to-debug problems.
This symptom is caused since the first member in the
ion_handle structure is the reference count and the
ion driver decrements the reference after it has been
freed.
To fix this problem client->lock mutex is extended
to protect all the codes that uses the handle.
Signed-off-by: Eun Taik Lee <eun.taik.lee@samsung.com>
Reviewed-by: Laura Abbott <labbott@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CWE ID: CWE-416 | 0 | 48,552 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int set_flags(struct task_struct *task, unsigned long value)
{
struct pt_regs *regs = task_pt_regs(task);
/*
* If the user value contains TF, mark that
* it was not "us" (the debugger) that set it.
* If not, make sure it stays set if we had.
*/
if (value & X86_EFLAGS_TF)
clear_tsk_thread_flag(task, TIF_FORCED_TF);
else if (test_tsk_thread_flag(task, TIF_FORCED_TF))
value |= X86_EFLAGS_TF;
regs->flags = (regs->flags & ~FLAG_MASK) | (value & FLAG_MASK);
return 0;
}
Commit Message: perf: Remove the nmi parameter from the swevent and overflow interface
The nmi parameter indicated if we could do wakeups from the current
context, if not, we would set some state and self-IPI and let the
resulting interrupt do the wakeup.
For the various event classes:
- hardware: nmi=0; PMI is in fact an NMI or we run irq_work_run from
the PMI-tail (ARM etc.)
- tracepoint: nmi=0; since tracepoint could be from NMI context.
- software: nmi=[0,1]; some, like the schedule thing cannot
perform wakeups, and hence need 0.
As one can see, there is very little nmi=1 usage, and the down-side of
not using it is that on some platforms some software events can have a
jiffy delay in wakeup (when arch_irq_work_raise isn't implemented).
The up-side however is that we can remove the nmi parameter and save a
bunch of conditionals in fast paths.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Michael Cree <mcree@orcon.net.nz>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com>
Cc: Anton Blanchard <anton@samba.org>
Cc: Eric B Munson <emunson@mgebm.net>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Don Zickus <dzickus@redhat.com>
Link: http://lkml.kernel.org/n/tip-agjev8eu666tvknpb3iaj0fg@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
CWE ID: CWE-399 | 0 | 25,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: static int pipe_to_sg(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
struct splice_desc *sd)
{
struct sg_list *sgl = sd->u.data;
unsigned int offset, len;
if (sgl->n == sgl->size)
return 0;
/* Try lock this page */
if (pipe_buf_steal(pipe, buf) == 0) {
/* Get reference and unlock page for moving */
get_page(buf->page);
unlock_page(buf->page);
len = min(buf->len, sd->len);
sg_set_page(&(sgl->sg[sgl->n]), buf->page, len, buf->offset);
} else {
/* Failback to copying a page */
struct page *page = alloc_page(GFP_KERNEL);
char *src;
if (!page)
return -ENOMEM;
offset = sd->pos & ~PAGE_MASK;
len = sd->len;
if (len + offset > PAGE_SIZE)
len = PAGE_SIZE - offset;
src = kmap_atomic(buf->page);
memcpy(page_address(page) + offset, src + buf->offset, len);
kunmap_atomic(src);
sg_set_page(&(sgl->sg[sgl->n]), page, len, offset);
}
sgl->n++;
sgl->len += len;
return len;
}
Commit Message: virtio-console: avoid DMA from stack
put_chars() stuffs the buffer it gets into an sg, but that buffer may be
on the stack. This breaks with CONFIG_VMAP_STACK=y (for me, it
manifested as printks getting turned into NUL bytes).
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
CWE ID: CWE-119 | 0 | 66,602 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: int ssl_verify_alarm_type(long type)
{
int al;
switch(type)
{
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
case X509_V_ERR_UNABLE_TO_GET_CRL:
case X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER:
al=SSL_AD_UNKNOWN_CA;
break;
case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE:
case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE:
case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY:
case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD:
case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD:
case X509_V_ERR_CERT_NOT_YET_VALID:
case X509_V_ERR_CRL_NOT_YET_VALID:
case X509_V_ERR_CERT_UNTRUSTED:
case X509_V_ERR_CERT_REJECTED:
al=SSL_AD_BAD_CERTIFICATE;
break;
case X509_V_ERR_CERT_SIGNATURE_FAILURE:
case X509_V_ERR_CRL_SIGNATURE_FAILURE:
al=SSL_AD_DECRYPT_ERROR;
break;
case X509_V_ERR_CERT_HAS_EXPIRED:
case X509_V_ERR_CRL_HAS_EXPIRED:
al=SSL_AD_CERTIFICATE_EXPIRED;
break;
case X509_V_ERR_CERT_REVOKED:
al=SSL_AD_CERTIFICATE_REVOKED;
break;
case X509_V_ERR_OUT_OF_MEM:
al=SSL_AD_INTERNAL_ERROR;
break;
case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
case X509_V_ERR_CERT_CHAIN_TOO_LONG:
case X509_V_ERR_PATH_LENGTH_EXCEEDED:
case X509_V_ERR_INVALID_CA:
al=SSL_AD_UNKNOWN_CA;
break;
case X509_V_ERR_APPLICATION_VERIFICATION:
al=SSL_AD_HANDSHAKE_FAILURE;
break;
case X509_V_ERR_INVALID_PURPOSE:
al=SSL_AD_UNSUPPORTED_CERTIFICATE;
break;
default:
al=SSL_AD_CERTIFICATE_UNKNOWN;
break;
}
return(al);
}
Commit Message:
CWE ID: CWE-20 | 0 | 15,805 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static struct net_device_stats *ipgre_get_stats(struct net_device *dev)
{
struct pcpu_tstats sum = { 0 };
int i;
for_each_possible_cpu(i) {
const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i);
sum.rx_packets += tstats->rx_packets;
sum.rx_bytes += tstats->rx_bytes;
sum.tx_packets += tstats->tx_packets;
sum.tx_bytes += tstats->tx_bytes;
}
dev->stats.rx_packets = sum.rx_packets;
dev->stats.rx_bytes = sum.rx_bytes;
dev->stats.tx_packets = sum.tx_packets;
dev->stats.tx_bytes = sum.tx_bytes;
return &dev->stats;
}
Commit Message: net: don't allow CAP_NET_ADMIN to load non-netdev kernel modules
Since a8f80e8ff94ecba629542d9b4b5f5a8ee3eb565c any process with
CAP_NET_ADMIN may load any module from /lib/modules/. This doesn't mean
that CAP_NET_ADMIN is a superset of CAP_SYS_MODULE as modules are
limited to /lib/modules/**. However, CAP_NET_ADMIN capability shouldn't
allow anybody load any module not related to networking.
This patch restricts an ability of autoloading modules to netdev modules
with explicit aliases. This fixes CVE-2011-1019.
Arnd Bergmann suggested to leave untouched the old pre-v2.6.32 behavior
of loading netdev modules by name (without any prefix) for processes
with CAP_SYS_MODULE to maintain the compatibility with network scripts
that use autoloading netdev modules by aliases like "eth0", "wlan0".
Currently there are only three users of the feature in the upstream
kernel: ipip, ip_gre and sit.
root@albatros:~# capsh --drop=$(seq -s, 0 11),$(seq -s, 13 34) --
root@albatros:~# grep Cap /proc/$$/status
CapInh: 0000000000000000
CapPrm: fffffff800001000
CapEff: fffffff800001000
CapBnd: fffffff800001000
root@albatros:~# modprobe xfs
FATAL: Error inserting xfs
(/lib/modules/2.6.38-rc6-00001-g2bf4ca3/kernel/fs/xfs/xfs.ko): Operation not permitted
root@albatros:~# lsmod | grep xfs
root@albatros:~# ifconfig xfs
xfs: error fetching interface information: Device not found
root@albatros:~# lsmod | grep xfs
root@albatros:~# lsmod | grep sit
root@albatros:~# ifconfig sit
sit: error fetching interface information: Device not found
root@albatros:~# lsmod | grep sit
root@albatros:~# ifconfig sit0
sit0 Link encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
root@albatros:~# lsmod | grep sit
sit 10457 0
tunnel4 2957 1 sit
For CAP_SYS_MODULE module loading is still relaxed:
root@albatros:~# grep Cap /proc/$$/status
CapInh: 0000000000000000
CapPrm: ffffffffffffffff
CapEff: ffffffffffffffff
CapBnd: ffffffffffffffff
root@albatros:~# ifconfig xfs
xfs: error fetching interface information: Device not found
root@albatros:~# lsmod | grep xfs
xfs 745319 0
Reference: https://lkml.org/lkml/2011/2/24/203
Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Kees Cook <kees.cook@canonical.com>
Signed-off-by: James Morris <jmorris@namei.org>
CWE ID: CWE-264 | 0 | 35,318 |
Analyze the following 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 remap_pfn_range(struct vm_area_struct *vma, unsigned long addr,
unsigned long pfn, unsigned long size, pgprot_t prot)
{
pgd_t *pgd;
unsigned long next;
unsigned long end = addr + PAGE_ALIGN(size);
struct mm_struct *mm = vma->vm_mm;
int err;
/*
* Physically remapped pages are special. Tell the
* rest of the world about it:
* VM_IO tells people not to look at these pages
* (accesses can have side effects).
* VM_RESERVED is specified all over the place, because
* in 2.4 it kept swapout's vma scan off this vma; but
* in 2.6 the LRU scan won't even find its pages, so this
* flag means no more than count its pages in reserved_vm,
* and omit it from core dump, even when VM_IO turned off.
* VM_PFNMAP tells the core MM that the base pages are just
* raw PFN mappings, and do not have a "struct page" associated
* with them.
*
* There's a horrible special case to handle copy-on-write
* behaviour that some programs depend on. We mark the "original"
* un-COW'ed pages by matching them up with "vma->vm_pgoff".
*/
if (addr == vma->vm_start && end == vma->vm_end) {
vma->vm_pgoff = pfn;
vma->vm_flags |= VM_PFN_AT_MMAP;
} else if (is_cow_mapping(vma->vm_flags))
return -EINVAL;
vma->vm_flags |= VM_IO | VM_RESERVED | VM_PFNMAP;
err = track_pfn_vma_new(vma, &prot, pfn, PAGE_ALIGN(size));
if (err) {
/*
* To indicate that track_pfn related cleanup is not
* needed from higher level routine calling unmap_vmas
*/
vma->vm_flags &= ~(VM_IO | VM_RESERVED | VM_PFNMAP);
vma->vm_flags &= ~VM_PFN_AT_MMAP;
return -EINVAL;
}
BUG_ON(addr >= end);
pfn -= addr >> PAGE_SHIFT;
pgd = pgd_offset(mm, addr);
flush_cache_range(vma, addr, end);
do {
next = pgd_addr_end(addr, end);
err = remap_pud_range(mm, pgd, addr, next,
pfn + (addr >> PAGE_SHIFT), prot);
if (err)
break;
} while (pgd++, addr = next, addr != end);
if (err)
untrack_pfn_vma(vma, pfn, PAGE_ALIGN(size));
return err;
}
Commit Message: mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode
commit 1a5a9906d4e8d1976b701f889d8f35d54b928f25 upstream.
In some cases it may happen that pmd_none_or_clear_bad() is called with
the mmap_sem hold in read mode. In those cases the huge page faults can
allocate hugepmds under pmd_none_or_clear_bad() and that can trigger a
false positive from pmd_bad() that will not like to see a pmd
materializing as trans huge.
It's not khugepaged causing the problem, khugepaged holds the mmap_sem
in write mode (and all those sites must hold the mmap_sem in read mode
to prevent pagetables to go away from under them, during code review it
seems vm86 mode on 32bit kernels requires that too unless it's
restricted to 1 thread per process or UP builds). The race is only with
the huge pagefaults that can convert a pmd_none() into a
pmd_trans_huge().
Effectively all these pmd_none_or_clear_bad() sites running with
mmap_sem in read mode are somewhat speculative with the page faults, and
the result is always undefined when they run simultaneously. This is
probably why it wasn't common to run into this. For example if the
madvise(MADV_DONTNEED) runs zap_page_range() shortly before the page
fault, the hugepage will not be zapped, if the page fault runs first it
will be zapped.
Altering pmd_bad() not to error out if it finds hugepmds won't be enough
to fix this, because zap_pmd_range would then proceed to call
zap_pte_range (which would be incorrect if the pmd become a
pmd_trans_huge()).
The simplest way to fix this is to read the pmd in the local stack
(regardless of what we read, no need of actual CPU barriers, only
compiler barrier needed), and be sure it is not changing under the code
that computes its value. Even if the real pmd is changing under the
value we hold on the stack, we don't care. If we actually end up in
zap_pte_range it means the pmd was not none already and it was not huge,
and it can't become huge from under us (khugepaged locking explained
above).
All we need is to enforce that there is no way anymore that in a code
path like below, pmd_trans_huge can be false, but pmd_none_or_clear_bad
can run into a hugepmd. The overhead of a barrier() is just a compiler
tweak and should not be measurable (I only added it for THP builds). I
don't exclude different compiler versions may have prevented the race
too by caching the value of *pmd on the stack (that hasn't been
verified, but it wouldn't be impossible considering
pmd_none_or_clear_bad, pmd_bad, pmd_trans_huge, pmd_none are all inlines
and there's no external function called in between pmd_trans_huge and
pmd_none_or_clear_bad).
if (pmd_trans_huge(*pmd)) {
if (next-addr != HPAGE_PMD_SIZE) {
VM_BUG_ON(!rwsem_is_locked(&tlb->mm->mmap_sem));
split_huge_page_pmd(vma->vm_mm, pmd);
} else if (zap_huge_pmd(tlb, vma, pmd, addr))
continue;
/* fall through */
}
if (pmd_none_or_clear_bad(pmd))
Because this race condition could be exercised without special
privileges this was reported in CVE-2012-1179.
The race was identified and fully explained by Ulrich who debugged it.
I'm quoting his accurate explanation below, for reference.
====== start quote =======
mapcount 0 page_mapcount 1
kernel BUG at mm/huge_memory.c:1384!
At some point prior to the panic, a "bad pmd ..." message similar to the
following is logged on the console:
mm/memory.c:145: bad pmd ffff8800376e1f98(80000000314000e7).
The "bad pmd ..." message is logged by pmd_clear_bad() before it clears
the page's PMD table entry.
143 void pmd_clear_bad(pmd_t *pmd)
144 {
-> 145 pmd_ERROR(*pmd);
146 pmd_clear(pmd);
147 }
After the PMD table entry has been cleared, there is an inconsistency
between the actual number of PMD table entries that are mapping the page
and the page's map count (_mapcount field in struct page). When the page
is subsequently reclaimed, __split_huge_page() detects this inconsistency.
1381 if (mapcount != page_mapcount(page))
1382 printk(KERN_ERR "mapcount %d page_mapcount %d\n",
1383 mapcount, page_mapcount(page));
-> 1384 BUG_ON(mapcount != page_mapcount(page));
The root cause of the problem is a race of two threads in a multithreaded
process. Thread B incurs a page fault on a virtual address that has never
been accessed (PMD entry is zero) while Thread A is executing an madvise()
system call on a virtual address within the same 2 MB (huge page) range.
virtual address space
.---------------------.
| |
| |
.-|---------------------|
| | |
| | |<-- B(fault)
| | |
2 MB | |/////////////////////|-.
huge < |/////////////////////| > A(range)
page | |/////////////////////|-'
| | |
| | |
'-|---------------------|
| |
| |
'---------------------'
- Thread A is executing an madvise(..., MADV_DONTNEED) system call
on the virtual address range "A(range)" shown in the picture.
sys_madvise
// Acquire the semaphore in shared mode.
down_read(¤t->mm->mmap_sem)
...
madvise_vma
switch (behavior)
case MADV_DONTNEED:
madvise_dontneed
zap_page_range
unmap_vmas
unmap_page_range
zap_pud_range
zap_pmd_range
//
// Assume that this huge page has never been accessed.
// I.e. content of the PMD entry is zero (not mapped).
//
if (pmd_trans_huge(*pmd)) {
// We don't get here due to the above assumption.
}
//
// Assume that Thread B incurred a page fault and
.---------> // sneaks in here as shown below.
| //
| if (pmd_none_or_clear_bad(pmd))
| {
| if (unlikely(pmd_bad(*pmd)))
| pmd_clear_bad
| {
| pmd_ERROR
| // Log "bad pmd ..." message here.
| pmd_clear
| // Clear the page's PMD entry.
| // Thread B incremented the map count
| // in page_add_new_anon_rmap(), but
| // now the page is no longer mapped
| // by a PMD entry (-> inconsistency).
| }
| }
|
v
- Thread B is handling a page fault on virtual address "B(fault)" shown
in the picture.
...
do_page_fault
__do_page_fault
// Acquire the semaphore in shared mode.
down_read_trylock(&mm->mmap_sem)
...
handle_mm_fault
if (pmd_none(*pmd) && transparent_hugepage_enabled(vma))
// We get here due to the above assumption (PMD entry is zero).
do_huge_pmd_anonymous_page
alloc_hugepage_vma
// Allocate a new transparent huge page here.
...
__do_huge_pmd_anonymous_page
...
spin_lock(&mm->page_table_lock)
...
page_add_new_anon_rmap
// Here we increment the page's map count (starts at -1).
atomic_set(&page->_mapcount, 0)
set_pmd_at
// Here we set the page's PMD entry which will be cleared
// when Thread A calls pmd_clear_bad().
...
spin_unlock(&mm->page_table_lock)
The mmap_sem does not prevent the race because both threads are acquiring
it in shared mode (down_read). Thread B holds the page_table_lock while
the page's map count and PMD table entry are updated. However, Thread A
does not synchronize on that lock.
====== end quote =======
[akpm@linux-foundation.org: checkpatch fixes]
Reported-by: Ulrich Obergfell <uobergfe@redhat.com>
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Hugh Dickins <hughd@google.com>
Cc: Dave Jones <davej@redhat.com>
Acked-by: Larry Woodman <lwoodman@redhat.com>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: Mark Salter <msalter@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CWE ID: CWE-264 | 0 | 21,257 |
Analyze the following 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 inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{
struct sock *sk = sock->sk;
struct net *net = sock_net(sk);
switch (cmd) {
case SIOCGSTAMP:
return sock_get_timestamp(sk, (struct timeval __user *)arg);
case SIOCGSTAMPNS:
return sock_get_timestampns(sk, (struct timespec __user *)arg);
case SIOCADDRT:
case SIOCDELRT:
return ipv6_route_ioctl(net, cmd, (void __user *)arg);
case SIOCSIFADDR:
return addrconf_add_ifaddr(net, (void __user *) arg);
case SIOCDIFADDR:
return addrconf_del_ifaddr(net, (void __user *) arg);
case SIOCSIFDSTADDR:
return addrconf_set_dstaddr(net, (void __user *) arg);
default:
if (!sk->sk_prot->ioctl)
return -ENOIOCTLCMD;
return sk->sk_prot->ioctl(sk, cmd, arg);
}
/*NOTREACHED*/
return 0;
}
Commit Message: net: add validation for the socket syscall protocol argument
郭永刚 reported that one could simply crash the kernel as root by
using a simple program:
int socket_fd;
struct sockaddr_in addr;
addr.sin_port = 0;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_family = 10;
socket_fd = socket(10,3,0x40000000);
connect(socket_fd , &addr,16);
AF_INET, AF_INET6 sockets actually only support 8-bit protocol
identifiers. inet_sock's skc_protocol field thus is sized accordingly,
thus larger protocol identifiers simply cut off the higher bits and
store a zero in the protocol fields.
This could lead to e.g. NULL function pointer because as a result of
the cut off inet_num is zero and we call down to inet_autobind, which
is NULL for raw sockets.
kernel: Call Trace:
kernel: [<ffffffff816db90e>] ? inet_autobind+0x2e/0x70
kernel: [<ffffffff816db9a4>] inet_dgram_connect+0x54/0x80
kernel: [<ffffffff81645069>] SYSC_connect+0xd9/0x110
kernel: [<ffffffff810ac51b>] ? ptrace_notify+0x5b/0x80
kernel: [<ffffffff810236d8>] ? syscall_trace_enter_phase2+0x108/0x200
kernel: [<ffffffff81645e0e>] SyS_connect+0xe/0x10
kernel: [<ffffffff81779515>] tracesys_phase2+0x84/0x89
I found no particular commit which introduced this problem.
CVE: CVE-2015-8543
Cc: Cong Wang <cwang@twopensource.com>
Reported-by: 郭永刚 <guoyonggang@360.cn>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: | 0 | 41,559 |
Analyze the following 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 ecryptfs_free_kmem_caches(void)
{
int i;
/*
* Make sure all delayed rcu free inodes are flushed before we
* destroy cache.
*/
rcu_barrier();
for (i = 0; i < ARRAY_SIZE(ecryptfs_cache_infos); i++) {
struct ecryptfs_cache_info *info;
info = &ecryptfs_cache_infos[i];
if (*(info->cache))
kmem_cache_destroy(*(info->cache));
}
}
Commit Message: fs: limit filesystem stacking depth
Add a simple read-only counter to super_block that indicates how deep this
is in the stack of filesystems. Previously ecryptfs was the only stackable
filesystem and it explicitly disallowed multiple layers of itself.
Overlayfs, however, can be stacked recursively and also may be stacked
on top of ecryptfs or vice versa.
To limit the kernel stack usage we must limit the depth of the
filesystem stack. Initially the limit is set to 2.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
CWE ID: CWE-264 | 0 | 74,569 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static inline int qeth_get_mtu_outof_framesize(int framesize)
{
switch (framesize) {
case 0x4000:
return 8192;
case 0x6000:
return 16384;
case 0xa000:
return 32768;
case 0xffff:
return 57344;
default:
return 0;
}
}
Commit Message: qeth: avoid buffer overflow in snmp ioctl
Check user-defined length in snmp ioctl request and allow request
only if it fits into a qeth command buffer.
Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com>
Reviewed-by: Heiko Carstens <heicars2@linux.vnet.ibm.com>
Reported-by: Nico Golde <nico@ngolde.de>
Reported-by: Fabian Yamaguchi <fabs@goesec.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-119 | 0 | 28,564 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: resp_print_integer(netdissect_options *ndo, register const u_char *bp, int length) {
return resp_print_string_error_integer(ndo, bp, length);
}
Commit Message: CVE-2017-12989/RESP: Make sure resp_get_length() advances the pointer for invalid lengths.
Make sure that it always sends *endp before returning and that, for
invalid lengths where we don't like a character in the length string,
what it sets *endp to is past the character in question, so we don't
run the risk of infinitely looping (or doing something else random) if a
character in the length is invalid.
This fixes an infinite loop discovered by Forcepoint's security
researchers Otto Airamo & Antti Levomäki.
Add a test using the capture file supplied by the reporter(s).
CWE ID: CWE-835 | 0 | 62,518 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void Document::EnqueueMediaQueryChangeListeners(
HeapVector<Member<MediaQueryListListener>>& listeners) {
EnsureScriptedAnimationController().EnqueueMediaQueryChangeListeners(
listeners);
}
Commit Message: Cleanup and remove dead code in SetFocusedElement
This early-out was added in:
https://crrev.com/ce8ea3446283965c7eabab592cbffe223b1cf2bc
Back then, we applied fragment focus in LayoutUpdated() which could
cause this issue. This got cleaned up in:
https://crrev.com/45236fd563e9df53dc45579be1f3d0b4784885a2
so that focus is no longer applied after layout.
+Cleanup: Goto considered harmful
Bug: 795381
Change-Id: Ifeb4d2e03e872fd48cca6720b1d4de36ad1ecbb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1524417
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#641101}
CWE ID: CWE-416 | 0 | 129,680 |
Analyze the following 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 cssAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
ExceptionState exceptionState(ExceptionState::SetterContext, "cssAttribute", "TestObjectPython", info.Holder(), info.GetIsolate());
TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());
V8TRYCATCH_EXCEPTION_VOID(int, cppValue, toInt32(jsValue, exceptionState), exceptionState);
imp->setCSSAttribute(cppValue);
}
Commit Message: document.location bindings fix
BUG=352374
R=jochen@chromium.org
Review URL: https://codereview.chromium.org/196343011
git-svn-id: svn://svn.chromium.org/blink/trunk@169176 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-399 | 0 | 122,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: size_t get_camera_metadata_data_capacity(const camera_metadata_t *metadata) {
return metadata->data_capacity;
}
Commit Message: Camera: Prevent data size overflow
Add a function to check overflow when calculating metadata
data size.
Bug: 30741779
Change-Id: I6405fe608567a4f4113674050f826f305ecae030
CWE ID: CWE-119 | 0 | 157,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: static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
{
char *f_org, *f_dest;
int f_org_len, f_dest_len;
long height, width, threshold;
gdImagePtr im_org, im_dest, im_tmp;
char *fn_org = NULL;
char *fn_dest = NULL;
FILE *org, *dest;
int dest_height = -1;
int dest_width = -1;
int org_height, org_width;
int white, black;
int color, color_org, median;
int int_threshold;
int x, y;
float x_ratio, y_ratio;
#ifdef HAVE_GD_JPG
long ignore_warning;
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pplll", &f_org, &f_org_len, &f_dest, &f_dest_len, &height, &width, &threshold) == FAILURE) {
return;
}
fn_org = f_org;
fn_dest = f_dest;
dest_height = height;
dest_width = width;
int_threshold = threshold;
/* Check threshold value */
if (int_threshold < 0 || int_threshold > 8) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid threshold value '%d'", int_threshold);
RETURN_FALSE;
}
/* Check origin file */
PHP_GD_CHECK_OPEN_BASEDIR(fn_org, "Invalid origin filename");
/* Check destination file */
PHP_GD_CHECK_OPEN_BASEDIR(fn_dest, "Invalid destination filename");
/* Open origin file */
org = VCWD_FOPEN(fn_org, "rb");
if (!org) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' for reading", fn_org);
RETURN_FALSE;
}
/* Open destination file */
dest = VCWD_FOPEN(fn_dest, "wb");
if (!dest) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' for writing", fn_dest);
RETURN_FALSE;
}
switch (image_type) {
#ifdef HAVE_GD_GIF_READ
case PHP_GDIMG_TYPE_GIF:
im_org = gdImageCreateFromGif(org);
if (im_org == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' Not a valid GIF file", fn_dest);
RETURN_FALSE;
}
break;
#endif /* HAVE_GD_GIF_READ */
#ifdef HAVE_GD_JPG
case PHP_GDIMG_TYPE_JPG:
ignore_warning = INI_INT("gd.jpeg_ignore_warning");
#ifdef HAVE_GD_BUNDLED
im_org = gdImageCreateFromJpeg(org, ignore_warning);
#else
im_org = gdImageCreateFromJpeg(org);
#endif
if (im_org == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' Not a valid JPEG file", fn_dest);
RETURN_FALSE;
}
break;
#endif /* HAVE_GD_JPG */
#ifdef HAVE_GD_PNG
case PHP_GDIMG_TYPE_PNG:
im_org = gdImageCreateFromPng(org);
if (im_org == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' Not a valid PNG file", fn_dest);
RETURN_FALSE;
}
break;
#endif /* HAVE_GD_PNG */
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Format not supported");
RETURN_FALSE;
break;
}
org_width = gdImageSX (im_org);
org_height = gdImageSY (im_org);
x_ratio = (float) org_width / (float) dest_width;
y_ratio = (float) org_height / (float) dest_height;
if (x_ratio > 1 && y_ratio > 1) {
if (y_ratio > x_ratio) {
x_ratio = y_ratio;
} else {
y_ratio = x_ratio;
}
dest_width = (int) (org_width / x_ratio);
dest_height = (int) (org_height / y_ratio);
} else {
x_ratio = (float) dest_width / (float) org_width;
y_ratio = (float) dest_height / (float) org_height;
if (y_ratio < x_ratio) {
x_ratio = y_ratio;
} else {
y_ratio = x_ratio;
}
dest_width = (int) (org_width * x_ratio);
dest_height = (int) (org_height * y_ratio);
}
im_tmp = gdImageCreate (dest_width, dest_height);
if (im_tmp == NULL ) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate temporary buffer");
RETURN_FALSE;
}
gdImageCopyResized (im_tmp, im_org, 0, 0, 0, 0, dest_width, dest_height, org_width, org_height);
gdImageDestroy(im_org);
fclose(org);
im_dest = gdImageCreate(dest_width, dest_height);
if (im_dest == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate destination buffer");
RETURN_FALSE;
}
white = gdImageColorAllocate(im_dest, 255, 255, 255);
if (white == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate the colors for the destination buffer");
RETURN_FALSE;
}
black = gdImageColorAllocate(im_dest, 0, 0, 0);
if (black == -1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate the colors for the destination buffer");
RETURN_FALSE;
}
int_threshold = int_threshold * 32;
for (y = 0; y < dest_height; y++) {
for (x = 0; x < dest_width; x++) {
color_org = gdImageGetPixel (im_tmp, x, y);
median = (im_tmp->red[color_org] + im_tmp->green[color_org] + im_tmp->blue[color_org]) / 3;
if (median < int_threshold) {
color = black;
} else {
color = white;
}
gdImageSetPixel (im_dest, x, y, color);
}
}
gdImageDestroy (im_tmp );
gdImageWBMP(im_dest, black , dest);
fflush(dest);
fclose(dest);
gdImageDestroy(im_dest);
RETURN_TRUE;
}
Commit Message:
CWE ID: CWE-254 | 0 | 15,184 |
Analyze the following 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 QQuickWebViewFlickablePrivate::loadDidCommit()
{
isTransitioningToNewPage = true;
}
Commit Message: [Qt][WK2] Allow transparent WebViews
https://bugs.webkit.org/show_bug.cgi?id=80608
Reviewed by Tor Arne Vestbø.
Added support for transparentBackground in QQuickWebViewExperimental.
This uses the existing drawsTransparentBackground property in WebKit2.
Also, changed LayerTreeHostQt to set the contentsOpaque flag when the root layer changes,
otherwise the change doesn't take effect.
A new API test was added.
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewPrivate::setTransparentBackground):
(QQuickWebViewPrivate::transparentBackground):
(QQuickWebViewExperimental::transparentBackground):
(QQuickWebViewExperimental::setTransparentBackground):
* UIProcess/API/qt/qquickwebview_p.h:
* UIProcess/API/qt/qquickwebview_p_p.h:
(QQuickWebViewPrivate):
* UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:
(tst_QQuickWebView):
(tst_QQuickWebView::transparentWebViews):
* WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
(WebKit::LayerTreeHostQt::LayerTreeHostQt):
(WebKit::LayerTreeHostQt::setRootCompositingLayer):
git-svn-id: svn://svn.chromium.org/blink/trunk@110254 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-189 | 0 | 101,730 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: bool Editor::canDHTMLCopy() {
return !frame().selection().isInPasswordField() &&
!dispatchCPPEvent(EventTypeNames::beforecopy, DataTransferNumb);
}
Commit Message: Make TypingCommand::insertText() to take SelectionInDOMTree instead of VisibleSelection
This patch makes |TypingCommand::insertText()| to take |SelectionInDOMTree|
instead of |VisibleSelection| to reduce usage of |VisibleSelection| for
improving code health.
BUG=657237
TEST=n/a
Review-Url: https://codereview.chromium.org/2733183002
Cr-Commit-Position: refs/heads/master@{#455368}
CWE ID: | 0 | 129,110 |
Analyze the following 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 RenderBlock::addPercentHeightDescendant(RenderBox* descendant)
{
insertIntoTrackedRendererMaps(descendant, gPercentHeightDescendantsMap, gPercentHeightContainerMap);
}
Commit Message: Separate repaint and layout requirements of StyleDifference (Step 1)
Previously StyleDifference was an enum that proximately bigger values
imply smaller values (e.g. StyleDifferenceLayout implies
StyleDifferenceRepaint). This causes unnecessary repaints in some cases
on layout change.
Convert StyleDifference to a structure containing relatively independent
flags.
This change doesn't directly improve the result, but can make further
repaint optimizations possible.
Step 1 doesn't change any functionality. RenderStyle still generate the
legacy StyleDifference enum when comparing styles and convert the result
to the new StyleDifference. Implicit requirements are not handled during
the conversion.
Converted call sites to use the new StyleDifference according to the
following conversion rules:
- diff == StyleDifferenceEqual (&& !context) => diff.hasNoChange()
- diff == StyleDifferenceRepaint => diff.needsRepaintObjectOnly()
- diff == StyleDifferenceRepaintLayer => diff.needsRepaintLayer()
- diff == StyleDifferenceRepaint || diff == StyleDifferenceRepaintLayer => diff.needsRepaintLayer()
- diff >= StyleDifferenceRepaint => diff.needsRepaint() || diff.needsLayout()
- diff >= StyleDifferenceRepaintLayer => diff.needsRepaintLayer() || diff.needsLayout()
- diff > StyleDifferenceRepaintLayer => diff.needsLayout()
- diff == StyleDifferencePositionedMovementLayoutOnly => diff.needsPositionedMovementLayoutOnly()
- diff == StyleDifferenceLayout => diff.needsFullLayout()
BUG=358460
TEST=All existing layout tests.
R=eseidel@chromium.org, esprehn@chromium.org, jchaffraix@chromium.org
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=171983
Review URL: https://codereview.chromium.org/236203020
git-svn-id: svn://svn.chromium.org/blink/trunk@172331 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-119 | 0 | 116,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: static void vmx_switch_vmcs(struct kvm_vcpu *vcpu, struct loaded_vmcs *vmcs)
{
struct vcpu_vmx *vmx = to_vmx(vcpu);
int cpu;
if (vmx->loaded_vmcs == vmcs)
return;
cpu = get_cpu();
vmx->loaded_vmcs = vmcs;
vmx_vcpu_put(vcpu);
vmx_vcpu_load(vcpu, cpu);
vcpu->cpu = cpu;
put_cpu();
}
Commit Message: kvm: nVMX: Don't allow L2 to access the hardware CR8
If L1 does not specify the "use TPR shadow" VM-execution control in
vmcs12, then L0 must specify the "CR8-load exiting" and "CR8-store
exiting" VM-execution controls in vmcs02. Failure to do so will give
the L2 VM unrestricted read/write access to the hardware CR8.
This fixes CVE-2017-12154.
Signed-off-by: Jim Mattson <jmattson@google.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
CWE ID: | 0 | 63,062 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: construct_data_tlv(struct sc_card *card, struct sc_apdu *apdu, unsigned char *apdu_buf,
unsigned char *data_tlv, size_t * data_tlv_len, const unsigned char key_type)
{
size_t block_size = (KEY_TYPE_AES == key_type ? 16 : 8);
unsigned char pad[4096] = { 0 };
size_t pad_len;
size_t tlv_more; /* increased tlv length */
unsigned char iv[16] = { 0 };
epass2003_exdata *exdata = NULL;
if (!card->drv_data)
return SC_ERROR_INVALID_ARGUMENTS;
exdata = (epass2003_exdata *)card->drv_data;
/* padding */
apdu_buf[block_size] = 0x87;
memcpy(pad, apdu->data, apdu->lc);
pad[apdu->lc] = 0x80;
if ((apdu->lc + 1) % block_size)
pad_len = ((apdu->lc + 1) / block_size + 1) * block_size;
else
pad_len = apdu->lc + 1;
/* encode Lc' */
if (pad_len > 0x7E) {
/* Lc' > 0x7E, use extended APDU */
apdu_buf[block_size + 1] = 0x82;
apdu_buf[block_size + 2] = (unsigned char)((pad_len + 1) / 0x100);
apdu_buf[block_size + 3] = (unsigned char)((pad_len + 1) % 0x100);
apdu_buf[block_size + 4] = 0x01;
tlv_more = 5;
}
else {
apdu_buf[block_size + 1] = (unsigned char)pad_len + 1;
apdu_buf[block_size + 2] = 0x01;
tlv_more = 3;
}
memcpy(data_tlv, &apdu_buf[block_size], tlv_more);
/* encrypt Data */
if (KEY_TYPE_AES == key_type)
aes128_encrypt_cbc(exdata->sk_enc, 16, iv, pad, pad_len, apdu_buf + block_size + tlv_more);
else
des3_encrypt_cbc(exdata->sk_enc, 16, iv, pad, pad_len, apdu_buf + block_size + tlv_more);
memcpy(data_tlv + tlv_more, apdu_buf + block_size + tlv_more, pad_len);
*data_tlv_len = tlv_more + pad_len;
return 0;
}
Commit Message: fixed out of bounds reads
Thanks to Eric Sesterhenn from X41 D-SEC GmbH
for reporting and suggesting security fixes.
CWE ID: CWE-125 | 0 | 78,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 int fpu_insn(RAnal* anal, RAnalOp* op, ut16 code){
op->family = R_ANAL_OP_FAMILY_FPU;
return op->size;
}
Commit Message: Fix #9903 - oobread in RAnal.sh
CWE ID: CWE-125 | 0 | 82,689 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: Platform::Graphics::Window* WebPagePrivate::platformWindow() const
{
return m_client->window();
}
Commit Message: [BlackBerry] Adapt to new BlackBerry::Platform::TouchPoint API
https://bugs.webkit.org/show_bug.cgi?id=105143
RIM PR 171941
Reviewed by Rob Buis.
Internally reviewed by George Staikos.
Source/WebCore:
TouchPoint instances now provide document coordinates for the viewport
and content position of the touch event. The pixel coordinates stored
in the TouchPoint should no longer be needed in WebKit.
Also adapt to new method names and encapsulation of TouchPoint data
members.
No change in behavior, no new tests.
* platform/blackberry/PlatformTouchPointBlackBerry.cpp:
(WebCore::PlatformTouchPoint::PlatformTouchPoint):
Source/WebKit/blackberry:
TouchPoint instances now provide document coordinates for the viewport
and content position of the touch event. The pixel coordinates stored
in the TouchPoint should no longer be needed in WebKit. One exception
is when passing events to a full screen plugin.
Also adapt to new method names and encapsulation of TouchPoint data
members.
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPage::touchEvent):
(BlackBerry::WebKit::WebPage::touchPointAsMouseEvent):
(BlackBerry::WebKit::WebPagePrivate::dispatchTouchEventToFullScreenPlugin):
(BlackBerry::WebKit::WebPagePrivate::dispatchTouchPointAsMouseEventToFullScreenPlugin):
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::shouldRequestSpellCheckingOptionsForPoint):
* WebKitSupport/InputHandler.h:
(InputHandler):
* WebKitSupport/TouchEventHandler.cpp:
(BlackBerry::WebKit::TouchEventHandler::doFatFingers):
(BlackBerry::WebKit::TouchEventHandler::handleTouchPoint):
* WebKitSupport/TouchEventHandler.h:
(TouchEventHandler):
Tools:
Adapt to new method names and encapsulation of TouchPoint data members.
* DumpRenderTree/blackberry/EventSender.cpp:
(addTouchPointCallback):
(updateTouchPointCallback):
(touchEndCallback):
(releaseTouchPointCallback):
(sendTouchEvent):
git-svn-id: svn://svn.chromium.org/blink/trunk@137880 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: | 0 | 104,332 |
Analyze the following 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 DeviceManagerImpl::set_connection_error_handler(
const mojo::Closure& error_handler) {
binding_.set_connection_error_handler(error_handler);
}
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,287 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void RenderFrameHostImpl::CancelBlockedRequestsForFrame() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
NotifyForEachFrameFromUI(
this, base::BindRepeating(
&ResourceDispatcherHostImpl::CancelBlockedRequestsForRoute));
}
Commit Message: If a page calls |window.focus()|, kick it out of fullscreen.
BUG=776418, 800056
Change-Id: I1880fe600e4814c073f247c43b1c1ac80c8fc017
Reviewed-on: https://chromium-review.googlesource.com/852378
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Philip Jägenstedt <foolip@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533790}
CWE ID: | 0 | 147,610 |
Analyze the following 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 ClassicPendingScript::Prefinalize() {
CancelStreaming();
prefinalizer_called_ = true;
}
Commit Message: Check CORS using PassesAccessControlCheck() with supplied SecurityOrigin
Partial revert of https://chromium-review.googlesource.com/535694.
Bug: 799477
Change-Id: I878bb9bcb83afaafe8601293db9aa644fc5929b3
Reviewed-on: https://chromium-review.googlesource.com/898427
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Takeshi Yoshino <tyoshino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#535176}
CWE ID: CWE-200 | 0 | 149,698 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void V8TestObject::ActivityLoggingSetterForAllWorldsLongAttributeAttributeSetterCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_activityLoggingSetterForAllWorldsLongAttribute_Setter");
v8::Local<v8::Value> v8_value = info[0];
ScriptState* script_state = ScriptState::ForRelevantRealm(info);
V8PerContextData* context_data = script_state->PerContextData();
if (context_data && context_data->ActivityLogger()) {
context_data->ActivityLogger()->LogSetter("TestObject.activityLoggingSetterForAllWorldsLongAttribute", v8_value);
}
test_object_v8_internal::ActivityLoggingSetterForAllWorldsLongAttributeAttributeSetter(v8_value, info);
}
Commit Message: bindings: Support "attribute FrozenArray<T>?"
Adds a quick hack to support a case of "attribute FrozenArray<T>?".
Bug: 1028047
Change-Id: Ib3cecc4beb6bcc0fb0dbc667aca595454cc90c86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1933866
Reviewed-by: Hitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718676}
CWE ID: | 0 | 134,515 |
Analyze the following 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 GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) {
const WebURL& blank_url = GURL(url::kAboutBlankURL);
WebVector<WebURL> urls;
ds->redirectChain(urls);
result->reserve(urls.size());
for (size_t i = 0; i < urls.size(); ++i) {
if (urls[i] != GURL(kSwappedOutURL))
result->push_back(urls[i]);
else
result->push_back(blank_url);
}
}
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,133 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static const char *set_loglevel_override(cmd_parms *cmd, void *d_, int argc,
char *const argv[])
{
core_server_config *sconf;
conn_log_config *entry;
int ret, i;
const char *addr, *mask, *err;
if (argc < 2)
return "LogLevelOverride requires at least two arguments";
entry = apr_pcalloc(cmd->pool, sizeof(conn_log_config));
sconf = ap_get_core_module_config(cmd->server->module_config);
if (!sconf->conn_log_level)
sconf->conn_log_level = apr_array_make(cmd->pool, 4, sizeof(entry));
APR_ARRAY_PUSH(sconf->conn_log_level, conn_log_config *) = entry;
addr = argv[0];
mask = ap_strchr_c(addr, '/');
if (mask) {
addr = apr_pstrmemdup(cmd->temp_pool, addr, mask - addr);
mask++;
}
ret = apr_ipsubnet_create(&entry->subnet, addr, mask, cmd->pool);
if (ret != APR_SUCCESS)
return "parsing of subnet/netmask failed";
for (i = 1; i < argc; i++) {
if ((err = update_loglevel(cmd, &entry->log, argv[i])) != NULL)
return err;
}
return NULL;
}
Commit Message: core: Disallow Methods' registration at run time (.htaccess), they may be
used only if registered at init time (httpd.conf).
Calling ap_method_register() in children processes is not the right scope
since it won't be shared for all requests.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1807655 13f79535-47bb-0310-9956-ffa450edef68
CWE ID: CWE-416 | 0 | 64,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: OneClickSigninSyncStarter::~OneClickSigninSyncStarter() {
BrowserList::RemoveObserver(this);
}
Commit Message: Display confirmation dialog for untrusted signins
BUG=252062
Review URL: https://chromiumcodereview.appspot.com/17482002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208520 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-200 | 0 | 112,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 BrowserPluginGuest::UpdateRect(
RenderViewHost* render_view_host,
const ViewHostMsg_UpdateRect_Params& params) {
if (!params.needs_ack)
return;
if (((auto_size_enabled_ && InAutoSizeBounds(params.view_size)) ||
(params.view_size.width() == damage_view_size().width() &&
params.view_size.height() == damage_view_size().height())) &&
params.scale_factor == damage_buffer_scale_factor()) {
TransportDIB* dib = render_view_host->GetProcess()->
GetTransportDIB(params.bitmap);
if (dib) {
#if defined(OS_WIN)
size_t guest_damage_buffer_size = params.bitmap_rect.width() *
params.bitmap_rect.height() * 4;
size_t embedder_damage_buffer_size = damage_buffer_size_;
#else
size_t guest_damage_buffer_size = dib->size();
size_t embedder_damage_buffer_size = damage_buffer_->size();
#endif
void* guest_memory = dib->memory();
void* embedder_memory = damage_buffer_->memory();
size_t size = std::min(guest_damage_buffer_size,
embedder_damage_buffer_size);
memcpy(embedder_memory, guest_memory, size);
}
}
BrowserPluginMsg_UpdateRect_Params relay_params;
#if defined(OS_MACOSX)
relay_params.damage_buffer_identifier = damage_buffer_->id();
#elif defined(OS_WIN)
relay_params.damage_buffer_identifier = remote_damage_buffer_handle_;
#else
relay_params.damage_buffer_identifier = damage_buffer_->handle();
#endif
relay_params.bitmap_rect = params.bitmap_rect;
relay_params.scroll_delta = params.scroll_delta;
relay_params.scroll_rect = params.scroll_rect;
relay_params.copy_rects = params.copy_rects;
relay_params.view_size = params.view_size;
relay_params.scale_factor = params.scale_factor;
relay_params.is_resize_ack = ViewHostMsg_UpdateRect_Flags::is_resize_ack(
params.flags);
int message_id = pending_update_counter_++;
pending_updates_.AddWithID(render_view_host, message_id);
SendMessageToEmbedder(new BrowserPluginMsg_UpdateRect(embedder_routing_id(),
instance_id(),
message_id,
relay_params));
}
Commit Message: Implement TextureImageTransportSurface using texture mailbox
This has a couple of advantages:
- allow tearing down and recreating the UI parent context without
losing the renderer contexts
- do not require a context to be able to generate textures when
creating the GLSurfaceHandle
- clearer ownership semantics that potentially allows for more
robust and easier lost context handling/thumbnailing/etc., since a texture is at
any given time owned by either: UI parent, mailbox, or
TextureImageTransportSurface
- simplify frontbuffer protection logic;
the frontbuffer textures are now owned by RWHV where they are refcounted
The TextureImageTransportSurface informs RenderWidgetHostView of the
mailbox names for the front- and backbuffer textures by
associating them with a surface_handle (1 or 2) in the AcceleratedSurfaceNew message.
During SwapBuffers() or PostSubBuffer() cycles, it then uses
produceTextureCHROMIUM() and consumeTextureCHROMIUM()
to transfer ownership between renderer and browser compositor.
RWHV sends back the surface_handle of the buffer being returned with the Swap ACK
(or 0 if no buffer is being returned in which case TextureImageTransportSurface will
allocate a new texture - note that this could be used to
simply keep textures for thumbnailing).
BUG=154815,139616
TBR=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11194042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171569 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: | 0 | 114,429 |
Analyze the following 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 TaskManagerView::ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) {
if (child == this) {
if (is_add) {
parent->AddChildView(about_memory_link_);
if (purge_memory_button_)
parent->AddChildView(purge_memory_button_);
parent->AddChildView(kill_button_);
AddChildView(tab_table_);
} else {
parent->RemoveChildView(kill_button_);
if (purge_memory_button_)
parent->RemoveChildView(purge_memory_button_);
parent->RemoveChildView(about_memory_link_);
}
}
}
Commit Message: accelerators: Remove deprecated Accelerator ctor that takes booleans.
BUG=128242
R=ben@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10399085
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137957 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-399 | 0 | 106,573 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static u32 cdc_ncm_max_dgram_size(struct usbnet *dev)
{
struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
if (cdc_ncm_comm_intf_is_mbim(dev->intf->cur_altsetting) && ctx->mbim_desc)
return le16_to_cpu(ctx->mbim_desc->wMaxSegmentSize);
if (ctx->ether_desc)
return le16_to_cpu(ctx->ether_desc->wMaxSegmentSize);
return CDC_NCM_MAX_DATAGRAM_SIZE;
}
Commit Message: cdc_ncm: do not call usbnet_link_change from cdc_ncm_bind
usbnet_link_change will call schedule_work and should be
avoided if bind is failing. Otherwise we will end up with
scheduled work referring to a netdev which has gone away.
Instead of making the call conditional, we can just defer
it to usbnet_probe, using the driver_info flag made for
this purpose.
Fixes: 8a34b0ae8778 ("usbnet: cdc_ncm: apply usbnet_link_change")
Reported-by: Andrey Konovalov <andreyknvl@gmail.com>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: | 0 | 53,622 |
Analyze the following 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 TabStripNotificationObserver::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(notification_, type);
if (type == chrome::NOTIFICATION_TAB_PARENTED) {
ObserveTab(&content::Source<content::WebContents>(source)->GetController());
} else if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
ObserveTab(&content::Source<content::WebContents>(source)->GetController());
} else {
ObserveTab(content::Source<NavigationController>(source).ptr());
}
delete this;
}
Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt.
BUG=107201
TEST=no visible change
Review URL: https://chromiumcodereview.appspot.com/11293205
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-20 | 0 | 117,562 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void tsc210x_audio_out_cb(TSC210xState *s, int free_b)
{
if (s->codec.out.len >= free_b) {
tsc210x_out_flush(s, free_b);
return;
}
s->codec.out.size = MIN(free_b, 16384);
qemu_irq_raise(s->codec.tx_start);
}
Commit Message:
CWE ID: CWE-119 | 0 | 15,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: static MagickStatusType ReadPSDChannelRaw(Image *image,const size_t channels,
const ssize_t type,ExceptionInfo *exception)
{
MagickStatusType
status;
size_t
count,
row_size;
ssize_t
y;
unsigned char
*pixels;
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" layer data is RAW");
row_size=GetPSDRowSize(image);
pixels=(unsigned char *) AcquireQuantumMemory(row_size,8*sizeof(*pixels));
if (pixels == (unsigned char *) NULL)
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
status=MagickTrue;
for (y=0; y < (ssize_t) image->rows; y++)
{
status=MagickFalse;
count=ReadBlob(image,row_size,pixels);
if (count != row_size)
break;
status=ReadPSDChannelPixels(image,channels,y,type,pixels,exception);
if (status == MagickFalse)
break;
}
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
return(status);
}
Commit Message:
CWE ID: CWE-119 | 0 | 71,655 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: RenderBox* RenderBox::findAutoscrollable(RenderObject* renderer)
{
while (renderer && !(renderer->isBox() && toRenderBox(renderer)->canAutoscroll())) {
if (!renderer->parent() && renderer->node() == renderer->document() && renderer->document().ownerElement())
renderer = renderer->document().ownerElement()->renderer();
else
renderer = renderer->parent();
}
return renderer && renderer->isBox() ? toRenderBox(renderer) : 0;
}
Commit Message: Separate repaint and layout requirements of StyleDifference (Step 1)
Previously StyleDifference was an enum that proximately bigger values
imply smaller values (e.g. StyleDifferenceLayout implies
StyleDifferenceRepaint). This causes unnecessary repaints in some cases
on layout change.
Convert StyleDifference to a structure containing relatively independent
flags.
This change doesn't directly improve the result, but can make further
repaint optimizations possible.
Step 1 doesn't change any functionality. RenderStyle still generate the
legacy StyleDifference enum when comparing styles and convert the result
to the new StyleDifference. Implicit requirements are not handled during
the conversion.
Converted call sites to use the new StyleDifference according to the
following conversion rules:
- diff == StyleDifferenceEqual (&& !context) => diff.hasNoChange()
- diff == StyleDifferenceRepaint => diff.needsRepaintObjectOnly()
- diff == StyleDifferenceRepaintLayer => diff.needsRepaintLayer()
- diff == StyleDifferenceRepaint || diff == StyleDifferenceRepaintLayer => diff.needsRepaintLayer()
- diff >= StyleDifferenceRepaint => diff.needsRepaint() || diff.needsLayout()
- diff >= StyleDifferenceRepaintLayer => diff.needsRepaintLayer() || diff.needsLayout()
- diff > StyleDifferenceRepaintLayer => diff.needsLayout()
- diff == StyleDifferencePositionedMovementLayoutOnly => diff.needsPositionedMovementLayoutOnly()
- diff == StyleDifferenceLayout => diff.needsFullLayout()
BUG=358460
TEST=All existing layout tests.
R=eseidel@chromium.org, esprehn@chromium.org, jchaffraix@chromium.org
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=171983
Review URL: https://codereview.chromium.org/236203020
git-svn-id: svn://svn.chromium.org/blink/trunk@172331 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-119 | 0 | 116,519 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void Browser::TabDetachedAtImpl(TabContentsWrapper* contents, int index,
DetachType type) {
if (type == DETACH_TYPE_DETACH) {
if (contents == GetSelectedTabContentsWrapper()) {
LocationBar* location_bar = window()->GetLocationBar();
if (location_bar)
location_bar->SaveStateToContents(contents->tab_contents());
}
if (!tab_handler_->GetTabStripModel()->closing_all())
SyncHistoryWithTabs(0);
}
SetAsDelegate(contents, NULL);
RemoveScheduledUpdatesFor(contents->tab_contents());
if (find_bar_controller_.get() &&
index == tab_handler_->GetTabStripModel()->active_index()) {
find_bar_controller_->ChangeTabContents(NULL);
}
if (is_attempting_to_close_browser_) {
ClearUnloadState(contents->tab_contents(), false);
}
registrar_.Remove(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED,
Source<TabContents>(contents->tab_contents()));
registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED,
Source<TabContents>(contents->tab_contents()));
}
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,399 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static struct dyn_lease *find_lease_by_nip(uint32_t nip)
{
unsigned i;
for (i = 0; i < server_config.max_leases; i++)
if (g_leases[i].lease_nip == nip)
return &g_leases[i];
return NULL;
}
Commit Message:
CWE ID: CWE-125 | 0 | 13,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: bool HTMLFormElement::ValidateInteractively() {
UseCounter::Count(GetDocument(), WebFeature::kFormValidationStarted);
for (const auto& element : ListedElements()) {
if (element->IsFormControlElement())
ToHTMLFormControlElement(element)->HideVisibleValidationMessage();
}
HeapVector<Member<HTMLFormControlElement>> unhandled_invalid_controls;
if (!CheckInvalidControlsAndCollectUnhandled(
&unhandled_invalid_controls, kCheckValidityDispatchInvalidEvent))
return true;
UseCounter::Count(GetDocument(),
WebFeature::kFormValidationAbortedSubmission);
GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
for (const auto& unhandled : unhandled_invalid_controls) {
if (unhandled->IsFocusable()) {
unhandled->ShowValidationMessage();
UseCounter::Count(GetDocument(),
WebFeature::kFormValidationShowedMessage);
break;
}
}
if (GetDocument().GetFrame()) {
for (const auto& unhandled : unhandled_invalid_controls) {
if (unhandled->IsFocusable())
continue;
String message(
"An invalid form control with name='%name' is not focusable.");
message.Replace("%name", unhandled->GetName());
GetDocument().AddConsoleMessage(ConsoleMessage::Create(
kRenderingMessageSource, kErrorMessageLevel, message));
}
}
return false;
}
Commit Message: Move user activation check to RemoteFrame::Navigate's callers.
Currently RemoteFrame::Navigate is the user of
Frame::HasTransientUserActivation that passes a RemoteFrame*, and
it seems wrong because the user activation (user gesture) needed by
the navigation should belong to the LocalFrame that initiated the
navigation.
Follow-up CLs after this one will update UserActivation code in
Frame to take a LocalFrame* instead of a Frame*, and get rid of
redundant IPCs.
Bug: 811414
Change-Id: I771c1694043edb54374a44213d16715d9c7da704
Reviewed-on: https://chromium-review.googlesource.com/914736
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536728}
CWE ID: CWE-190 | 0 | 152,243 |
Analyze the following 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 LockContentsView::OnDetachableBasePairingStatusChanged(
DetachableBasePairingStatus pairing_status) {
if (!CurrentBigUserView() || !CurrentBigUserView()->auth_user() ||
pairing_status == DetachableBasePairingStatus::kNone ||
(pairing_status == DetachableBasePairingStatus::kAuthenticated &&
detachable_base_model_->PairedBaseMatchesLastUsedByUser(
*CurrentBigUserView()->GetCurrentUser()->basic_user_info))) {
detachable_base_error_bubble_->Close();
return;
}
auth_error_bubble_->Close();
base::string16 error_text =
l10n_util::GetStringUTF16(IDS_ASH_LOGIN_ERROR_DETACHABLE_BASE_CHANGED);
views::Label* label =
new views::Label(error_text, views::style::CONTEXT_MESSAGE_BOX_BODY_TEXT,
views::style::STYLE_PRIMARY);
label->SetMultiLine(true);
label->SetAutoColorReadabilityEnabled(false);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
label->SetEnabledColor(SK_ColorWHITE);
detachable_base_error_bubble_->ShowErrorBubble(
label, CurrentBigUserView()->auth_user()->password_view() /*anchor_view*/,
LoginBubble::kFlagPersistent);
if (GetWidget()->IsActive())
GetWidget()->GetFocusManager()->ClearFocus();
}
Commit Message: cros: Check initial auth type when showing views login.
Bug: 859611
Change-Id: I0298db9bbf4aed6bd40600aef2e1c5794e8cd058
Reviewed-on: https://chromium-review.googlesource.com/1123056
Reviewed-by: Xiaoyin Hu <xiaoyinh@chromium.org>
Commit-Queue: Jacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572224}
CWE ID: | 0 | 131,517 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void WebContentsImpl::FriendWrapper::RemoveCreatedCallbackForTesting(
const CreatedCallback& callback) {
for (size_t i = 0; i < g_created_callbacks.Get().size(); ++i) {
if (g_created_callbacks.Get().at(i).Equals(callback)) {
g_created_callbacks.Get().erase(g_created_callbacks.Get().begin() + i);
return;
}
}
}
Commit Message: If JavaScript shows a dialog, cause the page to lose fullscreen.
BUG=670135, 550017, 726761, 728276
Review-Url: https://codereview.chromium.org/2906133004
Cr-Commit-Position: refs/heads/master@{#478884}
CWE ID: CWE-20 | 0 | 135,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: bool RenderViewImpl::HasTouchEventHandlersAt(const gfx::Point& point) const {
if (!webview())
return false;
return webview()->hasTouchEventHandlersAt(point);
}
Commit Message: Let the browser handle external navigations from DevTools.
BUG=180555
Review URL: https://chromiumcodereview.appspot.com/12531004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186793 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-264 | 0 | 115,520 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: QuotaManager::EvictionContext::EvictionContext()
: evicted_type(kStorageTypeUnknown) {
}
Commit Message: Wipe out QuotaThreadTask.
This is a one of a series of refactoring patches for QuotaManager.
http://codereview.chromium.org/10872054/
http://codereview.chromium.org/10917060/
BUG=139270
Review URL: https://chromiumcodereview.appspot.com/10919070
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@154987 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-399 | 0 | 102,181 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: base::Value* reference_value() const { return reference_value_.get(); }
Commit Message: V8ValueConverter::ToV8Value should not trigger setters
BUG=606390
Review URL: https://codereview.chromium.org/1918793003
Cr-Commit-Position: refs/heads/master@{#390045}
CWE ID: | 0 | 156,544 |
Analyze the following 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 check(RBinFile *arch) {
const ut8 *bytes = arch ? r_buf_buffer (arch->buf) : NULL;
ut64 sz = arch ? r_buf_size (arch->buf): 0;
return check_bytes (bytes, sz);
}
Commit Message: fix #6872
CWE ID: CWE-476 | 0 | 68,081 |
Analyze the following 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 kvm_iommu_put_pages(struct kvm *kvm,
gfn_t base_gfn, unsigned long npages)
{
struct iommu_domain *domain;
gfn_t end_gfn, gfn;
pfn_t pfn;
u64 phys;
domain = kvm->arch.iommu_domain;
end_gfn = base_gfn + npages;
gfn = base_gfn;
/* check if iommu exists and in use */
if (!domain)
return;
while (gfn < end_gfn) {
unsigned long unmap_pages;
size_t size;
/* Get physical address */
phys = iommu_iova_to_phys(domain, gfn_to_gpa(gfn));
pfn = phys >> PAGE_SHIFT;
/* Unmap address from IO address space */
size = iommu_unmap(domain, gfn_to_gpa(gfn), PAGE_SIZE);
unmap_pages = 1ULL << get_order(size);
/* Unpin all pages we just unmapped to not leak any memory */
kvm_unpin_pages(kvm, pfn, unmap_pages);
gfn += unmap_pages;
}
}
Commit Message: KVM: unmap pages from the iommu when slots are removed
commit 32f6daad4651a748a58a3ab6da0611862175722f upstream.
We've been adding new mappings, but not destroying old mappings.
This can lead to a page leak as pages are pinned using
get_user_pages, but only unpinned with put_page if they still
exist in the memslots list on vm shutdown. A memslot that is
destroyed while an iommu domain is enabled for the guest will
therefore result in an elevated page reference count that is
never cleared.
Additionally, without this fix, the iommu is only programmed
with the first translation for a gpa. This can result in
peer-to-peer errors if a mapping is destroyed and replaced by a
new mapping at the same gpa as the iommu will still be pointing
to the original, pinned memory address.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CWE ID: CWE-264 | 0 | 20,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: PasswordStoreLoginsChangedObserver::PasswordStoreLoginsChangedObserver(
AutomationProvider* automation,
IPC::Message* reply_message,
PasswordStoreChange::Type expected_type,
const std::string& result_key)
: automation_(automation->AsWeakPtr()),
reply_message_(reply_message),
expected_type_(expected_type),
result_key_(result_key),
done_event_(false, false) {
AddRef();
}
Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt.
BUG=107201
TEST=no visible change
Review URL: https://chromiumcodereview.appspot.com/11293205
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-20 | 0 | 117,619 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void GLES2DecoderImpl::RestoreTextureState(unsigned service_id) const {
Texture* texture = texture_manager()->GetTextureForServiceId(service_id);
if (texture) {
GLenum target = texture->target();
api()->glBindTextureFn(target, service_id);
api()->glTexParameteriFn(target, GL_TEXTURE_WRAP_S, texture->wrap_s());
api()->glTexParameteriFn(target, GL_TEXTURE_WRAP_T, texture->wrap_t());
api()->glTexParameteriFn(target, GL_TEXTURE_MIN_FILTER,
texture->min_filter());
api()->glTexParameteriFn(target, GL_TEXTURE_MAG_FILTER,
texture->mag_filter());
if (feature_info_->IsWebGL2OrES3Context()) {
api()->glTexParameteriFn(target, GL_TEXTURE_BASE_LEVEL,
texture->base_level());
}
RestoreTextureUnitBindings(state_.active_texture_unit);
}
}
Commit Message: Implement immutable texture base/max level clamping
It seems some drivers fail to handle that gracefully, so let's always clamp
to be on the safe side.
BUG=877874
TEST=test case in the bug, gpu_unittests
R=kbr@chromium.org
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I6d93cb9389ea70525df4604112223604577582a2
Reviewed-on: https://chromium-review.googlesource.com/1194994
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587264}
CWE ID: CWE-119 | 0 | 145,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: static av_cold void uninit(AVFilterContext *ctx)
{
GradFunContext *s = ctx->priv;
av_freep(&s->buf);
}
Commit Message: avfilter: fix plane validity checks
Fixes out of array accesses
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
CWE ID: CWE-119 | 0 | 29,756 |
Analyze the following 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 ext4_ext_calc_metadata_amount(struct inode *inode, ext4_lblk_t lblock)
{
struct ext4_inode_info *ei = EXT4_I(inode);
int idxs;
idxs = ((inode->i_sb->s_blocksize - sizeof(struct ext4_extent_header))
/ sizeof(struct ext4_extent_idx));
/*
* If the new delayed allocation block is contiguous with the
* previous da block, it can share index blocks with the
* previous block, so we only need to allocate a new index
* block every idxs leaf blocks. At ldxs**2 blocks, we need
* an additional index block, and at ldxs**3 blocks, yet
* another index blocks.
*/
if (ei->i_da_metadata_calc_len &&
ei->i_da_metadata_calc_last_lblock+1 == lblock) {
int num = 0;
if ((ei->i_da_metadata_calc_len % idxs) == 0)
num++;
if ((ei->i_da_metadata_calc_len % (idxs*idxs)) == 0)
num++;
if ((ei->i_da_metadata_calc_len % (idxs*idxs*idxs)) == 0) {
num++;
ei->i_da_metadata_calc_len = 0;
} else
ei->i_da_metadata_calc_len++;
ei->i_da_metadata_calc_last_lblock++;
return num;
}
/*
* In the worst case we need a new set of index blocks at
* every level of the inode's extent tree.
*/
ei->i_da_metadata_calc_len = 1;
ei->i_da_metadata_calc_last_lblock = lblock;
return ext_depth(inode) + 1;
}
Commit Message: ext4: race-condition protection for ext4_convert_unwritten_extents_endio
We assumed that at the time we call ext4_convert_unwritten_extents_endio()
extent in question is fully inside [map.m_lblk, map->m_len] because
it was already split during submission. But this may not be true due to
a race between writeback vs fallocate.
If extent in question is larger than requested we will split it again.
Special precautions should being done if zeroout required because
[map.m_lblk, map->m_len] already contains valid data.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@vger.kernel.org
CWE ID: CWE-362 | 0 | 18,546 |
Analyze the following 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 __fsnotify_update_child_dentry_flags(struct inode *inode)
{
struct dentry *alias;
int watched;
if (!S_ISDIR(inode->i_mode))
return;
/* determine if the children should tell inode about their events */
watched = fsnotify_inode_watches_children(inode);
spin_lock(&inode->i_lock);
/* run all of the dentries associated with this inode. Since this is a
* directory, there damn well better only be one item on this list */
hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) {
struct dentry *child;
/* run all of the children of the original inode and fix their
* d_flags to indicate parental interest (their parent is the
* original inode) */
spin_lock(&alias->d_lock);
list_for_each_entry(child, &alias->d_subdirs, d_child) {
if (!child->d_inode)
continue;
spin_lock_nested(&child->d_lock, DENTRY_D_LOCK_NESTED);
if (watched)
child->d_flags |= DCACHE_FSNOTIFY_PARENT_WATCHED;
else
child->d_flags &= ~DCACHE_FSNOTIFY_PARENT_WATCHED;
spin_unlock(&child->d_lock);
}
spin_unlock(&alias->d_lock);
}
spin_unlock(&inode->i_lock);
}
Commit Message: dentry name snapshots
take_dentry_name_snapshot() takes a safe snapshot of dentry name;
if the name is a short one, it gets copied into caller-supplied
structure, otherwise an extra reference to external name is grabbed
(those are never modified). In either case the pointer to stable
string is stored into the same structure.
dentry must be held by the caller of take_dentry_name_snapshot(),
but may be freely dropped afterwards - the snapshot will stay
until destroyed by release_dentry_name_snapshot().
Intended use:
struct name_snapshot s;
take_dentry_name_snapshot(&s, dentry);
...
access s.name
...
release_dentry_name_snapshot(&s);
Replaces fsnotify_oldname_...(), gets used in fsnotify to obtain the name
to pass down with event.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
CWE ID: CWE-362 | 0 | 67,470 |
Analyze the following 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 __cpuinit console_cpu_notify(struct notifier_block *self,
unsigned long action, void *hcpu)
{
switch (action) {
case CPU_ONLINE:
case CPU_DEAD:
case CPU_DYING:
case CPU_DOWN_FAILED:
case CPU_UP_CANCELED:
console_lock();
console_unlock();
}
return NOTIFY_OK;
}
Commit Message: printk: fix buffer overflow when calling log_prefix function from call_console_drivers
This patch corrects a buffer overflow in kernels from 3.0 to 3.4 when calling
log_prefix() function from call_console_drivers().
This bug existed in previous releases but has been revealed with commit
162a7e7500f9664636e649ba59defe541b7c2c60 (2.6.39 => 3.0) that made changes
about how to allocate memory for early printk buffer (use of memblock_alloc).
It disappears with commit 7ff9554bb578ba02166071d2d487b7fc7d860d62 (3.4 => 3.5)
that does a refactoring of printk buffer management.
In log_prefix(), the access to "p[0]", "p[1]", "p[2]" or
"simple_strtoul(&p[1], &endp, 10)" may cause a buffer overflow as this
function is called from call_console_drivers by passing "&LOG_BUF(cur_index)"
where the index must be masked to do not exceed the buffer's boundary.
The trick is to prepare in call_console_drivers() a buffer with the necessary
data (PRI field of syslog message) to be safely evaluated in log_prefix().
This patch can be applied to stable kernel branches 3.0.y, 3.2.y and 3.4.y.
Without this patch, one can freeze a server running this loop from shell :
$ export DUMMY=`cat /dev/urandom | tr -dc '12345AZERTYUIOPQSDFGHJKLMWXCVBNazertyuiopqsdfghjklmwxcvbn' | head -c255`
$ while true do ; echo $DUMMY > /dev/kmsg ; done
The "server freeze" depends on where memblock_alloc does allocate printk buffer :
if the buffer overflow is inside another kernel allocation the problem may not
be revealed, else the server may hangs up.
Signed-off-by: Alexandre SIMON <Alexandre.Simon@univ-lorraine.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CWE ID: CWE-119 | 0 | 33,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: check_table_width(struct table *t, double *newwidth, MAT * minv, int itr)
{
int i, j, k, m, bcol, ecol;
int corr = 0;
struct table_cell *cell = &t->cell;
#ifdef __GNUC__
short orgwidth[t->maxcol + 1], corwidth[t->maxcol + 1];
short cwidth[cell->maxcell + 1];
double swidth[cell->maxcell + 1];
#else /* __GNUC__ */
short orgwidth[MAXCOL], corwidth[MAXCOL];
short cwidth[MAXCELL];
double swidth[MAXCELL];
#endif /* __GNUC__ */
double twidth, sxy, *Sxx, stotal;
twidth = 0.;
stotal = 0.;
for (i = 0; i <= t->maxcol; i++) {
twidth += newwidth[i];
stotal += m_entry(minv, i, i);
for (m = 0; m < i; m++) {
stotal += 2 * m_entry(minv, i, m);
}
}
Sxx = NewAtom_N(double, cell->maxcell + 1);
for (k = 0; k <= cell->maxcell; k++) {
j = cell->index[k];
bcol = cell->col[j];
ecol = bcol + cell->colspan[j];
swidth[j] = 0.;
for (i = bcol; i < ecol; i++)
swidth[j] += newwidth[i];
cwidth[j] = cell->width[j] - (cell->colspan[j] - 1) * t->cellspacing;
Sxx[j] = 0.;
for (i = bcol; i < ecol; i++) {
Sxx[j] += m_entry(minv, i, i);
for (m = bcol; m <= ecol; m++) {
if (m < i)
Sxx[j] += 2 * m_entry(minv, i, m);
}
}
}
/* compress table */
corr = check_compressible_cell(t, minv, newwidth, swidth,
cwidth, twidth, Sxx, -1, -1, stotal, corr);
if (itr < MAX_ITERATION && corr > 0)
return corr;
/* compress multicolumn cell */
for (k = cell->maxcell; k >= 0; k--) {
j = cell->index[k];
corr = check_compressible_cell(t, minv, newwidth, swidth,
cwidth, twidth, Sxx,
-1, j, Sxx[j], corr);
if (itr < MAX_ITERATION && corr > 0)
return corr;
}
/* compress single column cell */
for (i = 0; i <= t->maxcol; i++) {
corr = check_compressible_cell(t, minv, newwidth, swidth,
cwidth, twidth, Sxx,
i, -1, m_entry(minv, i, i), corr);
if (itr < MAX_ITERATION && corr > 0)
return corr;
}
for (i = 0; i <= t->maxcol; i++)
corwidth[i] = orgwidth[i] = round(newwidth[i]);
check_minimum_width(t, corwidth);
for (i = 0; i <= t->maxcol; i++) {
double sx = sqrt(m_entry(minv, i, i));
if (sx < 0.1)
continue;
if (orgwidth[i] < t->minimum_width[i] &&
corwidth[i] == t->minimum_width[i]) {
double w = (sx > 0.5) ? 0.5 : sx * 0.2;
sxy = 0.;
for (m = 0; m <= t->maxcol; m++) {
if (m == i)
continue;
sxy += m_entry(minv, i, m);
}
if (sxy <= 0.) {
correct_table_matrix(t, i, 1, t->minimum_width[i], w);
corr++;
}
}
}
for (k = 0; k <= cell->maxcell; k++) {
int nwidth = 0, mwidth;
double sx;
j = cell->index[k];
sx = sqrt(Sxx[j]);
if (sx < 0.1)
continue;
bcol = cell->col[j];
ecol = bcol + cell->colspan[j];
for (i = bcol; i < ecol; i++)
nwidth += corwidth[i];
mwidth =
cell->minimum_width[j] - (cell->colspan[j] - 1) * t->cellspacing;
if (mwidth > swidth[j] && mwidth == nwidth) {
double w = (sx > 0.5) ? 0.5 : sx * 0.2;
sxy = 0.;
for (i = bcol; i < ecol; i++) {
for (m = 0; m <= t->maxcol; m++) {
if (m >= bcol && m < ecol)
continue;
sxy += m_entry(minv, i, m);
}
}
if (sxy <= 0.) {
correct_table_matrix(t, bcol, cell->colspan[j], mwidth, w);
corr++;
}
}
}
if (itr >= MAX_ITERATION)
return 0;
else
return corr;
}
Commit Message: Prevent negative indent value in feed_table_block_tag()
Bug-Debian: https://github.com/tats/w3m/issues/88
CWE ID: CWE-835 | 0 | 84,613 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void fsl_emb_pmu_stop(struct perf_event *event, int ef_flags)
{
unsigned long flags;
if (event->hw.idx < 0 || !event->hw.sample_period)
return;
if (event->hw.state & PERF_HES_STOPPED)
return;
local_irq_save(flags);
perf_pmu_disable(event->pmu);
fsl_emb_pmu_read(event);
event->hw.state |= PERF_HES_STOPPED | PERF_HES_UPTODATE;
write_pmc(event->hw.idx, 0);
perf_event_update_userpage(event);
perf_pmu_enable(event->pmu);
local_irq_restore(flags);
}
Commit Message: perf: Remove the nmi parameter from the swevent and overflow interface
The nmi parameter indicated if we could do wakeups from the current
context, if not, we would set some state and self-IPI and let the
resulting interrupt do the wakeup.
For the various event classes:
- hardware: nmi=0; PMI is in fact an NMI or we run irq_work_run from
the PMI-tail (ARM etc.)
- tracepoint: nmi=0; since tracepoint could be from NMI context.
- software: nmi=[0,1]; some, like the schedule thing cannot
perform wakeups, and hence need 0.
As one can see, there is very little nmi=1 usage, and the down-side of
not using it is that on some platforms some software events can have a
jiffy delay in wakeup (when arch_irq_work_raise isn't implemented).
The up-side however is that we can remove the nmi parameter and save a
bunch of conditionals in fast paths.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Michael Cree <mcree@orcon.net.nz>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Deng-Cheng Zhu <dengcheng.zhu@gmail.com>
Cc: Anton Blanchard <anton@samba.org>
Cc: Eric B Munson <emunson@mgebm.net>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Cc: Don Zickus <dzickus@redhat.com>
Link: http://lkml.kernel.org/n/tip-agjev8eu666tvknpb3iaj0fg@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
CWE ID: CWE-399 | 0 | 25,461 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void mp_encode_lua_table_as_map(lua_State *L, mp_buf *buf, int level) {
size_t len = 0;
/* First step: count keys into table. No other way to do it with the
* Lua API, we need to iterate a first time. Note that an alternative
* would be to do a single run, and then hack the buffer to insert the
* map opcodes for message pack. Too hackish for this lib. */
lua_pushnil(L);
while(lua_next(L,-2)) {
lua_pop(L,1); /* remove value, keep key for next iteration. */
len++;
}
/* Step two: actually encoding of the map. */
mp_encode_map(L,buf,len);
lua_pushnil(L);
while(lua_next(L,-2)) {
/* Stack: ... key value */
lua_pushvalue(L,-2); /* Stack: ... key value key */
mp_encode_lua_type(L,buf,level+1); /* encode key */
mp_encode_lua_type(L,buf,level+1); /* encode val */
}
}
Commit Message: Security: fix Lua cmsgpack library stack overflow.
During an auditing effort, the Apple Vulnerability Research team discovered
a critical Redis security issue affecting the Lua scripting part of Redis.
-- Description of the problem
Several years ago I merged a pull request including many small changes at
the Lua MsgPack library (that originally I authored myself). The Pull
Request entered Redis in commit 90b6337c1, in 2014.
Unfortunately one of the changes included a variadic Lua function that
lacked the check for the available Lua C stack. As a result, calling the
"pack" MsgPack library function with a large number of arguments, results
into pushing into the Lua C stack a number of new values proportional to
the number of arguments the function was called with. The pushed values,
moreover, are controlled by untrusted user input.
This in turn causes stack smashing which we believe to be exploitable,
while not very deterministic, but it is likely that an exploit could be
created targeting specific versions of Redis executables. However at its
minimum the issue results in a DoS, crashing the Redis server.
-- Versions affected
Versions greater or equal to Redis 2.8.18 are affected.
-- Reproducing
Reproduce with this (based on the original reproduction script by
Apple security team):
https://gist.github.com/antirez/82445fcbea6d9b19f97014cc6cc79f8a
-- Verification of the fix
The fix was tested in the following way:
1) I checked that the problem is no longer observable running the trigger.
2) The Lua code was analyzed to understand the stack semantics, and that
actually enough stack is allocated in all the cases of mp_pack() calls.
3) The mp_pack() function was modified in order to show exactly what items
in the stack were being set, to make sure that there is no silent overflow
even after the fix.
-- Credits
Thank you to the Apple team and to the other persons that helped me
checking the patch and coordinating this communication.
CWE ID: CWE-119 | 0 | 96,433 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: long do_msgsnd(int msqid, long mtype, void __user *mtext,
size_t msgsz, int msgflg)
{
struct msg_queue *msq;
struct msg_msg *msg;
int err;
struct ipc_namespace *ns;
ns = current->nsproxy->ipc_ns;
if (msgsz > ns->msg_ctlmax || (long) msgsz < 0 || msqid < 0)
return -EINVAL;
if (mtype < 1)
return -EINVAL;
msg = load_msg(mtext, msgsz);
if (IS_ERR(msg))
return PTR_ERR(msg);
msg->m_type = mtype;
msg->m_ts = msgsz;
msq = msg_lock_check(ns, msqid);
if (IS_ERR(msq)) {
err = PTR_ERR(msq);
goto out_free;
}
for (;;) {
struct msg_sender s;
err = -EACCES;
if (ipcperms(ns, &msq->q_perm, S_IWUGO))
goto out_unlock_free;
err = security_msg_queue_msgsnd(msq, msg, msgflg);
if (err)
goto out_unlock_free;
if (msgsz + msq->q_cbytes <= msq->q_qbytes &&
1 + msq->q_qnum <= msq->q_qbytes) {
break;
}
/* queue full, wait: */
if (msgflg & IPC_NOWAIT) {
err = -EAGAIN;
goto out_unlock_free;
}
ss_add(msq, &s);
ipc_rcu_getref(msq);
msg_unlock(msq);
schedule();
ipc_lock_by_ptr(&msq->q_perm);
ipc_rcu_putref(msq);
if (msq->q_perm.deleted) {
err = -EIDRM;
goto out_unlock_free;
}
ss_del(&s);
if (signal_pending(current)) {
err = -ERESTARTNOHAND;
goto out_unlock_free;
}
}
msq->q_lspid = task_tgid_vnr(current);
msq->q_stime = get_seconds();
if (!pipelined_send(msq, msg)) {
/* no one is waiting for this message, enqueue it */
list_add_tail(&msg->m_list, &msq->q_messages);
msq->q_cbytes += msgsz;
msq->q_qnum++;
atomic_add(msgsz, &ns->msg_bytes);
atomic_inc(&ns->msg_hdrs);
}
err = 0;
msg = NULL;
out_unlock_free:
msg_unlock(msq);
out_free:
if (msg != NULL)
free_msg(msg);
return err;
}
Commit Message: ipc,sem: fine grained locking for semtimedop
Introduce finer grained locking for semtimedop, to handle the common case
of a program wanting to manipulate one semaphore from an array with
multiple semaphores.
If the call is a semop manipulating just one semaphore in an array with
multiple semaphores, only take the lock for that semaphore itself.
If the call needs to manipulate multiple semaphores, or another caller is
in a transaction that manipulates multiple semaphores, the sem_array lock
is taken, as well as all the locks for the individual semaphores.
On a 24 CPU system, performance numbers with the semop-multi
test with N threads and N semaphores, look like this:
vanilla Davidlohr's Davidlohr's + Davidlohr's +
threads patches rwlock patches v3 patches
10 610652 726325 1783589 2142206
20 341570 365699 1520453 1977878
30 288102 307037 1498167 2037995
40 290714 305955 1612665 2256484
50 288620 312890 1733453 2650292
60 289987 306043 1649360 2388008
70 291298 306347 1723167 2717486
80 290948 305662 1729545 2763582
90 290996 306680 1736021 2757524
100 292243 306700 1773700 3059159
[davidlohr.bueso@hp.com: do not call sem_lock when bogus sma]
[davidlohr.bueso@hp.com: make refcounter atomic]
Signed-off-by: Rik van Riel <riel@redhat.com>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Davidlohr Bueso <davidlohr.bueso@hp.com>
Cc: Chegu Vinod <chegu_vinod@hp.com>
Cc: Jason Low <jason.low2@hp.com>
Reviewed-by: Michel Lespinasse <walken@google.com>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: Stanislav Kinsbursky <skinsbursky@parallels.com>
Tested-by: Emmanuel Benisty <benisty.e@gmail.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
CWE ID: CWE-189 | 1 | 165,967 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void TIFFGetEXIFProperties(TIFF *tiff,Image *image,
ExceptionInfo *exception)
{
#if defined(MAGICKCORE_HAVE_TIFFREADEXIFDIRECTORY)
char
value[MagickPathExtent];
register ssize_t
i;
tdir_t
directory;
#if defined(TIFF_VERSION_BIG)
uint64
#else
uint32
#endif
offset;
void
*sans;
/*
Read EXIF properties.
*/
offset=0;
if (TIFFGetField(tiff,TIFFTAG_EXIFIFD,&offset) != 1)
return;
directory=TIFFCurrentDirectory(tiff);
if (TIFFReadEXIFDirectory(tiff,offset) != 1)
{
TIFFSetDirectory(tiff,directory);
return;
}
sans=NULL;
for (i=0; exif_info[i].tag != 0; i++)
{
*value='\0';
switch (exif_info[i].type)
{
case TIFF_ASCII:
{
char
*ascii;
ascii=(char *) NULL;
if ((TIFFGetField(tiff,exif_info[i].tag,&ascii,&sans,&sans) == 1) &&
(ascii != (char *) NULL) && (*ascii != '\0'))
(void) CopyMagickString(value,ascii,MagickPathExtent);
break;
}
case TIFF_SHORT:
{
if (exif_info[i].variable_length == 0)
{
uint16
shorty;
shorty=0;
if (TIFFGetField(tiff,exif_info[i].tag,&shorty,&sans,&sans) == 1)
(void) FormatLocaleString(value,MagickPathExtent,"%d",shorty);
}
else
{
int
tiff_status;
uint16
*shorty;
uint16
shorty_num;
tiff_status=TIFFGetField(tiff,exif_info[i].tag,&shorty_num,&shorty,
&sans,&sans);
if (tiff_status == 1)
(void) FormatLocaleString(value,MagickPathExtent,"%d",
shorty_num != 0 ? shorty[0] : 0);
}
break;
}
case TIFF_LONG:
{
uint32
longy;
longy=0;
if (TIFFGetField(tiff,exif_info[i].tag,&longy,&sans,&sans) == 1)
(void) FormatLocaleString(value,MagickPathExtent,"%d",longy);
break;
}
#if defined(TIFF_VERSION_BIG)
case TIFF_LONG8:
{
uint64
long8y;
long8y=0;
if (TIFFGetField(tiff,exif_info[i].tag,&long8y,&sans,&sans) == 1)
(void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
((MagickOffsetType) long8y));
break;
}
#endif
case TIFF_RATIONAL:
case TIFF_SRATIONAL:
case TIFF_FLOAT:
{
float
floaty;
floaty=0.0;
if (TIFFGetField(tiff,exif_info[i].tag,&floaty,&sans,&sans) == 1)
(void) FormatLocaleString(value,MagickPathExtent,"%g",(double)
floaty);
break;
}
case TIFF_DOUBLE:
{
double
doubley;
doubley=0.0;
if (TIFFGetField(tiff,exif_info[i].tag,&doubley,&sans,&sans) == 1)
(void) FormatLocaleString(value,MagickPathExtent,"%g",doubley);
break;
}
default:
break;
}
if (*value != '\0')
(void) SetImageProperty(image,exif_info[i].property,value,exception);
}
TIFFSetDirectory(tiff,directory);
#else
(void) tiff;
(void) image;
#endif
}
Commit Message: https://github.com/ImageMagick/ImageMagick/issues/196
CWE ID: CWE-20 | 0 | 71,900 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static ssize_t snd_seq_write(struct file *file, const char __user *buf,
size_t count, loff_t *offset)
{
struct snd_seq_client *client = file->private_data;
int written = 0, len;
int err = -EINVAL;
struct snd_seq_event event;
if (!(snd_seq_file_flags(file) & SNDRV_SEQ_LFLG_OUTPUT))
return -ENXIO;
/* check client structures are in place */
if (snd_BUG_ON(!client))
return -ENXIO;
if (!client->accept_output || client->pool == NULL)
return -ENXIO;
/* allocate the pool now if the pool is not allocated yet */
if (client->pool->size > 0 && !snd_seq_write_pool_allocated(client)) {
if (snd_seq_pool_init(client->pool) < 0)
return -ENOMEM;
}
/* only process whole events */
while (count >= sizeof(struct snd_seq_event)) {
/* Read in the event header from the user */
len = sizeof(event);
if (copy_from_user(&event, buf, len)) {
err = -EFAULT;
break;
}
event.source.client = client->number; /* fill in client number */
/* Check for extension data length */
if (check_event_type_and_length(&event)) {
err = -EINVAL;
break;
}
/* check for special events */
if (event.type == SNDRV_SEQ_EVENT_NONE)
goto __skip_event;
else if (snd_seq_ev_is_reserved(&event)) {
err = -EINVAL;
break;
}
if (snd_seq_ev_is_variable(&event)) {
int extlen = event.data.ext.len & ~SNDRV_SEQ_EXT_MASK;
if ((size_t)(extlen + len) > count) {
/* back out, will get an error this time or next */
err = -EINVAL;
break;
}
/* set user space pointer */
event.data.ext.len = extlen | SNDRV_SEQ_EXT_USRPTR;
event.data.ext.ptr = (char __force *)buf
+ sizeof(struct snd_seq_event);
len += extlen; /* increment data length */
} else {
#ifdef CONFIG_COMPAT
if (client->convert32 && snd_seq_ev_is_varusr(&event)) {
void *ptr = (void __force *)compat_ptr(event.data.raw32.d[1]);
event.data.ext.ptr = ptr;
}
#endif
}
/* ok, enqueue it */
err = snd_seq_client_enqueue_event(client, &event, file,
!(file->f_flags & O_NONBLOCK),
0, 0);
if (err < 0)
break;
__skip_event:
/* Update pointers and counts */
count -= len;
buf += len;
written += len;
}
return written ? written : err;
}
Commit Message: ALSA: seq: Fix missing NULL check at remove_events ioctl
snd_seq_ioctl_remove_events() calls snd_seq_fifo_clear()
unconditionally even if there is no FIFO assigned, and this leads to
an Oops due to NULL dereference. The fix is just to add a proper NULL
check.
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
CWE ID: | 0 | 54,734 |
Analyze the following 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 gdImageAntialias (gdImagePtr im, int antialias)
{
if (im->trueColor){
im->antialias = antialias;
}
}
Commit Message: iFixed bug #72446 - Integer Overflow in gdImagePaletteToTrueColor() resulting in heap overflow
CWE ID: CWE-190 | 0 | 51,415 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static inline unsigned char *PopHexPixel(const char *const *hex_digits,
const size_t pixel,unsigned char *pixels)
{
register const char
*hex;
hex=hex_digits[pixel];
*pixels++=(unsigned char) (*hex++);
*pixels++=(unsigned char) (*hex);
return(pixels);
}
Commit Message: https://github.com/ImageMagick/ImageMagick/issues/715
CWE ID: CWE-834 | 0 | 61,545 |
Analyze the following 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 ipa_blob_seek(void* wand,long position)
{
return (int)SeekBlob((Image*)wand,(MagickOffsetType) position,SEEK_SET);
}
Commit Message:
CWE ID: CWE-119 | 0 | 71,812 |
Analyze the following 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 DownloadFilesToReadonlyFolder(size_t count,
DownloadInfo* download_info) {
DownloadFilesCheckErrorsSetup();
base::FilePath destination_folder = GetDownloadDirectory(browser());
DVLOG(1) << " " << __FUNCTION__ << "()"
<< " folder = '" << destination_folder.value() << "'";
base::FilePermissionRestorer permission_restorer(destination_folder);
EXPECT_TRUE(base::MakeFileUnwritable(destination_folder));
for (size_t i = 0; i < count; ++i) {
DownloadFilesCheckErrorsLoopBody(download_info[i], i);
}
}
Commit Message: When turning a download into a navigation, navigate the right frame
Code changes from Nate Chapin <japhet@chromium.org>
Bug: 926105
Change-Id: I098599394e6ebe7d2fce5af838014297a337d294
Reviewed-on: https://chromium-review.googlesource.com/c/1454962
Reviewed-by: Camille Lamy <clamy@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629547}
CWE ID: CWE-284 | 0 | 151,910 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: bool BrowserWindowGtk::GetCustomFramePrefDefault() {
ui::WindowManagerName wm_type = ui::GuessWindowManager();
return (wm_type == ui::WM_BLACKBOX ||
wm_type == ui::WM_COMPIZ ||
wm_type == ui::WM_ENLIGHTENMENT ||
wm_type == ui::WM_METACITY ||
wm_type == ui::WM_MUTTER ||
wm_type == ui::WM_OPENBOX ||
wm_type == ui::WM_XFWM4);
}
Commit Message: Remove TabContents from TabStripModelObserver::TabDetachedAt.
BUG=107201
TEST=no visible change
Review URL: https://chromiumcodereview.appspot.com/11293205
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167122 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-20 | 0 | 117,930 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static struct rtable *rt_cache_get_idx(struct seq_file *seq, loff_t pos)
{
struct rtable *r = rt_cache_get_first(seq);
if (r)
while (pos && (r = rt_cache_get_next(seq, r)))
--pos;
return pos ? NULL : r;
}
Commit Message: net: Compute protocol sequence numbers and fragment IDs using MD5.
Computers have become a lot faster since we compromised on the
partial MD4 hash which we use currently for performance reasons.
MD5 is a much safer choice, and is inline with both RFC1948 and
other ISS generators (OpenBSD, Solaris, etc.)
Furthermore, only having 24-bits of the sequence number be truly
unpredictable is a very serious limitation. So the periodic
regeneration and 8-bit counter have been removed. We compute and
use a full 32-bit sequence number.
For ipv6, DCCP was found to use a 32-bit truncated initial sequence
number (it needs 43-bits) and that is fixed here as well.
Reported-by: Dan Kaminsky <dan@doxpara.com>
Tested-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: | 0 | 25,152 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw)
{
(void)kvm_set_cr0(vcpu, kvm_read_cr0_bits(vcpu, ~0x0eul) | (msw & 0x0f));
}
Commit Message: KVM: Ensure all vcpus are consistent with in-kernel irqchip settings
(cherry picked from commit 3e515705a1f46beb1c942bb8043c16f8ac7b1e9e)
If some vcpus are created before KVM_CREATE_IRQCHIP, then
irqchip_in_kernel() and vcpu->arch.apic will be inconsistent, leading
to potential NULL pointer dereferences.
Fix by:
- ensuring that no vcpus are installed when KVM_CREATE_IRQCHIP is called
- ensuring that a vcpu has an apic if it is installed after KVM_CREATE_IRQCHIP
This is somewhat long winded because vcpu->arch.apic is created without
kvm->lock held.
Based on earlier patch by Michael Ellerman.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CWE ID: CWE-399 | 0 | 20,787 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int netlink_release(struct socket *sock)
{
struct sock *sk = sock->sk;
struct netlink_sock *nlk;
if (!sk)
return 0;
netlink_remove(sk);
sock_orphan(sk);
nlk = nlk_sk(sk);
/*
* OK. Socket is unlinked, any packets that arrive now
* will be purged.
*/
sock->sk = NULL;
wake_up_interruptible_all(&nlk->wait);
skb_queue_purge(&sk->sk_write_queue);
if (nlk->pid) {
struct netlink_notify n = {
.net = sock_net(sk),
.protocol = sk->sk_protocol,
.pid = nlk->pid,
};
atomic_notifier_call_chain(&netlink_chain,
NETLINK_URELEASE, &n);
}
module_put(nlk->module);
netlink_table_grab();
if (netlink_is_kernel(sk)) {
BUG_ON(nl_table[sk->sk_protocol].registered == 0);
if (--nl_table[sk->sk_protocol].registered == 0) {
kfree(nl_table[sk->sk_protocol].listeners);
nl_table[sk->sk_protocol].module = NULL;
nl_table[sk->sk_protocol].registered = 0;
}
} else if (nlk->subscriptions) {
netlink_update_listeners(sk);
}
netlink_table_ungrab();
kfree(nlk->groups);
nlk->groups = NULL;
local_bh_disable();
sock_prot_inuse_add(sock_net(sk), &netlink_proto, -1);
local_bh_enable();
sock_put(sk);
return 0;
}
Commit Message: af_netlink: force credentials passing [CVE-2012-3520]
Pablo Neira Ayuso discovered that avahi and
potentially NetworkManager accept spoofed Netlink messages because of a
kernel bug. The kernel passes all-zero SCM_CREDENTIALS ancillary data
to the receiver if the sender did not provide such data, instead of not
including any such data at all or including the correct data from the
peer (as it is the case with AF_UNIX).
This bug was introduced in commit 16e572626961
(af_unix: dont send SCM_CREDENTIALS by default)
This patch forces passing credentials for netlink, as
before the regression.
Another fix would be to not add SCM_CREDENTIALS in
netlink messages if not provided by the sender, but it
might break some programs.
With help from Florian Weimer & Petr Matousek
This issue is designated as CVE-2012-3520
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Petr Matousek <pmatouse@redhat.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-287 | 0 | 19,251 |
Analyze the following 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 AppListController::ScheduleWarmup() {
const int kInitWindowDelay = 5;
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&AppListController::LoadProfileForWarmup,
weak_factory_.GetWeakPtr()),
base::TimeDelta::FromSeconds(kInitWindowDelay));
const int kSendUsageStatsDelay = 5;
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&AppListController::SendAppListStats),
base::TimeDelta::FromSeconds(kSendUsageStatsDelay));
}
Commit Message: Upgrade old app host to new app launcher on startup
This patch is a continuation of https://codereview.chromium.org/16805002/.
BUG=248825
Review URL: https://chromiumcodereview.appspot.com/17022015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209604 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-399 | 0 | 113,645 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: PHP_FUNCTION(radius_request_authenticator)
{
radius_descriptor *raddesc;
ssize_t res;
char buf[LEN_AUTH];
zval *z_radh;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_radh) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(raddesc, radius_descriptor *, &z_radh, -1, "rad_handle", le_radius);
res = rad_request_authenticator(raddesc->radh, buf, sizeof buf);
if (res == -1) {
RETURN_FALSE;
} else {
RETURN_STRINGL(buf, res, 1);
}
}
Commit Message: Fix a security issue in radius_get_vendor_attr().
The underlying rad_get_vendor_attr() function assumed that it would always be
given valid VSA data. Indeed, the buffer length wasn't even passed in; the
assumption was that the length field within the VSA structure would be valid.
This could result in denial of service by providing a length that would be
beyond the memory limit, or potential arbitrary memory access by providing a
length greater than the actual data given.
rad_get_vendor_attr() has been changed to require the raw data length be
provided, and this is then used to check that the VSA is valid.
Conflicts:
radlib_vs.h
CWE ID: CWE-119 | 0 | 31,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: int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct inode *dir, struct inode *inode,
const char *name, int name_len)
{
int ret;
ret = __btrfs_unlink_inode(trans, root, dir, inode, name, name_len);
if (!ret) {
btrfs_drop_nlink(inode);
ret = btrfs_update_inode(trans, root, inode);
}
return ret;
}
Commit Message: Btrfs: fix hash overflow handling
The handling for directory crc hash overflows was fairly obscure,
split_leaf returns EOVERFLOW when we try to extend the item and that is
supposed to bubble up to userland. For a while it did so, but along the
way we added better handling of errors and forced the FS readonly if we
hit IO errors during the directory insertion.
Along the way, we started testing only for EEXIST and the EOVERFLOW case
was dropped. The end result is that we may force the FS readonly if we
catch a directory hash bucket overflow.
This fixes a few problem spots. First I add tests for EOVERFLOW in the
places where we can safely just return the error up the chain.
btrfs_rename is harder though, because it tries to insert the new
directory item only after it has already unlinked anything the rename
was going to overwrite. Rather than adding very complex logic, I added
a helper to test for the hash overflow case early while it is still safe
to bail out.
Snapshot and subvolume creation had a similar problem, so they are using
the new helper now too.
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Reported-by: Pascal Junod <pascal@junod.info>
CWE ID: CWE-310 | 0 | 34,357 |
Analyze the following 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 MediaControlTimelineElement::keepEventInNode(Event* event) {
return isUserInteractionEventForSlider(event, layoutObject());
}
Commit Message: Fixed volume slider element event handling
MediaControlVolumeSliderElement::defaultEventHandler has making
redundant calls to setVolume() & setMuted() on mouse activity. E.g. if
a mouse click changed the slider position, the above calls were made 4
times, once for each of these events: mousedown, input, mouseup,
DOMActive, click. This crack got exposed when PointerEvents are enabled
by default on M55, adding pointermove, pointerdown & pointerup to the
list.
This CL fixes the code to trigger the calls to setVolume() & setMuted()
only when the slider position is changed. Also added pointer events to
certain lists of mouse events in the code.
BUG=677900
Review-Url: https://codereview.chromium.org/2622273003
Cr-Commit-Position: refs/heads/master@{#446032}
CWE ID: CWE-119 | 0 | 126,968 |
Analyze the following 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 Editor::Copy(EditorCommandSource source) {
if (TryDHTMLCopy())
return; // DHTML did the whole operation
if (!CanCopy())
return;
GetFrame().GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
if (source == kCommandFromMenuOrKeyBinding &&
!GetFrame().Selection().SelectionHasFocus())
return;
if (EnclosingTextControl(
GetFrame().Selection().ComputeVisibleSelectionInDOMTree().Start())) {
Pasteboard::GeneralPasteboard()->WritePlainText(
GetFrame().SelectedTextForClipboard(),
CanSmartCopyOrDelete() ? Pasteboard::kCanSmartReplace
: Pasteboard::kCannotSmartReplace);
} else {
Document* document = GetFrame().GetDocument();
if (HTMLImageElement* image_element =
ImageElementFromImageDocument(document))
WriteImageNodeToPasteboard(Pasteboard::GeneralPasteboard(), image_element,
document->title());
else
WriteSelectionToPasteboard();
}
}
Commit Message: Move SelectionTemplate::is_handle_visible_ to FrameSelection
This patch moves |is_handle_visible_| to |FrameSelection| from |SelectionTemplate|
since handle visibility is used only for setting |FrameSelection|, hence it is
a redundant member variable of |SelectionTemplate|.
Bug: 742093
Change-Id: I3add4da3844fb40be34dcb4d4b46b5fa6fed1d7e
Reviewed-on: https://chromium-review.googlesource.com/595389
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491660}
CWE ID: CWE-119 | 0 | 124,669 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.