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 file_sb_list_del(struct file *file)
{
if (!list_empty(&file->f_u.fu_list)) {
lg_local_lock_cpu(&files_lglock, file_list_cpu(file));
list_del_init(&file->f_u.fu_list);
lg_local_unlock_cpu(&files_lglock, file_list_cpu(file));
}
}
Commit Message: get rid of s_files and files_lock
The only thing we need it for is alt-sysrq-r (emergency remount r/o)
and these days we can do just as well without going through the
list of files.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
CWE ID: CWE-17
| 1
| 166,799
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: virDomainMigrateFinish2(virConnectPtr dconn,
const char *dname,
const char *cookie,
int cookielen,
const char *uri,
unsigned long flags,
int retcode)
{
VIR_DEBUG("dconn=%p, dname=%s, cookie=%p, cookielen=%d, uri=%s, "
"flags=%lx, retcode=%d", dconn, NULLSTR(dname), cookie,
cookielen, NULLSTR(uri), flags, retcode);
virResetLastError();
virCheckConnectReturn(dconn, NULL);
virCheckReadOnlyGoto(dconn->flags, error);
if (dconn->driver->domainMigrateFinish2) {
virDomainPtr ret;
ret = dconn->driver->domainMigrateFinish2(dconn, dname,
cookie, cookielen,
uri, flags,
retcode);
if (!ret && !retcode)
goto error;
return ret;
}
virReportUnsupportedError();
error:
virDispatchError(dconn);
return NULL;
}
Commit Message: virDomainGetTime: Deny on RO connections
We have a policy that if API may end up talking to a guest agent
it should require RW connection. We don't obey the rule in
virDomainGetTime().
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
CWE ID: CWE-254
| 0
| 93,857
|
Analyze the following 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 hid_match_report(struct hid_device *hid, struct hid_report *report)
{
const struct hid_report_id *id = hid->driver->report_table;
if (!id) /* NULL means all */
return 1;
for (; id->report_type != HID_TERMINATOR; id++)
if (id->report_type == HID_ANY_ID ||
id->report_type == report->type)
return 1;
return 0;
}
Commit Message: HID: core: prevent out-of-bound readings
Plugging a Logitech DJ receiver with KASAN activated raises a bunch of
out-of-bound readings.
The fields are allocated up to MAX_USAGE, meaning that potentially, we do
not have enough fields to fit the incoming values.
Add checks and silence KASAN.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
CWE ID: CWE-125
| 0
| 49,502
|
Analyze the following 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 EnableAction(MediaSessionAction action) {
actions_.insert(action);
NotifyUpdatedActions();
}
Commit Message: [Lock Screen Media Controls] Tweak UI based on new mocks
This CL rearranges the different components of the CrOS lock screen
media controls based on the newest mocks. This involves resizing most
of the child views and their spacings. The artwork was also resized
and re-positioned. Additionally, the close button was moved from the
main view to the header row child view.
Artist and title data about the current session will eventually be
placed to the right of the artwork, but right now this space is empty.
See the bug for before and after pictures.
Bug: 991647
Change-Id: I7b97f31982ccf2912bd2564d5241bfd849d21d92
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1746554
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: Becca Hughes <beccahughes@chromium.org>
Commit-Queue: Mia Bergeron <miaber@google.com>
Cr-Commit-Position: refs/heads/master@{#686253}
CWE ID: CWE-200
| 0
| 136,512
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void LogRequestDeviceOptions(
const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options) {
DVLOG(1) << "requestDevice called with the following filters: ";
DVLOG(1) << "acceptAllDevices: " << options->accept_all_devices;
if (!options->filters)
return;
int i = 0;
for (const auto& filter : options->filters.value()) {
DVLOG(1) << "Filter #" << ++i;
if (filter->name)
DVLOG(1) << "Name: " << filter->name.value();
if (filter->name_prefix)
DVLOG(1) << "Name Prefix: " << filter->name_prefix.value();
if (filter->services) {
DVLOG(1) << "Services: ";
DVLOG(1) << "\t[";
for (const auto& service : filter->services.value())
DVLOG(1) << "\t\t" << service.canonical_value();
DVLOG(1) << "\t]";
}
}
}
Commit Message: bluetooth: Implement getAvailability()
This change implements the getAvailability() method for
navigator.bluetooth as defined in the specification.
Bug: 707640
Change-Id: I9e9b3e7f8ea7f259e975f71cb6d9570e5f04b479
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1651516
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Ovidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
Auto-Submit: Ovidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688987}
CWE ID: CWE-119
| 0
| 138,075
|
Analyze the following 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 ResourceLoader::DidReceiveResponse(
const WebURLResponse& web_url_response,
std::unique_ptr<WebDataConsumerHandle> handle) {
DCHECK(!web_url_response.IsNull());
Resource::Type resource_type = resource_->GetType();
const ResourceRequest& initial_request = resource_->GetResourceRequest();
WebURLRequest::RequestContext request_context =
initial_request.GetRequestContext();
WebURLRequest::FetchRequestMode fetch_request_mode =
initial_request.GetFetchRequestMode();
const ResourceLoaderOptions& options = resource_->Options();
const ResourceResponse& response = web_url_response.ToResourceResponse();
StringBuilder cors_error_msg;
resource_->SetCORSStatus(DetermineCORSStatus(response, cors_error_msg));
if (response.WasFetchedViaServiceWorker()) {
if (options.cors_handling_by_resource_fetcher ==
kEnableCORSHandlingByResourceFetcher &&
fetch_request_mode == WebURLRequest::kFetchRequestModeCORS &&
response.WasFallbackRequiredByServiceWorker()) {
ResourceRequest last_request = resource_->LastResourceRequest();
DCHECK_EQ(last_request.GetServiceWorkerMode(),
WebURLRequest::ServiceWorkerMode::kAll);
if (!Context().ShouldLoadNewResource(resource_type)) {
HandleError(ResourceError::CancelledError(response.Url()));
return;
}
last_request.SetServiceWorkerMode(
WebURLRequest::ServiceWorkerMode::kForeign);
Restart(last_request);
return;
}
const KURL& original_url = response.OriginalURLViaServiceWorker();
if (!original_url.IsEmpty()) {
Context().CheckCSPForRequest(
request_context, original_url, options,
SecurityViolationReportingPolicy::kReport,
ResourceRequest::RedirectStatus::kFollowedRedirect);
ResourceRequestBlockedReason blocked_reason = Context().CanRequest(
resource_type, initial_request, original_url, options,
SecurityViolationReportingPolicy::kReport,
FetchParameters::kUseDefaultOriginRestrictionForType,
ResourceRequest::RedirectStatus::kFollowedRedirect);
if (blocked_reason != ResourceRequestBlockedReason::kNone) {
HandleError(ResourceError::CancelledDueToAccessCheckError(
original_url, blocked_reason));
return;
}
}
} else if (options.cors_handling_by_resource_fetcher ==
kEnableCORSHandlingByResourceFetcher &&
fetch_request_mode == WebURLRequest::kFetchRequestModeCORS) {
if (!resource_->IsSameOriginOrCORSSuccessful()) {
if (!resource_->IsUnusedPreload())
Context().AddErrorConsoleMessage(cors_error_msg.ToString(),
FetchContext::kJSSource);
HandleError(ResourceError::CancelledDueToAccessCheckError(
response.Url(), ResourceRequestBlockedReason::kOther));
return;
}
}
Context().DispatchDidReceiveResponse(
resource_->Identifier(), response, initial_request.GetFrameType(),
request_context, resource_,
FetchContext::ResourceResponseType::kNotFromMemoryCache);
resource_->ResponseReceived(response, std::move(handle));
if (!resource_->Loader())
return;
if (response.HttpStatusCode() >= 400 &&
!resource_->ShouldIgnoreHTTPStatusCodeErrors())
HandleError(ResourceError::CancelledError(response.Url()));
}
Commit Message: DevTools: send proper resource type in Network.RequestWillBeSent
This patch plumbs resoure type into the DispatchWillSendRequest
instrumenation. This allows us to report accurate type in
Network.RequestWillBeSent event, instead of "Other", that we report
today.
BUG=765501
R=dgozman
Change-Id: I0134c08b841e8dd247fdc8ff208bfd51e462709c
Reviewed-on: https://chromium-review.googlesource.com/667504
Reviewed-by: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Andrey Lushnikov <lushnikov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#507936}
CWE ID: CWE-119
| 0
| 138,929
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static const char *cgfs_get_cgroup(void *hdata, const char *subsystem)
{
struct cgfs_data *d = hdata;
if (!d)
return NULL;
return lxc_cgroup_get_hierarchy_path_data(subsystem, d);
}
Commit Message: CVE-2015-1335: Protect container mounts against symlinks
When a container starts up, lxc sets up the container's inital fstree
by doing a bunch of mounting, guided by the container configuration
file. The container config is owned by the admin or user on the host,
so we do not try to guard against bad entries. However, since the
mount target is in the container, it's possible that the container admin
could divert the mount with symbolic links. This could bypass proper
container startup (i.e. confinement of a root-owned container by the
restrictive apparmor policy, by diverting the required write to
/proc/self/attr/current), or bypass the (path-based) apparmor policy
by diverting, say, /proc to /mnt in the container.
To prevent this,
1. do not allow mounts to paths containing symbolic links
2. do not allow bind mounts from relative paths containing symbolic
links.
Details:
Define safe_mount which ensures that the container has not inserted any
symbolic links into any mount targets for mounts to be done during
container setup.
The host's mount path may contain symbolic links. As it is under the
control of the administrator, that's ok. So safe_mount begins the check
for symbolic links after the rootfs->mount, by opening that directory.
It opens each directory along the path using openat() relative to the
parent directory using O_NOFOLLOW. When the target is reached, it
mounts onto /proc/self/fd/<targetfd>.
Use safe_mount() in mount_entry(), when mounting container proc,
and when needed. In particular, safe_mount() need not be used in
any case where:
1. the mount is done in the container's namespace
2. the mount is for the container's rootfs
3. the mount is relative to a tmpfs or proc/sysfs which we have
just safe_mount()ed ourselves
Since we were using proc/net as a temporary placeholder for /proc/sys/net
during container startup, and proc/net is a symbolic link, use proc/tty
instead.
Update the lxc.container.conf manpage with details about the new
restrictions.
Finally, add a testcase to test some symbolic link possibilities.
Reported-by: Roman Fiedler
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
CWE ID: CWE-59
| 0
| 44,460
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static inline bool vrend_format_can_render(enum virgl_formats format)
{
return tex_conv_table[format].bindings & VREND_BIND_RENDER;
}
Commit Message:
CWE ID: CWE-772
| 0
| 8,863
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: onig_new(regex_t** reg, const UChar* pattern, const UChar* pattern_end,
OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax,
OnigErrorInfo* einfo)
{
int r;
*reg = (regex_t* )xmalloc(sizeof(regex_t));
if (IS_NULL(*reg)) return ONIGERR_MEMORY;
r = onig_reg_init(*reg, option, ONIGENC_CASE_FOLD_DEFAULT, enc, syntax);
if (r != 0) goto err;
r = onig_compile(*reg, pattern, pattern_end, einfo);
if (r != 0) {
err:
onig_free(*reg);
*reg = NULL;
}
return r;
}
Commit Message: Fix CVE-2019-13225: problem in converting if-then-else pattern to bytecode.
CWE ID: CWE-476
| 0
| 89,194
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: int netdev_set_master(struct net_device *slave, struct net_device *master)
{
struct net_device *old = slave->master;
ASSERT_RTNL();
if (master) {
if (old)
return -EBUSY;
dev_hold(master);
}
slave->master = master;
if (old) {
synchronize_net();
dev_put(old);
}
if (master)
slave->flags |= IFF_SLAVE;
else
slave->flags &= ~IFF_SLAVE;
rtmsg_ifinfo(RTM_NEWLINK, slave, IFF_SLAVE);
return 0;
}
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,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: GPMF_ERR GPMF_ScaledData(GPMF_stream *ms, void *buffer, uint32_t buffersize, uint32_t sample_offset, uint32_t read_samples, GPMF_SampleType outputType)
{
if (ms && buffer)
{
uint8_t *data = (uint8_t *)&ms->buffer[ms->pos + 2];
uint8_t *output = (uint8_t *)buffer;
uint32_t sample_size = GPMF_SAMPLE_SIZE(ms->buffer[ms->pos + 1]);
uint32_t output_sample_size = GPMF_SizeofType(outputType);
uint32_t remaining_sample_size = GPMF_DATA_PACKEDSIZE(ms->buffer[ms->pos + 1]);
uint8_t type = GPMF_SAMPLE_TYPE(ms->buffer[ms->pos + 1]);
char complextype[64] = "L";
uint32_t inputtypesize = 0;
uint32_t inputtypeelements = 0;
uint8_t scaletype = 0;
uint8_t scalecount = 0;
uint32_t scaletypesize = 0;
uint32_t *scaledata = NULL;
uint32_t tmpbuffer[64];
uint32_t tmpbuffersize = sizeof(tmpbuffer);
uint32_t elements = 1;
type = GPMF_SAMPLE_TYPE(ms->buffer[ms->pos + 1]);
if (type == GPMF_TYPE_NEST)
return GPMF_ERROR_MEMORY;
if (GPMF_OK != IsValidSize(ms, remaining_sample_size >> 2))
return GPMF_ERROR_BAD_STRUCTURE;
remaining_sample_size -= sample_offset * sample_size; // skip samples
data += sample_offset * sample_size;
if (remaining_sample_size < sample_size * read_samples)
return GPMF_ERROR_MEMORY;
if (type == GPMF_TYPE_COMPLEX)
{
GPMF_stream find_stream;
GPMF_CopyState(ms, &find_stream);
if (GPMF_OK == GPMF_FindPrev(&find_stream, GPMF_KEY_TYPE, GPMF_RECURSE_LEVELS))
{
char *data1 = (char *)GPMF_RawData(&find_stream);
int size = GPMF_RawDataSize(&find_stream);
uint32_t typestringlength = sizeof(complextype);
if (GPMF_OK == GPMF_ExpandComplexTYPE(data1, size, complextype, &typestringlength))
{
inputtypeelements = elements = typestringlength;
if (sample_size != GPMF_SizeOfComplexTYPE(complextype, typestringlength))
return GPMF_ERROR_TYPE_NOT_SUPPORTED;
}
else
return GPMF_ERROR_TYPE_NOT_SUPPORTED;
}
else
return GPMF_ERROR_TYPE_NOT_SUPPORTED;
}
else
{
complextype[0] = type;
inputtypesize = GPMF_SizeofType(type);
if (inputtypesize == 0)
return GPMF_ERROR_MEMORY;
inputtypeelements = 1;
elements = sample_size / inputtypesize;
}
if (output_sample_size * elements * read_samples > buffersize)
return GPMF_ERROR_MEMORY;
switch (outputType) {
case GPMF_TYPE_SIGNED_BYTE:
case GPMF_TYPE_UNSIGNED_BYTE:
case GPMF_TYPE_SIGNED_SHORT:
case GPMF_TYPE_UNSIGNED_SHORT:
case GPMF_TYPE_FLOAT:
case GPMF_TYPE_SIGNED_LONG:
case GPMF_TYPE_UNSIGNED_LONG:
case GPMF_TYPE_DOUBLE:
{
GPMF_stream fs;
GPMF_CopyState(ms, &fs);
if (GPMF_OK == GPMF_FindPrev(&fs, GPMF_KEY_SCALE, GPMF_CURRENT_LEVEL))
{
scaledata = (uint32_t *)GPMF_RawData(&fs);
scaletype = GPMF_SAMPLE_TYPE(fs.buffer[fs.pos + 1]);
switch (scaletype)
{
case GPMF_TYPE_SIGNED_BYTE:
case GPMF_TYPE_UNSIGNED_BYTE:
case GPMF_TYPE_SIGNED_SHORT:
case GPMF_TYPE_UNSIGNED_SHORT:
case GPMF_TYPE_SIGNED_LONG:
case GPMF_TYPE_UNSIGNED_LONG:
case GPMF_TYPE_FLOAT:
scalecount = GPMF_SAMPLES(fs.buffer[fs.pos + 1]);
scaletypesize = GPMF_SizeofType(scaletype);
if (scalecount > 1)
if (scalecount != elements)
return GPMF_ERROR_SCALE_COUNT;
GPMF_FormattedData(&fs, tmpbuffer, tmpbuffersize, 0, scalecount);
scaledata = (uint32_t *)tmpbuffer;
break;
default:
return GPMF_ERROR_TYPE_NOT_SUPPORTED;
break;
}
}
else
{
scaletype = 'L';
scalecount = 1;
tmpbuffer[0] = 1; // set the scale to 1 is no scale was provided
scaledata = (uint32_t *)tmpbuffer;
}
}
while (read_samples--)
{
uint32_t i;
uint8_t *scaledata8 = (uint8_t *)scaledata;
for (i = 0; i < elements; i++)
{
switch (complextype[i % inputtypeelements])
{
case GPMF_TYPE_FLOAT: MACRO_BSWAP_CAST_SCALE(BYTESWAP32, float, uint32_t) break;
case GPMF_TYPE_SIGNED_BYTE: MACRO_BSWAP_CAST_SCALE(NOSWAP8, int8_t, uint8_t) break;
case GPMF_TYPE_UNSIGNED_BYTE: MACRO_BSWAP_CAST_SCALE(NOSWAP8, uint8_t, uint8_t) break;
case GPMF_TYPE_SIGNED_SHORT: MACRO_BSWAP_CAST_SCALE(BYTESWAP16, int16_t, uint16_t) break;
case GPMF_TYPE_UNSIGNED_SHORT: MACRO_BSWAP_CAST_SCALE(BYTESWAP16, uint16_t, uint16_t) break;
case GPMF_TYPE_SIGNED_LONG: MACRO_BSWAP_CAST_SCALE(BYTESWAP32, int32_t, uint32_t) break;
case GPMF_TYPE_UNSIGNED_LONG: MACRO_BSWAP_CAST_SCALE(BYTESWAP32, uint32_t, uint32_t) break;
case GPMF_TYPE_SIGNED_64BIT_INT: MACRO_BSWAP_CAST_SCALE(BYTESWAP64, uint64_t, uint64_t) break;
case GPMF_TYPE_UNSIGNED_64BIT_INT: MACRO_BSWAP_CAST_SCALE(BYTESWAP64, uint64_t, uint64_t) break;
default:
return GPMF_ERROR_TYPE_NOT_SUPPORTED;
break;
}
if (scalecount > 1)
scaledata8 += scaletypesize;
}
}
break;
default:
return GPMF_ERROR_TYPE_NOT_SUPPORTED;
break;
}
return GPMF_OK;
}
return GPMF_ERROR_MEMORY;
}
Commit Message: fixed many security issues with the too crude mp4 reader
CWE ID: CWE-787
| 0
| 88,448
|
Analyze the following 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 dump_data_attribute(FILE *trace, char *name, char *data, u32 data_size)
{
u32 i;
if (!data || !data_size) {
fprintf(trace, "%s=\"\"", name);
return;
}
fprintf(trace, "%s=\"0x", name);
for (i=0; i<data_size; i++) fprintf(trace, "%02X", (unsigned char) data[i]);
fprintf(trace, "\" ");
}
Commit Message: fixed 2 possible heap overflows (inc. #1088)
CWE ID: CWE-125
| 0
| 80,717
|
Analyze the following 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 HTMLMediaElement::requestRemotePlaybackControl() {
if (webMediaPlayer())
webMediaPlayer()->requestRemotePlaybackControl();
}
Commit Message: [Blink>Media] Allow autoplay muted on Android by default
There was a mistake causing autoplay muted is shipped on Android
but it will be disabled if the chromium embedder doesn't specify
content setting for "AllowAutoplay" preference. This CL makes the
AllowAutoplay preference true by default so that it is allowed by
embedders (including AndroidWebView) unless they explicitly
disable it.
Intent to ship:
https://groups.google.com/a/chromium.org/d/msg/blink-dev/Q1cnzNI2GpI/AL_eyUNABgAJ
BUG=689018
Review-Url: https://codereview.chromium.org/2677173002
Cr-Commit-Position: refs/heads/master@{#448423}
CWE ID: CWE-119
| 0
| 128,885
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: ImageFrame* JPEGImageDecoder::frameBufferAtIndex(size_t index)
{
if (index)
return 0;
if (m_frameBufferCache.isEmpty()) {
m_frameBufferCache.resize(1);
m_frameBufferCache[0].setPremultiplyAlpha(m_premultiplyAlpha);
}
ImageFrame& frame = m_frameBufferCache[0];
if (frame.status() != ImageFrame::FrameComplete) {
PlatformInstrumentation::willDecodeImage("JPEG");
decode(false);
PlatformInstrumentation::didDecodeImage();
}
return &frame;
}
Commit Message: Progressive JPEG outputScanlines() calls should handle failure
outputScanlines() can fail and delete |this|, so any attempt to access
members thereafter should be avoided. Copy the decoder pointer member,
and use that copy to detect and handle the failure case.
BUG=232763
R=pkasting@chromium.org
Review URL: https://codereview.chromium.org/14844003
git-svn-id: svn://svn.chromium.org/blink/trunk@150545 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-399
| 0
| 119,072
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: blink::WebFrame* RenderFrameImpl::FindFrame(const blink::WebString& name) {
if (render_view_->renderer_wide_named_frame_lookup()) {
for (const auto& it : g_routing_id_frame_map.Get()) {
WebLocalFrame* frame = it.second->GetWebFrame();
if (frame->AssignedName() == name)
return frame;
}
}
return GetContentClient()->renderer()->FindFrame(this->GetWebFrame(),
name.Utf8());
}
Commit Message: Convert FrameHostMsg_DidAddMessageToConsole to Mojo.
Note: Since this required changing the test
RenderViewImplTest.DispatchBeforeUnloadCanDetachFrame, I manually
re-introduced https://crbug.com/666714 locally (the bug the test was
added for), and reran the test to confirm that it still covers the bug.
Bug: 786836
Change-Id: I110668fa6f0f261fd2ac36bb91a8d8b31c99f4f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1526270
Commit-Queue: Lowell Manners <lowell@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653137}
CWE ID: CWE-416
| 0
| 139,632
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: enum nss_status _nss_mymachines_getgrgid_r(
gid_t gid,
struct group *gr,
char *buffer, size_t buflen,
int *errnop) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message* reply = NULL;
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
const char *machine, *object;
uint32_t mapped;
int r;
if (!gid_is_valid(gid)) {
r = -EINVAL;
goto fail;
}
/* We consider all gids < 65536 host gids */
if (gid < 0x10000)
goto not_found;
r = sd_bus_open_system(&bus);
if (r < 0)
goto fail;
r = sd_bus_call_method(bus,
"org.freedesktop.machine1",
"/org/freedesktop/machine1",
"org.freedesktop.machine1.Manager",
"MapToMachineGroup",
&error,
&reply,
"u",
(uint32_t) gid);
if (r < 0) {
if (sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_GROUP_MAPPING))
goto not_found;
goto fail;
}
r = sd_bus_message_read(reply, "sou", &machine, &object, &mapped);
if (r < 0)
goto fail;
if (buflen < sizeof(char*) + 1) {
*errnop = ENOMEM;
return NSS_STATUS_TRYAGAIN;
}
memzero(buffer, sizeof(char*));
if (snprintf(buffer + sizeof(char*), buflen - sizeof(char*), "vg-%s-" GID_FMT, machine, (gid_t) mapped) >= (int) buflen) {
*errnop = ENOMEM;
return NSS_STATUS_TRYAGAIN;
}
gr->gr_name = buffer + sizeof(char*);
gr->gr_gid = gid;
gr->gr_passwd = (char*) "*"; /* locked */
gr->gr_mem = (char**) buffer;
*errnop = 0;
return NSS_STATUS_SUCCESS;
not_found:
*errnop = 0;
return NSS_STATUS_NOTFOUND;
fail:
*errnop = -r;
return NSS_STATUS_UNAVAIL;
}
Commit Message: nss-mymachines: do not allow overlong machine names
https://github.com/systemd/systemd/issues/2002
CWE ID: CWE-119
| 0
| 74,094
|
Analyze the following 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 kvm_pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async,
bool write_fault, bool *writable)
{
struct vm_area_struct *vma;
kvm_pfn_t pfn = 0;
int npages, r;
/* we can do it either atomically or asynchronously, not both */
BUG_ON(atomic && async);
if (hva_to_pfn_fast(addr, atomic, async, write_fault, writable, &pfn))
return pfn;
if (atomic)
return KVM_PFN_ERR_FAULT;
npages = hva_to_pfn_slow(addr, async, write_fault, writable, &pfn);
if (npages == 1)
return pfn;
down_read(¤t->mm->mmap_sem);
if (npages == -EHWPOISON ||
(!async && check_user_page_hwpoison(addr))) {
pfn = KVM_PFN_ERR_HWPOISON;
goto exit;
}
retry:
vma = find_vma_intersection(current->mm, addr, addr + 1);
if (vma == NULL)
pfn = KVM_PFN_ERR_FAULT;
else if (vma->vm_flags & (VM_IO | VM_PFNMAP)) {
r = hva_to_pfn_remapped(vma, addr, async, write_fault, &pfn);
if (r == -EAGAIN)
goto retry;
if (r < 0)
pfn = KVM_PFN_ERR_FAULT;
} else {
if (async && vma_is_valid(vma, write_fault))
*async = true;
pfn = KVM_PFN_ERR_FAULT;
}
exit:
up_read(¤t->mm->mmap_sem);
return pfn;
}
Commit Message: KVM: use after free in kvm_ioctl_create_device()
We should move the ops->destroy(dev) after the list_del(&dev->vm_node)
so that we don't use "dev" after freeing it.
Fixes: a28ebea2adc4 ("KVM: Protect device ops->create and list_add with kvm->lock")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
CWE ID: CWE-416
| 0
| 71,188
|
Analyze the following 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 PHP_GINIT_FUNCTION(bcmath)
{
bcmath_globals->bc_precision = 0;
bc_init_numbers(TSRMLS_C);
}
Commit Message:
CWE ID: CWE-20
| 0
| 11,007
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: media_status_t AMediaCodec_releaseOutputBufferAtTime(
AMediaCodec *mData, size_t idx, int64_t timestampNs) {
ALOGV("render @ %" PRId64, timestampNs);
return translate_error(mData->mCodec->renderOutputBufferAndRelease(idx, timestampNs));
}
Commit Message: Check for overflow of crypto size
Bug: 111603051
Test: CTS
Change-Id: Ib5b1802b9b35769a25c16e2b977308cf7a810606
(cherry picked from commit d1fd02761236b35a336434367131f71bef7405c9)
CWE ID: CWE-190
| 0
| 163,006
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: iasecc_finish(struct sc_card *card)
{
struct sc_context *ctx = card->ctx;
struct iasecc_private_data *private_data = (struct iasecc_private_data *)card->drv_data;
struct iasecc_se_info *se_info = private_data->se_info, *next;
LOG_FUNC_CALLED(ctx);
while (se_info) {
sc_file_free(se_info->df);
next = se_info->next;
free(se_info);
se_info = next;
}
free(card->drv_data);
card->drv_data = NULL;
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
}
Commit Message: fixed out of bounds reads
Thanks to Eric Sesterhenn from X41 D-SEC GmbH
for reporting and suggesting security fixes.
CWE ID: CWE-125
| 0
| 78,486
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: WebGLRenderingContextBaseSet& ActiveContexts() {
DEFINE_THREAD_SAFE_STATIC_LOCAL(
ThreadSpecific<Persistent<WebGLRenderingContextBaseSet>>, active_contexts,
());
Persistent<WebGLRenderingContextBaseSet>& active_contexts_persistent =
*active_contexts;
if (!active_contexts_persistent) {
active_contexts_persistent =
MakeGarbageCollected<WebGLRenderingContextBaseSet>();
active_contexts_persistent.RegisterAsStaticReference();
}
return *active_contexts_persistent;
}
Commit Message: Add GL_PROGRAM_COMPLETION_QUERY_CHROMIUM
This makes the query of GL_COMPLETION_STATUS_KHR to programs much
cheaper by minimizing the round-trip to the GPU thread.
Bug: 881152, 957001
Change-Id: Iadfa798af29225e752c710ca5c25f50b3dd3101a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1586630
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657568}
CWE ID: CWE-416
| 0
| 142,217
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
auto it =
std::find(aec_dump_consumers_.begin(), aec_dump_consumers_.end(), id);
if (it != aec_dump_consumers_.end())
aec_dump_consumers_.erase(it);
}
Commit Message: Correct mojo::WrapSharedMemoryHandle usage
Fixes some incorrect uses of mojo::WrapSharedMemoryHandle which
were assuming that the call actually has any control over the memory
protection applied to a handle when mapped.
Where fixing usage is infeasible for this CL, TODOs are added to
annotate follow-up work.
Also updates the API and documentation to (hopefully) improve clarity
and avoid similar mistakes from being made in the future.
BUG=792900
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I0578aaa9ca3bfcb01aaf2451315d1ede95458477
Reviewed-on: https://chromium-review.googlesource.com/818282
Reviewed-by: Wei Li <weili@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: Yuzhu Shen <yzshen@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#530268}
CWE ID: CWE-787
| 0
| 149,344
|
Analyze the following 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 WebContentsImpl::CompletedFirstVisuallyNonEmptyPaint() const {
return did_first_visually_non_empty_paint_;
}
Commit Message: Prevent renderer initiated back navigation to cancel a browser one.
Renderer initiated back/forward navigations must not be able to cancel ongoing
browser initiated navigation if they are not user initiated.
Note: 'normal' renderer initiated navigation uses the
FrameHost::BeginNavigation() path. A code similar to this patch is done
in NavigatorImpl::OnBeginNavigation().
Test:
-----
Added: NavigationBrowserTest.
* HistoryBackInBeforeUnload
* HistoryBackInBeforeUnloadAfterSetTimeout
* HistoryBackCancelPendingNavigationNoUserGesture
* HistoryBackCancelPendingNavigationUserGesture
Fixed:
* (WPT) .../the-history-interface/traverse_the_history_2.html
* (WPT) .../the-history-interface/traverse_the_history_3.html
* (WPT) .../the-history-interface/traverse_the_history_4.html
* (WPT) .../the-history-interface/traverse_the_history_5.html
Bug: 879965
Change-Id: I1a9bfaaea1ffc219e6c32f6e676b660e746c578c
Reviewed-on: https://chromium-review.googlesource.com/1209744
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Mustaq Ahmed <mustaq@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592823}
CWE ID: CWE-254
| 0
| 144,918
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: megasas_check_reset_ppc(struct megasas_instance *instance,
struct megasas_register_set __iomem *regs)
{
if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL)
return 1;
return 0;
}
Commit Message: scsi: megaraid_sas: return error when create DMA pool failed
when create DMA pool for cmd frames failed, we should return -ENOMEM,
instead of 0.
In some case in:
megasas_init_adapter_fusion()
-->megasas_alloc_cmds()
-->megasas_create_frame_pool
create DMA pool failed,
--> megasas_free_cmds() [1]
-->megasas_alloc_cmds_fusion()
failed, then goto fail_alloc_cmds.
-->megasas_free_cmds() [2]
we will call megasas_free_cmds twice, [1] will kfree cmd_list,
[2] will use cmd_list.it will cause a problem:
Unable to handle kernel NULL pointer dereference at virtual address
00000000
pgd = ffffffc000f70000
[00000000] *pgd=0000001fbf893003, *pud=0000001fbf893003,
*pmd=0000001fbf894003, *pte=006000006d000707
Internal error: Oops: 96000005 [#1] SMP
Modules linked in:
CPU: 18 PID: 1 Comm: swapper/0 Not tainted
task: ffffffdfb9290000 ti: ffffffdfb923c000 task.ti: ffffffdfb923c000
PC is at megasas_free_cmds+0x30/0x70
LR is at megasas_free_cmds+0x24/0x70
...
Call trace:
[<ffffffc0005b779c>] megasas_free_cmds+0x30/0x70
[<ffffffc0005bca74>] megasas_init_adapter_fusion+0x2f4/0x4d8
[<ffffffc0005b926c>] megasas_init_fw+0x2dc/0x760
[<ffffffc0005b9ab0>] megasas_probe_one+0x3c0/0xcd8
[<ffffffc0004a5abc>] local_pci_probe+0x4c/0xb4
[<ffffffc0004a5c40>] pci_device_probe+0x11c/0x14c
[<ffffffc00053a5e4>] driver_probe_device+0x1ec/0x430
[<ffffffc00053a92c>] __driver_attach+0xa8/0xb0
[<ffffffc000538178>] bus_for_each_dev+0x74/0xc8
[<ffffffc000539e88>] driver_attach+0x28/0x34
[<ffffffc000539a18>] bus_add_driver+0x16c/0x248
[<ffffffc00053b234>] driver_register+0x6c/0x138
[<ffffffc0004a5350>] __pci_register_driver+0x5c/0x6c
[<ffffffc000ce3868>] megasas_init+0xc0/0x1a8
[<ffffffc000082a58>] do_one_initcall+0xe8/0x1ec
[<ffffffc000ca7be8>] kernel_init_freeable+0x1c8/0x284
[<ffffffc0008d90b8>] kernel_init+0x1c/0xe4
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
CWE ID: CWE-476
| 0
| 90,304
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
{
int mxsize, cmd_size, k;
int input_size, blocking;
unsigned char opcode;
Sg_device *sdp;
Sg_fd *sfp;
Sg_request *srp;
struct sg_header old_hdr;
sg_io_hdr_t *hp;
unsigned char cmnd[SG_MAX_CDB_SIZE];
if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
return -ENXIO;
SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp,
"sg_write: count=%d\n", (int) count));
if (atomic_read(&sdp->detaching))
return -ENODEV;
if (!((filp->f_flags & O_NONBLOCK) ||
scsi_block_when_processing_errors(sdp->device)))
return -ENXIO;
if (!access_ok(VERIFY_READ, buf, count))
return -EFAULT; /* protects following copy_from_user()s + get_user()s */
if (count < SZ_SG_HEADER)
return -EIO;
if (__copy_from_user(&old_hdr, buf, SZ_SG_HEADER))
return -EFAULT;
blocking = !(filp->f_flags & O_NONBLOCK);
if (old_hdr.reply_len < 0)
return sg_new_write(sfp, filp, buf, count,
blocking, 0, 0, NULL);
if (count < (SZ_SG_HEADER + 6))
return -EIO; /* The minimum scsi command length is 6 bytes. */
if (!(srp = sg_add_request(sfp))) {
SCSI_LOG_TIMEOUT(1, sg_printk(KERN_INFO, sdp,
"sg_write: queue full\n"));
return -EDOM;
}
buf += SZ_SG_HEADER;
__get_user(opcode, buf);
if (sfp->next_cmd_len > 0) {
cmd_size = sfp->next_cmd_len;
sfp->next_cmd_len = 0; /* reset so only this write() effected */
} else {
cmd_size = COMMAND_SIZE(opcode); /* based on SCSI command group */
if ((opcode >= 0xc0) && old_hdr.twelve_byte)
cmd_size = 12;
}
SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sdp,
"sg_write: scsi opcode=0x%02x, cmd_size=%d\n", (int) opcode, cmd_size));
/* Determine buffer size. */
input_size = count - cmd_size;
mxsize = (input_size > old_hdr.reply_len) ? input_size : old_hdr.reply_len;
mxsize -= SZ_SG_HEADER;
input_size -= SZ_SG_HEADER;
if (input_size < 0) {
sg_remove_request(sfp, srp);
return -EIO; /* User did not pass enough bytes for this command. */
}
hp = &srp->header;
hp->interface_id = '\0'; /* indicator of old interface tunnelled */
hp->cmd_len = (unsigned char) cmd_size;
hp->iovec_count = 0;
hp->mx_sb_len = 0;
if (input_size > 0)
hp->dxfer_direction = (old_hdr.reply_len > SZ_SG_HEADER) ?
SG_DXFER_TO_FROM_DEV : SG_DXFER_TO_DEV;
else
hp->dxfer_direction = (mxsize > 0) ? SG_DXFER_FROM_DEV : SG_DXFER_NONE;
hp->dxfer_len = mxsize;
if ((hp->dxfer_direction == SG_DXFER_TO_DEV) ||
(hp->dxfer_direction == SG_DXFER_TO_FROM_DEV))
hp->dxferp = (char __user *)buf + cmd_size;
else
hp->dxferp = NULL;
hp->sbp = NULL;
hp->timeout = old_hdr.reply_len; /* structure abuse ... */
hp->flags = input_size; /* structure abuse ... */
hp->pack_id = old_hdr.pack_id;
hp->usr_ptr = NULL;
if (__copy_from_user(cmnd, buf, cmd_size))
return -EFAULT;
/*
* SG_DXFER_TO_FROM_DEV is functionally equivalent to SG_DXFER_FROM_DEV,
* but is is possible that the app intended SG_DXFER_TO_DEV, because there
* is a non-zero input_size, so emit a warning.
*/
if (hp->dxfer_direction == SG_DXFER_TO_FROM_DEV) {
static char cmd[TASK_COMM_LEN];
if (strcmp(current->comm, cmd)) {
printk_ratelimited(KERN_WARNING
"sg_write: data in/out %d/%d bytes "
"for SCSI command 0x%x-- guessing "
"data in;\n program %s not setting "
"count and/or reply_len properly\n",
old_hdr.reply_len - (int)SZ_SG_HEADER,
input_size, (unsigned int) cmnd[0],
current->comm);
strcpy(cmd, current->comm);
}
}
k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking);
return (k < 0) ? k : count;
}
Commit Message: sg_write()/bsg_write() is not fit to be called under KERNEL_DS
Both damn things interpret userland pointers embedded into the payload;
worse, they are actually traversing those. Leaving aside the bad
API design, this is very much _not_ safe to call with KERNEL_DS.
Bail out early if that happens.
Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
CWE ID: CWE-416
| 1
| 166,841
|
Analyze the following 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 WebGLRenderingContextBase::TexImageHelperHTMLVideoElement(
const SecurityOrigin* security_origin,
TexImageFunctionID function_id,
GLenum target,
GLint level,
GLint internalformat,
GLenum format,
GLenum type,
GLint xoffset,
GLint yoffset,
GLint zoffset,
HTMLVideoElement* video,
const IntRect& source_image_rect,
GLsizei depth,
GLint unpack_image_height,
ExceptionState& exception_state) {
const char* func_name = GetTexImageFunctionName(function_id);
if (isContextLost())
return;
if (!ValidateHTMLVideoElement(security_origin, func_name, video,
exception_state))
return;
WebGLTexture* texture =
ValidateTexImageBinding(func_name, function_id, target);
if (!texture)
return;
TexImageFunctionType function_type;
if (function_id == kTexImage2D || function_id == kTexImage3D)
function_type = kTexImage;
else
function_type = kTexSubImage;
if (!ValidateTexFunc(func_name, function_type, kSourceHTMLVideoElement,
target, level, internalformat, video->videoWidth(),
video->videoHeight(), 1, 0, format, type, xoffset,
yoffset, zoffset))
return;
WebMediaPlayer::VideoFrameUploadMetadata frame_metadata = {};
int already_uploaded_id = -1;
WebMediaPlayer::VideoFrameUploadMetadata* frame_metadata_ptr = nullptr;
if (RuntimeEnabledFeatures::ExtraWebGLVideoTextureMetadataEnabled()) {
already_uploaded_id = texture->GetLastUploadedVideoFrameId();
frame_metadata_ptr = &frame_metadata;
}
if (!source_image_rect.IsValid()) {
SynthesizeGLError(GL_INVALID_OPERATION, func_name,
"source sub-rectangle specified via pixel unpack "
"parameters is invalid");
return;
}
bool source_image_rect_is_default =
source_image_rect == SentinelEmptyRect() ||
source_image_rect ==
IntRect(0, 0, video->videoWidth(), video->videoHeight());
const bool use_copyTextureCHROMIUM = function_id == kTexImage2D &&
source_image_rect_is_default &&
depth == 1 && GL_TEXTURE_2D == target &&
CanUseTexImageByGPU(format, type);
if (use_copyTextureCHROMIUM) {
DCHECK_EQ(xoffset, 0);
DCHECK_EQ(yoffset, 0);
DCHECK_EQ(zoffset, 0);
if (video->CopyVideoTextureToPlatformTexture(
ContextGL(), target, texture->Object(), internalformat, format,
type, level, unpack_premultiply_alpha_, unpack_flip_y_,
already_uploaded_id, frame_metadata_ptr)) {
texture->UpdateLastUploadedFrame(frame_metadata);
return;
}
}
if (source_image_rect_is_default) {
ScopedUnpackParametersResetRestore(
this, unpack_flip_y_ || unpack_premultiply_alpha_);
if (video->TexImageImpl(
static_cast<WebMediaPlayer::TexImageFunctionID>(function_id),
target, ContextGL(), texture->Object(), level,
ConvertTexInternalFormat(internalformat, type), format, type,
xoffset, yoffset, zoffset, unpack_flip_y_,
unpack_premultiply_alpha_ &&
unpack_colorspace_conversion_ == GL_NONE)) {
texture->ClearLastUploadedFrame();
return;
}
}
if (use_copyTextureCHROMIUM) {
std::unique_ptr<CanvasResourceProvider> resource_provider =
CanvasResourceProvider::Create(
IntSize(video->videoWidth(), video->videoHeight()),
CanvasResourceProvider::kAcceleratedResourceUsage,
SharedGpuContext::ContextProviderWrapper());
if (resource_provider && resource_provider->IsValid()) {
video->PaintCurrentFrame(
resource_provider->Canvas(),
IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr,
already_uploaded_id, frame_metadata_ptr);
TexImage2DBase(target, level, internalformat, video->videoWidth(),
video->videoHeight(), 0, format, type, nullptr);
if (Extensions3DUtil::CanUseCopyTextureCHROMIUM(target)) {
scoped_refptr<StaticBitmapImage> image = resource_provider->Snapshot();
if (!!image &&
image->CopyToTexture(
ContextGL(), target, texture->Object(),
unpack_premultiply_alpha_, unpack_flip_y_, IntPoint(0, 0),
IntRect(0, 0, video->videoWidth(), video->videoHeight()))) {
texture->UpdateLastUploadedFrame(frame_metadata);
return;
}
}
}
}
scoped_refptr<Image> image =
VideoFrameToImage(video, already_uploaded_id, frame_metadata_ptr);
if (!image)
return;
TexImageImpl(function_id, target, level, internalformat, xoffset, yoffset,
zoffset, format, type, image.get(),
WebGLImageConversion::kHtmlDomVideo, unpack_flip_y_,
unpack_premultiply_alpha_, source_image_rect, depth,
unpack_image_height);
texture->UpdateLastUploadedFrame(frame_metadata);
}
Commit Message: Validate all incoming WebGLObjects.
A few entry points were missing the correct validation.
Tested with improved conformance tests in
https://github.com/KhronosGroup/WebGL/pull/2654 .
Bug: 848914
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: Ib98a61cc5bf378d1b3338b04acd7e1bc4c2fe008
Reviewed-on: https://chromium-review.googlesource.com/1086718
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565016}
CWE ID: CWE-119
| 0
| 153,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: mm_auth_rhosts_rsa_key_allowed(struct passwd *pw, char *user,
char *host, Key *key)
{
int ret;
key->type = KEY_RSA; /* XXX hack for key_to_blob */
ret = mm_key_allowed(MM_RSAHOSTKEY, user, host, key, 0);
key->type = KEY_RSA1;
return (ret);
}
Commit Message: Don't resend username to PAM; it already has it.
Pointed out by Moritz Jodeit; ok dtucker@
CWE ID: CWE-20
| 0
| 42,139
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
int attr_mask, struct ib_udata *udata)
{
struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
struct mlx5_ib_qp *qp = to_mqp(ibqp);
struct mlx5_ib_modify_qp ucmd = {};
enum ib_qp_type qp_type;
enum ib_qp_state cur_state, new_state;
size_t required_cmd_sz;
int err = -EINVAL;
int port;
enum rdma_link_layer ll = IB_LINK_LAYER_UNSPECIFIED;
if (ibqp->rwq_ind_tbl)
return -ENOSYS;
if (udata && udata->inlen) {
required_cmd_sz = offsetof(typeof(ucmd), reserved) +
sizeof(ucmd.reserved);
if (udata->inlen < required_cmd_sz)
return -EINVAL;
if (udata->inlen > sizeof(ucmd) &&
!ib_is_udata_cleared(udata, sizeof(ucmd),
udata->inlen - sizeof(ucmd)))
return -EOPNOTSUPP;
if (ib_copy_from_udata(&ucmd, udata,
min(udata->inlen, sizeof(ucmd))))
return -EFAULT;
if (ucmd.comp_mask ||
memchr_inv(&ucmd.reserved, 0, sizeof(ucmd.reserved)) ||
memchr_inv(&ucmd.burst_info.reserved, 0,
sizeof(ucmd.burst_info.reserved)))
return -EOPNOTSUPP;
}
if (unlikely(ibqp->qp_type == IB_QPT_GSI))
return mlx5_ib_gsi_modify_qp(ibqp, attr, attr_mask);
if (ibqp->qp_type == IB_QPT_DRIVER)
qp_type = qp->qp_sub_type;
else
qp_type = (unlikely(ibqp->qp_type == MLX5_IB_QPT_HW_GSI)) ?
IB_QPT_GSI : ibqp->qp_type;
if (qp_type == MLX5_IB_QPT_DCT)
return mlx5_ib_modify_dct(ibqp, attr, attr_mask, udata);
mutex_lock(&qp->mutex);
cur_state = attr_mask & IB_QP_CUR_STATE ? attr->cur_qp_state : qp->state;
new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
if (!(cur_state == new_state && cur_state == IB_QPS_RESET)) {
port = attr_mask & IB_QP_PORT ? attr->port_num : qp->port;
ll = dev->ib_dev.get_link_layer(&dev->ib_dev, port);
}
if (qp->flags & MLX5_IB_QP_UNDERLAY) {
if (attr_mask & ~(IB_QP_STATE | IB_QP_CUR_STATE)) {
mlx5_ib_dbg(dev, "invalid attr_mask 0x%x when underlay QP is used\n",
attr_mask);
goto out;
}
} else if (qp_type != MLX5_IB_QPT_REG_UMR &&
qp_type != MLX5_IB_QPT_DCI &&
!ib_modify_qp_is_ok(cur_state, new_state, qp_type, attr_mask, ll)) {
mlx5_ib_dbg(dev, "invalid QP state transition from %d to %d, qp_type %d, attr_mask 0x%x\n",
cur_state, new_state, ibqp->qp_type, attr_mask);
goto out;
} else if (qp_type == MLX5_IB_QPT_DCI &&
!modify_dci_qp_is_ok(cur_state, new_state, attr_mask)) {
mlx5_ib_dbg(dev, "invalid QP state transition from %d to %d, qp_type %d, attr_mask 0x%x\n",
cur_state, new_state, qp_type, attr_mask);
goto out;
}
if ((attr_mask & IB_QP_PORT) &&
(attr->port_num == 0 ||
attr->port_num > dev->num_ports)) {
mlx5_ib_dbg(dev, "invalid port number %d. number of ports is %d\n",
attr->port_num, dev->num_ports);
goto out;
}
if (attr_mask & IB_QP_PKEY_INDEX) {
port = attr_mask & IB_QP_PORT ? attr->port_num : qp->port;
if (attr->pkey_index >=
dev->mdev->port_caps[port - 1].pkey_table_len) {
mlx5_ib_dbg(dev, "invalid pkey index %d\n",
attr->pkey_index);
goto out;
}
}
if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
attr->max_rd_atomic >
(1 << MLX5_CAP_GEN(dev->mdev, log_max_ra_res_qp))) {
mlx5_ib_dbg(dev, "invalid max_rd_atomic value %d\n",
attr->max_rd_atomic);
goto out;
}
if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC &&
attr->max_dest_rd_atomic >
(1 << MLX5_CAP_GEN(dev->mdev, log_max_ra_req_qp))) {
mlx5_ib_dbg(dev, "invalid max_dest_rd_atomic value %d\n",
attr->max_dest_rd_atomic);
goto out;
}
if (cur_state == new_state && cur_state == IB_QPS_RESET) {
err = 0;
goto out;
}
err = __mlx5_ib_modify_qp(ibqp, attr, attr_mask, cur_state,
new_state, &ucmd);
out:
mutex_unlock(&qp->mutex);
return err;
}
Commit Message: IB/mlx5: Fix leaking stack memory to userspace
mlx5_ib_create_qp_resp was never initialized and only the first 4 bytes
were written.
Fixes: 41d902cb7c32 ("RDMA/mlx5: Fix definition of mlx5_ib_create_qp_resp")
Cc: <stable@vger.kernel.org>
Acked-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
CWE ID: CWE-119
| 0
| 92,153
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: _dbus_connect_tcp_socket_with_nonce (const char *host,
const char *port,
const char *family,
const char *noncefile,
DBusError *error)
{
int saved_errno = 0;
int fd = -1, res;
struct addrinfo hints;
struct addrinfo *ai, *tmp;
_DBUS_ASSERT_ERROR_IS_CLEAR(error);
_DBUS_ZERO (hints);
if (!family)
hints.ai_family = AF_UNSPEC;
else if (!strcmp(family, "ipv4"))
hints.ai_family = AF_INET;
else if (!strcmp(family, "ipv6"))
hints.ai_family = AF_INET6;
else
{
dbus_set_error (error,
DBUS_ERROR_BAD_ADDRESS,
"Unknown address family %s", family);
return -1;
}
hints.ai_protocol = IPPROTO_TCP;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_ADDRCONFIG;
if ((res = getaddrinfo(host, port, &hints, &ai)) != 0)
{
dbus_set_error (error,
_dbus_error_from_errno (errno),
"Failed to lookup host/port: \"%s:%s\": %s (%d)",
host, port, gai_strerror(res), res);
return -1;
}
tmp = ai;
while (tmp)
{
if (!_dbus_open_socket (&fd, tmp->ai_family, SOCK_STREAM, 0, error))
{
freeaddrinfo(ai);
_DBUS_ASSERT_ERROR_IS_SET(error);
return -1;
}
_DBUS_ASSERT_ERROR_IS_CLEAR(error);
if (connect (fd, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) < 0)
{
saved_errno = errno;
_dbus_close(fd, NULL);
fd = -1;
tmp = tmp->ai_next;
continue;
}
break;
}
freeaddrinfo(ai);
if (fd == -1)
{
dbus_set_error (error,
_dbus_error_from_errno (saved_errno),
"Failed to connect to socket \"%s:%s\" %s",
host, port, _dbus_strerror(saved_errno));
return -1;
}
if (noncefile != NULL)
{
DBusString noncefileStr;
dbus_bool_t ret;
_dbus_string_init_const (&noncefileStr, noncefile);
ret = _dbus_send_nonce (fd, &noncefileStr, error);
_dbus_string_free (&noncefileStr);
if (!ret)
{
_dbus_close (fd, NULL);
return -1;
}
}
if (!_dbus_set_fd_nonblocking (fd, error))
{
_dbus_close (fd, NULL);
return -1;
}
return fd;
}
Commit Message:
CWE ID: CWE-20
| 0
| 3,725
|
Analyze the following 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 *threaded_find_deltas(void *arg)
{
struct thread_params *me = arg;
while (me->remaining) {
find_deltas(me->list, &me->remaining,
me->window, me->depth, me->processed);
progress_lock();
me->working = 0;
pthread_cond_signal(&progress_cond);
progress_unlock();
/*
* We must not set ->data_ready before we wait on the
* condition because the main thread may have set it to 1
* before we get here. In order to be sure that new
* work is available if we see 1 in ->data_ready, it
* was initialized to 0 before this thread was spawned
* and we reset it to 0 right away.
*/
pthread_mutex_lock(&me->mutex);
while (!me->data_ready)
pthread_cond_wait(&me->cond, &me->mutex);
me->data_ready = 0;
pthread_mutex_unlock(&me->mutex);
}
/* leave ->working 1 so that this doesn't get more work assigned */
return NULL;
}
Commit Message: list-objects: pass full pathname to callbacks
When we find a blob at "a/b/c", we currently pass this to
our show_object_fn callbacks as two components: "a/b/" and
"c". Callbacks which want the full value then call
path_name(), which concatenates the two. But this is an
inefficient interface; the path is a strbuf, and we could
simply append "c" to it temporarily, then roll back the
length, without creating a new copy.
So we could improve this by teaching the callsites of
path_name() this trick (and there are only 3). But we can
also notice that no callback actually cares about the
broken-down representation, and simply pass each callback
the full path "a/b/c" as a string. The callback code becomes
even simpler, then, as we do not have to worry about freeing
an allocated buffer, nor rolling back our modification to
the strbuf.
This is theoretically less efficient, as some callbacks
would not bother to format the final path component. But in
practice this is not measurable. Since we use the same
strbuf over and over, our work to grow it is amortized, and
we really only pay to memcpy a few bytes.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
CWE ID: CWE-119
| 0
| 54,876
|
Analyze the following 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 calc_load_migrate(struct rq *rq)
{
long delta = calc_load_fold_active(rq);
if (delta)
atomic_long_add(delta, &calc_load_tasks);
}
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,492
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: selRead(const char *fname)
{
FILE *fp;
SEL *sel;
PROCNAME("selRead");
if (!fname)
return (SEL *)ERROR_PTR("fname not defined", procName, NULL);
if ((fp = fopenReadStream(fname)) == NULL)
return (SEL *)ERROR_PTR("stream not opened", procName, NULL);
if ((sel = selReadStream(fp)) == NULL) {
fclose(fp);
return (SEL *)ERROR_PTR("sela not returned", procName, NULL);
}
fclose(fp);
return sel;
}
Commit Message: Security fixes: expect final changes for release 1.75.3.
* Fixed a debian security issue with fscanf() reading a string with
possible buffer overflow.
* There were also a few similar situations with sscanf().
CWE ID: CWE-119
| 0
| 84,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: invoke_NPN_NewStream(PluginInstance *plugin, NPMIMEType type, const char *target, NPStream **pstream)
{
npw_return_val_if_fail(rpc_method_invoke_possible(g_rpc_connection),
NPERR_GENERIC_ERROR);
int error = rpc_method_invoke(g_rpc_connection,
RPC_METHOD_NPN_NEW_STREAM,
RPC_TYPE_NPW_PLUGIN_INSTANCE, plugin,
RPC_TYPE_STRING, type,
RPC_TYPE_STRING, target,
RPC_TYPE_INVALID);
if (error != RPC_ERROR_NO_ERROR) {
npw_perror("NPN_NewStream() invoke", error);
return NPERR_OUT_OF_MEMORY_ERROR;
}
int32_t ret;
uint32_t stream_id;
char *url;
uint32_t end;
uint32_t lastmodified;
void *notifyData;
char *headers;
error = rpc_method_wait_for_reply(g_rpc_connection,
RPC_TYPE_INT32, &ret,
RPC_TYPE_UINT32, &stream_id,
RPC_TYPE_STRING, &url,
RPC_TYPE_UINT32, &end,
RPC_TYPE_UINT32, &lastmodified,
RPC_TYPE_NP_NOTIFY_DATA, ¬ifyData,
RPC_TYPE_STRING, &headers,
RPC_TYPE_INVALID);
if (error != RPC_ERROR_NO_ERROR) {
npw_perror("NPN_NewStream() wait for reply", error);
return NPERR_GENERIC_ERROR;
}
NPStream *stream = NULL;
if (ret == NPERR_NO_ERROR) {
if ((stream = malloc(sizeof(*stream))) == NULL)
return NPERR_OUT_OF_MEMORY_ERROR;
memset(stream, 0, sizeof(*stream));
StreamInstance *stream_ndata;
if ((stream_ndata = malloc(sizeof(*stream_ndata))) == NULL) {
free(stream);
return NPERR_OUT_OF_MEMORY_ERROR;
}
stream->ndata = stream_ndata;
stream->url = url;
stream->end = end;
stream->lastmodified = lastmodified;
stream->notifyData = notifyData;
stream->headers = headers;
memset(stream_ndata, 0, sizeof(*stream_ndata));
stream_ndata->stream_id = stream_id;
id_link(stream_id, stream_ndata);
stream_ndata->stream = stream;
stream_ndata->is_plugin_stream = 1;
}
else {
if (url)
free(url);
if (headers)
free(headers);
}
*pstream = stream;
return ret;
}
Commit Message: Support all the new variables added
CWE ID: CWE-264
| 0
| 27,130
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: bool MultibufferDataSource::media_has_played() const {
return media_has_played_;
}
Commit Message: Simplify "WouldTaintOrigin" concept in media/blink
Currently WebMediaPlayer has three predicates:
- DidGetOpaqueResponseFromServiceWorker
- HasSingleSecurityOrigin
- DidPassCORSAccessCheck
. These are used to determine whether the response body is available
for scripts. They are known to be confusing, and actually
MediaElementAudioSourceHandler::WouldTaintOrigin misuses them.
This CL merges the three predicates to one, WouldTaintOrigin, to remove
the confusion. Now the "response type" concept is available and we
don't need a custom CORS check, so this CL removes
BaseAudioContext::WouldTaintOrigin. This CL also renames
URLData::has_opaque_data_ and its (direct and indirect) data accessors
to match the spec.
Bug: 849942, 875153
Change-Id: I6acf50169d7445c4ff614e80ac606f79ee577d2a
Reviewed-on: https://chromium-review.googlesource.com/c/1238098
Reviewed-by: Fredrik Hubinette <hubbe@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Raymond Toy <rtoy@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#598258}
CWE ID: CWE-732
| 0
| 144,244
|
Analyze the following 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 snd_usb_gamecon780_boot_quirk(struct usb_device *dev)
{
/* set the initial volume and don't change; other values are either
* too loud or silent due to firmware bug (bko#65251)
*/
u8 buf[2] = { 0x74, 0xe3 };
return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
UAC_FU_VOLUME << 8, 9 << 8, buf, 2);
}
Commit Message: ALSA: usb-audio: Fix NULL dereference in create_fixed_stream_quirk()
create_fixed_stream_quirk() may cause a NULL-pointer dereference by
accessing the non-existing endpoint when a USB device with a malformed
USB descriptor is used.
This patch avoids it simply by adding a sanity check of bNumEndpoints
before the accesses.
Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=971125
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
CWE ID:
| 0
| 55,267
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void nlmclnt_release_call(struct nlm_rqst *call)
{
if (!atomic_dec_and_test(&call->a_count))
return;
nlmclnt_release_host(call->a_host);
nlmclnt_release_lockargs(call);
kfree(call);
}
Commit Message: NLM: Don't hang forever on NLM unlock requests
If the NLM daemon is killed on the NFS server, we can currently end up
hanging forever on an 'unlock' request, instead of aborting. Basically,
if the rpcbind request fails, or the server keeps returning garbage, we
really want to quit instead of retrying.
Tested-by: Vasily Averin <vvs@sw.ru>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@kernel.org
CWE ID: CWE-399
| 0
| 34,872
|
Analyze the following 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::Float32ArrayMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_float32ArrayMethod");
test_object_v8_internal::Float32ArrayMethodMethod(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,718
|
Analyze the following 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 kgdb_remove_all_hw_break(void)
{
int i;
int cpu = raw_smp_processor_id();
struct perf_event *bp;
for (i = 0; i < HBP_NUM; i++) {
if (!breakinfo[i].enabled)
continue;
bp = *per_cpu_ptr(breakinfo[i].pev, cpu);
if (!bp->attr.disabled) {
arch_uninstall_hw_breakpoint(bp);
bp->attr.disabled = 1;
continue;
}
if (dbg_is_early)
early_dr7 &= ~encode_dr7(i, breakinfo[i].len,
breakinfo[i].type);
else if (hw_break_release_slot(i))
printk(KERN_ERR "KGDB: hw bpt remove failed %lx\n",
breakinfo[i].addr);
breakinfo[i].enabled = 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,880
|
Analyze the following 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 zlib_decompress_final(struct crypto_pcomp *tfm,
struct comp_request *req)
{
int ret;
struct zlib_ctx *dctx = crypto_tfm_ctx(crypto_pcomp_tfm(tfm));
struct z_stream_s *stream = &dctx->decomp_stream;
pr_debug("avail_in %u, avail_out %u\n", req->avail_in, req->avail_out);
stream->next_in = req->next_in;
stream->avail_in = req->avail_in;
stream->next_out = req->next_out;
stream->avail_out = req->avail_out;
if (dctx->decomp_windowBits < 0) {
ret = zlib_inflate(stream, Z_SYNC_FLUSH);
/*
* Work around a bug in zlib, which sometimes wants to taste an
* extra byte when being used in the (undocumented) raw deflate
* mode. (From USAGI).
*/
if (ret == Z_OK && !stream->avail_in && stream->avail_out) {
const void *saved_next_in = stream->next_in;
u8 zerostuff = 0;
stream->next_in = &zerostuff;
stream->avail_in = 1;
ret = zlib_inflate(stream, Z_FINISH);
stream->next_in = saved_next_in;
stream->avail_in = 0;
}
} else
ret = zlib_inflate(stream, Z_FINISH);
if (ret != Z_STREAM_END) {
pr_debug("zlib_inflate failed %d\n", ret);
return -EINVAL;
}
ret = req->avail_out - stream->avail_out;
pr_debug("avail_in %lu, avail_out %lu (consumed %lu, produced %u)\n",
stream->avail_in, stream->avail_out,
req->avail_in - stream->avail_in, ret);
req->next_in = stream->next_in;
req->avail_in = stream->avail_in;
req->next_out = stream->next_out;
req->avail_out = stream->avail_out;
return ret;
}
Commit Message: crypto: prefix module autoloading with "crypto-"
This prefixes all crypto module loading with "crypto-" so we never run
the risk of exposing module auto-loading to userspace via a crypto API,
as demonstrated by Mathias Krause:
https://lkml.org/lkml/2013/3/4/70
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
CWE ID: CWE-264
| 0
| 47,416
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: OxideQQuickWebViewPrivate::~OxideQQuickWebViewPrivate() {}
Commit Message:
CWE ID: CWE-20
| 0
| 17,194
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static ssize_t proc_sessionid_read(struct file * file, char __user * buf,
size_t count, loff_t *ppos)
{
struct inode * inode = file_inode(file);
struct task_struct *task = get_proc_task(inode);
ssize_t length;
char tmpbuf[TMPBUFLEN];
if (!task)
return -ESRCH;
length = scnprintf(tmpbuf, TMPBUFLEN, "%u",
audit_get_sessionid(task));
put_task_struct(task);
return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
}
Commit Message: proc: prevent accessing /proc/<PID>/environ until it's ready
If /proc/<PID>/environ gets read before the envp[] array is fully set up
in create_{aout,elf,elf_fdpic,flat}_tables(), we might end up trying to
read more bytes than are actually written, as env_start will already be
set but env_end will still be zero, making the range calculation
underflow, allowing to read beyond the end of what has been written.
Fix this as it is done for /proc/<PID>/cmdline by testing env_end for
zero. It is, apparently, intentionally set last in create_*_tables().
This bug was found by the PaX size_overflow plugin that detected the
arithmetic underflow of 'this_len = env_end - (env_start + src)' when
env_end is still zero.
The expected consequence is that userland trying to access
/proc/<PID>/environ of a not yet fully set up process may get
inconsistent data as we're in the middle of copying in the environment
variables.
Fixes: https://forums.grsecurity.net/viewtopic.php?f=3&t=4363
Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=116461
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Emese Revfy <re.emese@gmail.com>
Cc: Pax Team <pageexec@freemail.hu>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Mateusz Guzik <mguzik@redhat.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
CWE ID: CWE-362
| 0
| 49,448
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: error::Error GLES2DecoderPassthroughImpl::DoGetUniformBlocksCHROMIUM(
GLuint program,
std::vector<uint8_t>* data) {
GLuint service_program = 0;
if (!resources_->program_id_map.GetServiceID(program, &service_program)) {
return error::kNoError;
}
GLint num_uniform_blocks = 0;
api()->glGetProgramivFn(service_program, GL_ACTIVE_UNIFORM_BLOCKS,
&num_uniform_blocks);
const base::CheckedNumeric<size_t> buffer_header_size(
sizeof(UniformBlocksHeader));
const base::CheckedNumeric<size_t> buffer_block_size(
sizeof(UniformBlockInfo));
data->resize((buffer_header_size + (num_uniform_blocks * buffer_block_size))
.ValueOrDie(),
0);
UniformBlocksHeader header;
header.num_uniform_blocks = num_uniform_blocks;
InsertValueIntoBuffer(data, header, 0);
GLint active_uniform_block_max_length = 0;
api()->glGetProgramivFn(service_program,
GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH,
&active_uniform_block_max_length);
std::vector<char> uniform_block_name_buf(active_uniform_block_max_length, 0);
for (GLint uniform_block_index = 0; uniform_block_index < num_uniform_blocks;
uniform_block_index++) {
UniformBlockInfo block_info;
GLint uniform_block_binding = 0;
api()->glGetActiveUniformBlockivFn(service_program, uniform_block_index,
GL_UNIFORM_BLOCK_BINDING,
&uniform_block_binding);
block_info.binding = uniform_block_binding;
GLint uniform_block_data_size = 0;
api()->glGetActiveUniformBlockivFn(service_program, uniform_block_index,
GL_UNIFORM_BLOCK_DATA_SIZE,
&uniform_block_data_size);
block_info.data_size = uniform_block_data_size;
GLint uniform_block_name_length = 0;
api()->glGetActiveUniformBlockNameFn(
service_program, uniform_block_index, active_uniform_block_max_length,
&uniform_block_name_length, uniform_block_name_buf.data());
DCHECK(uniform_block_name_length + 1 <= active_uniform_block_max_length);
block_info.name_offset = data->size();
block_info.name_length = uniform_block_name_length + 1;
AppendStringToBuffer(data, uniform_block_name_buf.data(),
uniform_block_name_length + 1);
GLint uniform_block_active_uniforms = 0;
api()->glGetActiveUniformBlockivFn(service_program, uniform_block_index,
GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS,
&uniform_block_active_uniforms);
block_info.active_uniforms = uniform_block_active_uniforms;
std::vector<GLint> uniform_block_indices_buf(uniform_block_active_uniforms,
0);
api()->glGetActiveUniformBlockivFn(service_program, uniform_block_index,
GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES,
uniform_block_indices_buf.data());
block_info.active_uniform_offset = data->size();
for (GLint uniform_block_uniform_index_index = 0;
uniform_block_uniform_index_index < uniform_block_active_uniforms;
uniform_block_uniform_index_index++) {
AppendValueToBuffer(
data,
static_cast<uint32_t>(
uniform_block_indices_buf[uniform_block_uniform_index_index]));
}
GLint uniform_block_referenced_by_vertex_shader = 0;
api()->glGetActiveUniformBlockivFn(
service_program, uniform_block_index,
GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER,
&uniform_block_referenced_by_vertex_shader);
block_info.referenced_by_vertex_shader =
uniform_block_referenced_by_vertex_shader;
GLint uniform_block_referenced_by_fragment_shader = 0;
api()->glGetActiveUniformBlockivFn(
service_program, uniform_block_index,
GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER,
&uniform_block_referenced_by_fragment_shader);
block_info.referenced_by_fragment_shader =
uniform_block_referenced_by_fragment_shader;
InsertValueIntoBuffer(
data, block_info,
(buffer_header_size + (buffer_block_size * uniform_block_index))
.ValueOrDie());
}
return error::kNoError;
}
Commit Message: Add GL_PROGRAM_COMPLETION_QUERY_CHROMIUM
This makes the query of GL_COMPLETION_STATUS_KHR to programs much
cheaper by minimizing the round-trip to the GPU thread.
Bug: 881152, 957001
Change-Id: Iadfa798af29225e752c710ca5c25f50b3dd3101a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1586630
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657568}
CWE ID: CWE-416
| 0
| 142,024
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: apr_byte_t oidc_get_remote_user(request_rec *r, const char *claim_name,
const char *reg_exp, const char *replace, json_t *json,
char **request_user) {
/* get the claim value from the JSON object */
json_t *username = json_object_get(json, claim_name);
if ((username == NULL) || (!json_is_string(username))) {
oidc_warn(r, "JSON object did not contain a \"%s\" string", claim_name);
return FALSE;
}
*request_user = apr_pstrdup(r->pool, json_string_value(username));
if (reg_exp != NULL) {
char *error_str = NULL;
if (replace == NULL) {
if (oidc_util_regexp_first_match(r->pool, *request_user, reg_exp,
request_user, &error_str) == FALSE) {
oidc_error(r, "oidc_util_regexp_first_match failed: %s",
error_str);
*request_user = NULL;
return FALSE;
}
} else if (oidc_util_regexp_substitute(r->pool, *request_user, reg_exp,
replace, request_user, &error_str) == FALSE) {
oidc_error(r, "oidc_util_regexp_substitute failed: %s", error_str);
*request_user = NULL;
return FALSE;
}
}
return TRUE;
}
Commit Message: release 2.3.10.2: fix XSS vulnerability for poll parameter
in OIDC Session Management RP iframe; CSNC-2019-001; thanks Mischa
Bachmann
Signed-off-by: Hans Zandbelt <hans.zandbelt@zmartzone.eu>
CWE ID: CWE-79
| 0
| 87,067
|
Analyze the following 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 AudioOutputDevice::AudioThreadCallback::MapSharedMemory() {
shared_memory_.Map(TotalSharedMemorySizeInBytes(memory_length_));
int output_memory_size = AudioBus::CalculateMemorySize(audio_parameters_);
int frames = audio_parameters_.frames_per_buffer();
int input_memory_size =
AudioBus::CalculateMemorySize(input_channels_, frames);
int io_size = output_memory_size + input_memory_size;
DCHECK_EQ(memory_length_, io_size);
output_bus_ =
AudioBus::WrapMemory(audio_parameters_, shared_memory_.memory());
if (input_channels_ > 0) {
char* input_data =
static_cast<char*>(shared_memory_.memory()) + output_memory_size;
input_bus_ =
AudioBus::WrapMemory(input_channels_, frames, input_data);
}
}
Commit Message: Revert r157378 as it caused WebRTC to dereference null pointers when restarting a call.
I've kept my unit test changes intact but disabled until I get a proper fix.
BUG=147499,150805
TBR=henrika
Review URL: https://codereview.chromium.org/10946040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157626 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-362
| 0
| 103,016
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static void setup_rock_ridge(struct iso_directory_record *de,
struct inode *inode, struct rock_state *rs)
{
rs->len = sizeof(struct iso_directory_record) + de->name_len[0];
if (rs->len & 1)
(rs->len)++;
rs->chr = (unsigned char *)de + rs->len;
rs->len = *((unsigned char *)de) - rs->len;
if (rs->len < 0)
rs->len = 0;
if (ISOFS_SB(inode->i_sb)->s_rock_offset != -1) {
rs->len -= ISOFS_SB(inode->i_sb)->s_rock_offset;
rs->chr += ISOFS_SB(inode->i_sb)->s_rock_offset;
if (rs->len < 0)
rs->len = 0;
}
}
Commit Message: isofs: Fix infinite looping over CE entries
Rock Ridge extensions define so called Continuation Entries (CE) which
define where is further space with Rock Ridge data. Corrupted isofs
image can contain arbitrarily long chain of these, including a one
containing loop and thus causing kernel to end in an infinite loop when
traversing these entries.
Limit the traversal to 32 entries which should be more than enough space
to store all the Rock Ridge data.
Reported-by: P J P <ppandit@redhat.com>
CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
CWE ID: CWE-399
| 0
| 35,385
|
Analyze the following 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 log_btmp(struct passwd const *pw)
{
struct utmpx ut;
struct timeval tv;
const char *tty_name, *tty_num;
memset(&ut, 0, sizeof(ut));
strncpy(ut.ut_user,
pw && pw->pw_name ? pw->pw_name : "(unknown)",
sizeof(ut.ut_user));
get_terminal_name(NULL, &tty_name, &tty_num);
if (tty_num)
xstrncpy(ut.ut_id, tty_num, sizeof(ut.ut_id));
if (tty_name)
xstrncpy(ut.ut_line, tty_name, sizeof(ut.ut_line));
gettimeofday(&tv, NULL);
ut.ut_tv.tv_sec = tv.tv_sec;
ut.ut_tv.tv_usec = tv.tv_usec;
ut.ut_type = LOGIN_PROCESS; /* XXX doesn't matter */
ut.ut_pid = getpid();
updwtmpx(_PATH_BTMP, &ut);
}
Commit Message: su: properly clear child PID
Reported-by: Tobias Stöckmann <tobias@stoeckmann.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
CWE ID: CWE-362
| 0
| 86,500
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static int lua_apr_mkdir(lua_State *L)
{
request_rec *r;
const char *path;
apr_status_t status;
apr_fileperms_t perms;
r = ap_lua_check_request_rec(L, 1);
luaL_checktype(L, 2, LUA_TSTRING);
path = lua_tostring(L, 2);
perms = luaL_optinteger(L, 3, APR_OS_DEFAULT);
status = apr_dir_make(path, perms, r->pool);
lua_pushboolean(L, (status == 0));
return 1;
}
Commit Message: *) SECURITY: CVE-2015-0228 (cve.mitre.org)
mod_lua: A maliciously crafted websockets PING after a script
calls r:wsupgrade() can cause a child process crash.
[Edward Lu <Chaosed0 gmail.com>]
Discovered by Guido Vranken <guidovranken gmail.com>
Submitted by: Edward Lu
Committed by: covener
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1657261 13f79535-47bb-0310-9956-ffa450edef68
CWE ID: CWE-20
| 0
| 45,095
|
Analyze the following 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 get_derived_key(u8 *derived_key, enum derived_key_type key_type,
const u8 *master_key, size_t master_keylen)
{
u8 *derived_buf;
unsigned int derived_buf_len;
int ret;
derived_buf_len = strlen("AUTH_KEY") + 1 + master_keylen;
if (derived_buf_len < HASH_SIZE)
derived_buf_len = HASH_SIZE;
derived_buf = kzalloc(derived_buf_len, GFP_KERNEL);
if (!derived_buf) {
pr_err("encrypted_key: out of memory\n");
return -ENOMEM;
}
if (key_type)
strcpy(derived_buf, "AUTH_KEY");
else
strcpy(derived_buf, "ENC_KEY");
memcpy(derived_buf + strlen(derived_buf) + 1, master_key,
master_keylen);
ret = calc_hash(derived_key, derived_buf, derived_buf_len);
kfree(derived_buf);
return ret;
}
Commit Message: KEYS: Fix handling of stored error in a negatively instantiated user key
If a user key gets negatively instantiated, an error code is cached in the
payload area. A negatively instantiated key may be then be positively
instantiated by updating it with valid data. However, the ->update key
type method must be aware that the error code may be there.
The following may be used to trigger the bug in the user key type:
keyctl request2 user user "" @u
keyctl add user user "a" @u
which manifests itself as:
BUG: unable to handle kernel paging request at 00000000ffffff8a
IP: [<ffffffff810a376f>] __call_rcu.constprop.76+0x1f/0x280 kernel/rcu/tree.c:3046
PGD 7cc30067 PUD 0
Oops: 0002 [#1] SMP
Modules linked in:
CPU: 3 PID: 2644 Comm: a.out Not tainted 4.3.0+ #49
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
task: ffff88003ddea700 ti: ffff88003dd88000 task.ti: ffff88003dd88000
RIP: 0010:[<ffffffff810a376f>] [<ffffffff810a376f>] __call_rcu.constprop.76+0x1f/0x280
[<ffffffff810a376f>] __call_rcu.constprop.76+0x1f/0x280 kernel/rcu/tree.c:3046
RSP: 0018:ffff88003dd8bdb0 EFLAGS: 00010246
RAX: 00000000ffffff82 RBX: 0000000000000000 RCX: 0000000000000001
RDX: ffffffff81e3fe40 RSI: 0000000000000000 RDI: 00000000ffffff82
RBP: ffff88003dd8bde0 R08: ffff88007d2d2da0 R09: 0000000000000000
R10: 0000000000000000 R11: ffff88003e8073c0 R12: 00000000ffffff82
R13: ffff88003dd8be68 R14: ffff88007d027600 R15: ffff88003ddea700
FS: 0000000000b92880(0063) GS:ffff88007fd00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 00000000ffffff8a CR3: 000000007cc5f000 CR4: 00000000000006e0
Stack:
ffff88003dd8bdf0 ffffffff81160a8a 0000000000000000 00000000ffffff82
ffff88003dd8be68 ffff88007d027600 ffff88003dd8bdf0 ffffffff810a39e5
ffff88003dd8be20 ffffffff812a31ab ffff88007d027600 ffff88007d027620
Call Trace:
[<ffffffff810a39e5>] kfree_call_rcu+0x15/0x20 kernel/rcu/tree.c:3136
[<ffffffff812a31ab>] user_update+0x8b/0xb0 security/keys/user_defined.c:129
[< inline >] __key_update security/keys/key.c:730
[<ffffffff8129e5c1>] key_create_or_update+0x291/0x440 security/keys/key.c:908
[< inline >] SYSC_add_key security/keys/keyctl.c:125
[<ffffffff8129fc21>] SyS_add_key+0x101/0x1e0 security/keys/keyctl.c:60
[<ffffffff8185f617>] entry_SYSCALL_64_fastpath+0x12/0x6a arch/x86/entry/entry_64.S:185
Note the error code (-ENOKEY) in EDX.
A similar bug can be tripped by:
keyctl request2 trusted user "" @u
keyctl add trusted user "a" @u
This should also affect encrypted keys - but that has to be correctly
parameterised or it will fail with EINVAL before getting to the bit that
will crashes.
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
CWE ID: CWE-264
| 0
| 57,390
|
Analyze the following 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 perWorldBindingsVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
TestObjectPythonV8Internal::perWorldBindingsVoidMethodMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
Commit Message: document.location bindings fix
BUG=352374
R=jochen@chromium.org
Review URL: https://codereview.chromium.org/196343011
git-svn-id: svn://svn.chromium.org/blink/trunk@169176 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-399
| 0
| 122,521
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: int vfs_rmdir(struct inode *dir, struct dentry *dentry)
{
int error = may_delete(dir, dentry, 1);
if (error)
return error;
if (!dir->i_op->rmdir)
return -EPERM;
dget(dentry);
mutex_lock(&dentry->d_inode->i_mutex);
error = -EBUSY;
if (d_mountpoint(dentry))
goto out;
error = security_inode_rmdir(dir, dentry);
if (error)
goto out;
shrink_dcache_parent(dentry);
error = dir->i_op->rmdir(dir, dentry);
if (error)
goto out;
dentry->d_inode->i_flags |= S_DEAD;
dont_mount(dentry);
out:
mutex_unlock(&dentry->d_inode->i_mutex);
dput(dentry);
if (!error)
d_delete(dentry);
return error;
}
Commit Message: fs: umount on symlink leaks mnt count
Currently umount on symlink blocks following umount:
/vz is separate mount
# ls /vz/ -al | grep test
drwxr-xr-x. 2 root root 4096 Jul 19 01:14 testdir
lrwxrwxrwx. 1 root root 11 Jul 19 01:16 testlink -> /vz/testdir
# umount -l /vz/testlink
umount: /vz/testlink: not mounted (expected)
# lsof /vz
# umount /vz
umount: /vz: device is busy. (unexpected)
In this case mountpoint_last() gets an extra refcount on path->mnt
Signed-off-by: Vasily Averin <vvs@openvz.org>
Acked-by: Ian Kent <raven@themaw.net>
Acked-by: Jeff Layton <jlayton@primarydata.com>
Cc: stable@vger.kernel.org
Signed-off-by: Christoph Hellwig <hch@lst.de>
CWE ID: CWE-59
| 0
| 36,392
|
Analyze the following 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 RenderViewHostImpl::SetZoomLevel(double level) {
Send(new ViewMsg_SetZoomLevel(GetRoutingID(), level));
}
Commit Message: Filter more incoming URLs in the CreateWindow path.
BUG=170532
Review URL: https://chromiumcodereview.appspot.com/12036002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178728 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID:
| 0
| 117,299
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static int ras_getdatastd(jas_stream_t *in, ras_hdr_t *hdr, ras_cmap_t *cmap,
jas_image_t *image)
{
int pad;
int nz;
int z;
int c;
int y;
int x;
int v;
int i;
jas_matrix_t *data[3];
/* Note: This function does not properly handle images with a colormap. */
/* Avoid compiler warnings about unused parameters. */
cmap = 0;
for (i = 0; i < jas_image_numcmpts(image); ++i) {
data[i] = jas_matrix_create(1, jas_image_width(image));
assert(data[i]);
}
pad = RAS_ROWSIZE(hdr) - (hdr->width * hdr->depth + 7) / 8;
for (y = 0; y < hdr->height; y++) {
nz = 0;
z = 0;
for (x = 0; x < hdr->width; x++) {
while (nz < hdr->depth) {
if ((c = jas_stream_getc(in)) == EOF) {
return -1;
}
z = (z << 8) | c;
nz += 8;
}
v = (z >> (nz - hdr->depth)) & RAS_ONES(hdr->depth);
z &= RAS_ONES(nz - hdr->depth);
nz -= hdr->depth;
if (jas_image_numcmpts(image) == 3) {
jas_matrix_setv(data[0], x, (RAS_GETRED(v)));
jas_matrix_setv(data[1], x, (RAS_GETGREEN(v)));
jas_matrix_setv(data[2], x, (RAS_GETBLUE(v)));
} else {
jas_matrix_setv(data[0], x, (v));
}
}
if (pad) {
if ((c = jas_stream_getc(in)) == EOF) {
return -1;
}
}
for (i = 0; i < jas_image_numcmpts(image); ++i) {
if (jas_image_writecmpt(image, i, 0, y, hdr->width, 1,
data[i])) {
return -1;
}
}
}
for (i = 0; i < jas_image_numcmpts(image); ++i) {
jas_matrix_destroy(data[i]);
}
return 0;
}
Commit Message: Fixed a few bugs in the RAS encoder and decoder where errors were tested
with assertions instead of being gracefully handled.
CWE ID:
| 1
| 168,740
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: PrintingContextCairo::~PrintingContextCairo() {
ReleaseContext();
#if !defined(OS_CHROMEOS)
if (print_dialog_)
print_dialog_->ReleaseDialog();
#endif
}
Commit Message: Fix print preview workflow to reflect settings of selected printer.
BUG=95110
TEST=none
Review URL: http://codereview.chromium.org/7831041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102242 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-399
| 0
| 97,575
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void Document::setStyleDependentState(RenderStyle* documentStyle)
{
const Pagination& pagination = view()->pagination();
if (pagination.mode != Pagination::Unpaginated) {
Pagination::setStylesForPaginationMode(pagination.mode, documentStyle);
documentStyle->setColumnGap(pagination.gap);
if (renderView()->hasColumns())
renderView()->updateColumnInfoFromStyle(documentStyle);
}
if (shouldDisplaySeamlesslyWithParent())
return;
FontBuilder fontBuilder;
fontBuilder.initForStyleResolve(*this, documentStyle, isSVGDocument());
RefPtr<CSSFontSelector> selector = m_styleResolver ? m_styleResolver->fontSelector() : 0;
fontBuilder.createFontForDocument(selector, documentStyle);
}
Commit Message: Refactoring: Move m_mayDisplaySeamlesslyWithParent down to Document
The member is used only in Document, thus no reason to
stay in SecurityContext.
TEST=none
BUG=none
R=haraken@chromium.org, abarth, haraken, hayato
Review URL: https://codereview.chromium.org/27615003
git-svn-id: svn://svn.chromium.org/blink/trunk@159829 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-20
| 0
| 102,875
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static inline bool is_invalid_opcode(u32 intr_info)
{
return is_exception_n(intr_info, UD_VECTOR);
}
Commit Message: kvm: nVMX: Allow L1 to intercept software exceptions (#BP and #OF)
When L2 exits to L0 due to "exception or NMI", software exceptions
(#BP and #OF) for which L1 has requested an intercept should be
handled by L1 rather than L0. Previously, only hardware exceptions
were forwarded to L1.
Signed-off-by: Jim Mattson <jmattson@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
CWE ID: CWE-388
| 0
| 48,058
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static void remove_pidfile(const char *pid_file) {
if (pid_file == NULL)
return;
if (unlink(pid_file) != 0) {
fprintf(stderr, "Could not remove the pid file %s.\n", pid_file);
}
}
Commit Message: Use strncmp when checking for large ascii multigets.
CWE ID: CWE-20
| 0
| 18,281
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: GURL URLFixerUpper::FixupURL(const std::string& text,
const std::string& desired_tld) {
std::string trimmed;
TrimWhitespaceUTF8(text, TRIM_ALL, &trimmed);
if (trimmed.empty())
return GURL(); // Nothing here.
url_parse::Parsed parts;
std::string scheme(SegmentURL(trimmed, &parts));
if (scheme == chrome::kViewSourceScheme) {
std::string view_source(chrome::kViewSourceScheme + std::string(":"));
if (!StartsWithASCII(text, view_source + view_source, false)) {
return GURL(chrome::kViewSourceScheme + std::string(":") +
FixupURL(trimmed.substr(scheme.length() + 1),
desired_tld).possibly_invalid_spec());
}
}
if (scheme == chrome::kFileScheme)
return GURL(parts.scheme.is_valid() ? text : FixupPath(text));
bool chrome_url = !LowerCaseEqualsASCII(trimmed, chrome::kAboutBlankURL) &&
((scheme == chrome::kAboutScheme) || (scheme == chrome::kChromeUIScheme));
if (chrome_url || url_util::IsStandard(scheme.c_str(),
url_parse::Component(0, static_cast<int>(scheme.length())))) {
std::string url(chrome_url ? chrome::kChromeUIScheme : scheme);
url.append(chrome::kStandardSchemeSeparator);
if (parts.username.is_valid()) {
FixupUsername(trimmed, parts.username, &url);
FixupPassword(trimmed, parts.password, &url);
url.append("@");
}
FixupHost(trimmed, parts.host, parts.scheme.is_valid(), desired_tld, &url);
if (chrome_url && !parts.host.is_valid())
url.append(chrome::kChromeUIDefaultHost);
FixupPort(trimmed, parts.port, &url);
FixupPath(trimmed, parts.path, &url);
FixupQuery(trimmed, parts.query, &url);
FixupRef(trimmed, parts.ref, &url);
return GURL(url);
}
if (!parts.scheme.is_valid()) {
std::string fixed_scheme(scheme);
fixed_scheme.append(chrome::kStandardSchemeSeparator);
trimmed.insert(0, fixed_scheme);
}
return GURL(trimmed);
}
Commit Message: Be a little more careful whether something is an URL or a file path.
BUG=72492
Review URL: http://codereview.chromium.org/7572046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95731 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-20
| 0
| 99,440
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: file_compare( VipsForeignClass *a, VipsForeignClass *b )
{
return( b->priority - a->priority );
}
Commit Message: fix a crash with delayed load
If a delayed load failed, it could leave the pipeline only half-set up.
Sebsequent threads could then segv.
Set a load-has-failed flag and test before generate.
See https://github.com/jcupitt/libvips/issues/893
CWE ID: CWE-362
| 0
| 83,885
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
xmlNodePtr contextNode, xmlNodePtr list,
xsltTemplatePtr templ)
{
xmlNodePtr oldInsert, oldInst, oldCurInst, oldContextNode;
xmlNodePtr cur, insert, copy = NULL;
int level = 0, oldVarsNr;
xmlDocPtr oldLocalFragmentTop, oldLocalFragmentBase;
#ifdef XSLT_REFACTORED
xsltStylePreCompPtr info;
#endif
#ifdef WITH_DEBUGGER
int addCallResult = 0;
xmlNodePtr debuggedNode = NULL;
#endif
if (ctxt == NULL)
return;
#ifdef WITH_DEBUGGER
if (ctxt->debugStatus != XSLT_DEBUG_NONE) {
debuggedNode =
xsltDebuggerStartSequenceConstructor(ctxt, contextNode,
list, templ, &addCallResult);
if (debuggedNode == NULL)
return;
}
#endif
if (list == NULL)
return;
CHECK_STOPPED;
oldLocalFragmentTop = ctxt->localRVT;
oldInsert = insert = ctxt->insert;
oldInst = oldCurInst = ctxt->inst;
oldContextNode = ctxt->node;
/*
* Save current number of variables on the stack; new vars are popped when
* exiting.
*/
oldVarsNr = ctxt->varsNr;
/*
* Process the sequence constructor.
*/
cur = list;
while (cur != NULL) {
ctxt->inst = cur;
#ifdef WITH_DEBUGGER
switch (ctxt->debugStatus) {
case XSLT_DEBUG_RUN_RESTART:
case XSLT_DEBUG_QUIT:
break;
}
#endif
/*
* Test; we must have a valid insertion point.
*/
if (insert == NULL) {
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
"xsltApplySequenceConstructor: insert == NULL !\n"));
#endif
goto error;
}
#ifdef WITH_DEBUGGER
if ((ctxt->debugStatus != XSLT_DEBUG_NONE) && (debuggedNode != cur))
xslHandleDebugger(cur, contextNode, templ, ctxt);
#endif
#ifdef XSLT_REFACTORED
if (cur->type == XML_ELEMENT_NODE) {
info = (xsltStylePreCompPtr) cur->psvi;
/*
* We expect a compiled representation on:
* 1) XSLT instructions of this XSLT version (1.0)
* (with a few exceptions)
* 2) Literal result elements
* 3) Extension instructions
* 4) XSLT instructions of future XSLT versions
* (forwards-compatible mode).
*/
if (info == NULL) {
/*
* Handle the rare cases where we don't expect a compiled
* representation on an XSLT element.
*/
if (IS_XSLT_ELEM_FAST(cur) && IS_XSLT_NAME(cur, "message")) {
xsltMessage(ctxt, contextNode, cur);
goto skip_children;
}
/*
* Something really went wrong:
*/
xsltTransformError(ctxt, NULL, cur,
"Internal error in xsltApplySequenceConstructor(): "
"The element '%s' in the stylesheet has no compiled "
"representation.\n",
cur->name);
goto skip_children;
}
if (info->type == XSLT_FUNC_LITERAL_RESULT_ELEMENT) {
xsltStyleItemLRElementInfoPtr lrInfo =
(xsltStyleItemLRElementInfoPtr) info;
/*
* Literal result elements
* --------------------------------------------------------
*/
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt, XSLT_TRACE_APPLY_TEMPLATE,
xsltGenericDebug(xsltGenericDebugContext,
"xsltApplySequenceConstructor: copy literal result "
"element '%s'\n", cur->name));
#endif
/*
* Copy the raw element-node.
* OLD: if ((copy = xsltShallowCopyElem(ctxt, cur, insert))
* == NULL)
* goto error;
*/
copy = xmlDocCopyNode(cur, insert->doc, 0);
if (copy == NULL) {
xsltTransformError(ctxt, NULL, cur,
"Internal error in xsltApplySequenceConstructor(): "
"Failed to copy literal result element '%s'.\n",
cur->name);
goto error;
} else {
/*
* Add the element-node to the result tree.
*/
copy->doc = ctxt->output;
copy = xsltAddChild(insert, copy);
/*
* Create effective namespaces declarations.
* OLD: xsltCopyNamespaceList(ctxt, copy, cur->nsDef);
*/
if (lrInfo->effectiveNs != NULL) {
xsltEffectiveNsPtr effNs = lrInfo->effectiveNs;
xmlNsPtr ns, lastns = NULL;
while (effNs != NULL) {
/*
* Avoid generating redundant namespace
* declarations; thus lookup if there is already
* such a ns-decl in the result.
*/
ns = xmlSearchNs(copy->doc, copy, effNs->prefix);
if ((ns != NULL) &&
(xmlStrEqual(ns->href, effNs->nsName)))
{
effNs = effNs->next;
continue;
}
ns = xmlNewNs(copy, effNs->nsName, effNs->prefix);
if (ns == NULL) {
xsltTransformError(ctxt, NULL, cur,
"Internal error in "
"xsltApplySequenceConstructor(): "
"Failed to copy a namespace "
"declaration.\n");
goto error;
}
if (lastns == NULL)
copy->nsDef = ns;
else
lastns->next =ns;
lastns = ns;
effNs = effNs->next;
}
}
/*
* NOTE that we don't need to apply ns-alising: this was
* already done at compile-time.
*/
if (cur->ns != NULL) {
/*
* If there's no such ns-decl in the result tree,
* then xsltGetSpecialNamespace() will
* create a ns-decl on the copied node.
*/
copy->ns = xsltGetSpecialNamespace(ctxt, cur,
cur->ns->href, cur->ns->prefix, copy);
} else {
/*
* Undeclare the default namespace if needed.
* This can be skipped, if the result element has
* no ns-decls, in which case the result element
* obviously does not declare a default namespace;
* AND there's either no parent, or the parent
* element is in no namespace; this means there's no
* default namespace is scope to care about.
*
* REVISIT: This might result in massive
* generation of ns-decls if nodes in a default
* namespaces are mixed with nodes in no namespace.
*
*/
if (copy->nsDef ||
((insert != NULL) &&
(insert->type == XML_ELEMENT_NODE) &&
(insert->ns != NULL)))
{
xsltGetSpecialNamespace(ctxt, cur,
NULL, NULL, copy);
}
}
}
/*
* SPEC XSLT 2.0 "Each attribute of the literal result
* element, other than an attribute in the XSLT namespace,
* is processed to produce an attribute for the element in
* the result tree."
* NOTE: See bug #341325.
*/
if (cur->properties != NULL) {
xsltAttrListTemplateProcess(ctxt, copy, cur->properties);
}
} else if (IS_XSLT_ELEM_FAST(cur)) {
/*
* XSLT instructions
* --------------------------------------------------------
*/
if (info->type == XSLT_FUNC_UNKOWN_FORWARDS_COMPAT) {
/*
* We hit an unknown XSLT element.
* Try to apply one of the fallback cases.
*/
ctxt->insert = insert;
if (!xsltApplyFallbacks(ctxt, contextNode, cur)) {
xsltTransformError(ctxt, NULL, cur,
"The is no fallback behaviour defined for "
"the unknown XSLT element '%s'.\n",
cur->name);
}
ctxt->insert = oldInsert;
} else if (info->func != NULL) {
/*
* Execute the XSLT instruction.
*/
ctxt->insert = insert;
info->func(ctxt, contextNode, cur,
(xsltElemPreCompPtr) info);
/*
* Cleanup temporary tree fragments.
*/
if (oldLocalFragmentTop != ctxt->localRVT)
xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
ctxt->insert = oldInsert;
} else if (info->type == XSLT_FUNC_VARIABLE) {
xsltStackElemPtr tmpvar = ctxt->vars;
xsltParseStylesheetVariable(ctxt, cur);
if (tmpvar != ctxt->vars) {
/*
* TODO: Using a @tmpvar is an annoying workaround, but
* the current mechanisms do not provide any other way
* of knowing if the var was really pushed onto the
* stack.
*/
ctxt->vars->level = level;
}
} else if (info->type == XSLT_FUNC_MESSAGE) {
/*
* TODO: Won't be hit, since we don't compile xsl:message.
*/
xsltMessage(ctxt, contextNode, cur);
} else {
xsltTransformError(ctxt, NULL, cur,
"Unexpected XSLT element '%s'.\n", cur->name);
}
goto skip_children;
} else {
xsltTransformFunction func;
/*
* Extension intructions (elements)
* --------------------------------------------------------
*/
if (cur->psvi == xsltExtMarker) {
/*
* The xsltExtMarker was set during the compilation
* of extension instructions if there was no registered
* handler for this specific extension function at
* compile-time.
* Libxslt will now lookup if a handler is
* registered in the context of this transformation.
*/
func = (xsltTransformFunction)
xsltExtElementLookup(ctxt, cur->name, cur->ns->href);
} else
func = ((xsltElemPreCompPtr) cur->psvi)->func;
if (func == NULL) {
/*
* No handler available.
* Try to execute fallback behaviour via xsl:fallback.
*/
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt, XSLT_TRACE_APPLY_TEMPLATE,
xsltGenericDebug(xsltGenericDebugContext,
"xsltApplySequenceConstructor: unknown extension %s\n",
cur->name));
#endif
ctxt->insert = insert;
if (!xsltApplyFallbacks(ctxt, contextNode, cur)) {
xsltTransformError(ctxt, NULL, cur,
"Unknown extension instruction '{%s}%s'.\n",
cur->ns->href, cur->name);
}
ctxt->insert = oldInsert;
} else {
/*
* Execute the handler-callback.
*/
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
"xsltApplySequenceConstructor: extension construct %s\n",
cur->name));
#endif
ctxt->insert = insert;
/*
* We need the fragment base for extension instructions
* which return values (like EXSLT's function).
*/
oldLocalFragmentBase = ctxt->localRVTBase;
ctxt->localRVTBase = NULL;
func(ctxt, contextNode, cur, cur->psvi);
ctxt->localRVTBase = oldLocalFragmentBase;
/*
* Cleanup temporary tree fragments.
*/
if (oldLocalFragmentTop != ctxt->localRVT)
xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
ctxt->insert = oldInsert;
}
goto skip_children;
}
} else if (XSLT_IS_TEXT_NODE(cur)) {
/*
* Text
* ------------------------------------------------------------
*/
#ifdef WITH_XSLT_DEBUG_PROCESS
if (cur->name == xmlStringTextNoenc) {
XSLT_TRACE(ctxt, XSLT_TRACE_APPLY_TEMPLATE,
xsltGenericDebug(xsltGenericDebugContext,
"xsltApplySequenceConstructor: copy unescaped text '%s'\n",
cur->content));
} else {
XSLT_TRACE(ctxt, XSLT_TRACE_APPLY_TEMPLATE,
xsltGenericDebug(xsltGenericDebugContext,
"xsltApplySequenceConstructor: copy text '%s'\n",
cur->content));
}
#endif
if (xsltCopyText(ctxt, insert, cur, ctxt->internalized) == NULL)
goto error;
}
#else /* XSLT_REFACTORED */
if (IS_XSLT_ELEM(cur)) {
/*
* This is an XSLT node
*/
xsltStylePreCompPtr info = (xsltStylePreCompPtr) cur->psvi;
if (info == NULL) {
if (IS_XSLT_NAME(cur, "message")) {
xsltMessage(ctxt, contextNode, cur);
} else {
/*
* That's an error try to apply one of the fallback cases
*/
ctxt->insert = insert;
if (!xsltApplyFallbacks(ctxt, contextNode, cur)) {
xsltGenericError(xsltGenericErrorContext,
"xsltApplySequenceConstructor: %s was not compiled\n",
cur->name);
}
ctxt->insert = oldInsert;
}
goto skip_children;
}
if (info->func != NULL) {
oldCurInst = ctxt->inst;
ctxt->inst = cur;
ctxt->insert = insert;
oldLocalFragmentBase = ctxt->localRVTBase;
ctxt->localRVTBase = NULL;
info->func(ctxt, contextNode, cur, (xsltElemPreCompPtr) info);
ctxt->localRVTBase = oldLocalFragmentBase;
/*
* Cleanup temporary tree fragments.
*/
if (oldLocalFragmentTop != ctxt->localRVT)
xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
ctxt->insert = oldInsert;
ctxt->inst = oldCurInst;
goto skip_children;
}
if (IS_XSLT_NAME(cur, "variable")) {
xsltStackElemPtr tmpvar = ctxt->vars;
oldCurInst = ctxt->inst;
ctxt->inst = cur;
xsltParseStylesheetVariable(ctxt, cur);
ctxt->inst = oldCurInst;
if (tmpvar != ctxt->vars) {
/*
* TODO: Using a @tmpvar is an annoying workaround, but
* the current mechanisms do not provide any other way
* of knowing if the var was really pushed onto the
* stack.
*/
ctxt->vars->level = level;
}
} else if (IS_XSLT_NAME(cur, "message")) {
xsltMessage(ctxt, contextNode, cur);
} else {
xsltTransformError(ctxt, NULL, cur,
"Unexpected XSLT element '%s'.\n", cur->name);
}
goto skip_children;
} else if ((cur->type == XML_TEXT_NODE) ||
(cur->type == XML_CDATA_SECTION_NODE)) {
/*
* This text comes from the stylesheet
* For stylesheets, the set of whitespace-preserving
* element names consists of just xsl:text.
*/
#ifdef WITH_XSLT_DEBUG_PROCESS
if (cur->type == XML_CDATA_SECTION_NODE) {
XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
"xsltApplySequenceConstructor: copy CDATA text %s\n",
cur->content));
} else if (cur->name == xmlStringTextNoenc) {
XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
"xsltApplySequenceConstructor: copy unescaped text %s\n",
cur->content));
} else {
XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
"xsltApplySequenceConstructor: copy text %s\n",
cur->content));
}
#endif
if (xsltCopyText(ctxt, insert, cur, ctxt->internalized) == NULL)
goto error;
} else if ((cur->type == XML_ELEMENT_NODE) &&
(cur->ns != NULL) && (cur->psvi != NULL)) {
xsltTransformFunction function;
oldCurInst = ctxt->inst;
ctxt->inst = cur;
/*
* Flagged as an extension element
*/
if (cur->psvi == xsltExtMarker)
function = (xsltTransformFunction)
xsltExtElementLookup(ctxt, cur->name, cur->ns->href);
else
function = ((xsltElemPreCompPtr) cur->psvi)->func;
if (function == NULL) {
xmlNodePtr child;
int found = 0;
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
"xsltApplySequenceConstructor: unknown extension %s\n",
cur->name));
#endif
/*
* Search if there are fallbacks
*/
child = cur->children;
while (child != NULL) {
if ((IS_XSLT_ELEM(child)) &&
(IS_XSLT_NAME(child, "fallback")))
{
found = 1;
xsltApplySequenceConstructor(ctxt, contextNode,
child->children, NULL);
}
child = child->next;
}
if (!found) {
xsltTransformError(ctxt, NULL, cur,
"xsltApplySequenceConstructor: failed to find extension %s\n",
cur->name);
}
} else {
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
"xsltApplySequenceConstructor: extension construct %s\n",
cur->name));
#endif
ctxt->insert = insert;
/*
* We need the fragment base for extension instructions
* which return values (like EXSLT's function).
*/
oldLocalFragmentBase = ctxt->localRVTBase;
ctxt->localRVTBase = NULL;
function(ctxt, contextNode, cur, cur->psvi);
/*
* Cleanup temporary tree fragments.
*/
if (oldLocalFragmentTop != ctxt->localRVT)
xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
ctxt->localRVTBase = oldLocalFragmentBase;
ctxt->insert = oldInsert;
}
ctxt->inst = oldCurInst;
goto skip_children;
} else if (cur->type == XML_ELEMENT_NODE) {
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
"xsltApplySequenceConstructor: copy node %s\n",
cur->name));
#endif
oldCurInst = ctxt->inst;
ctxt->inst = cur;
if ((copy = xsltShallowCopyElem(ctxt, cur, insert, 1)) == NULL)
goto error;
/*
* Add extra namespaces inherited from the current template
* if we are in the first level children and this is a
* "real" template.
*/
if ((templ != NULL) && (oldInsert == insert) &&
(ctxt->templ != NULL) && (ctxt->templ->inheritedNs != NULL)) {
int i;
xmlNsPtr ns, ret;
for (i = 0; i < ctxt->templ->inheritedNsNr; i++) {
const xmlChar *URI = NULL;
xsltStylesheetPtr style;
ns = ctxt->templ->inheritedNs[i];
/* Note that the XSLT namespace was already excluded
* in xsltGetInheritedNsList().
*/
#if 0
if (xmlStrEqual(ns->href, XSLT_NAMESPACE))
continue;
#endif
style = ctxt->style;
while (style != NULL) {
if (style->nsAliases != NULL)
URI = (const xmlChar *)
xmlHashLookup(style->nsAliases, ns->href);
if (URI != NULL)
break;
style = xsltNextImport(style);
}
if (URI == UNDEFINED_DEFAULT_NS)
continue;
if (URI == NULL)
URI = ns->href;
/*
* TODO: The following will still be buggy for the
* non-refactored code.
*/
ret = xmlSearchNs(copy->doc, copy, ns->prefix);
if ((ret == NULL) || (!xmlStrEqual(ret->href, URI)))
{
xmlNewNs(copy, URI, ns->prefix);
}
}
if (copy->ns != NULL) {
/*
* Fix the node namespace if needed
*/
copy->ns = xsltGetNamespace(ctxt, cur, copy->ns, copy);
}
}
/*
* all the attributes are directly inherited
*/
if (cur->properties != NULL) {
xsltAttrListTemplateProcess(ctxt, copy, cur->properties);
}
ctxt->inst = oldCurInst;
}
#endif /* else of XSLT_REFACTORED */
/*
* Descend into content in document order.
*/
if (cur->children != NULL) {
if (cur->children->type != XML_ENTITY_DECL) {
cur = cur->children;
level++;
if (copy != NULL)
insert = copy;
continue;
}
}
skip_children:
/*
* If xslt:message was just processed, we might have hit a
* terminate='yes'; if so, then break the loop and clean up.
* TODO: Do we need to check this also before trying to descend
* into the content?
*/
if (ctxt->state == XSLT_STATE_STOPPED)
break;
if (cur->next != NULL) {
cur = cur->next;
continue;
}
do {
cur = cur->parent;
level--;
/*
* Pop variables/params (xsl:variable and xsl:param).
*/
if ((ctxt->varsNr > oldVarsNr) && (ctxt->vars->level > level)) {
xsltLocalVariablePop(ctxt, oldVarsNr, level);
}
insert = insert->parent;
if (cur == NULL)
break;
if (cur == list->parent) {
cur = NULL;
break;
}
if (cur->next != NULL) {
cur = cur->next;
break;
}
} while (cur != NULL);
}
error:
/*
* In case of errors: pop remaining variables.
*/
if (ctxt->varsNr > oldVarsNr)
xsltLocalVariablePop(ctxt, oldVarsNr, -1);
ctxt->node = oldContextNode;
ctxt->inst = oldInst;
ctxt->insert = oldInsert;
#ifdef WITH_DEBUGGER
if ((ctxt->debugStatus != XSLT_DEBUG_NONE) && (addCallResult)) {
xslDropCall();
}
#endif
}
Commit Message: Roll libxslt to 891681e3e948f31732229f53cb6db7215f740fc7
BUG=583156,583171
Review URL: https://codereview.chromium.org/1853083002
Cr-Commit-Position: refs/heads/master@{#385338}
CWE ID: CWE-119
| 0
| 156,808
|
Analyze the following 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 igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
int type)
{
struct sk_buff *skb;
struct iphdr *iph;
struct igmphdr *ih;
struct rtable *rt;
struct net_device *dev = in_dev->dev;
struct net *net = dev_net(dev);
__be32 group = pmc ? pmc->multiaddr : 0;
struct flowi4 fl4;
__be32 dst;
int hlen, tlen;
if (type == IGMPV3_HOST_MEMBERSHIP_REPORT)
return igmpv3_send_report(in_dev, pmc);
else if (type == IGMP_HOST_LEAVE_MESSAGE)
dst = IGMP_ALL_ROUTER;
else
dst = group;
rt = ip_route_output_ports(net, &fl4, NULL, dst, 0,
0, 0,
IPPROTO_IGMP, 0, dev->ifindex);
if (IS_ERR(rt))
return -1;
hlen = LL_RESERVED_SPACE(dev);
tlen = dev->needed_tailroom;
skb = alloc_skb(IGMP_SIZE + hlen + tlen, GFP_ATOMIC);
if (skb == NULL) {
ip_rt_put(rt);
return -1;
}
skb_dst_set(skb, &rt->dst);
skb_reserve(skb, hlen);
skb_reset_network_header(skb);
iph = ip_hdr(skb);
skb_put(skb, sizeof(struct iphdr) + 4);
iph->version = 4;
iph->ihl = (sizeof(struct iphdr)+4)>>2;
iph->tos = 0xc0;
iph->frag_off = htons(IP_DF);
iph->ttl = 1;
iph->daddr = dst;
iph->saddr = fl4.saddr;
iph->protocol = IPPROTO_IGMP;
ip_select_ident(iph, &rt->dst, NULL);
((u8*)&iph[1])[0] = IPOPT_RA;
((u8*)&iph[1])[1] = 4;
((u8*)&iph[1])[2] = 0;
((u8*)&iph[1])[3] = 0;
ih = (struct igmphdr *)skb_put(skb, sizeof(struct igmphdr));
ih->type = type;
ih->code = 0;
ih->csum = 0;
ih->group = group;
ih->csum = ip_compute_csum((void *)ih, sizeof(struct igmphdr));
return ip_local_out(skb);
}
Commit Message: igmp: Avoid zero delay when receiving odd mixture of IGMP queries
Commit 5b7c84066733c5dfb0e4016d939757b38de189e4 ('ipv4: correct IGMP
behavior on v3 query during v2-compatibility mode') added yet another
case for query parsing, which can result in max_delay = 0. Substitute
a value of 1, as in the usual v3 case.
Reported-by: Simon McVittie <smcv@debian.org>
References: http://bugs.debian.org/654876
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-399
| 0
| 21,611
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static int myrecvfrom6(int sockfd, void *buf, size_t *buflen, int flags,
struct in6_addr *addr, uint32_t *ifindex, int *hoplimit)
{
struct sockaddr_in6 sin6;
unsigned char cbuf[2 * CMSG_SPACE(sizeof(struct in6_pktinfo))];
struct iovec iovec;
struct msghdr msghdr;
struct cmsghdr *cmsghdr;
ssize_t len;
iovec.iov_len = *buflen;
iovec.iov_base = buf;
memset(&msghdr, 0, sizeof(msghdr));
msghdr.msg_name = &sin6;
msghdr.msg_namelen = sizeof(sin6);
msghdr.msg_iov = &iovec;
msghdr.msg_iovlen = 1;
msghdr.msg_control = cbuf;
msghdr.msg_controllen = sizeof(cbuf);
len = recvmsg(sockfd, &msghdr, flags);
if (len == -1)
return -errno;
*buflen = len;
/* Set ifindex to scope_id now. But since scope_id gets not
* set by kernel for linklocal addresses, use pktinfo to obtain that
* value right after.
*/
*ifindex = sin6.sin6_scope_id;
for (cmsghdr = CMSG_FIRSTHDR(&msghdr); cmsghdr;
cmsghdr = CMSG_NXTHDR(&msghdr, cmsghdr)) {
if (cmsghdr->cmsg_level != IPPROTO_IPV6)
continue;
switch(cmsghdr->cmsg_type) {
case IPV6_PKTINFO:
if (cmsghdr->cmsg_len == CMSG_LEN(sizeof(struct in6_pktinfo))) {
struct in6_pktinfo *pktinfo;
pktinfo = (struct in6_pktinfo *) CMSG_DATA(cmsghdr);
*ifindex = pktinfo->ipi6_ifindex;
}
break;
case IPV6_HOPLIMIT:
if (cmsghdr->cmsg_len == CMSG_LEN(sizeof(int))) {
int *val;
val = (int *) CMSG_DATA(cmsghdr);
*hoplimit = *val;
}
break;
}
}
*addr = sin6.sin6_addr;
return 0;
}
Commit Message: libndb: reject redirect and router advertisements from non-link-local
RFC4861 suggests that these messages should only originate from
link-local addresses in 6.1.2 (RA) and 8.1. (redirect):
Mitigates CVE-2016-3698.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
CWE ID: CWE-284
| 0
| 94,929
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static bool pi_test_and_set_on(struct pi_desc *pi_desc)
{
return test_and_set_bit(POSTED_INTR_ON,
(unsigned long *)&pi_desc->control);
}
Commit Message: x86,kvm,vmx: Preserve CR4 across VM entry
CR4 isn't constant; at least the TSD and PCE bits can vary.
TBH, treating CR0 and CR3 as constant scares me a bit, too, but it looks
like it's correct.
This adds a branch and a read from cr4 to each vm entry. Because it is
extremely likely that consecutive entries into the same vcpu will have
the same host cr4 value, this fixes up the vmcs instead of restoring cr4
after the fact. A subsequent patch will add a kernel-wide cr4 shadow,
reducing the overhead in the common case to just two memory reads and a
branch.
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: stable@vger.kernel.org
Cc: Petr Matousek <pmatouse@redhat.com>
Cc: Gleb Natapov <gleb@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
CWE ID: CWE-399
| 0
| 37,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: static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn)
{
struct bpf_reg_state *regs = cur_regs(env);
u8 opcode = BPF_OP(insn->code);
int err;
if (opcode == BPF_END || opcode == BPF_NEG) {
if (opcode == BPF_NEG) {
if (BPF_SRC(insn->code) != 0 ||
insn->src_reg != BPF_REG_0 ||
insn->off != 0 || insn->imm != 0) {
verbose(env, "BPF_NEG uses reserved fields\n");
return -EINVAL;
}
} else {
if (insn->src_reg != BPF_REG_0 || insn->off != 0 ||
(insn->imm != 16 && insn->imm != 32 && insn->imm != 64) ||
BPF_CLASS(insn->code) == BPF_ALU64) {
verbose(env, "BPF_END uses reserved fields\n");
return -EINVAL;
}
}
/* check src operand */
err = check_reg_arg(env, insn->dst_reg, SRC_OP);
if (err)
return err;
if (is_pointer_value(env, insn->dst_reg)) {
verbose(env, "R%d pointer arithmetic prohibited\n",
insn->dst_reg);
return -EACCES;
}
/* check dest operand */
err = check_reg_arg(env, insn->dst_reg, DST_OP);
if (err)
return err;
} else if (opcode == BPF_MOV) {
if (BPF_SRC(insn->code) == BPF_X) {
if (insn->imm != 0 || insn->off != 0) {
verbose(env, "BPF_MOV uses reserved fields\n");
return -EINVAL;
}
/* check src operand */
err = check_reg_arg(env, insn->src_reg, SRC_OP);
if (err)
return err;
} else {
if (insn->src_reg != BPF_REG_0 || insn->off != 0) {
verbose(env, "BPF_MOV uses reserved fields\n");
return -EINVAL;
}
}
/* check dest operand */
err = check_reg_arg(env, insn->dst_reg, DST_OP);
if (err)
return err;
if (BPF_SRC(insn->code) == BPF_X) {
if (BPF_CLASS(insn->code) == BPF_ALU64) {
/* case: R1 = R2
* copy register state to dest reg
*/
regs[insn->dst_reg] = regs[insn->src_reg];
regs[insn->dst_reg].live |= REG_LIVE_WRITTEN;
} else {
/* R1 = (u32) R2 */
if (is_pointer_value(env, insn->src_reg)) {
verbose(env,
"R%d partial copy of pointer\n",
insn->src_reg);
return -EACCES;
}
mark_reg_unknown(env, regs, insn->dst_reg);
/* high 32 bits are known zero. */
regs[insn->dst_reg].var_off = tnum_cast(
regs[insn->dst_reg].var_off, 4);
__update_reg_bounds(®s[insn->dst_reg]);
}
} else {
/* case: R = imm
* remember the value we stored into this reg
*/
regs[insn->dst_reg].type = SCALAR_VALUE;
if (BPF_CLASS(insn->code) == BPF_ALU64) {
__mark_reg_known(regs + insn->dst_reg,
insn->imm);
} else {
__mark_reg_known(regs + insn->dst_reg,
(u32)insn->imm);
}
}
} else if (opcode > BPF_END) {
verbose(env, "invalid BPF_ALU opcode %x\n", opcode);
return -EINVAL;
} else { /* all other ALU ops: and, sub, xor, add, ... */
if (BPF_SRC(insn->code) == BPF_X) {
if (insn->imm != 0 || insn->off != 0) {
verbose(env, "BPF_ALU uses reserved fields\n");
return -EINVAL;
}
/* check src1 operand */
err = check_reg_arg(env, insn->src_reg, SRC_OP);
if (err)
return err;
} else {
if (insn->src_reg != BPF_REG_0 || insn->off != 0) {
verbose(env, "BPF_ALU uses reserved fields\n");
return -EINVAL;
}
}
/* check src2 operand */
err = check_reg_arg(env, insn->dst_reg, SRC_OP);
if (err)
return err;
if ((opcode == BPF_MOD || opcode == BPF_DIV) &&
BPF_SRC(insn->code) == BPF_K && insn->imm == 0) {
verbose(env, "div by zero\n");
return -EINVAL;
}
if ((opcode == BPF_LSH || opcode == BPF_RSH ||
opcode == BPF_ARSH) && BPF_SRC(insn->code) == BPF_K) {
int size = BPF_CLASS(insn->code) == BPF_ALU64 ? 64 : 32;
if (insn->imm < 0 || insn->imm >= size) {
verbose(env, "invalid shift %d\n", insn->imm);
return -EINVAL;
}
}
/* check dest operand */
err = check_reg_arg(env, insn->dst_reg, DST_OP_NO_MARK);
if (err)
return err;
return adjust_reg_min_max_vals(env, insn);
}
return 0;
}
Commit Message: bpf: fix incorrect tracking of register size truncation
Properly handle register truncation to a smaller size.
The old code first mirrors the clearing of the high 32 bits in the bitwise
tristate representation, which is correct. But then, it computes the new
arithmetic bounds as the intersection between the old arithmetic bounds and
the bounds resulting from the bitwise tristate representation. Therefore,
when coerce_reg_to_32() is called on a number with bounds
[0xffff'fff8, 0x1'0000'0007], the verifier computes
[0xffff'fff8, 0xffff'ffff] as bounds of the truncated number.
This is incorrect: The truncated number could also be in the range [0, 7],
and no meaningful arithmetic bounds can be computed in that case apart from
the obvious [0, 0xffff'ffff].
Starting with v4.14, this is exploitable by unprivileged users as long as
the unprivileged_bpf_disabled sysctl isn't set.
Debian assigned CVE-2017-16996 for this issue.
v2:
- flip the mask during arithmetic bounds calculation (Ben Hutchings)
v3:
- add CVE number (Ben Hutchings)
Fixes: b03c9f9fdc37 ("bpf/verifier: track signed and unsigned min/max values")
Signed-off-by: Jann Horn <jannh@google.com>
Acked-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
CWE ID: CWE-119
| 1
| 167,658
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: inline void ImageLoader::ClearFailedLoadURL() {
failed_load_url_ = AtomicString();
}
Commit Message: service worker: Disable interception when OBJECT/EMBED uses ImageLoader.
Per the specification, service worker should not intercept requests for
OBJECT/EMBED elements.
R=kinuko
Bug: 771933
Change-Id: Ia6da6107dc5c68aa2c2efffde14bd2c51251fbd4
Reviewed-on: https://chromium-review.googlesource.com/927303
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#538027}
CWE ID:
| 0
| 147,475
|
Analyze the following 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 xhci_ep_nuke_one_xfer(XHCITransfer *t, TRBCCode report)
{
int killed = 0;
if (report && (t->running_async || t->running_retry)) {
t->status = report;
xhci_xfer_report(t);
}
if (t->running_async) {
usb_cancel_packet(&t->packet);
t->running_async = 0;
killed = 1;
}
if (t->running_retry) {
XHCIEPContext *epctx = t->xhci->slots[t->slotid-1].eps[t->epid-1];
if (epctx) {
epctx->retry = NULL;
timer_del(epctx->kick_timer);
}
t->running_retry = 0;
killed = 1;
}
if (t->trbs) {
g_free(t->trbs);
}
t->trbs = NULL;
t->trb_count = t->trb_alloced = 0;
return killed;
}
Commit Message:
CWE ID: CWE-119
| 0
| 10,741
|
Analyze the following 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 tcp_new_space(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
if (tcp_should_expand_sndbuf(sk)) {
int sndmem = SKB_TRUESIZE(max_t(u32,
tp->rx_opt.mss_clamp,
tp->mss_cache) +
MAX_TCP_HEADER);
int demanded = max_t(unsigned int, tp->snd_cwnd,
tp->reordering + 1);
sndmem *= 2 * demanded;
if (sndmem > sk->sk_sndbuf)
sk->sk_sndbuf = min(sndmem, sysctl_tcp_wmem[2]);
tp->snd_cwnd_stamp = tcp_time_stamp;
}
sk->sk_write_space(sk);
}
Commit Message: tcp: drop SYN+FIN messages
Denys Fedoryshchenko reported that SYN+FIN attacks were bringing his
linux machines to their limits.
Dont call conn_request() if the TCP flags includes SYN flag
Reported-by: Denys Fedoryshchenko <denys@visp.net.lb>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-399
| 0
| 41,178
|
Analyze the following 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 fb_set_logocmap(struct fb_info *info,
const struct linux_logo *logo)
{
struct fb_cmap palette_cmap;
u16 palette_green[16];
u16 palette_blue[16];
u16 palette_red[16];
int i, j, n;
const unsigned char *clut = logo->clut;
palette_cmap.start = 0;
palette_cmap.len = 16;
palette_cmap.red = palette_red;
palette_cmap.green = palette_green;
palette_cmap.blue = palette_blue;
palette_cmap.transp = NULL;
for (i = 0; i < logo->clutsize; i += n) {
n = logo->clutsize - i;
/* palette_cmap provides space for only 16 colors at once */
if (n > 16)
n = 16;
palette_cmap.start = 32 + i;
palette_cmap.len = n;
for (j = 0; j < n; ++j) {
palette_cmap.red[j] = clut[0] << 8 | clut[0];
palette_cmap.green[j] = clut[1] << 8 | clut[1];
palette_cmap.blue[j] = clut[2] << 8 | clut[2];
clut += 3;
}
fb_set_cmap(&palette_cmap, info);
}
}
Commit Message: vm: convert fb_mmap to vm_iomap_memory() helper
This is my example conversion of a few existing mmap users. The
fb_mmap() case is a good example because it is a bit more complicated
than some: fb_mmap() mmaps one of two different memory areas depending
on the page offset of the mmap (but happily there is never any mixing of
the two, so the helper function still works).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
CWE ID: CWE-189
| 0
| 31,155
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: int flags() const { return flags_; }
Commit Message: Pass ui::LatencyInfo correct with unified gesture detector on Aura.
BUG=379812
TEST=GestureRecognizerTest.LatencyPassedFromTouchEvent
Review URL: https://codereview.chromium.org/309823002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274602 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID:
| 0
| 112,100
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: int nft_register_set(struct nft_set_ops *ops)
{
nfnl_lock(NFNL_SUBSYS_NFTABLES);
list_add_tail_rcu(&ops->list, &nf_tables_set_ops);
nfnl_unlock(NFNL_SUBSYS_NFTABLES);
return 0;
}
Commit Message: netfilter: nf_tables: fix flush ruleset chain dependencies
Jumping between chains doesn't mix well with flush ruleset. Rules
from a different chain and set elements may still refer to us.
[ 353.373791] ------------[ cut here ]------------
[ 353.373845] kernel BUG at net/netfilter/nf_tables_api.c:1159!
[ 353.373896] invalid opcode: 0000 [#1] SMP
[ 353.373942] Modules linked in: intel_powerclamp uas iwldvm iwlwifi
[ 353.374017] CPU: 0 PID: 6445 Comm: 31c3.nft Not tainted 3.18.0 #98
[ 353.374069] Hardware name: LENOVO 5129CTO/5129CTO, BIOS 6QET47WW (1.17 ) 07/14/2010
[...]
[ 353.375018] Call Trace:
[ 353.375046] [<ffffffff81964c31>] ? nf_tables_commit+0x381/0x540
[ 353.375101] [<ffffffff81949118>] nfnetlink_rcv+0x3d8/0x4b0
[ 353.375150] [<ffffffff81943fc5>] netlink_unicast+0x105/0x1a0
[ 353.375200] [<ffffffff8194438e>] netlink_sendmsg+0x32e/0x790
[ 353.375253] [<ffffffff818f398e>] sock_sendmsg+0x8e/0xc0
[ 353.375300] [<ffffffff818f36b9>] ? move_addr_to_kernel.part.20+0x19/0x70
[ 353.375357] [<ffffffff818f44f9>] ? move_addr_to_kernel+0x19/0x30
[ 353.375410] [<ffffffff819016d2>] ? verify_iovec+0x42/0xd0
[ 353.375459] [<ffffffff818f3e10>] ___sys_sendmsg+0x3f0/0x400
[ 353.375510] [<ffffffff810615fa>] ? native_sched_clock+0x2a/0x90
[ 353.375563] [<ffffffff81176697>] ? acct_account_cputime+0x17/0x20
[ 353.375616] [<ffffffff8110dc78>] ? account_user_time+0x88/0xa0
[ 353.375667] [<ffffffff818f4bbd>] __sys_sendmsg+0x3d/0x80
[ 353.375719] [<ffffffff81b184f4>] ? int_check_syscall_exit_work+0x34/0x3d
[ 353.375776] [<ffffffff818f4c0d>] SyS_sendmsg+0xd/0x20
[ 353.375823] [<ffffffff81b1826d>] system_call_fastpath+0x16/0x1b
Release objects in this order: rules -> sets -> chains -> tables, to
make sure no references to chains are held anymore.
Reported-by: Asbjoern Sloth Toennesen <asbjorn@asbjorn.biz>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
CWE ID: CWE-19
| 0
| 58,026
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static void btif_read_le_key(const uint8_t key_type, const size_t key_len, bt_bdaddr_t bd_addr,
const uint8_t addr_type, const bool add_key, bool *device_added, bool *key_found)
{
assert(device_added);
assert(key_found);
char buffer[100];
memset(buffer, 0, sizeof(buffer));
if (btif_storage_get_ble_bonding_key(&bd_addr, key_type, buffer, key_len) == BT_STATUS_SUCCESS)
{
if (add_key)
{
BD_ADDR bta_bd_addr;
bdcpy(bta_bd_addr, bd_addr.address);
if (!*device_added)
{
BTA_DmAddBleDevice(bta_bd_addr, addr_type, BT_DEVICE_TYPE_BLE);
*device_added = true;
}
char bd_str[20] = {0};
BTIF_TRACE_DEBUG("%s() Adding key type %d for %s", __func__,
key_type, bdaddr_to_string(&bd_addr, bd_str, sizeof(bd_str)));
BTA_DmAddBleKey(bta_bd_addr, (tBTA_LE_KEY_VALUE *)buffer, key_type);
}
*key_found = true;
}
}
Commit Message: Add guest mode functionality (2/3)
Add a flag to enable() to start Bluetooth in restricted
mode. In restricted mode, all devices that are paired during
restricted mode are deleted upon leaving restricted mode.
Right now restricted mode is only entered while a guest
user is active.
Bug: 27410683
Change-Id: I8f23d28ef0aa3a8df13d469c73005c8e1b894d19
CWE ID: CWE-20
| 0
| 159,681
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static int coolkey_fetch_object(list_t *list, sc_cardctl_coolkey_object_t *coolkey_obj)
{
sc_cardctl_coolkey_object_t *ptr;
if (!list_iterator_hasnext(list)) {
return SC_ERROR_FILE_END_REACHED;
}
ptr = list_iterator_next(list);
*coolkey_obj = *ptr;
return SC_SUCCESS;
}
Commit Message: fixed out of bounds reads
Thanks to Eric Sesterhenn from X41 D-SEC GmbH
for reporting and suggesting security fixes.
CWE ID: CWE-125
| 0
| 78,281
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static inline unsigned int dccp_basic_hdr_len(const struct dccp_hdr *dh)
{
return DCCPH_X(dh) ? sizeof(struct dccp_hdr_ext) : sizeof(struct dccp_hdr);
}
Commit Message: (for 4.9.3) CVE-2018-16229/DCCP: Fix printing "Timestamp" and "Timestamp Echo" options
Add some comments.
Moreover:
Put a function definition name at the beginning of the line.
(This change was ported from commit 6df4852 in the master branch.)
Ryan Ackroyd had independently identified this buffer over-read later by
means of fuzzing and provided the packet capture file for the test.
CWE ID: CWE-125
| 0
| 93,162
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: SPL_METHOD(MultipleIterator, key)
{
spl_SplObjectStorage *intern;
intern = Z_SPLOBJSTORAGE_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
spl_multiple_iterator_get_all(intern, SPL_MULTIPLE_ITERATOR_GET_ALL_KEY, return_value);
}
Commit Message: Fix bug #73257 and bug #73258 - SplObjectStorage unserialize allows use of non-object as key
CWE ID: CWE-119
| 0
| 73,690
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void ParamTraits<std::vector<char> >::Write(Message* m, const param_type& p) {
if (p.empty()) {
m->WriteData(NULL, 0);
} else {
m->WriteData(&p.front(), static_cast<int>(p.size()));
}
}
Commit Message: Validate that paths don't contain embedded NULLs at deserialization.
BUG=166867
Review URL: https://chromiumcodereview.appspot.com/11743009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174935 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID:
| 0
| 117,410
|
Analyze the following 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 em_pusha(struct x86_emulate_ctxt *ctxt)
{
unsigned long old_esp = reg_read(ctxt, VCPU_REGS_RSP);
int rc = X86EMUL_CONTINUE;
int reg = VCPU_REGS_RAX;
while (reg <= VCPU_REGS_RDI) {
(reg == VCPU_REGS_RSP) ?
(ctxt->src.val = old_esp) : (ctxt->src.val = reg_read(ctxt, reg));
rc = em_push(ctxt);
if (rc != X86EMUL_CONTINUE)
return rc;
++reg;
}
return rc;
}
Commit Message: KVM: emulate: avoid accessing NULL ctxt->memopp
A failure to decode the instruction can cause a NULL pointer access.
This is fixed simply by moving the "done" label as close as possible
to the return.
This fixes CVE-2014-8481.
Reported-by: Andy Lutomirski <luto@amacapital.net>
Cc: stable@vger.kernel.org
Fixes: 41061cdb98a0bec464278b4db8e894a3121671f5
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
CWE ID: CWE-399
| 0
| 35,543
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: pdf14_forward_device_procs(gx_device * dev)
{
gx_device_forward * pdev = (gx_device_forward *)dev;
/*
* We are using gx_device_forward_fill_in_procs to set the various procs.
* This will ensure that any new device procs are also set. However that
* routine only changes procs which are NULL. Thus we start by setting all
* procs to NULL.
*/
memset(&(pdev->procs), 0, size_of(pdev->procs));
gx_device_forward_fill_in_procs(pdev);
/*
* gx_device_forward_fill_in_procs does not forward all procs.
* Set the remainding procs to also forward.
*/
set_dev_proc(dev, close_device, gx_forward_close_device);
set_dev_proc(dev, fill_rectangle, gx_forward_fill_rectangle);
set_dev_proc(dev, fill_rectangle_hl_color, gx_forward_fill_rectangle_hl_color);
set_dev_proc(dev, tile_rectangle, gx_forward_tile_rectangle);
set_dev_proc(dev, copy_mono, gx_forward_copy_mono);
set_dev_proc(dev, copy_color, gx_forward_copy_color);
set_dev_proc(dev, get_page_device, gx_forward_get_page_device);
set_dev_proc(dev, strip_tile_rectangle, gx_forward_strip_tile_rectangle);
set_dev_proc(dev, copy_alpha, gx_forward_copy_alpha);
set_dev_proc(dev, get_profile, gx_forward_get_profile);
set_dev_proc(dev, set_graphics_type_tag, gx_forward_set_graphics_type_tag);
/* These are forwarding devices with minor tweaks. */
set_dev_proc(dev, open_device, pdf14_forward_open_device);
set_dev_proc(dev, put_params, pdf14_forward_put_params);
}
Commit Message:
CWE ID: CWE-416
| 0
| 2,953
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: PHP_FUNCTION(pg_lo_read_all)
{
zval *pgsql_id;
int tbytes;
volatile int nbytes;
char buf[PGSQL_LO_READ_BUF_SIZE];
pgLofp *pgsql;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pgsql_id) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_id, -1, "PostgreSQL large object", le_lofp);
tbytes = 0;
while ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, buf, PGSQL_LO_READ_BUF_SIZE))>0) {
PHPWRITE(buf, nbytes);
tbytes += nbytes;
}
RETURN_LONG(tbytes);
}
Commit Message:
CWE ID:
| 0
| 5,163
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: int proc_dostring(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
warn_sysctl_write(table);
return _proc_do_string((char *)(table->data), table->maxlen, write,
(char __user *)buffer, lenp, ppos);
}
Commit Message: mnt: Add a per mount namespace limit on the number of mounts
CAI Qian <caiqian@redhat.com> pointed out that the semantics
of shared subtrees make it possible to create an exponentially
increasing number of mounts in a mount namespace.
mkdir /tmp/1 /tmp/2
mount --make-rshared /
for i in $(seq 1 20) ; do mount --bind /tmp/1 /tmp/2 ; done
Will create create 2^20 or 1048576 mounts, which is a practical problem
as some people have managed to hit this by accident.
As such CVE-2016-6213 was assigned.
Ian Kent <raven@themaw.net> described the situation for autofs users
as follows:
> The number of mounts for direct mount maps is usually not very large because of
> the way they are implemented, large direct mount maps can have performance
> problems. There can be anywhere from a few (likely case a few hundred) to less
> than 10000, plus mounts that have been triggered and not yet expired.
>
> Indirect mounts have one autofs mount at the root plus the number of mounts that
> have been triggered and not yet expired.
>
> The number of autofs indirect map entries can range from a few to the common
> case of several thousand and in rare cases up to between 30000 and 50000. I've
> not heard of people with maps larger than 50000 entries.
>
> The larger the number of map entries the greater the possibility for a large
> number of active mounts so it's not hard to expect cases of a 1000 or somewhat
> more active mounts.
So I am setting the default number of mounts allowed per mount
namespace at 100,000. This is more than enough for any use case I
know of, but small enough to quickly stop an exponential increase
in mounts. Which should be perfect to catch misconfigurations and
malfunctioning programs.
For anyone who needs a higher limit this can be changed by writing
to the new /proc/sys/fs/mount-max sysctl.
Tested-by: CAI Qian <caiqian@redhat.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
CWE ID: CWE-400
| 0
| 50,998
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: error::Error GLES2DecoderPassthroughImpl::DoIsEnabled(GLenum cap,
uint32_t* result) {
*result = api()->glIsEnabledFn(cap);
return error::kNoError;
}
Commit Message: Add GL_PROGRAM_COMPLETION_QUERY_CHROMIUM
This makes the query of GL_COMPLETION_STATUS_KHR to programs much
cheaper by minimizing the round-trip to the GPU thread.
Bug: 881152, 957001
Change-Id: Iadfa798af29225e752c710ca5c25f50b3dd3101a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1586630
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657568}
CWE ID: CWE-416
| 0
| 142,042
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: bool ConfirmInfoBarDelegate::Cancel() {
return true;
}
Commit Message: Allow to specify elide behavior for confrim infobar message
Used in "<extension name> is debugging this browser" infobar.
Bug: 823194
Change-Id: Iff6627097c020cccca8f7cc3e21a803a41fd8f2c
Reviewed-on: https://chromium-review.googlesource.com/1048064
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557245}
CWE ID: CWE-254
| 0
| 154,208
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void DevToolsWindow::InspectedContentsClosing() {
intercepted_page_beforeunload_ = false;
life_stage_ = kClosing;
main_web_contents_->ClosePage();
}
Commit Message: [DevTools] Move sanitize url to devtools_ui.cc.
Compatibility script is not reliable enough.
BUG=653134
Review-Url: https://codereview.chromium.org/2403633002
Cr-Commit-Position: refs/heads/master@{#425814}
CWE ID: CWE-200
| 0
| 140,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: void Sys_SetBinaryPath(const char *path)
{
Q_strncpyz(binaryPath, path, sizeof(binaryPath));
}
Commit Message: All: Don't load .pk3s as .dlls, and don't load user config files from .pk3s
CWE ID: CWE-269
| 0
| 95,865
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: std::unique_ptr<HistogramBase> Histogram::PersistentCreate(
const std::string& name,
Sample minimum,
Sample maximum,
const BucketRanges* ranges,
HistogramBase::AtomicCount* counts,
HistogramBase::AtomicCount* logged_counts,
uint32_t counts_size,
HistogramSamples::Metadata* meta,
HistogramSamples::Metadata* logged_meta) {
return WrapUnique(new Histogram(name, minimum, maximum, ranges, counts,
logged_counts, counts_size, meta,
logged_meta));
}
Commit Message: Convert DCHECKs to CHECKs for histogram types
When a histogram is looked up by name, there is currently a DCHECK that
verifies the type of the stored histogram matches the expected type.
A mismatch represents a significant problem because the returned
HistogramBase is cast to a Histogram in ValidateRangeChecksum,
potentially causing a crash.
This CL converts the DCHECK to a CHECK to prevent the possibility of
type confusion in release builds.
BUG=651443
R=isherman@chromium.org
Review-Url: https://codereview.chromium.org/2381893003
Cr-Commit-Position: refs/heads/master@{#421929}
CWE ID: CWE-476
| 0
| 140,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: pdf_load_object(fz_context *ctx, pdf_document *doc, int num)
{
pdf_xref_entry *entry = pdf_cache_object(ctx, doc, num);
assert(entry->obj != NULL);
return pdf_keep_obj(ctx, entry->obj);
}
Commit Message:
CWE ID: CWE-119
| 0
| 16,710
|
Analyze the following 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 InputConnectionImpl::DeleteSurroundingText(int before, int after) {
StartStateUpdateTimer();
std::string error;
if (!ime_engine_->DeleteSurroundingText(input_context_id_, -before,
before + after, &error)) {
LOG(ERROR) << "DeleteSurroundingText failed: before = " << before
<< ", after = " << after << ", error = \"" << error << "\"";
}
}
Commit Message: Clear |composing_text_| after CommitText() is called.
|composing_text_| of InputConnectionImpl should be cleared after
CommitText() is called. Otherwise, FinishComposingText() will commit the
same text twice.
Bug: 899736
Test: unit_tests
Change-Id: Idb22d968ffe95d946789fbe62454e8e79cb0b384
Reviewed-on: https://chromium-review.googlesource.com/c/1304773
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Reviewed-by: Yusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603518}
CWE ID: CWE-119
| 0
| 156,939
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static void __exit hidp_exit(void)
{
hidp_cleanup_sockets();
}
Commit Message: Bluetooth: Fix incorrect strncpy() in hidp_setup_hid()
The length parameter should be sizeof(req->name) - 1 because there is no
guarantee that string provided by userspace will contain the trailing
'\0'.
Can be easily reproduced by manually setting req->name to 128 non-zero
bytes prior to ioctl(HIDPCONNADD) and checking the device name setup on
input subsystem:
$ cat /sys/devices/pnp0/00\:04/tty/ttyS0/hci0/hci0\:1/input8/name
AAAAAA[...]AAAAAAAAf0:af:f0:af:f0:af
("f0:af:f0:af:f0:af" is the device bluetooth address, taken from "phys"
field in struct hid_device due to overflow.)
Cc: stable@vger.kernel.org
Signed-off-by: Anderson Lizardo <anderson.lizardo@openbossa.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
CWE ID: CWE-200
| 0
| 33,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: static unsigned int rcvbuf_limit(struct sock *sk, struct sk_buff *buf)
{
struct tipc_msg *msg = buf_msg(buf);
unsigned int limit;
if (msg_connected(msg))
limit = sysctl_tipc_rmem[2];
else
limit = sk->sk_rcvbuf >> TIPC_CRITICAL_IMPORTANCE <<
msg_importance(msg);
return limit;
}
Commit Message: net: rework recvmsg handler msg_name and msg_namelen logic
This patch now always passes msg->msg_namelen as 0. recvmsg handlers must
set msg_namelen to the proper size <= sizeof(struct sockaddr_storage)
to return msg_name to the user.
This prevents numerous uninitialized memory leaks we had in the
recvmsg handlers and makes it harder for new code to accidentally leak
uninitialized memory.
Optimize for the case recvfrom is called with NULL as address. We don't
need to copy the address at all, so set it to NULL before invoking the
recvmsg handler. We can do so, because all the recvmsg handlers must
cope with the case a plain read() is called on them. read() also sets
msg_name to NULL.
Also document these changes in include/linux/net.h as suggested by David
Miller.
Changes since RFC:
Set msg->msg_name = NULL if user specified a NULL in msg_name but had a
non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't
affect sendto as it would bail out earlier while trying to copy-in the
address. It also more naturally reflects the logic by the callers of
verify_iovec.
With this change in place I could remove "
if (!uaddr || msg_sys->msg_namelen == 0)
msg->msg_name = NULL
".
This change does not alter the user visible error logic as we ignore
msg_namelen as long as msg_name is NULL.
Also remove two unnecessary curly brackets in ___sys_recvmsg and change
comments to netdev style.
Cc: David Miller <davem@davemloft.net>
Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-20
| 0
| 40,717
|
Analyze the following 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 ImageProcessorClient::CreateImageProcessorTask(
const ImageProcessor::PortConfig& input_config,
const ImageProcessor::PortConfig& output_config,
size_t num_buffers,
base::WaitableEvent* done) {
DCHECK_CALLED_ON_VALID_THREAD(image_processor_client_thread_checker_);
image_processor_ = ImageProcessorFactory::Create(
input_config, output_config, {ImageProcessor::OutputMode::IMPORT},
num_buffers,
base::BindRepeating(&ImageProcessorClient::NotifyError,
base::Unretained(this)));
done->Signal();
}
Commit Message: media/gpu/test: ImageProcessorClient: Use bytes for width and height in libyuv::CopyPlane()
|width| is in bytes in libyuv::CopyPlane(). We formerly pass width in pixels.
This should matter when a pixel format is used whose pixel is composed of
more than one bytes.
Bug: None
Test: image_processor_test
Change-Id: I98e90be70c8d0128319172d4d19f3a8017b65d78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1553129
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#648117}
CWE ID: CWE-20
| 0
| 137,475
|
Analyze the following 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 adev_set_mode(struct audio_hw_device *dev, audio_mode_t mode)
{
struct audio_device *adev = (struct audio_device *)dev;
pthread_mutex_lock(&adev->lock);
if (adev->mode != mode) {
ALOGI("%s mode = %d", __func__, mode);
adev->mode = mode;
}
pthread_mutex_unlock(&adev->lock);
return 0;
}
Commit Message: Fix audio record pre-processing
proc_buf_out consistently initialized.
intermediate scratch buffers consistently initialized.
prevent read failure from overwriting memory.
Test: POC, CTS, camera record
Bug: 62873231
Change-Id: Ie26e12a419a5819c1c5c3a0bcf1876d6d7aca686
(cherry picked from commit 6d7b330c27efba944817e647955da48e54fd74eb)
CWE ID: CWE-125
| 0
| 162,256
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: QMimeData *IRCView::createMimeDataFromSelection() const
{
const QTextDocumentFragment fragment(textCursor());
return new IrcViewMimeData(fragment);
}
Commit Message:
CWE ID:
| 0
| 1,749
|
Analyze the following 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 OPJ_BOOL opj_pi_next_lrcp(opj_pi_iterator_t * pi) {
opj_pi_comp_t *comp = NULL;
opj_pi_resolution_t *res = NULL;
OPJ_UINT32 index = 0;
if (!pi->first) {
comp = &pi->comps[pi->compno];
res = &comp->resolutions[pi->resno];
goto LABEL_SKIP;
} else {
pi->first = 0;
}
for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
for (pi->resno = pi->poc.resno0; pi->resno < pi->poc.resno1;
pi->resno++) {
for (pi->compno = pi->poc.compno0; pi->compno < pi->poc.compno1; pi->compno++) {
comp = &pi->comps[pi->compno];
if (pi->resno >= comp->numresolutions) {
continue;
}
res = &comp->resolutions[pi->resno];
if (!pi->tp_on){
pi->poc.precno1 = res->pw * res->ph;
}
for (pi->precno = pi->poc.precno0; pi->precno < pi->poc.precno1; pi->precno++) {
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno * pi->step_c + pi->precno * pi->step_p;
if (!pi->include[index]) {
pi->include[index] = 1;
return OPJ_TRUE;
}
LABEL_SKIP:;
}
}
}
}
return OPJ_FALSE;
}
Commit Message: Fix an integer overflow issue (#809)
Prevent an integer overflow issue in function opj_pi_create_decode of
pi.c.
CWE ID: CWE-125
| 0
| 50,051
|
Analyze the following 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 kern_ipc_perm *sysvipc_find_ipc(struct ipc_ids *ids, loff_t pos,
loff_t *new_pos)
{
struct kern_ipc_perm *ipc;
int total, id;
total = 0;
for (id = 0; id < pos && total < ids->in_use; id++) {
ipc = idr_find(&ids->ipcs_idr, id);
if (ipc != NULL)
total++;
}
if (total >= ids->in_use)
return NULL;
for ( ; pos < IPCMNI; pos++) {
ipc = idr_find(&ids->ipcs_idr, pos);
if (ipc != NULL) {
*new_pos = pos + 1;
ipc_lock_by_ptr(ipc);
return ipc;
}
}
/* Out of range - return NULL to terminate iteration */
return NULL;
}
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
| 0
| 29,583
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: DEFINE_TRACE(ContainerNode)
{
visitor->trace(m_firstChild);
visitor->trace(m_lastChild);
Node::trace(visitor);
}
Commit Message: Fix an optimisation in ContainerNode::notifyNodeInsertedInternal
R=tkent@chromium.org
BUG=544020
Review URL: https://codereview.chromium.org/1420653003
Cr-Commit-Position: refs/heads/master@{#355240}
CWE ID:
| 0
| 125,057
|
Analyze the following 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 jpeg2000_dec_cleanup(Jpeg2000DecoderContext *s)
{
int tileno, compno;
for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++) {
if (s->tile[tileno].comp) {
for (compno = 0; compno < s->ncomponents; compno++) {
Jpeg2000Component *comp = s->tile[tileno].comp + compno;
Jpeg2000CodingStyle *codsty = s->tile[tileno].codsty + compno;
ff_jpeg2000_cleanup(comp, codsty);
}
av_freep(&s->tile[tileno].comp);
}
}
av_freep(&s->tile);
s->numXtiles = s->numYtiles = 0;
}
Commit Message: jpeg2000: check log2_cblk dimensions
Fixes out of array access
Fixes Ticket2895
Found-by: Piotr Bandurski <ami_stuff@o2.pl>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
CWE ID: CWE-119
| 0
| 28,063
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: void WebPagePrivate::resumeDocumentStyleRecalc()
{
if (Document* document = m_mainFrame->document()) {
if (m_documentChildNeedsStyleRecalc)
document->setChildNeedsStyleRecalc();
if (m_documentStyleRecalcPostponed)
document->scheduleStyleRecalc();
}
m_documentChildNeedsStyleRecalc = false;
m_documentStyleRecalcPostponed = false;
}
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,365
|
Analyze the following 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 mkdir_p(const char *path, mode_t mode) {
int r;
/* Like mkdir -p */
if ((r = mkdir_parents(path, mode)) < 0)
return r;
if (label_mkdir(path, mode) < 0 && errno != EEXIST)
return -errno;
return 0;
}
Commit Message:
CWE ID: CWE-362
| 0
| 11,554
|
Analyze the following 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::DidNavigateMainFramePostCommit(WebContents* web_contents) {
if (web_contents == chrome::GetActiveWebContents(this))
UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
}
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,765
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: BOOLEAN btm_sec_are_all_trusted(UINT32 p_mask[])
{
UINT32 trusted_inx;
for (trusted_inx = 0; trusted_inx < BTM_SEC_SERVICE_ARRAY_SIZE; trusted_inx++)
{
if (p_mask[trusted_inx] != BTM_SEC_TRUST_ALL)
return(FALSE);
}
return(TRUE);
}
Commit Message: DO NOT MERGE Remove Porsche car-kit pairing workaround
Bug: 26551752
Change-Id: I14c5e3fcda0849874c8a94e48aeb7d09585617e1
CWE ID: CWE-264
| 0
| 161,417
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: static inline void phar_write_32(char buffer[4], php_uint32 value)
{
buffer[3] = (unsigned char) ((value & 0xff000000) >> 24);
buffer[2] = (unsigned char) ((value & 0xff0000) >> 16);
buffer[1] = (unsigned char) ((value & 0xff00) >> 8);
buffer[0] = (unsigned char) (value & 0xff);
}
Commit Message:
CWE ID: CWE-119
| 0
| 12,317
|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'.
|
Code: vrrp_tfile_end_handler(void)
{
vrrp_tracked_file_t *tfile = LIST_TAIL_DATA(vrrp_data->vrrp_track_files);
struct stat statb;
FILE *tf;
int ret;
if (!tfile->file_path) {
report_config_error(CONFIG_GENERAL_ERROR, "No file set for track_file %s - removing", tfile->fname);
free_list_element(vrrp_data->vrrp_track_files, vrrp_data->vrrp_track_files->tail);
return;
}
if (track_file_init == TRACK_FILE_NO_INIT)
return;
ret = stat(tfile->file_path, &statb);
if (!ret) {
if (track_file_init == TRACK_FILE_CREATE) {
/* The file exists */
return;
}
if ((statb.st_mode & S_IFMT) != S_IFREG) {
/* It is not a regular file */
report_config_error(CONFIG_GENERAL_ERROR, "Cannot initialise track file %s - it is not a regular file", tfile->fname);
return;
}
/* Don't overwrite a file on reload */
if (reload)
return;
}
if (!__test_bit(CONFIG_TEST_BIT, &debug)) {
/* Write the value to the file */
if ((tf = fopen(tfile->file_path, "w"))) {
fprintf(tf, "%d\n", track_file_init_value);
fclose(tf);
}
else
report_config_error(CONFIG_GENERAL_ERROR, "Unable to initialise track file %s", tfile->fname);
}
}
Commit Message: When opening files for write, ensure they aren't symbolic links
Issue #1048 identified that if, for example, a non privileged user
created a symbolic link from /etc/keepalvied.data to /etc/passwd,
writing to /etc/keepalived.data (which could be invoked via DBus)
would cause /etc/passwd to be overwritten.
This commit stops keepalived writing to pathnames where the ultimate
component is a symbolic link, by setting O_NOFOLLOW whenever opening
a file for writing.
This might break some setups, where, for example, /etc/keepalived.data
was a symbolic link to /home/fred/keepalived.data. If this was the case,
instead create a symbolic link from /home/fred/keepalived.data to
/tmp/keepalived.data, so that the file is still accessible via
/home/fred/keepalived.data.
There doesn't appear to be a way around this backward incompatibility,
since even checking if the pathname is a symbolic link prior to opening
for writing would create a race condition.
Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
CWE ID: CWE-59
| 1
| 168,990
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.