instruction stringclasses 1 value | input stringlengths 64 129k | output int64 0 1 | __index_level_0__ int64 0 30k |
|---|---|---|---|
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: AP_DECLARE(const char *) ap_resolve_env(apr_pool_t *p, const char * word)
{
# define SMALL_EXPANSION 5
struct sll {
struct sll *next;
const char *string;
apr_size_t len;
} *result, *current, sresult[SMALL_EXPANSION];
char *res_buf, *cp;
const char *s, *e, *ep;
unsigned spc;
apr_size_t outlen;
s = ap_strchr_c(word, '$');
if (!s) {
return word;
}
/* well, actually something to do */
ep = word + strlen(word);
spc = 0;
result = current = &(sresult[spc++]);
current->next = NULL;
current->string = word;
current->len = s - word;
outlen = current->len;
do {
/* prepare next entry */
if (current->len) {
current->next = (spc < SMALL_EXPANSION)
? &(sresult[spc++])
: (struct sll *)apr_palloc(p,
sizeof(*current->next));
current = current->next;
current->next = NULL;
current->len = 0;
}
if (*s == '$') {
if (s[1] == '{' && (e = ap_strchr_c(s+2, '}'))) {
char *name = apr_pstrmemdup(p, s+2, e-s-2);
word = NULL;
if (server_config_defined_vars)
word = apr_table_get(server_config_defined_vars, name);
if (!word)
word = getenv(name);
if (word) {
current->string = word;
current->len = strlen(word);
outlen += current->len;
}
else {
if (ap_strchr(name, ':') == 0)
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL, APLOGNO(00111)
"Config variable ${%s} is not defined",
name);
current->string = s;
current->len = e - s + 1;
outlen += current->len;
}
s = e + 1;
}
else {
current->string = s++;
current->len = 1;
++outlen;
}
}
else {
word = s;
s = ap_strchr_c(s, '$');
current->string = word;
current->len = s ? s - word : ep - word;
outlen += current->len;
}
} while (s && *s);
/* assemble result */
res_buf = cp = apr_palloc(p, outlen + 1);
do {
if (result->len) {
memcpy(cp, result->string, result->len);
cp += result->len;
}
result = result->next;
} while (result);
res_buf[outlen] = '\0';
return res_buf;
}
Commit Message: core: Disallow Methods' registration at run time (.htaccess), they may be
used only if registered at init time (httpd.conf).
Calling ap_method_register() in children processes is not the right scope
since it won't be shared for all requests.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1807655 13f79535-47bb-0310-9956-ffa450edef68
CWE ID: CWE-416 | 0 | 17,839 |
Analyze the following 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 ecryptfs_write_metadata(struct dentry *ecryptfs_dentry,
struct inode *ecryptfs_inode)
{
struct ecryptfs_crypt_stat *crypt_stat =
&ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat;
unsigned int order;
char *virt;
size_t virt_len;
size_t size = 0;
int rc = 0;
if (likely(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
if (!(crypt_stat->flags & ECRYPTFS_KEY_VALID)) {
printk(KERN_ERR "Key is invalid; bailing out\n");
rc = -EINVAL;
goto out;
}
} else {
printk(KERN_WARNING "%s: Encrypted flag not set\n",
__func__);
rc = -EINVAL;
goto out;
}
virt_len = crypt_stat->metadata_size;
order = get_order(virt_len);
/* Released in this function */
virt = (char *)ecryptfs_get_zeroed_pages(GFP_KERNEL, order);
if (!virt) {
printk(KERN_ERR "%s: Out of memory\n", __func__);
rc = -ENOMEM;
goto out;
}
/* Zeroed page ensures the in-header unencrypted i_size is set to 0 */
rc = ecryptfs_write_headers_virt(virt, virt_len, &size, crypt_stat,
ecryptfs_dentry);
if (unlikely(rc)) {
printk(KERN_ERR "%s: Error whilst writing headers; rc = [%d]\n",
__func__, rc);
goto out_free;
}
if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR)
rc = ecryptfs_write_metadata_to_xattr(ecryptfs_dentry, virt,
size);
else
rc = ecryptfs_write_metadata_to_contents(ecryptfs_inode, virt,
virt_len);
if (rc) {
printk(KERN_ERR "%s: Error writing metadata out to lower file; "
"rc = [%d]\n", __func__, rc);
goto out_free;
}
out_free:
free_pages((unsigned long)virt, order);
out:
return rc;
}
Commit Message: eCryptfs: Remove buggy and unnecessary write in file name decode routine
Dmitry Chernenkov used KASAN to discover that eCryptfs writes past the
end of the allocated buffer during encrypted filename decoding. This
fix corrects the issue by getting rid of the unnecessary 0 write when
the current bit offset is 2.
Signed-off-by: Michael Halcrow <mhalcrow@google.com>
Reported-by: Dmitry Chernenkov <dmitryc@google.com>
Suggested-by: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org # v2.6.29+: 51ca58d eCryptfs: Filename Encryption: Encoding and encryption functions
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
CWE ID: CWE-189 | 0 | 9,279 |
Analyze the following 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 release_pmc_hardware(void)
{
int i;
for (i = 0; i < x86_pmu.num_counters; i++) {
release_perfctr_nmi(x86_pmu_event_addr(i));
release_evntsel_nmi(x86_pmu_config_addr(i));
}
}
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 | 5,199 |
Analyze the following 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 CloudPolicyController::HandlePolicyResponse(
const em::DevicePolicyResponse& response) {
if (response.response_size() > 0) {
if (response.response_size() > 1) {
LOG(WARNING) << "More than one policy in the response of the device "
<< "management server, discarding.";
}
if (response.response(0).error_code() !=
DeviceManagementBackend::kErrorServicePolicyNotFound) {
cache_->SetPolicy(response.response(0));
SetState(STATE_POLICY_VALID);
} else {
UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchBadResponse,
kMetricPolicySize);
SetState(STATE_POLICY_UNAVAILABLE);
}
} else {
UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchBadResponse,
kMetricPolicySize);
}
}
Commit Message: Reset the device policy machinery upon retrying enrollment.
BUG=chromium-os:18208
TEST=See bug description
Review URL: http://codereview.chromium.org/7676005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97615 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-399 | 0 | 19,456 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void __sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
struct sk_buff *skb)
{
sock_recv_timestamp(msg, sk, skb);
sock_recv_drops(msg, sk, skb);
}
Commit Message: Fix order of arguments to compat_put_time[spec|val]
Commit 644595f89620 ("compat: Handle COMPAT_USE_64BIT_TIME in
net/socket.c") introduced a bug where the helper functions to take
either a 64-bit or compat time[spec|val] got the arguments in the wrong
order, passing the kernel stack pointer off as a user pointer (and vice
versa).
Because of the user address range check, that in turn then causes an
EFAULT due to the user pointer range checking failing for the kernel
address. Incorrectly resuling in a failed system call for 32-bit
processes with a 64-bit kernel.
On odder architectures like HP-PA (with separate user/kernel address
spaces), it can be used read kernel memory.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
CWE ID: CWE-399 | 0 | 19,578 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void WebGLRenderingContextBase::texParameterf(GLenum target,
GLenum pname,
GLfloat param) {
TexParameter(target, pname, param, 0, true);
}
Commit Message: Reset ES3 pixel pack parameters and PIXEL_PACK_BUFFER binding in DrawingBuffer before ReadPixels() and recover them later.
BUG=740603
TEST=new conformance test
R=kbr@chromium.org,piman@chromium.org
Change-Id: I3ea54c6cc34f34e249f7c8b9f792d93c5e1958f4
Reviewed-on: https://chromium-review.googlesource.com/570840
Reviewed-by: Antoine Labour <piman@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486518}
CWE ID: CWE-119 | 0 | 24,911 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: SQLWCHAR* _single_string_alloc_and_expand( LPCSTR in )
{
SQLWCHAR *chr;
int len = 0;
if ( !in )
{
return in;
}
while ( in[ len ] != 0 )
{
len ++;
}
chr = malloc( sizeof( SQLWCHAR ) * ( len + 1 ));
len = 0;
while ( in[ len ] != 0 )
{
chr[ len ] = in[ len ];
len ++;
}
chr[ len ++ ] = 0;
return chr;
}
Commit Message: New Pre Source
CWE ID: CWE-119 | 1 | 15,513 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void EditorClientBlackBerry::didEndEditing()
{
if (m_webPagePrivate->m_dumpRenderTree)
m_webPagePrivate->m_dumpRenderTree->didEndEditing();
}
Commit Message: [BlackBerry] Prevent text selection inside Colour and Date/Time input fields
https://bugs.webkit.org/show_bug.cgi?id=111733
Reviewed by Rob Buis.
PR 305194.
Prevent selection for popup input fields as they are buttons.
Informally Reviewed Gen Mak.
* WebCoreSupport/EditorClientBlackBerry.cpp:
(WebCore::EditorClientBlackBerry::shouldChangeSelectedRange):
git-svn-id: svn://svn.chromium.org/blink/trunk@145121 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: | 0 | 251 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static inline void __ap_schedule_poll_timer(void)
{
ktime_t hr_time;
spin_lock_bh(&ap_poll_timer_lock);
if (hrtimer_is_queued(&ap_poll_timer) || ap_suspend_flag)
goto out;
if (ktime_to_ns(hrtimer_expires_remaining(&ap_poll_timer)) <= 0) {
hr_time = ktime_set(0, poll_timeout);
hrtimer_forward_now(&ap_poll_timer, hr_time);
hrtimer_restart(&ap_poll_timer);
}
out:
spin_unlock_bh(&ap_poll_timer_lock);
}
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 | 29,266 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: print_pixel(char string[64], const Pixel *pixel, png_uint_32 format)
{
switch (format & (PNG_FORMAT_FLAG_ALPHA|PNG_FORMAT_FLAG_COLOR))
{
case 0:
sprintf(string, "%s(%d)", format_names[format], pixel->g);
break;
case PNG_FORMAT_FLAG_ALPHA:
sprintf(string, "%s(%d,%d)", format_names[format], pixel->g,
pixel->a);
break;
case PNG_FORMAT_FLAG_COLOR:
sprintf(string, "%s(%d,%d,%d)", format_names[format],
pixel->r, pixel->g, pixel->b);
break;
case PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA:
sprintf(string, "%s(%d,%d,%d,%d)", format_names[format],
pixel->r, pixel->g, pixel->b, pixel->a);
break;
default:
sprintf(string, "invalid-format");
break;
}
}
Commit Message: DO NOT MERGE Update libpng to 1.6.20
BUG:23265085
Change-Id: I85199805636d771f3597b691b63bc0bf46084833
(cherry picked from commit bbe98b40cda082024b669fa508931042eed18f82)
CWE ID: | 0 | 19,509 |
Analyze the following 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 CheckTMPrediction() const {
for (int p = 0; p < num_planes_; p++)
for (int y = 0; y < block_size_; y++)
for (int x = 0; x < block_size_; x++) {
const int expected = ClipByte(data_ptr_[p][x - stride_]
+ data_ptr_[p][stride_ * y - 1]
- data_ptr_[p][-1 - stride_]);
ASSERT_EQ(expected, data_ptr_[p][y * stride_ + x]);
}
}
Commit Message: Merge Conflict Fix CL to lmp-mr1-release for ag/849478
DO NOT MERGE - libvpx: Pull from upstream
Current HEAD: 7105df53d7dc13d5e575bc8df714ec8d1da36b06
BUG=23452792
Change-Id: Ic78176fc369e0bacc71d423e0e2e6075d004aaec
CWE ID: CWE-119 | 0 | 8,933 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: type_name(png_uint_32 type, FILE *out)
{
putc(type_char(type >> 24), out);
putc(type_char(type >> 16), out);
putc(type_char(type >> 8), out);
putc(type_char(type ), out);
}
Commit Message: DO NOT MERGE Update libpng to 1.6.20
BUG:23265085
Change-Id: I85199805636d771f3597b691b63bc0bf46084833
(cherry picked from commit bbe98b40cda082024b669fa508931042eed18f82)
CWE ID: | 0 | 29,133 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: std::string SerializeOrigin(const url::Origin& origin) {
return origin.GetURL().spec();
}
Commit Message: Reland "AppCache: Add padding to cross-origin responses."
This is a reland of 85b389caa7d725cdd31f59e9a2b79ff54804b7b7
Initialized CacheRecord::padding_size to 0.
Original change's description:
> AppCache: Add padding to cross-origin responses.
>
> Bug: 918293
> Change-Id: I4f16640f06feac009d6bbbb624951da6d2669f6c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1488059
> Commit-Queue: Staphany Park <staphany@chromium.org>
> Reviewed-by: Victor Costan <pwnall@chromium.org>
> Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#644624}
Bug: 918293
Change-Id: Ie1d3f99c7e8a854d33255a4d66243da2ce16441c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1539906
Reviewed-by: Victor Costan <pwnall@chromium.org>
Commit-Queue: Staphany Park <staphany@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644719}
CWE ID: CWE-200 | 0 | 23,648 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static WebCore::FloatSize computeRelativeOffset(const WebCore::IntPoint& absoluteOffset, const WebCore::LayoutRect& rect)
{
WebCore::FloatSize relativeOffset = WebCore::FloatPoint(absoluteOffset) - rect.location();
relativeOffset.scale(1.f / rect.width(), 1.f / rect.height());
return relativeOffset;
}
Commit Message: Call didAccessInitialDocument when javascript: URLs are used.
BUG=265221
TEST=See bug for repro.
Review URL: https://chromiumcodereview.appspot.com/22572004
git-svn-id: svn://svn.chromium.org/blink/trunk@155790 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: | 0 | 3,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: void WebGL2RenderingContextBase::RemoveBoundBuffer(WebGLBuffer* buffer) {
if (bound_copy_read_buffer_ == buffer)
bound_copy_read_buffer_ = nullptr;
if (bound_copy_write_buffer_ == buffer)
bound_copy_write_buffer_ = nullptr;
if (bound_pixel_pack_buffer_ == buffer)
bound_pixel_pack_buffer_ = nullptr;
if (bound_pixel_unpack_buffer_ == buffer)
bound_pixel_unpack_buffer_ = nullptr;
if (bound_uniform_buffer_ == buffer)
bound_uniform_buffer_ = nullptr;
if (transform_feedback_binding_)
transform_feedback_binding_->UnbindBuffer(buffer);
WebGLRenderingContextBase::RemoveBoundBuffer(buffer);
}
Commit Message: Reset ES3 pixel pack parameters and PIXEL_PACK_BUFFER binding in DrawingBuffer before ReadPixels() and recover them later.
BUG=740603
TEST=new conformance test
R=kbr@chromium.org,piman@chromium.org
Change-Id: I3ea54c6cc34f34e249f7c8b9f792d93c5e1958f4
Reviewed-on: https://chromium-review.googlesource.com/570840
Reviewed-by: Antoine Labour <piman@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486518}
CWE ID: CWE-119 | 0 | 29,978 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: bool find_numa_distance(int distance)
{
int i;
if (distance == node_distance(0, 0))
return true;
for (i = 0; i < sched_domains_numa_levels; i++) {
if (sched_domains_numa_distance[i] == distance)
return true;
}
return false;
}
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 | 2,036 |
Analyze the following 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 CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a,
CancelableSyncSocket* socket_b) {
return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true);
}
Commit Message: Convert ARRAYSIZE_UNSAFE -> arraysize in base/.
R=thestig@chromium.org
BUG=423134
Review URL: https://codereview.chromium.org/656033009
Cr-Commit-Position: refs/heads/master@{#299835}
CWE ID: CWE-189 | 0 | 1,220 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: bool GLES2DecoderImpl::GetUniformSetup(GLuint program_id,
GLint fake_location,
uint32_t shm_id,
uint32_t shm_offset,
error::Error* error,
GLint* real_location,
GLuint* service_id,
SizedResult<T>** result_pointer,
GLenum* result_type,
GLsizei* result_size) {
DCHECK(error);
DCHECK(service_id);
DCHECK(result_pointer);
DCHECK(result_type);
DCHECK(result_size);
DCHECK(real_location);
*error = error::kNoError;
SizedResult<T>* result;
result = GetSharedMemoryAs<SizedResult<T>*>(
shm_id, shm_offset, SizedResult<T>::ComputeSize(0));
if (!result) {
*error = error::kOutOfBounds;
return false;
}
*result_pointer = result;
result->SetNumResults(0);
Program* program = GetProgramInfoNotShader(program_id, "glGetUniform");
if (!program) {
return false;
}
if (!program->IsValid()) {
LOCAL_SET_GL_ERROR(
GL_INVALID_OPERATION, "glGetUniform", "program not linked");
return false;
}
*service_id = program->service_id();
GLint array_index = -1;
const Program::UniformInfo* uniform_info =
program->GetUniformInfoByFakeLocation(
fake_location, real_location, &array_index);
if (!uniform_info) {
LOCAL_SET_GL_ERROR(
GL_INVALID_OPERATION, "glGetUniform", "unknown location");
return false;
}
GLenum type = uniform_info->type;
uint32_t num_elements = GLES2Util::GetElementCountForUniformType(type);
if (num_elements == 0) {
LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetUniform", "unknown type");
return false;
}
result = GetSharedMemoryAs<SizedResult<T>*>(
shm_id, shm_offset, SizedResult<T>::ComputeSize(num_elements));
if (!result) {
*error = error::kOutOfBounds;
return false;
}
result->SetNumResults(num_elements);
*result_size = num_elements * sizeof(T);
*result_type = type;
return true;
}
Commit Message: Implement immutable texture base/max level clamping
It seems some drivers fail to handle that gracefully, so let's always clamp
to be on the safe side.
BUG=877874
TEST=test case in the bug, gpu_unittests
R=kbr@chromium.org
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I6d93cb9389ea70525df4604112223604577582a2
Reviewed-on: https://chromium-review.googlesource.com/1194994
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587264}
CWE ID: CWE-119 | 0 | 24,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: static double blendDoubles(double from, double to, double progress)
{
return from * (1 - progress) + to * progress;
}
Commit Message: [chromium] We should accelerate all transformations, except when we must blend matrices that cannot be decomposed.
https://bugs.webkit.org/show_bug.cgi?id=95855
Reviewed by James Robinson.
Source/Platform:
WebTransformOperations are now able to report if they can successfully blend.
WebTransformationMatrix::blend now returns a bool if blending would fail.
* chromium/public/WebTransformOperations.h:
(WebTransformOperations):
* chromium/public/WebTransformationMatrix.h:
(WebTransformationMatrix):
Source/WebCore:
WebTransformOperations are now able to report if they can successfully blend.
WebTransformationMatrix::blend now returns a bool if blending would fail.
Unit tests:
AnimationTranslationUtilTest.createTransformAnimationWithNonDecomposableMatrix
AnimationTranslationUtilTest.createTransformAnimationWithNonInvertibleTransform
* platform/chromium/support/WebTransformOperations.cpp:
(WebKit::blendTransformOperations):
(WebKit::WebTransformOperations::blend):
(WebKit::WebTransformOperations::canBlendWith):
(WebKit):
(WebKit::WebTransformOperations::blendInternal):
* platform/chromium/support/WebTransformationMatrix.cpp:
(WebKit::WebTransformationMatrix::blend):
* platform/graphics/chromium/AnimationTranslationUtil.cpp:
(WebCore::WebTransformAnimationCurve):
Source/WebKit/chromium:
Added the following unit tests:
AnimationTranslationUtilTest.createTransformAnimationWithNonDecomposableMatrix
AnimationTranslationUtilTest.createTransformAnimationWithNonInvertibleTransform
* tests/AnimationTranslationUtilTest.cpp:
(WebKit::TEST):
(WebKit):
git-svn-id: svn://svn.chromium.org/blink/trunk@127868 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-119 | 0 | 4,463 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: const char* xfrmMsgTypeToString(uint16_t msg) {
switch (msg) {
XFRM_MSG_TRANS(XFRM_MSG_NEWSA)
XFRM_MSG_TRANS(XFRM_MSG_DELSA)
XFRM_MSG_TRANS(XFRM_MSG_GETSA)
XFRM_MSG_TRANS(XFRM_MSG_NEWPOLICY)
XFRM_MSG_TRANS(XFRM_MSG_DELPOLICY)
XFRM_MSG_TRANS(XFRM_MSG_GETPOLICY)
XFRM_MSG_TRANS(XFRM_MSG_ALLOCSPI)
XFRM_MSG_TRANS(XFRM_MSG_ACQUIRE)
XFRM_MSG_TRANS(XFRM_MSG_EXPIRE)
XFRM_MSG_TRANS(XFRM_MSG_UPDPOLICY)
XFRM_MSG_TRANS(XFRM_MSG_UPDSA)
XFRM_MSG_TRANS(XFRM_MSG_POLEXPIRE)
XFRM_MSG_TRANS(XFRM_MSG_FLUSHSA)
XFRM_MSG_TRANS(XFRM_MSG_FLUSHPOLICY)
XFRM_MSG_TRANS(XFRM_MSG_NEWAE)
XFRM_MSG_TRANS(XFRM_MSG_GETAE)
XFRM_MSG_TRANS(XFRM_MSG_REPORT)
XFRM_MSG_TRANS(XFRM_MSG_MIGRATE)
XFRM_MSG_TRANS(XFRM_MSG_NEWSADINFO)
XFRM_MSG_TRANS(XFRM_MSG_GETSADINFO)
XFRM_MSG_TRANS(XFRM_MSG_GETSPDINFO)
XFRM_MSG_TRANS(XFRM_MSG_NEWSPDINFO)
XFRM_MSG_TRANS(XFRM_MSG_MAPPING)
default:
return "XFRM_MSG UNKNOWN";
}
}
Commit Message: Set optlen for UDP-encap check in XfrmController
When setting the socket owner for an encap socket XfrmController will
first attempt to verify that the socket has the UDP-encap socket option
set. When doing so it would pass in an uninitialized optlen parameter
which could cause the call to not modify the option value if the optlen
happened to be too short. So for example if the stack happened to
contain a zero where optlen was located the check would fail and the
socket owner would not be changed.
Fix this by setting optlen to the size of the option value parameter.
Test: run cts -m CtsNetTestCases
BUG: 111650288
Change-Id: I57b6e9dba09c1acda71e3ec2084652e961667bd9
(cherry picked from commit fc42a105147310bd680952d4b71fe32974bd8506)
CWE ID: CWE-909 | 0 | 25,227 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: CStarter::RemoveRecoveryFile()
{
if ( m_recoveryFile.Length() > 0 ) {
unlink( m_recoveryFile.Value() );
m_recoveryFile = "";
}
}
Commit Message:
CWE ID: CWE-134 | 0 | 5,467 |
Analyze the following 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 crypto_register_shashes(struct shash_alg *algs, int count)
{
int i, ret;
for (i = 0; i < count; i++) {
ret = crypto_register_shash(&algs[i]);
if (ret)
goto err;
}
return 0;
err:
for (--i; i >= 0; --i)
crypto_unregister_shash(&algs[i]);
return ret;
}
Commit Message: crypto: user - fix info leaks in report API
Three errors resulting in kernel memory disclosure:
1/ The structures used for the netlink based crypto algorithm report API
are located on the stack. As snprintf() does not fill the remainder of
the buffer with null bytes, those stack bytes will be disclosed to users
of the API. Switch to strncpy() to fix this.
2/ crypto_report_one() does not initialize all field of struct
crypto_user_alg. Fix this to fix the heap info leak.
3/ For the module name we should copy only as many bytes as
module_name() returns -- not as much as the destination buffer could
hold. But the current code does not and therefore copies random data
from behind the end of the module name, as the module name is always
shorter than CRYPTO_MAX_ALG_NAME.
Also switch to use strncpy() to copy the algorithm's name and
driver_name. They are strings, after all.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
CWE ID: CWE-310 | 0 | 17,482 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: explicit RemovePasswordsTester(TestingProfile* testing_profile) {
PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse(
testing_profile,
password_manager::BuildPasswordStore<
content::BrowserContext,
testing::NiceMock<password_manager::MockPasswordStore>>);
store_ = static_cast<password_manager::MockPasswordStore*>(
PasswordStoreFactory::GetInstance()
->GetForProfile(testing_profile, ServiceAccessType::EXPLICIT_ACCESS)
.get());
OSCryptMocker::SetUp();
}
Commit Message: Don't downcast DownloadManagerDelegate to ChromeDownloadManagerDelegate.
DownloadManager has public SetDelegate method and tests and or other subsystems
can install their own implementations of the delegate.
Bug: 805905
Change-Id: Iecf1e0aceada0e1048bed1e2d2ceb29ca64295b8
TBR: tests updated to follow the API change.
Reviewed-on: https://chromium-review.googlesource.com/894702
Reviewed-by: David Vallet <dvallet@chromium.org>
Reviewed-by: Min Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533515}
CWE ID: CWE-125 | 0 | 28,229 |
Analyze the following 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_seq_ioctl_get_client_info(struct snd_seq_client *client,
void *arg)
{
struct snd_seq_client_info *client_info = arg;
struct snd_seq_client *cptr;
/* requested client number */
cptr = snd_seq_client_use_ptr(client_info->client);
if (cptr == NULL)
return -ENOENT; /* don't change !!! */
get_client_info(cptr, client_info);
snd_seq_client_unlock(cptr);
return 0;
}
Commit Message: ALSA: seq: Fix use-after-free at creating a port
There is a potential race window opened at creating and deleting a
port via ioctl, as spotted by fuzzing. snd_seq_create_port() creates
a port object and returns its pointer, but it doesn't take the
refcount, thus it can be deleted immediately by another thread.
Meanwhile, snd_seq_ioctl_create_port() still calls the function
snd_seq_system_client_ev_port_start() with the created port object
that is being deleted, and this triggers use-after-free like:
BUG: KASAN: use-after-free in snd_seq_ioctl_create_port+0x504/0x630 [snd_seq] at addr ffff8801f2241cb1
=============================================================================
BUG kmalloc-512 (Tainted: G B ): kasan: bad access detected
-----------------------------------------------------------------------------
INFO: Allocated in snd_seq_create_port+0x94/0x9b0 [snd_seq] age=1 cpu=3 pid=4511
___slab_alloc+0x425/0x460
__slab_alloc+0x20/0x40
kmem_cache_alloc_trace+0x150/0x190
snd_seq_create_port+0x94/0x9b0 [snd_seq]
snd_seq_ioctl_create_port+0xd1/0x630 [snd_seq]
snd_seq_do_ioctl+0x11c/0x190 [snd_seq]
snd_seq_ioctl+0x40/0x80 [snd_seq]
do_vfs_ioctl+0x54b/0xda0
SyS_ioctl+0x79/0x90
entry_SYSCALL_64_fastpath+0x16/0x75
INFO: Freed in port_delete+0x136/0x1a0 [snd_seq] age=1 cpu=2 pid=4717
__slab_free+0x204/0x310
kfree+0x15f/0x180
port_delete+0x136/0x1a0 [snd_seq]
snd_seq_delete_port+0x235/0x350 [snd_seq]
snd_seq_ioctl_delete_port+0xc8/0x180 [snd_seq]
snd_seq_do_ioctl+0x11c/0x190 [snd_seq]
snd_seq_ioctl+0x40/0x80 [snd_seq]
do_vfs_ioctl+0x54b/0xda0
SyS_ioctl+0x79/0x90
entry_SYSCALL_64_fastpath+0x16/0x75
Call Trace:
[<ffffffff81b03781>] dump_stack+0x63/0x82
[<ffffffff81531b3b>] print_trailer+0xfb/0x160
[<ffffffff81536db4>] object_err+0x34/0x40
[<ffffffff815392d3>] kasan_report.part.2+0x223/0x520
[<ffffffffa07aadf4>] ? snd_seq_ioctl_create_port+0x504/0x630 [snd_seq]
[<ffffffff815395fe>] __asan_report_load1_noabort+0x2e/0x30
[<ffffffffa07aadf4>] snd_seq_ioctl_create_port+0x504/0x630 [snd_seq]
[<ffffffffa07aa8f0>] ? snd_seq_ioctl_delete_port+0x180/0x180 [snd_seq]
[<ffffffff8136be50>] ? taskstats_exit+0xbc0/0xbc0
[<ffffffffa07abc5c>] snd_seq_do_ioctl+0x11c/0x190 [snd_seq]
[<ffffffffa07abd10>] snd_seq_ioctl+0x40/0x80 [snd_seq]
[<ffffffff8136d433>] ? acct_account_cputime+0x63/0x80
[<ffffffff815b515b>] do_vfs_ioctl+0x54b/0xda0
.....
We may fix this in a few different ways, and in this patch, it's fixed
simply by taking the refcount properly at snd_seq_create_port() and
letting the caller unref the object after use. Also, there is another
potential use-after-free by sprintf() call in snd_seq_create_port(),
and this is moved inside the lock.
This fix covers CVE-2017-15265.
Reported-and-tested-by: Michael23 Yu <ycqzsy@gmail.com>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
CWE ID: CWE-416 | 0 | 25,546 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void booleanAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());
V8TRYCATCH_VOID(bool, cppValue, jsValue->BooleanValue());
imp->setBooleanAttribute(cppValue);
}
Commit Message: document.location bindings fix
BUG=352374
R=jochen@chromium.org
Review URL: https://codereview.chromium.org/196343011
git-svn-id: svn://svn.chromium.org/blink/trunk@169176 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-399 | 0 | 9,167 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: ResizeObserverController& Document::EnsureResizeObserverController() {
if (!resize_observer_controller_) {
resize_observer_controller_ =
MakeGarbageCollected<ResizeObserverController>();
}
return *resize_observer_controller_;
}
Commit Message: Cleanup and remove dead code in SetFocusedElement
This early-out was added in:
https://crrev.com/ce8ea3446283965c7eabab592cbffe223b1cf2bc
Back then, we applied fragment focus in LayoutUpdated() which could
cause this issue. This got cleaned up in:
https://crrev.com/45236fd563e9df53dc45579be1f3d0b4784885a2
so that focus is no longer applied after layout.
+Cleanup: Goto considered harmful
Bug: 795381
Change-Id: Ifeb4d2e03e872fd48cca6720b1d4de36ad1ecbb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1524417
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#641101}
CWE ID: CWE-416 | 0 | 28,659 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: GfxDeviceNColorSpace::~GfxDeviceNColorSpace() {
int i;
for (i = 0; i < nComps; ++i) {
delete names[i];
}
delete alt;
delete func;
}
Commit Message:
CWE ID: CWE-189 | 0 | 22,852 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void HTMLFormControlElement::dispatchChangeEvent()
{
dispatchScopedEvent(Event::createBubble(EventTypeNames::change));
}
Commit Message: Add HTMLFormControlElement::supportsAutofocus to fix a FIXME comment.
This virtual function should return true if the form control can hanlde
'autofocucs' attribute if it is specified.
Note: HTMLInputElement::supportsAutofocus reuses InputType::isInteractiveContent
because interactiveness is required for autofocus capability.
BUG=none
TEST=none; no behavior changes.
Review URL: https://codereview.chromium.org/143343003
git-svn-id: svn://svn.chromium.org/blink/trunk@165432 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-119 | 0 | 26,413 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: long long EBMLHeader::Parse(IMkvReader* pReader, long long& pos) {
assert(pReader);
long long total, available;
long status = pReader->Length(&total, &available);
if (status < 0) // error
return status;
pos = 0;
long long end = (available >= 1024) ? 1024 : available;
for (;;) {
unsigned char b = 0;
while (pos < end) {
status = pReader->Read(pos, 1, &b);
if (status < 0) // error
return status;
if (b == 0x1A)
break;
++pos;
}
if (b != 0x1A) {
if (pos >= 1024)
return E_FILE_FORMAT_INVALID; // don't bother looking anymore
if ((total >= 0) && ((total - available) < 5))
return E_FILE_FORMAT_INVALID;
return available + 5; // 5 = 4-byte ID + 1st byte of size
}
if ((total >= 0) && ((total - pos) < 5))
return E_FILE_FORMAT_INVALID;
if ((available - pos) < 5)
return pos + 5; // try again later
long len;
const long long result = ReadUInt(pReader, pos, len);
if (result < 0) // error
return result;
if (result == 0x0A45DFA3) { // EBML Header ID
pos += len; // consume ID
break;
}
++pos; // throw away just the 0x1A byte, and try again
}
long len;
long long result = GetUIntLength(pReader, pos, len);
if (result < 0) // error
return result;
if (result > 0) // need more data
return result;
assert(len > 0);
assert(len <= 8);
if ((total >= 0) && ((total - pos) < len))
return E_FILE_FORMAT_INVALID;
if ((available - pos) < len)
return pos + len; // try again later
result = ReadUInt(pReader, pos, len);
if (result < 0) // error
return result;
pos += len; // consume size field
if ((total >= 0) && ((total - pos) < result))
return E_FILE_FORMAT_INVALID;
if ((available - pos) < result)
return pos + result;
end = pos + result;
Init();
while (pos < end) {
long long id, size;
status = ParseElementHeader(pReader, pos, end, id, size);
if (status < 0) // error
return status;
if (size == 0) // weird
return E_FILE_FORMAT_INVALID;
if (id == 0x0286) { // version
m_version = UnserializeUInt(pReader, pos, size);
if (m_version <= 0)
return E_FILE_FORMAT_INVALID;
} else if (id == 0x02F7) { // read version
m_readVersion = UnserializeUInt(pReader, pos, size);
if (m_readVersion <= 0)
return E_FILE_FORMAT_INVALID;
} else if (id == 0x02F2) { // max id length
m_maxIdLength = UnserializeUInt(pReader, pos, size);
if (m_maxIdLength <= 0)
return E_FILE_FORMAT_INVALID;
} else if (id == 0x02F3) { // max size length
m_maxSizeLength = UnserializeUInt(pReader, pos, size);
if (m_maxSizeLength <= 0)
return E_FILE_FORMAT_INVALID;
} else if (id == 0x0282) { // doctype
if (m_docType)
return E_FILE_FORMAT_INVALID;
status = UnserializeString(pReader, pos, size, m_docType);
if (status) // error
return status;
} else if (id == 0x0287) { // doctype version
m_docTypeVersion = UnserializeUInt(pReader, pos, size);
if (m_docTypeVersion <= 0)
return E_FILE_FORMAT_INVALID;
} else if (id == 0x0285) { // doctype read version
m_docTypeReadVersion = UnserializeUInt(pReader, pos, size);
if (m_docTypeReadVersion <= 0)
return E_FILE_FORMAT_INVALID;
}
pos += size;
}
assert(pos == end);
return 0;
}
Commit Message: external/libvpx/libwebm: Update snapshot
Update libwebm snapshot. This update contains security fixes from upstream.
Upstream git hash: 229f49347d19b0ca0941e072b199a242ef6c5f2b
BUG=23167726
Change-Id: Id3e140e7b31ae11294724b1ecfe2e9c83b4d4207
(cherry picked from commit d0281a15b3c6bd91756e453cc9398c5ef412d99a)
CWE ID: CWE-20 | 1 | 14,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: unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, unsigned char *limit)
{
int extdatalen=0;
unsigned char *orig = buf;
unsigned char *ret = buf;
/* don't add extensions for SSLv3 unless doing secure renegotiation */
if (s->client_version == SSL3_VERSION
&& !s->s3->send_connection_binding)
return orig;
ret+=2;
if (ret>=limit) return NULL; /* this really never occurs, but ... */
if (s->tlsext_hostname != NULL)
{
/* Add TLS extension servername to the Client Hello message */
unsigned long size_str;
long lenmax;
/* check for enough space.
4 for the servername type and entension length
2 for servernamelist length
1 for the hostname type
2 for hostname length
+ hostname length
*/
if ((lenmax = limit - ret - 9) < 0
|| (size_str = strlen(s->tlsext_hostname)) > (unsigned long)lenmax)
return NULL;
/* extension type and length */
s2n(TLSEXT_TYPE_server_name,ret);
s2n(size_str+5,ret);
/* length of servername list */
s2n(size_str+3,ret);
/* hostname type, length and hostname */
*(ret++) = (unsigned char) TLSEXT_NAMETYPE_host_name;
s2n(size_str,ret);
memcpy(ret, s->tlsext_hostname, size_str);
ret+=size_str;
}
/* Add RI if renegotiating */
if (s->renegotiate)
{
int el;
if(!ssl_add_clienthello_renegotiate_ext(s, 0, &el, 0))
{
SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);
return NULL;
}
if((limit - ret - 4 - el) < 0) return NULL;
s2n(TLSEXT_TYPE_renegotiate,ret);
s2n(el,ret);
if(!ssl_add_clienthello_renegotiate_ext(s, ret, &el, el))
{
SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);
return NULL;
}
ret += el;
}
#ifndef OPENSSL_NO_SRP
/* Add SRP username if there is one */
if (s->srp_ctx.login != NULL)
{ /* Add TLS extension SRP username to the Client Hello message */
int login_len = strlen(s->srp_ctx.login);
if (login_len > 255 || login_len == 0)
{
SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);
return NULL;
}
/* check for enough space.
4 for the srp type type and entension length
1 for the srp user identity
+ srp user identity length
*/
if ((limit - ret - 5 - login_len) < 0) return NULL;
/* fill in the extension */
s2n(TLSEXT_TYPE_srp,ret);
s2n(login_len+1,ret);
(*ret++) = (unsigned char) login_len;
memcpy(ret, s->srp_ctx.login, login_len);
ret+=login_len;
}
#endif
#ifndef OPENSSL_NO_EC
if (s->tlsext_ecpointformatlist != NULL)
{
/* Add TLS extension ECPointFormats to the ClientHello message */
long lenmax;
if ((lenmax = limit - ret - 5) < 0) return NULL;
if (s->tlsext_ecpointformatlist_length > (unsigned long)lenmax) return NULL;
if (s->tlsext_ecpointformatlist_length > 255)
{
SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);
return NULL;
}
s2n(TLSEXT_TYPE_ec_point_formats,ret);
s2n(s->tlsext_ecpointformatlist_length + 1,ret);
*(ret++) = (unsigned char) s->tlsext_ecpointformatlist_length;
memcpy(ret, s->tlsext_ecpointformatlist, s->tlsext_ecpointformatlist_length);
ret+=s->tlsext_ecpointformatlist_length;
}
if (s->tlsext_ellipticcurvelist != NULL)
{
/* Add TLS extension EllipticCurves to the ClientHello message */
long lenmax;
if ((lenmax = limit - ret - 6) < 0) return NULL;
if (s->tlsext_ellipticcurvelist_length > (unsigned long)lenmax) return NULL;
if (s->tlsext_ellipticcurvelist_length > 65532)
{
SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);
return NULL;
}
s2n(TLSEXT_TYPE_elliptic_curves,ret);
s2n(s->tlsext_ellipticcurvelist_length + 2, ret);
/* NB: draft-ietf-tls-ecc-12.txt uses a one-byte prefix for
* elliptic_curve_list, but the examples use two bytes.
* http://www1.ietf.org/mail-archive/web/tls/current/msg00538.html
* resolves this to two bytes.
*/
s2n(s->tlsext_ellipticcurvelist_length, ret);
memcpy(ret, s->tlsext_ellipticcurvelist, s->tlsext_ellipticcurvelist_length);
ret+=s->tlsext_ellipticcurvelist_length;
}
#endif /* OPENSSL_NO_EC */
if (!(SSL_get_options(s) & SSL_OP_NO_TICKET))
{
int ticklen;
if (!s->new_session && s->session && s->session->tlsext_tick)
ticklen = s->session->tlsext_ticklen;
else if (s->session && s->tlsext_session_ticket &&
s->tlsext_session_ticket->data)
{
ticklen = s->tlsext_session_ticket->length;
s->session->tlsext_tick = OPENSSL_malloc(ticklen);
if (!s->session->tlsext_tick)
return NULL;
memcpy(s->session->tlsext_tick,
s->tlsext_session_ticket->data,
ticklen);
s->session->tlsext_ticklen = ticklen;
}
else
ticklen = 0;
if (ticklen == 0 && s->tlsext_session_ticket &&
s->tlsext_session_ticket->data == NULL)
goto skip_ext;
/* Check for enough room 2 for extension type, 2 for len
* rest for ticket
*/
if ((long)(limit - ret - 4 - ticklen) < 0) return NULL;
s2n(TLSEXT_TYPE_session_ticket,ret);
s2n(ticklen,ret);
if (ticklen)
{
memcpy(ret, s->session->tlsext_tick, ticklen);
ret += ticklen;
}
}
skip_ext:
if (TLS1_get_client_version(s) >= TLS1_2_VERSION)
{
if ((size_t)(limit - ret) < sizeof(tls12_sigalgs) + 6)
return NULL;
s2n(TLSEXT_TYPE_signature_algorithms,ret);
s2n(sizeof(tls12_sigalgs) + 2, ret);
s2n(sizeof(tls12_sigalgs), ret);
memcpy(ret, tls12_sigalgs, sizeof(tls12_sigalgs));
ret += sizeof(tls12_sigalgs);
}
#ifdef TLSEXT_TYPE_opaque_prf_input
if (s->s3->client_opaque_prf_input != NULL &&
s->version != DTLS1_VERSION)
{
size_t col = s->s3->client_opaque_prf_input_len;
if ((long)(limit - ret - 6 - col < 0))
return NULL;
if (col > 0xFFFD) /* can't happen */
return NULL;
s2n(TLSEXT_TYPE_opaque_prf_input, ret);
s2n(col + 2, ret);
s2n(col, ret);
memcpy(ret, s->s3->client_opaque_prf_input, col);
ret += col;
}
#endif
if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp &&
s->version != DTLS1_VERSION)
{
int i;
long extlen, idlen, itmp;
OCSP_RESPID *id;
idlen = 0;
for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++)
{
id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i);
itmp = i2d_OCSP_RESPID(id, NULL);
if (itmp <= 0)
return NULL;
idlen += itmp + 2;
}
if (s->tlsext_ocsp_exts)
{
extlen = i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, NULL);
if (extlen < 0)
return NULL;
}
else
extlen = 0;
if ((long)(limit - ret - 7 - extlen - idlen) < 0) return NULL;
s2n(TLSEXT_TYPE_status_request, ret);
if (extlen + idlen > 0xFFF0)
return NULL;
s2n(extlen + idlen + 5, ret);
*(ret++) = TLSEXT_STATUSTYPE_ocsp;
s2n(idlen, ret);
for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++)
{
/* save position of id len */
unsigned char *q = ret;
id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i);
/* skip over id len */
ret += 2;
itmp = i2d_OCSP_RESPID(id, &ret);
/* write id len */
s2n(itmp, q);
}
s2n(extlen, ret);
if (extlen > 0)
i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, &ret);
}
#ifndef OPENSSL_NO_HEARTBEATS
/* Add Heartbeat extension */
if ((limit - ret - 4 - 1) < 0)
return NULL;
s2n(TLSEXT_TYPE_heartbeat,ret);
s2n(1,ret);
/* Set mode:
* 1: peer may send requests
* 2: peer not allowed to send requests
*/
if (s->tlsext_heartbeat & SSL_TLSEXT_HB_DONT_RECV_REQUESTS)
*(ret++) = SSL_TLSEXT_HB_DONT_SEND_REQUESTS;
else
*(ret++) = SSL_TLSEXT_HB_ENABLED;
#endif
#ifndef OPENSSL_NO_NEXTPROTONEG
if (s->ctx->next_proto_select_cb && !s->s3->tmp.finish_md_len)
{
/* The client advertises an emtpy extension to indicate its
* support for Next Protocol Negotiation */
if (limit - ret - 4 < 0)
return NULL;
s2n(TLSEXT_TYPE_next_proto_neg,ret);
s2n(0,ret);
}
#endif
#ifndef OPENSSL_NO_SRTP
if(SSL_get_srtp_profiles(s))
{
int el;
ssl_add_clienthello_use_srtp_ext(s, 0, &el, 0);
if((limit - ret - 4 - el) < 0) return NULL;
s2n(TLSEXT_TYPE_use_srtp,ret);
s2n(el,ret);
if(ssl_add_clienthello_use_srtp_ext(s, ret, &el, el))
{
SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR);
return NULL;
}
ret += el;
}
#endif
/* Add padding to workaround bugs in F5 terminators.
* See https://tools.ietf.org/html/draft-agl-tls-padding-03
*
* NB: because this code works out the length of all existing
* extensions it MUST always appear last.
*/
if (s->options & SSL_OP_TLSEXT_PADDING)
{
int hlen = ret - (unsigned char *)s->init_buf->data;
/* The code in s23_clnt.c to build ClientHello messages
* includes the 5-byte record header in the buffer, while
* the code in s3_clnt.c does not.
*/
if (s->state == SSL23_ST_CW_CLNT_HELLO_A)
hlen -= 5;
if (hlen > 0xff && hlen < 0x200)
{
hlen = 0x200 - hlen;
if (hlen >= 4)
hlen -= 4;
else
hlen = 0;
s2n(TLSEXT_TYPE_padding, ret);
s2n(hlen, ret);
memset(ret, 0, hlen);
ret += hlen;
}
}
if ((extdatalen = ret-orig-2)== 0)
return orig;
s2n(extdatalen, orig);
return ret;
}
Commit Message:
CWE ID: CWE-20 | 1 | 17,258 |
Analyze the following 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_match(struct xt_entry_match *m, struct xt_mtchk_param *par)
{
const struct ip6t_ip6 *ipv6 = par->entryinfo;
int ret;
par->match = m->u.kernel.match;
par->matchinfo = m->data;
ret = xt_check_match(par, m->u.match_size - sizeof(*m),
ipv6->proto, ipv6->invflags & IP6T_INV_PROTO);
if (ret < 0) {
duprintf("ip_tables: check failed for `%s'.\n",
par.match->name);
return ret;
}
return 0;
}
Commit Message: netfilter: x_tables: make sure e->next_offset covers remaining blob size
Otherwise this function may read data beyond the ruleset blob.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
CWE ID: CWE-119 | 0 | 26,520 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void correct_endian_basic(struct usbip_header_basic *base, int send)
{
if (send) {
base->command = cpu_to_be32(base->command);
base->seqnum = cpu_to_be32(base->seqnum);
base->devid = cpu_to_be32(base->devid);
base->direction = cpu_to_be32(base->direction);
base->ep = cpu_to_be32(base->ep);
} else {
base->command = be32_to_cpu(base->command);
base->seqnum = be32_to_cpu(base->seqnum);
base->devid = be32_to_cpu(base->devid);
base->direction = be32_to_cpu(base->direction);
base->ep = be32_to_cpu(base->ep);
}
}
Commit Message: USB: usbip: fix potential out-of-bounds write
Fix potential out-of-bounds write to urb->transfer_buffer
usbip handles network communication directly in the kernel. When receiving a
packet from its peer, usbip code parses headers according to protocol. As
part of this parsing urb->actual_length is filled. Since the input for
urb->actual_length comes from the network, it should be treated as untrusted.
Any entity controlling the network may put any value in the input and the
preallocated urb->transfer_buffer may not be large enough to hold the data.
Thus, the malicious entity is able to write arbitrary data to kernel memory.
Signed-off-by: Ignat Korchagin <ignat.korchagin@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CWE ID: CWE-119 | 0 | 22,176 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: BrotliResult BrotliDecompressBuffer(size_t encoded_size,
const uint8_t* encoded_buffer,
size_t* decoded_size,
uint8_t* decoded_buffer) {
BrotliState s;
BrotliResult result;
size_t total_out = 0;
size_t available_in = encoded_size;
const uint8_t* next_in = encoded_buffer;
size_t available_out = *decoded_size;
uint8_t* next_out = decoded_buffer;
BrotliStateInit(&s);
result = BrotliDecompressStream(&available_in, &next_in, &available_out,
&next_out, &total_out, &s);
*decoded_size = total_out;
BrotliStateCleanup(&s);
if (result != BROTLI_RESULT_SUCCESS) {
result = BROTLI_RESULT_ERROR;
}
return result;
}
Commit Message: Cherry pick underflow fix.
BUG=583607
Review URL: https://codereview.chromium.org/1662313002
Cr-Commit-Position: refs/heads/master@{#373736}
CWE ID: CWE-119 | 0 | 10,523 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: atol8(const char *p, unsigned char_cnt)
{
int64_t l;
int digit;
l = 0;
while (char_cnt-- > 0) {
if (*p >= '0' && *p <= '7')
digit = *p - '0';
else
return (l);
p++;
l <<= 3;
l |= digit;
}
return (l);
}
Commit Message: Reject cpio symlinks that exceed 1MB
CWE ID: CWE-20 | 0 | 18,667 |
Analyze the following 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 _nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cred *cred)
{
struct nfs_fsinfo fsinfo;
struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID_CONFIRM],
.rpc_argp = clp,
.rpc_resp = &fsinfo,
.rpc_cred = cred,
};
unsigned long now;
int status;
now = jiffies;
status = rpc_call_sync(clp->cl_rpcclient, &msg, 0);
if (status == 0) {
spin_lock(&clp->cl_lock);
clp->cl_lease_time = fsinfo.lease_time * HZ;
clp->cl_last_renewal = now;
spin_unlock(&clp->cl_lock);
}
return status;
}
Commit Message: NFSv4: Convert the open and close ops to use fmode
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
CWE ID: | 0 | 9,646 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: struct r_bin_mdmp_obj *r_bin_mdmp_new_buf(struct r_buf_t *buf) {
bool fail = false;
struct r_bin_mdmp_obj *obj = R_NEW0 (struct r_bin_mdmp_obj);
if (!obj) {
return NULL;
}
obj->kv = sdb_new0 ();
obj->b = r_buf_new ();
obj->size = (ut32)buf->length;
fail |= (!(obj->streams.ex_threads = r_list_new ()));
fail |= (!(obj->streams.memories = r_list_new ()));
fail |= (!(obj->streams.memories64.memories = r_list_new ()));
fail |= (!(obj->streams.memory_infos = r_list_new ()));
fail |= (!(obj->streams.modules = r_list_new ()));
fail |= (!(obj->streams.operations = r_list_new ()));
fail |= (!(obj->streams.thread_infos = r_list_new ()));
fail |= (!(obj->streams.threads = r_list_new ()));
fail |= (!(obj->streams.unloaded_modules = r_list_new ()));
fail |= (!(obj->pe32_bins = r_list_newf (r_bin_mdmp_free_pe32_bin)));
fail |= (!(obj->pe64_bins = r_list_newf (r_bin_mdmp_free_pe64_bin)));
if (fail) {
r_bin_mdmp_free (obj);
return NULL;
}
if (!r_buf_set_bytes (obj->b, buf->buf, buf->length)) {
r_bin_mdmp_free (obj);
return NULL;
}
if (!r_bin_mdmp_init (obj)) {
r_bin_mdmp_free (obj);
return NULL;
}
return obj;
}
Commit Message: Fix #10464 - oobread crash in mdmp
CWE ID: CWE-125 | 0 | 26,087 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: SpeechRecognitionEventListener* SpeechRecognitionManagerImpl::GetListener(
int session_id) const {
Session* session = GetSession(session_id);
if (session->config.event_listener)
return session->config.event_listener.get();
return nullptr;
}
Commit Message: Make MediaStreamDispatcherHost per-request instead of per-frame.
Instead of having RenderFrameHost own a single MSDH to handle all
requests from a frame, MSDH objects will be owned by a strong binding.
A consequence of this is that an additional requester ID is added to
requests to MediaStreamManager, so that an MSDH is able to cancel only
requests generated by it.
In practice, MSDH will continue to be per frame in most cases since
each frame normally makes a single request for an MSDH object.
This fixes a lifetime issue caused by the IO thread executing tasks
after the RenderFrameHost dies.
Drive-by: Fix some minor lint issues.
Bug: 912520
Change-Id: I52742ffc98b9fc57ce8e6f5093a61aed86d3e516
Reviewed-on: https://chromium-review.googlesource.com/c/1369799
Reviewed-by: Emircan Uysaler <emircan@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Olga Sharonova <olka@chromium.org>
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616347}
CWE ID: CWE-189 | 0 | 19,603 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen)
{
struct key *key;
key_ref_t key_ref;
long ret;
/* find the key first */
key_ref = lookup_user_key(keyid, 0, 0);
if (IS_ERR(key_ref)) {
ret = -ENOKEY;
goto error;
}
key = key_ref_to_ptr(key_ref);
/* see if we can read it directly */
ret = key_permission(key_ref, KEY_NEED_READ);
if (ret == 0)
goto can_read_key;
if (ret != -EACCES)
goto error;
/* we can't; see if it's searchable from this process's keyrings
* - we automatically take account of the fact that it may be
* dangling off an instantiation key
*/
if (!is_key_possessed(key_ref)) {
ret = -EACCES;
goto error2;
}
/* the key is probably readable - now try to read it */
can_read_key:
ret = -EOPNOTSUPP;
if (key->type->read) {
/* Read the data with the semaphore held (since we might sleep)
* to protect against the key being updated or revoked.
*/
down_read(&key->sem);
ret = key_validate(key);
if (ret == 0)
ret = key->type->read(key, buffer, buflen);
up_read(&key->sem);
}
error2:
key_put(key);
error:
return ret;
}
Commit Message: KEYS: fix dereferencing NULL payload with nonzero length
sys_add_key() and the KEYCTL_UPDATE operation of sys_keyctl() allowed a
NULL payload with nonzero length to be passed to the key type's
->preparse(), ->instantiate(), and/or ->update() methods. Various key
types including asymmetric, cifs.idmap, cifs.spnego, and pkcs7_test did
not handle this case, allowing an unprivileged user to trivially cause a
NULL pointer dereference (kernel oops) if one of these key types was
present. Fix it by doing the copy_from_user() when 'plen' is nonzero
rather than when '_payload' is non-NULL, causing the syscall to fail
with EFAULT as expected when an invalid buffer is specified.
Cc: stable@vger.kernel.org # 2.6.10+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
CWE ID: CWE-476 | 0 | 22,101 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void qib_user_remove(struct qib_devdata *dd)
{
if (atomic_dec_return(&user_count) == 0)
qib_cdev_cleanup(&wildcard_cdev, &wildcard_device);
qib_cdev_cleanup(&dd->user_cdev, &dd->user_device);
}
Commit Message: IB/security: Restrict use of the write() interface
The drivers/infiniband stack uses write() as a replacement for
bi-directional ioctl(). This is not safe. There are ways to
trigger write calls that result in the return structure that
is normally written to user space being shunted off to user
specified kernel memory instead.
For the immediate repair, detect and deny suspicious accesses to
the write API.
For long term, update the user space libraries and the kernel API
to something that doesn't present the same security vulnerabilities
(likely a structured ioctl() interface).
The impacted uAPI interfaces are generally only available if
hardware from drivers/infiniband is installed in the system.
Reported-by: Jann Horn <jann@thejh.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
[ Expanded check to all known write() entry points ]
Cc: stable@vger.kernel.org
Signed-off-by: Doug Ledford <dledford@redhat.com>
CWE ID: CWE-264 | 0 | 22,822 |
Analyze the following 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 PrintOutParsingResult(
tTcpIpPacketParsingResult res,
int level,
LPCSTR procname)
{
DPrintf(level, ("[%s] %s packet IPCS %s%s, checksum %s%s\n", procname,
GetPacketCase(res),
GetIPCSCase(res),
res.fixedIpCS ? "(fixed)" : "",
GetXxpCSCase(res),
res.fixedXxpCS ? "(fixed)" : ""));
}
Commit Message: NetKVM: BZ#1169718: More rigoruous testing of incoming packet
Signed-off-by: Joseph Hindin <yhindin@rehat.com>
CWE ID: CWE-20 | 0 | 24,770 |
Analyze the following 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 double pcerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
{
/* Percentage error permitted in the linear values. Note that the specified
* value is a percentage but this routine returns a simple number.
*/
if (pm->assume_16_bit_calculations ||
(pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
return pm->maxpc16 * .01;
else
return pm->maxpc8 * .01;
}
Commit Message: DO NOT MERGE Update libpng to 1.6.20
BUG:23265085
Change-Id: I85199805636d771f3597b691b63bc0bf46084833
(cherry picked from commit bbe98b40cda082024b669fa508931042eed18f82)
CWE ID: | 1 | 2,777 |
Analyze the following 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_buf_new(gs_int_rect *rect, bool has_tags, bool has_alpha_g,
bool has_shape, bool idle, int n_chan, int num_spots,
gs_memory_t *memory)
{
/* Note that alpha_g is the alpha for the GROUP */
/* This is distinct from the alpha that may also exist */
/* for the objects within the group. Hence it can introduce */
/* yet another plane */
pdf14_buf *result;
pdf14_parent_color_t *new_parent_color;
int rowstride = (rect->q.x - rect->p.x + 3) & -4;
int height = (rect->q.y - rect->p.y);
int n_planes = n_chan + (has_shape ? 1 : 0) + (has_alpha_g ? 1 : 0) +
(has_tags ? 1 : 0);
int planestride;
double dsize = (((double) rowstride) * height) * n_planes;
if (dsize > (double)max_uint)
return NULL;
result = gs_alloc_struct(memory, pdf14_buf, &st_pdf14_buf,
"pdf14_buf_new");
if (result == NULL)
return result;
result->backdrop = NULL;
result->saved = NULL;
result->isolated = false;
result->knockout = false;
result->has_alpha_g = has_alpha_g;
result->has_shape = has_shape;
result->has_tags = has_tags;
result->rect = *rect;
result->n_chan = n_chan;
result->n_planes = n_planes;
result->rowstride = rowstride;
result->transfer_fn = NULL;
result->matte_num_comps = 0;
result->matte = NULL;
result->mask_stack = NULL;
result->idle = idle;
result->mask_id = 0;
result->num_spots = num_spots;
new_parent_color = gs_alloc_struct(memory, pdf14_parent_color_t, &st_pdf14_clr,
"pdf14_buf_new");
if (new_parent_color == NULL) {
gs_free_object(memory, result, "pdf14_buf_new");
return NULL;
}
result->parent_color_info_procs = new_parent_color;
result->parent_color_info_procs->get_cmap_procs = NULL;
result->parent_color_info_procs->parent_color_mapping_procs = NULL;
result->parent_color_info_procs->parent_color_comp_index = NULL;
result->parent_color_info_procs->icc_profile = NULL;
result->parent_color_info_procs->previous = NULL;
result->parent_color_info_procs->encode = NULL;
result->parent_color_info_procs->decode = NULL;
if (height <= 0) {
/* Empty clipping - will skip all drawings. */
result->planestride = 0;
result->data = 0;
} else {
planestride = rowstride * height;
result->planestride = planestride;
result->data = gs_alloc_bytes(memory, planestride * n_planes,
"pdf14_buf_new");
if (result->data == NULL) {
gs_free_object(memory, result, "pdf14_buf_new");
return NULL;
}
if (has_alpha_g) {
int alpha_g_plane = n_chan + (has_shape ? 1 : 0);
memset (result->data + alpha_g_plane * planestride, 0, planestride);
}
if (has_tags) {
int tags_plane = n_chan + (has_shape ? 1 : 0) + (has_alpha_g ? 1 : 0);
memset (result->data + tags_plane * planestride,
GS_UNTOUCHED_TAG, planestride);
}
}
/* Initialize dirty box with an invalid rectangle (the reversed rectangle).
* Any future drawing will make it valid again, so we won't blend back
* more than we need. */
result->dirty.p.x = rect->q.x;
result->dirty.p.y = rect->q.y;
result->dirty.q.x = rect->p.x;
result->dirty.q.y = rect->p.y;
return result;
}
Commit Message:
CWE ID: CWE-476 | 0 | 19,789 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void FileSystemManagerImpl::Write(
const GURL& file_path,
const std::string& blob_uuid,
int64_t position,
blink::mojom::FileSystemCancellableOperationRequest op_request,
blink::mojom::FileSystemOperationListenerPtr listener) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
FileSystemURL url(context_->CrackURL(file_path));
base::Optional<base::File::Error> opt_error = ValidateFileSystemURL(url);
if (opt_error) {
listener->ErrorOccurred(opt_error.value());
return;
}
if (!security_policy_->CanWriteFileSystemFile(process_id_, url)) {
listener->ErrorOccurred(base::File::FILE_ERROR_SECURITY);
return;
}
std::unique_ptr<storage::BlobDataHandle> blob =
blob_storage_context_->context()->GetBlobDataFromUUID(blob_uuid);
OperationListenerID listener_id = AddOpListener(std::move(listener));
OperationID op_id = operation_runner()->Write(
url, std::move(blob), position,
base::BindRepeating(&FileSystemManagerImpl::DidWrite, GetWeakPtr(),
listener_id));
cancellable_operations_.AddBinding(
std::make_unique<FileSystemCancellableOperationImpl>(op_id, this),
std::move(op_request));
}
Commit Message: Disable FileSystemManager::CreateWriter if WritableFiles isn't enabled.
Bug: 922677
Change-Id: Ib16137cbabb2ec07f1ffc0484722f1d9cc533404
Reviewed-on: https://chromium-review.googlesource.com/c/1416570
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#623552}
CWE ID: CWE-189 | 0 | 11,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: svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)
{
struct svc_pool_map *m = &svc_pool_map;
unsigned int node = m->pool_to[pidx];
/*
* The caller checks for sv_nrpools > 1, which
* implies that we've been initialized.
*/
WARN_ON_ONCE(m->count == 0);
if (m->count == 0)
return;
switch (m->mode) {
case SVC_POOL_PERCPU:
{
set_cpus_allowed_ptr(task, cpumask_of(node));
break;
}
case SVC_POOL_PERNODE:
{
set_cpus_allowed_ptr(task, cpumask_of_node(node));
break;
}
}
}
Commit Message: Merge tag 'nfsd-4.12' of git://linux-nfs.org/~bfields/linux
Pull nfsd updates from Bruce Fields:
"Another RDMA update from Chuck Lever, and a bunch of miscellaneous
bugfixes"
* tag 'nfsd-4.12' of git://linux-nfs.org/~bfields/linux: (26 commits)
nfsd: Fix up the "supattr_exclcreat" attributes
nfsd: encoders mustn't use unitialized values in error cases
nfsd: fix undefined behavior in nfsd4_layout_verify
lockd: fix lockd shutdown race
NFSv4: Fix callback server shutdown
SUNRPC: Refactor svc_set_num_threads()
NFSv4.x/callback: Create the callback service through svc_create_pooled
lockd: remove redundant check on block
svcrdma: Clean out old XDR encoders
svcrdma: Remove the req_map cache
svcrdma: Remove unused RDMA Write completion handler
svcrdma: Reduce size of sge array in struct svc_rdma_op_ctxt
svcrdma: Clean up RPC-over-RDMA backchannel reply processing
svcrdma: Report Write/Reply chunk overruns
svcrdma: Clean up RDMA_ERROR path
svcrdma: Use rdma_rw API in RPC reply path
svcrdma: Introduce local rdma_rw API helpers
svcrdma: Clean up svc_rdma_get_inv_rkey()
svcrdma: Add helper to save pages under I/O
svcrdma: Eliminate RPCRDMA_SQ_DEPTH_MULT
...
CWE ID: CWE-404 | 0 | 3,402 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void GLES2DecoderImpl::DoTexParameterfv(
GLenum target, GLenum pname, const GLfloat* params) {
TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
if (!info) {
SetGLError(GL_INVALID_VALUE, "glTexParameterfv: unknown texture");
return;
}
if (!texture_manager()->SetParameter(
info, pname, static_cast<GLint>(params[0]))) {
SetGLError(GL_INVALID_ENUM, "glTexParameterfv: param GL_INVALID_ENUM");
return;
}
glTexParameterfv(target, pname, params);
}
Commit Message: Always write data to new buffer in SimulateAttrib0
This is to work around linux nvidia driver bug.
TEST=asan
BUG=118970
Review URL: http://codereview.chromium.org/10019003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131538 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: | 0 | 12,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: bool AreSwitchesIdenticalToCurrentCommandLine(
const base::CommandLine& new_cmdline,
const base::CommandLine& active_cmdline,
std::set<base::CommandLine::StringType>* out_difference) {
std::set<base::CommandLine::StringType> new_flags =
ExtractFlagsFromCommandLine(new_cmdline);
std::set<base::CommandLine::StringType> active_flags =
ExtractFlagsFromCommandLine(active_cmdline);
bool result = false;
if (new_flags.size() == active_flags.size()) {
result =
std::equal(new_flags.begin(), new_flags.end(), active_flags.begin());
}
if (out_difference && !result) {
std::set_symmetric_difference(
new_flags.begin(),
new_flags.end(),
active_flags.begin(),
active_flags.end(),
std::inserter(*out_difference, out_difference->begin()));
}
return result;
}
Commit Message: Move smart deploy to tristate.
BUG=
Review URL: https://codereview.chromium.org/1149383006
Cr-Commit-Position: refs/heads/master@{#333058}
CWE ID: CWE-399 | 0 | 156 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: qreal OxideQQuickWebView::contentWidth() const {
Q_D(const OxideQQuickWebView);
if (!d->proxy_) {
return 0.f;
}
return const_cast<OxideQQuickWebViewPrivate*>(
d)->proxy_->compositorFrameContentSize().width();
}
Commit Message:
CWE ID: CWE-20 | 0 | 5,540 |
Analyze the following 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 GetExtendedAttributeNames(vector<string>* attr_names) const {
ssize_t len = listxattr(test_file().value().c_str(), nullptr, 0);
if (len <= static_cast<ssize_t>(0))
return;
char* buffer = new char[len];
len = listxattr(test_file().value().c_str(), buffer, len);
*attr_names =
base::SplitString(string(buffer, len), std::string(1, '\0'),
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
delete[] buffer;
}
Commit Message: Disable setxattr calls from quarantine subsystem on Chrome OS.
BUG=733943
Change-Id: I6e743469a8dc91536e180ecf4ff0df0cf427037c
Reviewed-on: https://chromium-review.googlesource.com/c/1380571
Commit-Queue: Will Harris <wfh@chromium.org>
Reviewed-by: Raymes Khoury <raymes@chromium.org>
Reviewed-by: David Trainor <dtrainor@chromium.org>
Reviewed-by: Thiemo Nagel <tnagel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#617961}
CWE ID: CWE-200 | 0 | 23,970 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int set_efer(struct kvm_vcpu *vcpu, u64 efer)
{
u64 old_efer = vcpu->arch.efer;
if (!kvm_valid_efer(vcpu, efer))
return 1;
if (is_paging(vcpu)
&& (vcpu->arch.efer & EFER_LME) != (efer & EFER_LME))
return 1;
efer &= ~EFER_LMA;
efer |= vcpu->arch.efer & EFER_LMA;
kvm_x86_ops->set_efer(vcpu, efer);
/* Update reserved bits */
if ((efer ^ old_efer) & EFER_NX)
kvm_mmu_reset_context(vcpu);
return 0;
}
Commit Message: KVM: x86: Convert vapic synchronization to _cached functions (CVE-2013-6368)
In kvm_lapic_sync_from_vapic and kvm_lapic_sync_to_vapic there is the
potential to corrupt kernel memory if userspace provides an address that
is at the end of a page. This patches concerts those functions to use
kvm_write_guest_cached and kvm_read_guest_cached. It also checks the
vapic_address specified by userspace during ioctl processing and returns
an error to userspace if the address is not a valid GPA.
This is generally not guest triggerable, because the required write is
done by firmware that runs before the guest. Also, it only affects AMD
processors and oldish Intel that do not have the FlexPriority feature
(unless you disable FlexPriority, of course; then newer processors are
also affected).
Fixes: b93463aa59d6 ('KVM: Accelerated apic support')
Reported-by: Andrew Honig <ahonig@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Andrew Honig <ahonig@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
CWE ID: CWE-20 | 0 | 271 |
Analyze the following 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 DateTimeSymbolicFieldElement::optionCount() const
{
return m_symbols.size();
}
Commit Message: INPUT_MULTIPLE_FIELDS_UI: Inconsistent value of aria-valuetext attribute
https://bugs.webkit.org/show_bug.cgi?id=107897
Reviewed by Kentaro Hara.
Source/WebCore:
aria-valuetext and aria-valuenow attributes had inconsistent values in
a case of initial empty state and a case that a user clears a field.
- aria-valuetext attribute should have "blank" message in the initial
empty state.
- aria-valuenow attribute should be removed in the cleared empty state.
Also, we have a bug that aira-valuenow had a symbolic value such as "AM"
"January". It should always have a numeric value according to the
specification.
http://www.w3.org/TR/wai-aria/states_and_properties#aria-valuenow
No new tests. Updates fast/forms/*-multiple-fields/*-multiple-fields-ax-aria-attributes.html.
* html/shadow/DateTimeFieldElement.cpp:
(WebCore::DateTimeFieldElement::DateTimeFieldElement):
Set "blank" message to aria-valuetext attribute.
(WebCore::DateTimeFieldElement::updateVisibleValue):
aria-valuenow attribute should be a numeric value. Apply String::number
to the return value of valueForARIAValueNow.
Remove aria-valuenow attribute if nothing is selected.
(WebCore::DateTimeFieldElement::valueForARIAValueNow):
Added.
* html/shadow/DateTimeFieldElement.h:
(DateTimeFieldElement): Declare valueForARIAValueNow.
* html/shadow/DateTimeSymbolicFieldElement.cpp:
(WebCore::DateTimeSymbolicFieldElement::valueForARIAValueNow):
Added. Returns 1 + internal selection index.
For example, the function returns 1 for January.
* html/shadow/DateTimeSymbolicFieldElement.h:
(DateTimeSymbolicFieldElement): Declare valueForARIAValueNow.
LayoutTests:
Fix existing tests to show aria-valuenow attribute values.
* fast/forms/resources/multiple-fields-ax-aria-attributes.js: Added.
* fast/forms/date-multiple-fields/date-multiple-fields-ax-aria-attributes-expected.txt:
* fast/forms/date-multiple-fields/date-multiple-fields-ax-aria-attributes.html:
Use multiple-fields-ax-aria-attributes.js.
Add tests for initial empty-value state.
* fast/forms/month-multiple-fields/month-multiple-fields-ax-aria-attributes-expected.txt:
* fast/forms/month-multiple-fields/month-multiple-fields-ax-aria-attributes.html:
Use multiple-fields-ax-aria-attributes.js.
* fast/forms/time-multiple-fields/time-multiple-fields-ax-aria-attributes-expected.txt:
* fast/forms/time-multiple-fields/time-multiple-fields-ax-aria-attributes.html:
Use multiple-fields-ax-aria-attributes.js.
git-svn-id: svn://svn.chromium.org/blink/trunk@140803 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-119 | 0 | 18,735 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
u32 mask)
{
struct crypto_alg *alg;
struct crypto_tfm *tfm;
alg = crypto_spawn_alg(spawn);
if (IS_ERR(alg))
return ERR_CAST(alg);
tfm = ERR_PTR(-EINVAL);
if (unlikely((alg->cra_flags ^ type) & mask))
goto out_put_alg;
tfm = __crypto_alloc_tfm(alg, type, mask);
if (IS_ERR(tfm))
goto out_put_alg;
return tfm;
out_put_alg:
crypto_mod_put(alg);
return tfm;
}
Commit Message: crypto: include crypto- module prefix in template
This adds the module loading prefix "crypto-" to the template lookup
as well.
For example, attempting to load 'vfat(blowfish)' via AF_ALG now correctly
includes the "crypto-" prefix at every level, correctly rejecting "vfat":
net-pf-38
algif-hash
crypto-vfat(blowfish)
crypto-vfat(blowfish)-all
crypto-vfat
Reported-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
CWE ID: CWE-264 | 0 | 6,704 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: WORD32 ih264d_video_decode(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op)
{
/* ! */
dec_struct_t * ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle);
WORD32 i4_err_status = 0;
UWORD8 *pu1_buf = NULL;
WORD32 buflen;
UWORD32 u4_max_ofst, u4_length_of_start_code = 0;
UWORD32 bytes_consumed = 0;
UWORD32 cur_slice_is_nonref = 0;
UWORD32 u4_next_is_aud;
UWORD32 u4_first_start_code_found = 0;
WORD32 ret = 0,api_ret_value = IV_SUCCESS;
WORD32 header_data_left = 0,frame_data_left = 0;
UWORD8 *pu1_bitstrm_buf;
ivd_video_decode_ip_t *ps_dec_ip;
ivd_video_decode_op_t *ps_dec_op;
ithread_set_name((void*)"Parse_thread");
ps_dec_ip = (ivd_video_decode_ip_t *)pv_api_ip;
ps_dec_op = (ivd_video_decode_op_t *)pv_api_op;
{
UWORD32 u4_size;
u4_size = ps_dec_op->u4_size;
memset(ps_dec_op, 0, sizeof(ivd_video_decode_op_t));
ps_dec_op->u4_size = u4_size;
}
ps_dec->pv_dec_out = ps_dec_op;
ps_dec->process_called = 1;
if(ps_dec->init_done != 1)
{
return IV_FAIL;
}
/*Data memory barries instruction,so that bitstream write by the application is complete*/
DATA_SYNC();
if(0 == ps_dec->u1_flushfrm)
{
if(ps_dec_ip->pv_stream_buffer == NULL)
{
ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;
ps_dec_op->u4_error_code |= IVD_DEC_FRM_BS_BUF_NULL;
return IV_FAIL;
}
if(ps_dec_ip->u4_num_Bytes <= 0)
{
ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;
ps_dec_op->u4_error_code |= IVD_DEC_NUMBYTES_INV;
return IV_FAIL;
}
}
ps_dec->u1_pic_decode_done = 0;
ps_dec_op->u4_num_bytes_consumed = 0;
ps_dec->ps_out_buffer = NULL;
if(ps_dec_ip->u4_size
>= offsetof(ivd_video_decode_ip_t, s_out_buffer))
ps_dec->ps_out_buffer = &ps_dec_ip->s_out_buffer;
ps_dec->u4_fmt_conv_cur_row = 0;
ps_dec->u4_output_present = 0;
ps_dec->s_disp_op.u4_error_code = 1;
ps_dec->u4_fmt_conv_num_rows = FMT_CONV_NUM_ROWS;
ps_dec->u4_stop_threads = 0;
if(0 == ps_dec->u4_share_disp_buf
&& ps_dec->i4_decode_header == 0)
{
UWORD32 i;
if(ps_dec->ps_out_buffer->u4_num_bufs == 0)
{
ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;
ps_dec_op->u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUFS;
return IV_FAIL;
}
for(i = 0; i < ps_dec->ps_out_buffer->u4_num_bufs; i++)
{
if(ps_dec->ps_out_buffer->pu1_bufs[i] == NULL)
{
ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;
ps_dec_op->u4_error_code |= IVD_DISP_FRM_OP_BUF_NULL;
return IV_FAIL;
}
if(ps_dec->ps_out_buffer->u4_min_out_buf_size[i] == 0)
{
ps_dec_op->u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM;
ps_dec_op->u4_error_code |=
IVD_DISP_FRM_ZERO_OP_BUF_SIZE;
return IV_FAIL;
}
}
}
if(ps_dec->u4_total_frames_decoded >= NUM_FRAMES_LIMIT)
{
ps_dec_op->u4_error_code = ERROR_FRAME_LIMIT_OVER;
return IV_FAIL;
}
/* ! */
ps_dec->u4_ts = ps_dec_ip->u4_ts;
ps_dec_op->u4_error_code = 0;
ps_dec_op->e_pic_type = -1;
ps_dec_op->u4_output_present = 0;
ps_dec_op->u4_frame_decoded_flag = 0;
ps_dec->i4_frametype = -1;
ps_dec->i4_content_type = -1;
ps_dec->u4_slice_start_code_found = 0;
/* In case the deocder is not in flush mode(in shared mode),
then decoder has to pick up a buffer to write current frame.
Check if a frame is available in such cases */
if(ps_dec->u1_init_dec_flag == 1 && ps_dec->u4_share_disp_buf == 1
&& ps_dec->u1_flushfrm == 0)
{
UWORD32 i;
WORD32 disp_avail = 0, free_id;
/* Check if at least one buffer is available with the codec */
/* If not then return to application with error */
for(i = 0; i < ps_dec->u1_pic_bufs; i++)
{
if(0 == ps_dec->u4_disp_buf_mapping[i]
|| 1 == ps_dec->u4_disp_buf_to_be_freed[i])
{
disp_avail = 1;
break;
}
}
if(0 == disp_avail)
{
/* If something is queued for display wait for that buffer to be returned */
ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL;
ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM);
return (IV_FAIL);
}
while(1)
{
pic_buffer_t *ps_pic_buf;
ps_pic_buf = (pic_buffer_t *)ih264_buf_mgr_get_next_free(
(buf_mgr_t *)ps_dec->pv_pic_buf_mgr, &free_id);
if(ps_pic_buf == NULL)
{
UWORD32 i, display_queued = 0;
/* check if any buffer was given for display which is not returned yet */
for(i = 0; i < (MAX_DISP_BUFS_NEW); i++)
{
if(0 != ps_dec->u4_disp_buf_mapping[i])
{
display_queued = 1;
break;
}
}
/* If some buffer is queued for display, then codec has to singal an error and wait
for that buffer to be returned.
If nothing is queued for display then codec has ownership of all display buffers
and it can reuse any of the existing buffers and continue decoding */
if(1 == display_queued)
{
/* If something is queued for display wait for that buffer to be returned */
ps_dec_op->u4_error_code = IVD_DEC_REF_BUF_NULL;
ps_dec_op->u4_error_code |= (1
<< IVD_UNSUPPORTEDPARAM);
return (IV_FAIL);
}
}
else
{
/* If the buffer is with display, then mark it as in use and then look for a buffer again */
if(1 == ps_dec->u4_disp_buf_mapping[free_id])
{
ih264_buf_mgr_set_status(
(buf_mgr_t *)ps_dec->pv_pic_buf_mgr,
free_id,
BUF_MGR_IO);
}
else
{
/**
* Found a free buffer for present call. Release it now.
* Will be again obtained later.
*/
ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr,
free_id,
BUF_MGR_IO);
break;
}
}
}
}
if(ps_dec->u1_flushfrm && ps_dec->u1_init_dec_flag)
{
ih264d_get_next_display_field(ps_dec, ps_dec->ps_out_buffer,
&(ps_dec->s_disp_op));
if(0 == ps_dec->s_disp_op.u4_error_code)
{
ps_dec->u4_fmt_conv_cur_row = 0;
ps_dec->u4_fmt_conv_num_rows = ps_dec->s_disp_frame_info.u4_y_ht;
ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op),
ps_dec->u4_fmt_conv_cur_row,
ps_dec->u4_fmt_conv_num_rows);
ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows;
ps_dec->u4_output_present = 1;
}
ih264d_release_display_field(ps_dec, &(ps_dec->s_disp_op));
ps_dec_op->u4_pic_wd = (UWORD32)ps_dec->u2_disp_width;
ps_dec_op->u4_pic_ht = (UWORD32)ps_dec->u2_disp_height;
ps_dec_op->u4_new_seq = 0;
ps_dec_op->u4_output_present = ps_dec->u4_output_present;
ps_dec_op->u4_progressive_frame_flag =
ps_dec->s_disp_op.u4_progressive_frame_flag;
ps_dec_op->e_output_format =
ps_dec->s_disp_op.e_output_format;
ps_dec_op->s_disp_frm_buf = ps_dec->s_disp_op.s_disp_frm_buf;
ps_dec_op->e4_fld_type = ps_dec->s_disp_op.e4_fld_type;
ps_dec_op->u4_ts = ps_dec->s_disp_op.u4_ts;
ps_dec_op->u4_disp_buf_id = ps_dec->s_disp_op.u4_disp_buf_id;
/*In the case of flush ,since no frame is decoded set pic type as invalid*/
ps_dec_op->u4_is_ref_flag = -1;
ps_dec_op->e_pic_type = IV_NA_FRAME;
ps_dec_op->u4_frame_decoded_flag = 0;
if(0 == ps_dec->s_disp_op.u4_error_code)
{
return (IV_SUCCESS);
}
else
return (IV_FAIL);
}
if(ps_dec->u1_res_changed == 1)
{
/*if resolution has changed and all buffers have been flushed, reset decoder*/
ih264d_init_decoder(ps_dec);
}
ps_dec->u4_prev_nal_skipped = 0;
ps_dec->u2_cur_mb_addr = 0;
ps_dec->u2_total_mbs_coded = 0;
ps_dec->u2_cur_slice_num = 0;
ps_dec->cur_dec_mb_num = 0;
ps_dec->cur_recon_mb_num = 0;
ps_dec->u4_first_slice_in_pic = 2;
ps_dec->u1_first_pb_nal_in_pic = 1;
ps_dec->u1_slice_header_done = 0;
ps_dec->u1_dangling_field = 0;
ps_dec->u4_dec_thread_created = 0;
ps_dec->u4_bs_deblk_thread_created = 0;
ps_dec->u4_cur_bs_mb_num = 0;
ps_dec->u4_start_recon_deblk = 0;
DEBUG_THREADS_PRINTF(" Starting process call\n");
ps_dec->u4_pic_buf_got = 0;
do
{
pu1_buf = (UWORD8*)ps_dec_ip->pv_stream_buffer
+ ps_dec_op->u4_num_bytes_consumed;
u4_max_ofst = ps_dec_ip->u4_num_Bytes
- ps_dec_op->u4_num_bytes_consumed;
pu1_bitstrm_buf = ps_dec->ps_mem_tab[MEM_REC_BITSBUF].pv_base;
u4_next_is_aud = 0;
buflen = ih264d_find_start_code(pu1_buf, 0, u4_max_ofst,
&u4_length_of_start_code,
&u4_next_is_aud);
if(buflen == -1)
buflen = 0;
/* Ignore bytes beyond the allocated size of intermediate buffer */
/* Since 8 bytes are read ahead, ensure 8 bytes are free at the
end of the buffer, which will be memset to 0 after emulation prevention */
buflen = MIN(buflen, (WORD32)(ps_dec->ps_mem_tab[MEM_REC_BITSBUF].u4_mem_size - 8));
bytes_consumed = buflen + u4_length_of_start_code;
ps_dec_op->u4_num_bytes_consumed += bytes_consumed;
if(buflen >= MAX_NAL_UNIT_SIZE)
{
ih264d_fill_output_struct_from_context(ps_dec, ps_dec_op);
H264_DEC_DEBUG_PRINT(
"\nNal Size exceeded %d, Processing Stopped..\n",
MAX_NAL_UNIT_SIZE);
ps_dec->i4_error_code = 1 << IVD_CORRUPTEDDATA;
ps_dec_op->e_pic_type = -1;
/*signal the decode thread*/
ih264d_signal_decode_thread(ps_dec);
/*signal end of frame decode for curren frame*/
if(ps_dec->u4_pic_buf_got == 0)
{
if(ps_dec->i4_header_decoded == 3)
{
ps_dec->u2_total_mbs_coded =
ps_dec->ps_cur_sps->u2_max_mb_addr + 1;
}
/* close deblock thread if it is not closed yet*/
if(ps_dec->u4_num_cores == 3)
{
ih264d_signal_bs_deblk_thread(ps_dec);
}
return IV_FAIL;
}
else
{
ps_dec->u1_pic_decode_done = 1;
continue;
}
}
{
UWORD8 u1_firstbyte, u1_nal_ref_idc;
if(ps_dec->i4_app_skip_mode == IVD_SKIP_B)
{
u1_firstbyte = *(pu1_buf + u4_length_of_start_code);
u1_nal_ref_idc = (UWORD8)(NAL_REF_IDC(u1_firstbyte));
if(u1_nal_ref_idc == 0)
{
/*skip non reference frames*/
cur_slice_is_nonref = 1;
continue;
}
else
{
if(1 == cur_slice_is_nonref)
{
/*We have encountered a referenced frame,return to app*/
ps_dec_op->u4_num_bytes_consumed -=
bytes_consumed;
ps_dec_op->e_pic_type = IV_B_FRAME;
ps_dec_op->u4_error_code =
IVD_DEC_FRM_SKIPPED;
ps_dec_op->u4_error_code |= (1
<< IVD_UNSUPPORTEDPARAM);
ps_dec_op->u4_frame_decoded_flag = 0;
ps_dec_op->u4_size =
sizeof(ivd_video_decode_op_t);
/*signal the decode thread*/
ih264d_signal_decode_thread(ps_dec);
/* close deblock thread if it is not closed yet*/
if(ps_dec->u4_num_cores == 3)
{
ih264d_signal_bs_deblk_thread(ps_dec);
}
return (IV_FAIL);
}
}
}
}
if(buflen)
{
memcpy(pu1_bitstrm_buf, pu1_buf + u4_length_of_start_code,
buflen);
u4_first_start_code_found = 1;
}
else
{
/*start code not found*/
if(u4_first_start_code_found == 0)
{
/*no start codes found in current process call*/
ps_dec->i4_error_code = ERROR_START_CODE_NOT_FOUND;
ps_dec_op->u4_error_code |= 1 << IVD_INSUFFICIENTDATA;
if(ps_dec->u4_pic_buf_got == 0)
{
ih264d_fill_output_struct_from_context(ps_dec,
ps_dec_op);
ps_dec_op->u4_error_code = ps_dec->i4_error_code;
ps_dec_op->u4_frame_decoded_flag = 0;
return (IV_FAIL);
}
else
{
ps_dec->u1_pic_decode_done = 1;
continue;
}
}
else
{
/* a start code has already been found earlier in the same process call*/
frame_data_left = 0;
header_data_left = 0;
continue;
}
}
ps_dec->u4_return_to_app = 0;
ret = ih264d_parse_nal_unit(dec_hdl, ps_dec_op,
pu1_bitstrm_buf, buflen);
if(ret != OK)
{
UWORD32 error = ih264d_map_error(ret);
ps_dec_op->u4_error_code = error | ret;
api_ret_value = IV_FAIL;
if((ret == IVD_RES_CHANGED)
|| (ret == IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED)
|| (ret == ERROR_UNAVAIL_PICBUF_T)
|| (ret == ERROR_UNAVAIL_MVBUF_T)
|| (ret == ERROR_INV_SPS_PPS_T))
{
ps_dec->u4_slice_start_code_found = 0;
break;
}
if((ret == ERROR_INCOMPLETE_FRAME) || (ret == ERROR_DANGLING_FIELD_IN_PIC))
{
ps_dec_op->u4_num_bytes_consumed -= bytes_consumed;
api_ret_value = IV_FAIL;
break;
}
if(ret == ERROR_IN_LAST_SLICE_OF_PIC)
{
api_ret_value = IV_FAIL;
break;
}
}
if(ps_dec->u4_return_to_app)
{
/*We have encountered a referenced frame,return to app*/
ps_dec_op->u4_num_bytes_consumed -= bytes_consumed;
ps_dec_op->u4_error_code = IVD_DEC_FRM_SKIPPED;
ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM);
ps_dec_op->u4_frame_decoded_flag = 0;
ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t);
/*signal the decode thread*/
ih264d_signal_decode_thread(ps_dec);
/* close deblock thread if it is not closed yet*/
if(ps_dec->u4_num_cores == 3)
{
ih264d_signal_bs_deblk_thread(ps_dec);
}
return (IV_FAIL);
}
header_data_left = ((ps_dec->i4_decode_header == 1)
&& (ps_dec->i4_header_decoded != 3)
&& (ps_dec_op->u4_num_bytes_consumed
< ps_dec_ip->u4_num_Bytes));
frame_data_left = (((ps_dec->i4_decode_header == 0)
&& ((ps_dec->u1_pic_decode_done == 0)
|| (u4_next_is_aud == 1)))
&& (ps_dec_op->u4_num_bytes_consumed
< ps_dec_ip->u4_num_Bytes));
}
while(( header_data_left == 1)||(frame_data_left == 1));
if((ps_dec->u4_slice_start_code_found == 1)
&& ps_dec->u2_total_mbs_coded < ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)
{
WORD32 num_mb_skipped;
WORD32 prev_slice_err;
pocstruct_t temp_poc;
WORD32 ret1;
WORD32 ht_in_mbs;
ht_in_mbs = ps_dec->u2_pic_ht >> (4 + ps_dec->ps_cur_slice->u1_field_pic_flag);
num_mb_skipped = (ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)
- ps_dec->u2_total_mbs_coded;
if(ps_dec->u4_first_slice_in_pic && (ps_dec->u4_pic_buf_got == 0))
prev_slice_err = 1;
else
prev_slice_err = 2;
if(ps_dec->u4_first_slice_in_pic && (ps_dec->u2_total_mbs_coded == 0))
prev_slice_err = 1;
ret1 = ih264d_mark_err_slice_skip(ps_dec, num_mb_skipped, ps_dec->u1_nal_unit_type == IDR_SLICE_NAL, ps_dec->ps_cur_slice->u2_frame_num,
&temp_poc, prev_slice_err);
if((ret1 == ERROR_UNAVAIL_PICBUF_T) || (ret1 == ERROR_UNAVAIL_MVBUF_T) ||
(ret1 == ERROR_INV_SPS_PPS_T))
{
ret = ret1;
}
}
if((ret == IVD_RES_CHANGED)
|| (ret == IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED)
|| (ret == ERROR_UNAVAIL_PICBUF_T)
|| (ret == ERROR_UNAVAIL_MVBUF_T)
|| (ret == ERROR_INV_SPS_PPS_T))
{
/* signal the decode thread */
ih264d_signal_decode_thread(ps_dec);
/* close deblock thread if it is not closed yet */
if(ps_dec->u4_num_cores == 3)
{
ih264d_signal_bs_deblk_thread(ps_dec);
}
/* dont consume bitstream for change in resolution case */
if(ret == IVD_RES_CHANGED)
{
ps_dec_op->u4_num_bytes_consumed -= bytes_consumed;
}
return IV_FAIL;
}
if(ps_dec->u1_separate_parse)
{
/* If Format conversion is not complete,
complete it here */
if(ps_dec->u4_num_cores == 2)
{
/*do deblocking of all mbs*/
if((ps_dec->u4_nmb_deblk == 0) &&(ps_dec->u4_start_recon_deblk == 1) && (ps_dec->ps_cur_sps->u1_mb_aff_flag == 0))
{
UWORD32 u4_num_mbs,u4_max_addr;
tfr_ctxt_t s_tfr_ctxt;
tfr_ctxt_t *ps_tfr_cxt = &s_tfr_ctxt;
pad_mgr_t *ps_pad_mgr = &ps_dec->s_pad_mgr;
/*BS is done for all mbs while parsing*/
u4_max_addr = (ps_dec->u2_frm_wd_in_mbs * ps_dec->u2_frm_ht_in_mbs) - 1;
ps_dec->u4_cur_bs_mb_num = u4_max_addr + 1;
ih264d_init_deblk_tfr_ctxt(ps_dec, ps_pad_mgr, ps_tfr_cxt,
ps_dec->u2_frm_wd_in_mbs, 0);
u4_num_mbs = u4_max_addr
- ps_dec->u4_cur_deblk_mb_num + 1;
DEBUG_PERF_PRINTF("mbs left for deblocking= %d \n",u4_num_mbs);
if(u4_num_mbs != 0)
ih264d_check_mb_map_deblk(ps_dec, u4_num_mbs,
ps_tfr_cxt,1);
ps_dec->u4_start_recon_deblk = 0;
}
}
/*signal the decode thread*/
ih264d_signal_decode_thread(ps_dec);
/* close deblock thread if it is not closed yet*/
if(ps_dec->u4_num_cores == 3)
{
ih264d_signal_bs_deblk_thread(ps_dec);
}
}
DATA_SYNC();
if((ps_dec_op->u4_error_code & 0xff)
!= ERROR_DYNAMIC_RESOLUTION_NOT_SUPPORTED)
{
ps_dec_op->u4_pic_wd = (UWORD32)ps_dec->u2_disp_width;
ps_dec_op->u4_pic_ht = (UWORD32)ps_dec->u2_disp_height;
}
if(ps_dec->i4_header_decoded != 3)
{
ps_dec_op->u4_error_code |= (1 << IVD_INSUFFICIENTDATA);
}
if(ps_dec->i4_decode_header == 1 && ps_dec->i4_header_decoded != 3)
{
ps_dec_op->u4_error_code |= (1 << IVD_INSUFFICIENTDATA);
}
if(ps_dec->u4_prev_nal_skipped)
{
/*We have encountered a referenced frame,return to app*/
ps_dec_op->u4_error_code = IVD_DEC_FRM_SKIPPED;
ps_dec_op->u4_error_code |= (1 << IVD_UNSUPPORTEDPARAM);
ps_dec_op->u4_frame_decoded_flag = 0;
ps_dec_op->u4_size = sizeof(ivd_video_decode_op_t);
/* close deblock thread if it is not closed yet*/
if(ps_dec->u4_num_cores == 3)
{
ih264d_signal_bs_deblk_thread(ps_dec);
}
return (IV_FAIL);
}
if((ps_dec->u4_slice_start_code_found == 1)
&& (ERROR_DANGLING_FIELD_IN_PIC != i4_err_status))
{
/*
* For field pictures, set the bottom and top picture decoded u4_flag correctly.
*/
if(ps_dec->ps_cur_slice->u1_field_pic_flag)
{
if(1 == ps_dec->ps_cur_slice->u1_bottom_field_flag)
{
ps_dec->u1_top_bottom_decoded |= BOT_FIELD_ONLY;
}
else
{
ps_dec->u1_top_bottom_decoded |= TOP_FIELD_ONLY;
}
}
/* if new frame in not found (if we are still getting slices from previous frame)
* ih264d_deblock_display is not called. Such frames will not be added to reference /display
*/
if (((ps_dec->ps_dec_err_status->u1_err_flag & REJECT_CUR_PIC) == 0)
&& (ps_dec->u4_pic_buf_got == 1))
{
/* Calling Function to deblock Picture and Display */
ret = ih264d_deblock_display(ps_dec);
}
/*set to complete ,as we dont support partial frame decode*/
if(ps_dec->i4_header_decoded == 3)
{
ps_dec->u2_total_mbs_coded = ps_dec->ps_cur_sps->u2_max_mb_addr + 1;
}
/*Update the i4_frametype at the end of picture*/
if(ps_dec->ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL)
{
ps_dec->i4_frametype = IV_IDR_FRAME;
}
else if(ps_dec->i4_pic_type == B_SLICE)
{
ps_dec->i4_frametype = IV_B_FRAME;
}
else if(ps_dec->i4_pic_type == P_SLICE)
{
ps_dec->i4_frametype = IV_P_FRAME;
}
else if(ps_dec->i4_pic_type == I_SLICE)
{
ps_dec->i4_frametype = IV_I_FRAME;
}
else
{
H264_DEC_DEBUG_PRINT("Shouldn't come here\n");
}
ps_dec->i4_content_type = ps_dec->ps_cur_slice->u1_field_pic_flag;
ps_dec->u4_total_frames_decoded = ps_dec->u4_total_frames_decoded + 2;
ps_dec->u4_total_frames_decoded = ps_dec->u4_total_frames_decoded
- ps_dec->ps_cur_slice->u1_field_pic_flag;
}
/* close deblock thread if it is not closed yet*/
if(ps_dec->u4_num_cores == 3)
{
ih264d_signal_bs_deblk_thread(ps_dec);
}
{
/* In case the decoder is configured to run in low delay mode,
* then get display buffer and then format convert.
* Note in this mode, format conversion does not run paralelly in a thread and adds to the codec cycles
*/
if((0 == ps_dec->u4_num_reorder_frames_at_init)
&& ps_dec->u1_init_dec_flag)
{
ih264d_get_next_display_field(ps_dec, ps_dec->ps_out_buffer,
&(ps_dec->s_disp_op));
if(0 == ps_dec->s_disp_op.u4_error_code)
{
ps_dec->u4_fmt_conv_cur_row = 0;
ps_dec->u4_output_present = 1;
}
}
ih264d_fill_output_struct_from_context(ps_dec, ps_dec_op);
/* If Format conversion is not complete,
complete it here */
if(ps_dec->u4_output_present &&
(ps_dec->u4_fmt_conv_cur_row < ps_dec->s_disp_frame_info.u4_y_ht))
{
ps_dec->u4_fmt_conv_num_rows = ps_dec->s_disp_frame_info.u4_y_ht
- ps_dec->u4_fmt_conv_cur_row;
ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op),
ps_dec->u4_fmt_conv_cur_row,
ps_dec->u4_fmt_conv_num_rows);
ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows;
}
ih264d_release_display_field(ps_dec, &(ps_dec->s_disp_op));
}
if(ps_dec->i4_decode_header == 1 && (ps_dec->i4_header_decoded & 1) == 1)
{
ps_dec_op->u4_progressive_frame_flag = 1;
if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid)))
{
if((0 == ps_dec->ps_sps->u1_frame_mbs_only_flag)
&& (0 == ps_dec->ps_sps->u1_mb_aff_flag))
ps_dec_op->u4_progressive_frame_flag = 0;
}
}
if((TOP_FIELD_ONLY | BOT_FIELD_ONLY) == ps_dec->u1_top_bottom_decoded)
{
ps_dec->u1_top_bottom_decoded = 0;
}
/*--------------------------------------------------------------------*/
/* Do End of Pic processing. */
/* Should be called only if frame was decoded in previous process call*/
/*--------------------------------------------------------------------*/
if(ps_dec->u4_pic_buf_got == 1)
{
if(1 == ps_dec->u1_last_pic_not_decoded)
{
ret = ih264d_end_of_pic_dispbuf_mgr(ps_dec);
if(ret != OK)
return ret;
ret = ih264d_end_of_pic(ps_dec);
if(ret != OK)
return ret;
}
else
{
ret = ih264d_end_of_pic(ps_dec);
if(ret != OK)
return ret;
}
}
/*Data memory barrier instruction,so that yuv write by the library is complete*/
DATA_SYNC();
H264_DEC_DEBUG_PRINT("The num bytes consumed: %d\n",
ps_dec_op->u4_num_bytes_consumed);
return api_ret_value;
}
Commit Message: Decoder: Fixed initialization of first_slice_in_pic
To handle some errors, first_slice_in_pic was being set to 2.
This is now cleaned up and first_slice_in_pic is set to 1 only once per pic.
This will ensure picture level initializations are done only once even in case
of error clips
Bug: 33717589
Bug: 33551775
Bug: 33716442
Bug: 33677995
Change-Id: If341436b3cbaa724017eedddd88c2e6fac36d8ba
CWE ID: CWE-200 | 1 | 9,243 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static CURLcode smtp_state_mail_resp(struct connectdata *conn, int smtpcode,
smtpstate instate)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
(void)instate; /* no use for this yet */
if(smtpcode/100 != 2) {
failf(data, "MAIL failed: %d", smtpcode);
result = CURLE_SEND_ERROR;
}
else
/* Start the RCPT TO command */
result = smtp_perform_rcpt_to(conn);
return result;
}
Commit Message: smtp: use the upload buffer size for scratch buffer malloc
... not the read buffer size, as that can be set smaller and thus cause
a buffer overflow! CVE-2018-0500
Reported-by: Peter Wu
Bug: https://curl.haxx.se/docs/adv_2018-70a2.html
CWE ID: CWE-119 | 0 | 27,035 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
{
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
struct ieee80211_hdr *hdr = (void *)tx->skb->data;
struct ieee80211_supported_band *sband;
u32 len;
struct ieee80211_tx_rate_control txrc;
struct ieee80211_sta_rates *ratetbl = NULL;
bool assoc = false;
memset(&txrc, 0, sizeof(txrc));
sband = tx->local->hw.wiphy->bands[info->band];
len = min_t(u32, tx->skb->len + FCS_LEN,
tx->local->hw.wiphy->frag_threshold);
/* set up the tx rate control struct we give the RC algo */
txrc.hw = &tx->local->hw;
txrc.sband = sband;
txrc.bss_conf = &tx->sdata->vif.bss_conf;
txrc.skb = tx->skb;
txrc.reported_rate.idx = -1;
txrc.rate_idx_mask = tx->sdata->rc_rateidx_mask[info->band];
if (txrc.rate_idx_mask == (1 << sband->n_bitrates) - 1)
txrc.max_rate_idx = -1;
else
txrc.max_rate_idx = fls(txrc.rate_idx_mask) - 1;
if (tx->sdata->rc_has_mcs_mask[info->band])
txrc.rate_idx_mcs_mask =
tx->sdata->rc_rateidx_mcs_mask[info->band];
txrc.bss = (tx->sdata->vif.type == NL80211_IFTYPE_AP ||
tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
tx->sdata->vif.type == NL80211_IFTYPE_ADHOC);
/* set up RTS protection if desired */
if (len > tx->local->hw.wiphy->rts_threshold) {
txrc.rts = true;
}
info->control.use_rts = txrc.rts;
info->control.use_cts_prot = tx->sdata->vif.bss_conf.use_cts_prot;
/*
* Use short preamble if the BSS can handle it, but not for
* management frames unless we know the receiver can handle
* that -- the management frame might be to a station that
* just wants a probe response.
*/
if (tx->sdata->vif.bss_conf.use_short_preamble &&
(ieee80211_is_data(hdr->frame_control) ||
(tx->sta && test_sta_flag(tx->sta, WLAN_STA_SHORT_PREAMBLE))))
txrc.short_preamble = true;
info->control.short_preamble = txrc.short_preamble;
if (tx->sta)
assoc = test_sta_flag(tx->sta, WLAN_STA_ASSOC);
/*
* Lets not bother rate control if we're associated and cannot
* talk to the sta. This should not happen.
*/
if (WARN(test_bit(SCAN_SW_SCANNING, &tx->local->scanning) && assoc &&
!rate_usable_index_exists(sband, &tx->sta->sta),
"%s: Dropped data frame as no usable bitrate found while "
"scanning and associated. Target station: "
"%pM on %d GHz band\n",
tx->sdata->name, hdr->addr1,
info->band ? 5 : 2))
return TX_DROP;
/*
* If we're associated with the sta at this point we know we can at
* least send the frame at the lowest bit rate.
*/
rate_control_get_rate(tx->sdata, tx->sta, &txrc);
if (tx->sta && !info->control.skip_table)
ratetbl = rcu_dereference(tx->sta->sta.rates);
if (unlikely(info->control.rates[0].idx < 0)) {
if (ratetbl) {
struct ieee80211_tx_rate rate = {
.idx = ratetbl->rate[0].idx,
.flags = ratetbl->rate[0].flags,
.count = ratetbl->rate[0].count
};
if (ratetbl->rate[0].idx < 0)
return TX_DROP;
tx->rate = rate;
} else {
return TX_DROP;
}
} else {
tx->rate = info->control.rates[0];
}
if (txrc.reported_rate.idx < 0) {
txrc.reported_rate = tx->rate;
if (tx->sta && ieee80211_is_data(hdr->frame_control))
tx->sta->last_tx_rate = txrc.reported_rate;
} else if (tx->sta)
tx->sta->last_tx_rate = txrc.reported_rate;
if (ratetbl)
return TX_CONTINUE;
if (unlikely(!info->control.rates[0].count))
info->control.rates[0].count = 1;
if (WARN_ON_ONCE((info->control.rates[0].count > 1) &&
(info->flags & IEEE80211_TX_CTL_NO_ACK)))
info->control.rates[0].count = 1;
return TX_CONTINUE;
}
Commit Message: mac80211: fix fragmentation code, particularly for encryption
The "new" fragmentation code (since my rewrite almost 5 years ago)
erroneously sets skb->len rather than using skb_trim() to adjust
the length of the first fragment after copying out all the others.
This leaves the skb tail pointer pointing to after where the data
originally ended, and thus causes the encryption MIC to be written
at that point, rather than where it belongs: immediately after the
data.
The impact of this is that if software encryption is done, then
a) encryption doesn't work for the first fragment, the connection
becomes unusable as the first fragment will never be properly
verified at the receiver, the MIC is practically guaranteed to
be wrong
b) we leak up to 8 bytes of plaintext (!) of the packet out into
the air
This is only mitigated by the fact that many devices are capable
of doing encryption in hardware, in which case this can't happen
as the tail pointer is irrelevant in that case. Additionally,
fragmentation is not used very frequently and would normally have
to be configured manually.
Fix this by using skb_trim() properly.
Cc: stable@vger.kernel.org
Fixes: 2de8e0d999b8 ("mac80211: rewrite fragmentation")
Reported-by: Jouni Malinen <j@w1.fi>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
CWE ID: CWE-200 | 0 | 13,321 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void edge_interrupt_callback(struct urb *urb)
{
struct edgeport_serial *edge_serial = urb->context;
struct usb_serial_port *port;
struct edgeport_port *edge_port;
struct device *dev;
unsigned char *data = urb->transfer_buffer;
int length = urb->actual_length;
int port_number;
int function;
int retval;
__u8 lsr;
__u8 msr;
int status = urb->status;
switch (status) {
case 0:
/* success */
break;
case -ECONNRESET:
case -ENOENT:
case -ESHUTDOWN:
/* this urb is terminated, clean up */
dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n",
__func__, status);
return;
default:
dev_err(&urb->dev->dev, "%s - nonzero urb status received: "
"%d\n", __func__, status);
goto exit;
}
if (!length) {
dev_dbg(&urb->dev->dev, "%s - no data in urb\n", __func__);
goto exit;
}
dev = &edge_serial->serial->dev->dev;
usb_serial_debug_data(dev, __func__, length, data);
if (length != 2) {
dev_dbg(dev, "%s - expecting packet of size 2, got %d\n", __func__, length);
goto exit;
}
port_number = TIUMP_GET_PORT_FROM_CODE(data[0]);
function = TIUMP_GET_FUNC_FROM_CODE(data[0]);
dev_dbg(dev, "%s - port_number %d, function %d, info 0x%x\n", __func__,
port_number, function, data[1]);
if (port_number >= edge_serial->serial->num_ports) {
dev_err(dev, "bad port number %d\n", port_number);
goto exit;
}
port = edge_serial->serial->port[port_number];
edge_port = usb_get_serial_port_data(port);
if (!edge_port) {
dev_dbg(dev, "%s - edge_port not found\n", __func__);
return;
}
switch (function) {
case TIUMP_INTERRUPT_CODE_LSR:
lsr = map_line_status(data[1]);
if (lsr & UMP_UART_LSR_DATA_MASK) {
/*
* Save the LSR event for bulk read completion routine
*/
dev_dbg(dev, "%s - LSR Event Port %u LSR Status = %02x\n",
__func__, port_number, lsr);
edge_port->lsr_event = 1;
edge_port->lsr_mask = lsr;
} else {
dev_dbg(dev, "%s - ===== Port %d LSR Status = %02x ======\n",
__func__, port_number, lsr);
handle_new_lsr(edge_port, 0, lsr, 0);
}
break;
case TIUMP_INTERRUPT_CODE_MSR: /* MSR */
/* Copy MSR from UMP */
msr = data[1];
dev_dbg(dev, "%s - ===== Port %u MSR Status = %02x ======\n",
__func__, port_number, msr);
handle_new_msr(edge_port, msr);
break;
default:
dev_err(&urb->dev->dev,
"%s - Unknown Interrupt code from UMP %x\n",
__func__, data[1]);
break;
}
exit:
retval = usb_submit_urb(urb, GFP_ATOMIC);
if (retval)
dev_err(&urb->dev->dev,
"%s - usb_submit_urb failed with result %d\n",
__func__, retval);
}
Commit Message: USB: serial: io_ti: fix information leak in completion handler
Add missing sanity check to the bulk-in completion handler to avoid an
integer underflow that can be triggered by a malicious device.
This avoids leaking 128 kB of memory content from after the URB transfer
buffer to user space.
Fixes: 8c209e6782ca ("USB: make actual_length in struct urb field u32")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org> # 2.6.30
Signed-off-by: Johan Hovold <johan@kernel.org>
CWE ID: CWE-191 | 0 | 2,191 |
Analyze the following 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 megasas_ld_get_info_submit(SCSIDevice *sdev, int lun,
MegasasCmd *cmd)
{
struct mfi_ld_info *info = cmd->iov_buf;
size_t dcmd_size = sizeof(struct mfi_ld_info);
uint8_t cdb[6];
SCSIRequest *req;
ssize_t len, resid;
uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (lun & 0xFF);
uint64_t ld_size;
if (!cmd->iov_buf) {
cmd->iov_buf = g_malloc0(dcmd_size);
info = cmd->iov_buf;
megasas_setup_inquiry(cdb, 0x83, sizeof(info->vpd_page83));
req = scsi_req_new(sdev, cmd->index, lun, cdb, cmd);
if (!req) {
trace_megasas_dcmd_req_alloc_failed(cmd->index,
"LD get info vpd inquiry");
g_free(cmd->iov_buf);
cmd->iov_buf = NULL;
return MFI_STAT_FLASH_ALLOC_FAIL;
}
trace_megasas_dcmd_internal_submit(cmd->index,
"LD get info vpd inquiry", lun);
len = scsi_req_enqueue(req);
if (len > 0) {
cmd->iov_size = len;
scsi_req_continue(req);
}
return MFI_STAT_INVALID_STATUS;
}
info->ld_config.params.state = MFI_LD_STATE_OPTIMAL;
info->ld_config.properties.ld.v.target_id = lun;
info->ld_config.params.stripe_size = 3;
info->ld_config.params.num_drives = 1;
info->ld_config.params.is_consistent = 1;
/* Logical device size is in blocks */
blk_get_geometry(sdev->conf.blk, &ld_size);
info->size = cpu_to_le64(ld_size);
memset(info->ld_config.span, 0, sizeof(info->ld_config.span));
info->ld_config.span[0].start_block = 0;
info->ld_config.span[0].num_blocks = info->size;
info->ld_config.span[0].array_ref = cpu_to_le16(sdev_id);
resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg);
g_free(cmd->iov_buf);
cmd->iov_size = dcmd_size - resid;
cmd->iov_buf = NULL;
return MFI_STAT_OK;
}
Commit Message:
CWE ID: CWE-200 | 0 | 23,864 |
Analyze the following 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 longAttrAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
TestObjectV8Internal::longAttrAttributeGetter(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 | 9,804 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: buffer_start_read(struct buffer *buffer)
{
buffer->current = &buffer->first;
buffer->read_count = 0;
}
Commit Message: DO NOT MERGE Update libpng to 1.6.20
BUG:23265085
Change-Id: I85199805636d771f3597b691b63bc0bf46084833
(cherry picked from commit bbe98b40cda082024b669fa508931042eed18f82)
CWE ID: | 0 | 6,331 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: KURL PageSerializer::urlForBlankFrame(Frame* frame)
{
HashMap<Frame*, KURL>::iterator iter = m_blankFrameURLs.find(frame);
if (iter != m_blankFrameURLs.end())
return iter->value;
String url = "wyciwyg://frame/" + String::number(m_blankFrameCounter++);
KURL fakeURL(ParsedURLString, url);
m_blankFrameURLs.add(frame, fakeURL);
return fakeURL;
}
Commit Message: Revert 162155 "This review merges the two existing page serializ..."
Change r162155 broke the world even though it was landed using the CQ.
> This review merges the two existing page serializers, WebPageSerializerImpl and
> PageSerializer, into one, PageSerializer. In addition to this it moves all
> the old tests from WebPageNewSerializerTest and WebPageSerializerTest to the
> PageSerializerTest structure and splits out one test for MHTML into a new
> MHTMLTest file.
>
> Saving as 'Webpage, Complete', 'Webpage, HTML Only' and as MHTML when the
> 'Save Page as MHTML' flag is enabled now uses the same code, and should thus
> have the same feature set. Meaning that both modes now should be a bit better.
>
> Detailed list of changes:
>
> - PageSerializerTest: Prepare for more DTD test
> - PageSerializerTest: Remove now unneccesary input image test
> - PageSerializerTest: Remove unused WebPageSerializer/Impl code
> - PageSerializerTest: Move data URI morph test
> - PageSerializerTest: Move data URI test
> - PageSerializerTest: Move namespace test
> - PageSerializerTest: Move SVG Image test
> - MHTMLTest: Move MHTML specific test to own test file
> - PageSerializerTest: Delete duplicate XML header test
> - PageSerializerTest: Move blank frame test
> - PageSerializerTest: Move CSS test
> - PageSerializerTest: Add frameset/frame test
> - PageSerializerTest: Move old iframe test
> - PageSerializerTest: Move old elements test
> - Use PageSerizer for saving web pages
> - PageSerializerTest: Test for rewriting links
> - PageSerializer: Add rewrite link accumulator
> - PageSerializer: Serialize images in iframes/frames src
> - PageSerializer: XHTML fix for meta tags
> - PageSerializer: Add presentation CSS
> - PageSerializer: Rename out parameter
>
> BUG=
> R=abarth@chromium.org
>
> Review URL: https://codereview.chromium.org/68613003
TBR=tiger@opera.com
Review URL: https://codereview.chromium.org/73673003
git-svn-id: svn://svn.chromium.org/blink/trunk@162156 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-119 | 0 | 16,895 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: explicit ScopedTexture2DRestorer(WebGLRenderingContextBase* context)
: context_(context) {}
Commit Message: Reset ES3 pixel pack parameters and PIXEL_PACK_BUFFER binding in DrawingBuffer before ReadPixels() and recover them later.
BUG=740603
TEST=new conformance test
R=kbr@chromium.org,piman@chromium.org
Change-Id: I3ea54c6cc34f34e249f7c8b9f792d93c5e1958f4
Reviewed-on: https://chromium-review.googlesource.com/570840
Reviewed-by: Antoine Labour <piman@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486518}
CWE ID: CWE-119 | 0 | 8,497 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static MagickBooleanType WriteSUNImage(const ImageInfo *image_info,Image *image,
ExceptionInfo *exception)
{
#define RMT_EQUAL_RGB 1
#define RMT_NONE 0
#define RMT_RAW 2
#define RT_STANDARD 1
#define RT_FORMAT_RGB 3
typedef struct _SUNInfo
{
unsigned int
magic,
width,
height,
depth,
length,
type,
maptype,
maplength;
} SUNInfo;
MagickBooleanType
status;
MagickOffsetType
scene;
MagickSizeType
number_pixels;
register const Quantum
*p;
register ssize_t
i,
x;
ssize_t
y;
SUNInfo
sun_info;
/*
Open output image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
scene=0;
do
{
/*
Initialize SUN raster file header.
*/
(void) TransformImageColorspace(image,sRGBColorspace,exception);
sun_info.magic=0x59a66a95;
if ((image->columns != (unsigned int) image->columns) ||
(image->rows != (unsigned int) image->rows))
ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit");
sun_info.width=(unsigned int) image->columns;
sun_info.height=(unsigned int) image->rows;
sun_info.type=(unsigned int)
(image->storage_class == DirectClass ? RT_FORMAT_RGB : RT_STANDARD);
sun_info.maptype=RMT_NONE;
sun_info.maplength=0;
number_pixels=(MagickSizeType) image->columns*image->rows;
if ((4*number_pixels) != (size_t) (4*number_pixels))
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
if (image->storage_class == DirectClass)
{
/*
Full color SUN raster.
*/
sun_info.depth=(unsigned int) image->alpha_trait != UndefinedPixelTrait ?
32U : 24U;
sun_info.length=(unsigned int) ((image->alpha_trait != UndefinedPixelTrait ?
4 : 3)*number_pixels);
sun_info.length+=sun_info.length & 0x01 ? (unsigned int) image->rows :
0;
}
else
if (IsImageMonochrome(image,exception) != MagickFalse)
{
/*
Monochrome SUN raster.
*/
sun_info.depth=1;
sun_info.length=(unsigned int) (((image->columns+7) >> 3)*
image->rows);
sun_info.length+=(unsigned int) (((image->columns/8)+(image->columns %
8 ? 1 : 0)) % 2 ? image->rows : 0);
}
else
{
/*
Colormapped SUN raster.
*/
sun_info.depth=8;
sun_info.length=(unsigned int) number_pixels;
sun_info.length+=(unsigned int) (image->columns & 0x01 ? image->rows :
0);
sun_info.maptype=RMT_EQUAL_RGB;
sun_info.maplength=(unsigned int) (3*image->colors);
}
/*
Write SUN header.
*/
(void) WriteBlobMSBLong(image,sun_info.magic);
(void) WriteBlobMSBLong(image,sun_info.width);
(void) WriteBlobMSBLong(image,sun_info.height);
(void) WriteBlobMSBLong(image,sun_info.depth);
(void) WriteBlobMSBLong(image,sun_info.length);
(void) WriteBlobMSBLong(image,sun_info.type);
(void) WriteBlobMSBLong(image,sun_info.maptype);
(void) WriteBlobMSBLong(image,sun_info.maplength);
/*
Convert MIFF to SUN raster pixels.
*/
x=0;
y=0;
if (image->storage_class == DirectClass)
{
register unsigned char
*q;
size_t
bytes_per_pixel,
length;
unsigned char
*pixels;
/*
Allocate memory for pixels.
*/
bytes_per_pixel=3;
if (image->alpha_trait != UndefinedPixelTrait)
bytes_per_pixel++;
length=image->columns;
pixels=(unsigned char *) AcquireQuantumMemory(length,4*sizeof(*pixels));
if (pixels == (unsigned char *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
/*
Convert DirectClass packet to SUN RGB pixel.
*/
for (y=0; y < (ssize_t) image->rows; y++)
{
p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
q=pixels;
for (x=0; x < (ssize_t) image->columns; x++)
{
if (image->alpha_trait != UndefinedPixelTrait)
*q++=ScaleQuantumToChar(GetPixelAlpha(image,p));
*q++=ScaleQuantumToChar(GetPixelRed(image,p));
*q++=ScaleQuantumToChar(GetPixelGreen(image,p));
*q++=ScaleQuantumToChar(GetPixelBlue(image,p));
p+=GetPixelChannels(image);
}
if (((bytes_per_pixel*image->columns) & 0x01) != 0)
*q++='\0'; /* pad scanline */
(void) WriteBlob(image,(size_t) (q-pixels),pixels);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
}
else
if (IsImageMonochrome(image,exception) != MagickFalse)
{
register unsigned char
bit,
byte;
/*
Convert PseudoClass image to a SUN monochrome image.
*/
(void) SetImageType(image,BilevelType,exception);
for (y=0; y < (ssize_t) image->rows; y++)
{
p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
bit=0;
byte=0;
for (x=0; x < (ssize_t) image->columns; x++)
{
byte<<=1;
if (GetPixelLuma(image,p) < (QuantumRange/2.0))
byte|=0x01;
bit++;
if (bit == 8)
{
(void) WriteBlobByte(image,byte);
bit=0;
byte=0;
}
p+=GetPixelChannels(image);
}
if (bit != 0)
(void) WriteBlobByte(image,(unsigned char) (byte << (8-bit)));
if ((((image->columns/8)+
(image->columns % 8 ? 1 : 0)) % 2) != 0)
(void) WriteBlobByte(image,0); /* pad scanline */
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
}
else
{
/*
Dump colormap to file.
*/
for (i=0; i < (ssize_t) image->colors; i++)
(void) WriteBlobByte(image,ScaleQuantumToChar(
ClampToQuantum(image->colormap[i].red)));
for (i=0; i < (ssize_t) image->colors; i++)
(void) WriteBlobByte(image,ScaleQuantumToChar(
ClampToQuantum(image->colormap[i].green)));
for (i=0; i < (ssize_t) image->colors; i++)
(void) WriteBlobByte(image,ScaleQuantumToChar(
ClampToQuantum(image->colormap[i].blue)));
/*
Convert PseudoClass packet to SUN colormapped pixel.
*/
for (y=0; y < (ssize_t) image->rows; y++)
{
p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
(void) WriteBlobByte(image,(unsigned char)
GetPixelIndex(image,p));
p+=GetPixelChannels(image);
}
if (image->columns & 0x01)
(void) WriteBlobByte(image,0); /* pad scanline */
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
}
if (GetNextImageInList(image) == (Image *) NULL)
break;
image=SyncNextImageInList(image);
status=SetImageProgress(image,SaveImagesTag,scene++,
GetImageListLength(image));
if (status == MagickFalse)
break;
} while (image_info->adjoin != MagickFalse);
(void) CloseBlob(image);
return(MagickTrue);
}
Commit Message: http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=26857
CWE ID: CWE-125 | 0 | 27,465 |
Analyze the following 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 iw_conn_req_handler(struct iw_cm_id *cm_id,
struct iw_cm_event *iw_event)
{
struct rdma_cm_id *new_cm_id;
struct rdma_id_private *listen_id, *conn_id;
struct rdma_cm_event event;
int ret;
struct ib_device_attr attr;
struct sockaddr *laddr = (struct sockaddr *)&iw_event->local_addr;
struct sockaddr *raddr = (struct sockaddr *)&iw_event->remote_addr;
listen_id = cm_id->context;
if (cma_disable_callback(listen_id, RDMA_CM_LISTEN))
return -ECONNABORTED;
/* Create a new RDMA id for the new IW CM ID */
new_cm_id = rdma_create_id(listen_id->id.event_handler,
listen_id->id.context,
RDMA_PS_TCP, IB_QPT_RC);
if (IS_ERR(new_cm_id)) {
ret = -ENOMEM;
goto out;
}
conn_id = container_of(new_cm_id, struct rdma_id_private, id);
mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING);
conn_id->state = RDMA_CM_CONNECT;
ret = rdma_translate_ip(laddr, &conn_id->id.route.addr.dev_addr, NULL);
if (ret) {
mutex_unlock(&conn_id->handler_mutex);
rdma_destroy_id(new_cm_id);
goto out;
}
ret = cma_acquire_dev(conn_id, listen_id);
if (ret) {
mutex_unlock(&conn_id->handler_mutex);
rdma_destroy_id(new_cm_id);
goto out;
}
conn_id->cm_id.iw = cm_id;
cm_id->context = conn_id;
cm_id->cm_handler = cma_iw_handler;
memcpy(cma_src_addr(conn_id), laddr, rdma_addr_size(laddr));
memcpy(cma_dst_addr(conn_id), raddr, rdma_addr_size(raddr));
ret = ib_query_device(conn_id->id.device, &attr);
if (ret) {
mutex_unlock(&conn_id->handler_mutex);
rdma_destroy_id(new_cm_id);
goto out;
}
memset(&event, 0, sizeof event);
event.event = RDMA_CM_EVENT_CONNECT_REQUEST;
event.param.conn.private_data = iw_event->private_data;
event.param.conn.private_data_len = iw_event->private_data_len;
event.param.conn.initiator_depth = iw_event->ird;
event.param.conn.responder_resources = iw_event->ord;
/*
* Protect against the user destroying conn_id from another thread
* until we're done accessing it.
*/
atomic_inc(&conn_id->refcount);
ret = conn_id->id.event_handler(&conn_id->id, &event);
if (ret) {
/* User wants to destroy the CM ID */
conn_id->cm_id.iw = NULL;
cma_exch(conn_id, RDMA_CM_DESTROYING);
mutex_unlock(&conn_id->handler_mutex);
cma_deref_id(conn_id);
rdma_destroy_id(&conn_id->id);
goto out;
}
mutex_unlock(&conn_id->handler_mutex);
cma_deref_id(conn_id);
out:
mutex_unlock(&listen_id->handler_mutex);
return ret;
}
Commit Message: IB/core: Don't resolve passive side RoCE L2 address in CMA REQ handler
The code that resolves the passive side source MAC within the rdma_cm
connection request handler was both redundant and buggy, so remove it.
It was redundant since later, when an RC QP is modified to RTR state,
the resolution will take place in the ib_core module. It was buggy
because this callback also deals with UD SIDR exchange, for which we
incorrectly looked at the REQ member of the CM event and dereferenced
a random value.
Fixes: dd5f03beb4f7 ("IB/core: Ethernet L2 attributes in verbs/cm structures")
Signed-off-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
CWE ID: CWE-20 | 0 | 3,861 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static char *MakeNewMapValue(STRING2PTR value, const char *mapstr)
{
char *ptr;
char *newtitle = NULL;
StrAllocCopy(newtitle, "[");
StrAllocCat(newtitle, mapstr); /* ISMAP or USEMAP */
if (verbose_img && non_empty(value[HTML_IMG_SRC])) {
StrAllocCat(newtitle, ":");
ptr = strrchr(value[HTML_IMG_SRC], '/');
if (!ptr) {
StrAllocCat(newtitle, value[HTML_IMG_SRC]);
} else {
StrAllocCat(newtitle, ptr + 1);
}
}
StrAllocCat(newtitle, "]");
return newtitle;
}
Commit Message: snapshot of project "lynx", label v2-8-9dev_15b
CWE ID: CWE-416 | 0 | 3,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: std::unique_ptr<WebContents> CreateWebContents() {
std::unique_ptr<WebContents> web_contents = CreateTestWebContents();
content::WebContentsTester::For(web_contents.get())
->NavigateAndCommit(GURL("https://www.example.com"));
return web_contents;
}
Commit Message: Connect the LocalDB to TabManager.
Bug: 773382
Change-Id: Iec8fe5226ee175105d51f300f30b4865478ac099
Reviewed-on: https://chromium-review.googlesource.com/1118611
Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572871}
CWE ID: | 1 | 24,619 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void OutOfProcessInstance::LoadUrl(const std::string& url) {
LoadUrlInternal(url, &embed_loader_, &OutOfProcessInstance::DidOpen);
}
Commit Message: Prevent leaking PDF data cross-origin
BUG=520422
Review URL: https://codereview.chromium.org/1311973002
Cr-Commit-Position: refs/heads/master@{#345267}
CWE ID: CWE-20 | 0 | 16,856 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: std::string DownloadItemImpl::DebugString(bool verbose) const {
std::string description =
base::StringPrintf("{ id = %d"
" state = %s",
download_id_.local(),
DebugDownloadStateString(GetState()));
std::string url_list("<none>");
if (!url_chain_.empty()) {
std::vector<GURL>::const_iterator iter = url_chain_.begin();
std::vector<GURL>::const_iterator last = url_chain_.end();
url_list = (*iter).spec();
++iter;
for ( ; verbose && (iter != last); ++iter) {
url_list += " ->\n\t";
const GURL& next_url = *iter;
url_list += next_url.spec();
}
}
if (verbose) {
description += base::StringPrintf(
" db_handle = %" PRId64
" total = %" PRId64
" received = %" PRId64
" reason = %s"
" paused = %c"
" otr = %c"
" safety = %s"
" last_modified = '%s'"
" etag = '%s'"
" url_chain = \n\t\"%s\"\n\t"
" full_path = \"%" PRFilePath "\""
" target_path = \"%" PRFilePath "\"",
GetDbHandle(),
GetTotalBytes(),
GetReceivedBytes(),
InterruptReasonDebugString(last_reason_).c_str(),
IsPaused() ? 'T' : 'F',
IsOtr() ? 'T' : 'F',
DebugSafetyStateString(GetSafetyState()),
GetLastModifiedTime().c_str(),
GetETag().c_str(),
url_list.c_str(),
GetFullPath().value().c_str(),
GetTargetFilePath().value().c_str());
} else {
description += base::StringPrintf(" url = \"%s\"", url_list.c_str());
}
description += " }";
return description;
}
Commit Message: Refactors to simplify rename pathway in DownloadFileManager.
This is https://chromiumcodereview.appspot.com/10668004 / r144817 (reverted
due to CrOS failure) with the completion logic moved to after the
auto-opening. The tests that test the auto-opening (for web store install)
were waiting for download completion to check install, and hence were
failing when completion was moved earlier.
Doing this right would probably require another state (OPENED).
BUG=123998
BUG-134930
R=asanka@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10701040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145157 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-119 | 0 | 28,922 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: incremental_gc_until(mrb_state *mrb, mrb_gc *gc, mrb_gc_state to_state)
{
do {
incremental_gc(mrb, gc, SIZE_MAX);
} while (gc->state != to_state);
}
Commit Message: Clear unused stack region that may refer freed objects; fix #3596
CWE ID: CWE-416 | 0 | 11,464 |
Analyze the following 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 main(int argc, char **argv) {
int i;
int prog_index = -1; // index in argv where the program command starts
int lockfd = -1;
int option_cgroup = 0;
int option_force = 0;
int custom_profile = 0; // custom profile loaded
char *custom_profile_dir = NULL; // custom profile directory
int arg_noprofile = 0; // use default.profile if none other found/specified
#ifdef HAVE_SECCOMP
int highest_errno = errno_highest_nr();
#endif
detect_quiet(argc, argv);
detect_allow_debuggers(argc, argv);
EUID_INIT();
EUID_USER();
if (*argv[0] != '-')
run_symlink(argc, argv);
if (check_namespace_virt() == 0) {
EUID_ROOT();
int rv = check_kernel_procs();
EUID_USER();
if (rv == 0) {
int found = 0;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "--force") == 0 ||
strcmp(argv[i], "--list") == 0 ||
strcmp(argv[i], "--netstats") == 0 ||
strcmp(argv[i], "--tree") == 0 ||
strcmp(argv[i], "--top") == 0 ||
strncmp(argv[i], "--ls=", 5) == 0 ||
strncmp(argv[i], "--get=", 6) == 0 ||
strcmp(argv[i], "--debug-caps") == 0 ||
strcmp(argv[i], "--debug-errnos") == 0 ||
strcmp(argv[i], "--debug-syscalls") == 0 ||
strcmp(argv[i], "--debug-protocols") == 0 ||
strcmp(argv[i], "--help") == 0 ||
strcmp(argv[i], "--version") == 0 ||
strcmp(argv[i], "--overlay-clean") == 0 ||
strncmp(argv[i], "--dns.print=", 12) == 0 ||
strncmp(argv[i], "--bandwidth=", 12) == 0 ||
strncmp(argv[i], "--caps.print=", 13) == 0 ||
strncmp(argv[i], "--cpu.print=", 12) == 0 ||
strncmp(argv[i], "--join=", 7) == 0 ||
strncmp(argv[i], "--join-filesystem=", 18) == 0 ||
strncmp(argv[i], "--join-network=", 15) == 0 ||
strncmp(argv[i], "--fs.print=", 11) == 0 ||
strncmp(argv[i], "--protocol.print=", 17) == 0 ||
strncmp(argv[i], "--seccomp.print", 15) == 0 ||
strncmp(argv[i], "--shutdown=", 11) == 0) {
found = 1;
break;
}
if (strcmp(argv[i], "--") == 0)
break;
if (strncmp(argv[i], "--", 2) != 0)
break;
}
if (found == 0) {
run_no_sandbox(argc, argv);
assert(0);
}
else
option_force = 1;
}
}
EUID_ROOT();
if (geteuid()) {
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "--version") == 0) {
printf("firejail version %s\n", VERSION);
exit(0);
}
if (strcmp(argv[i], "--") == 0)
break;
if (strncmp(argv[i], "--", 2) != 0)
break;
}
exit(1);
}
EUID_USER();
init_cfg(argc, argv);
EUID_ROOT();
fs_build_firejail_dir();
bandwidth_del_run_file(sandbox_pid);
network_del_run_file(sandbox_pid);
delete_name_file(sandbox_pid);
delete_x11_file(sandbox_pid);
EUID_USER();
int parent_sshd = 0;
{
pid_t ppid = getppid();
EUID_ROOT();
char *comm = pid_proc_comm(ppid);
EUID_USER();
if (comm) {
if (strcmp(comm, "sshd") == 0) {
arg_quiet = 1;
parent_sshd = 1;
#ifdef DEBUG_RESTRICTED_SHELL
{EUID_ROOT();
FILE *fp = fopen("/firelog", "w");
if (fp) {
int i;
fprintf(fp, "argc %d: ", argc);
for (i = 0; i < argc; i++)
fprintf(fp, "#%s# ", argv[i]);
fprintf(fp, "\n");
fclose(fp);
}
EUID_USER();}
#endif
if (*argv[0] != '-') {
if (strcmp(argv[1], "-c") == 0 && argc > 2) {
if (strcmp(argv[2], "/usr/lib/openssh/sftp-server") == 0 ||
strncmp(argv[2], "scp ", 4) == 0) {
#ifdef DEBUG_RESTRICTED_SHELL
{EUID_ROOT();
FILE *fp = fopen("/firelog", "a");
if (fp) {
fprintf(fp, "run without a sandbox\n");
fclose(fp);
}
EUID_USER();}
#endif
drop_privs(1);
int rv = system(argv[2]);
exit(rv);
}
}
}
}
free(comm);
}
}
if (*argv[0] == '-' || parent_sshd) {
if (argc == 1)
login_shell = 1;
fullargc = restricted_shell(cfg.username);
if (fullargc) {
#ifdef DEBUG_RESTRICTED_SHELL
{EUID_ROOT();
FILE *fp = fopen("/firelog", "a");
if (fp) {
fprintf(fp, "fullargc %d: ", fullargc);
int i;
for (i = 0; i < fullargc; i++)
fprintf(fp, "#%s# ", fullargv[i]);
fprintf(fp, "\n");
fclose(fp);
}
EUID_USER();}
#endif
int j;
for (i = 1, j = fullargc; i < argc && j < MAX_ARGS; i++, j++, fullargc++)
fullargv[j] = argv[i];
argv = fullargv;
argc = j;
#ifdef DEBUG_RESTRICTED_SHELL
{EUID_ROOT();
FILE *fp = fopen("/firelog", "a");
if (fp) {
fprintf(fp, "argc %d: ", argc);
int i;
for (i = 0; i < argc; i++)
fprintf(fp, "#%s# ", argv[i]);
fprintf(fp, "\n");
fclose(fp);
}
EUID_USER();}
#endif
}
}
else {
check_output(argc, argv); // the function will not return if --output option was found
}
if (checkcfg(CFG_FORCE_NONEWPRIVS))
arg_nonewprivs = 1;
if (arg_allow_debuggers) {
char *cmd = strdup("noblacklist ${PATH}/strace");
if (!cmd)
errExit("strdup");
profile_add(cmd);
}
for (i = 1; i < argc; i++) {
run_cmd_and_exit(i, argc, argv); // will exit if the command is recognized
if (strcmp(argv[i], "--debug") == 0) {
if (!arg_quiet) {
arg_debug = 1;
if (option_force)
printf("Entering sandbox-in-sandbox mode\n");
}
}
else if (strcmp(argv[i], "--debug-check-filename") == 0)
arg_debug_check_filename = 1;
else if (strcmp(argv[i], "--debug-blacklists") == 0)
arg_debug_blacklists = 1;
else if (strcmp(argv[i], "--debug-whitelists") == 0)
arg_debug_whitelists = 1;
else if (strcmp(argv[i], "--quiet") == 0) {
arg_quiet = 1;
arg_debug = 0;
}
else if (strcmp(argv[i], "--force") == 0)
;
else if (strcmp(argv[i], "--allow-debuggers") == 0) {
}
#ifdef HAVE_APPARMOR
else if (strcmp(argv[i], "--apparmor") == 0)
arg_apparmor = 1;
#endif
#ifdef HAVE_SECCOMP
else if (strncmp(argv[i], "--protocol=", 11) == 0) {
if (checkcfg(CFG_SECCOMP)) {
protocol_store(argv[i] + 11);
}
else {
fprintf(stderr, "Error: seccomp feature is disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strcmp(argv[i], "--seccomp") == 0) {
if (checkcfg(CFG_SECCOMP)) {
if (arg_seccomp) {
fprintf(stderr, "Error: seccomp already enabled\n");
exit(1);
}
arg_seccomp = 1;
}
else {
fprintf(stderr, "Error: seccomp feature is disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--seccomp=", 10) == 0) {
if (checkcfg(CFG_SECCOMP)) {
if (arg_seccomp) {
fprintf(stderr, "Error: seccomp already enabled\n");
exit(1);
}
arg_seccomp = 1;
cfg.seccomp_list = strdup(argv[i] + 10);
if (!cfg.seccomp_list)
errExit("strdup");
}
else {
fprintf(stderr, "Error: seccomp feature is disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--seccomp.drop=", 15) == 0) {
if (checkcfg(CFG_SECCOMP)) {
if (arg_seccomp) {
fprintf(stderr, "Error: seccomp already enabled\n");
exit(1);
}
arg_seccomp = 1;
cfg.seccomp_list_drop = strdup(argv[i] + 15);
if (!cfg.seccomp_list_drop)
errExit("strdup");
}
else {
fprintf(stderr, "Error: seccomp feature is disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--seccomp.keep=", 15) == 0) {
if (checkcfg(CFG_SECCOMP)) {
if (arg_seccomp) {
fprintf(stderr, "Error: seccomp already enabled\n");
exit(1);
}
arg_seccomp = 1;
cfg.seccomp_list_keep = strdup(argv[i] + 15);
if (!cfg.seccomp_list_keep)
errExit("strdup");
}
else {
fprintf(stderr, "Error: seccomp feature is disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--seccomp.e", 11) == 0 && strchr(argv[i], '=')) {
if (checkcfg(CFG_SECCOMP)) {
if (arg_seccomp && !cfg.seccomp_list_errno) {
fprintf(stderr, "Error: seccomp already enabled\n");
exit(1);
}
char *eq = strchr(argv[i], '=');
char *errnoname = strndup(argv[i] + 10, eq - (argv[i] + 10));
int nr = errno_find_name(errnoname);
if (nr == -1) {
fprintf(stderr, "Error: unknown errno %s\n", errnoname);
free(errnoname);
exit(1);
}
if (!cfg.seccomp_list_errno)
cfg.seccomp_list_errno = calloc(highest_errno+1, sizeof(cfg.seccomp_list_errno[0]));
if (cfg.seccomp_list_errno[nr]) {
fprintf(stderr, "Error: errno %s already configured\n", errnoname);
free(errnoname);
exit(1);
}
arg_seccomp = 1;
cfg.seccomp_list_errno[nr] = strdup(eq+1);
if (!cfg.seccomp_list_errno[nr])
errExit("strdup");
free(errnoname);
}
else {
fprintf(stderr, "Error: seccomp feature is disabled in Firejail configuration file\n");
exit(1);
}
}
#endif
else if (strcmp(argv[i], "--caps") == 0)
arg_caps_default_filter = 1;
else if (strcmp(argv[i], "--caps.drop=all") == 0)
arg_caps_drop_all = 1;
else if (strncmp(argv[i], "--caps.drop=", 12) == 0) {
arg_caps_drop = 1;
arg_caps_list = strdup(argv[i] + 12);
if (!arg_caps_list)
errExit("strdup");
if (caps_check_list(arg_caps_list, NULL))
return 1;
}
else if (strncmp(argv[i], "--caps.keep=", 12) == 0) {
arg_caps_keep = 1;
arg_caps_list = strdup(argv[i] + 12);
if (!arg_caps_list)
errExit("strdup");
if (caps_check_list(arg_caps_list, NULL))
return 1;
}
else if (strcmp(argv[i], "--trace") == 0)
arg_trace = 1;
else if (strcmp(argv[i], "--tracelog") == 0)
arg_tracelog = 1;
else if (strncmp(argv[i], "--rlimit-nofile=", 16) == 0) {
if (not_unsigned(argv[i] + 16)) {
fprintf(stderr, "Error: invalid rlimt nofile\n");
exit(1);
}
sscanf(argv[i] + 16, "%u", &cfg.rlimit_nofile);
arg_rlimit_nofile = 1;
}
else if (strncmp(argv[i], "--rlimit-nproc=", 15) == 0) {
if (not_unsigned(argv[i] + 15)) {
fprintf(stderr, "Error: invalid rlimt nproc\n");
exit(1);
}
sscanf(argv[i] + 15, "%u", &cfg.rlimit_nproc);
arg_rlimit_nproc = 1;
}
else if (strncmp(argv[i], "--rlimit-fsize=", 15) == 0) {
if (not_unsigned(argv[i] + 15)) {
fprintf(stderr, "Error: invalid rlimt fsize\n");
exit(1);
}
sscanf(argv[i] + 15, "%u", &cfg.rlimit_fsize);
arg_rlimit_fsize = 1;
}
else if (strncmp(argv[i], "--rlimit-sigpending=", 20) == 0) {
if (not_unsigned(argv[i] + 20)) {
fprintf(stderr, "Error: invalid rlimt sigpending\n");
exit(1);
}
sscanf(argv[i] + 20, "%u", &cfg.rlimit_sigpending);
arg_rlimit_sigpending = 1;
}
else if (strncmp(argv[i], "--ipc-namespace", 15) == 0)
arg_ipc = 1;
else if (strncmp(argv[i], "--cpu=", 6) == 0)
read_cpu_list(argv[i] + 6);
else if (strncmp(argv[i], "--nice=", 7) == 0) {
cfg.nice = atoi(argv[i] + 7);
if (getuid() != 0 &&cfg.nice < 0)
cfg.nice = 0;
arg_nice = 1;
}
else if (strncmp(argv[i], "--cgroup=", 9) == 0) {
if (option_cgroup) {
fprintf(stderr, "Error: only a cgroup can be defined\n");
exit(1);
}
option_cgroup = 1;
cfg.cgroup = strdup(argv[i] + 9);
if (!cfg.cgroup)
errExit("strdup");
set_cgroup(cfg.cgroup);
}
else if (strcmp(argv[i], "--allusers") == 0)
arg_allusers = 1;
#ifdef HAVE_BIND
else if (strncmp(argv[i], "--bind=", 7) == 0) {
if (checkcfg(CFG_BIND)) {
char *line;
if (asprintf(&line, "bind %s", argv[i] + 7) == -1)
errExit("asprintf");
profile_check_line(line, 0, NULL); // will exit if something wrong
profile_add(line);
}
else {
fprintf(stderr, "Error: --bind feature is disabled in Firejail configuration file\n");
exit(1);
}
}
#endif
else if (strncmp(argv[i], "--tmpfs=", 8) == 0) {
char *line;
if (asprintf(&line, "tmpfs %s", argv[i] + 8) == -1)
errExit("asprintf");
profile_check_line(line, 0, NULL); // will exit if something wrong
profile_add(line);
}
else if (strncmp(argv[i], "--blacklist=", 12) == 0) {
char *line;
if (asprintf(&line, "blacklist %s", argv[i] + 12) == -1)
errExit("asprintf");
profile_check_line(line, 0, NULL); // will exit if something wrong
profile_add(line);
}
else if (strncmp(argv[i], "--noblacklist=", 14) == 0) {
char *line;
if (asprintf(&line, "noblacklist %s", argv[i] + 14) == -1)
errExit("asprintf");
profile_check_line(line, 0, NULL); // will exit if something wrong
profile_add(line);
}
#ifdef HAVE_WHITELIST
else if (strncmp(argv[i], "--whitelist=", 12) == 0) {
if (checkcfg(CFG_WHITELIST)) {
char *line;
if (asprintf(&line, "whitelist %s", argv[i] + 12) == -1)
errExit("asprintf");
profile_check_line(line, 0, NULL); // will exit if something wrong
profile_add(line);
}
else {
fprintf(stderr, "Error: whitelist feature is disabled in Firejail configuration file\n");
exit(1);
}
}
#endif
else if (strncmp(argv[i], "--read-only=", 12) == 0) {
char *line;
if (asprintf(&line, "read-only %s", argv[i] + 12) == -1)
errExit("asprintf");
profile_check_line(line, 0, NULL); // will exit if something wrong
profile_add(line);
}
else if (strncmp(argv[i], "--noexec=", 9) == 0) {
char *line;
if (asprintf(&line, "noexec %s", argv[i] + 9) == -1)
errExit("asprintf");
profile_check_line(line, 0, NULL); // will exit if something wrong
profile_add(line);
}
else if (strncmp(argv[i], "--read-write=", 13) == 0) {
char *line;
if (asprintf(&line, "read-write %s", argv[i] + 13) == -1)
errExit("asprintf");
profile_check_line(line, 0, NULL); // will exit if something wrong
profile_add(line);
}
#ifdef HAVE_OVERLAYFS
else if (strcmp(argv[i], "--overlay") == 0) {
if (checkcfg(CFG_OVERLAYFS)) {
if (cfg.chrootdir) {
fprintf(stderr, "Error: --overlay and --chroot options are mutually exclusive\n");
exit(1);
}
struct stat s;
if (stat("/proc/sys/kernel/grsecurity", &s) == 0) {
fprintf(stderr, "Error: --overlay option is not available on Grsecurity systems\n");
exit(1);
}
arg_overlay = 1;
arg_overlay_keep = 1;
char *subdirname;
if (asprintf(&subdirname, "%d", getpid()) == -1)
errExit("asprintf");
cfg.overlay_dir = fs_check_overlay_dir(subdirname, arg_overlay_reuse);
free(subdirname);
}
else {
fprintf(stderr, "Error: overlayfs feature is disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--overlay-named=", 16) == 0) {
if (checkcfg(CFG_OVERLAYFS)) {
if (cfg.chrootdir) {
fprintf(stderr, "Error: --overlay and --chroot options are mutually exclusive\n");
exit(1);
}
struct stat s;
if (stat("/proc/sys/kernel/grsecurity", &s) == 0) {
fprintf(stderr, "Error: --overlay option is not available on Grsecurity systems\n");
exit(1);
}
arg_overlay = 1;
arg_overlay_keep = 1;
arg_overlay_reuse = 1;
char *subdirname = argv[i] + 16;
if (subdirname == '\0') {
fprintf(stderr, "Error: invalid overlay option\n");
exit(1);
}
invalid_filename(subdirname);
if (strstr(subdirname, "..") || strstr(subdirname, "/")) {
fprintf(stderr, "Error: invalid overlay name\n");
exit(1);
}
cfg.overlay_dir = fs_check_overlay_dir(subdirname, arg_overlay_reuse);
}
else {
fprintf(stderr, "Error: overlayfs feature is disabled in Firejail configuration file\n");
exit(1);
}
}
#if 0 // disabled for now, it could be used to overwrite system directories
else if (strncmp(argv[i], "--overlay-path=", 15) == 0) {
if (checkcfg(CFG_OVERLAYFS)) {
if (cfg.chrootdir) {
fprintf(stderr, "Error: --overlay and --chroot options are mutually exclusive\n");
exit(1);
}
struct stat s;
if (stat("/proc/sys/kernel/grsecurity", &s) == 0) {
fprintf(stderr, "Error: --overlay option is not available on Grsecurity systems\n");
exit(1);
}
arg_overlay = 1;
arg_overlay_keep = 1;
arg_overlay_reuse = 1;
char *dirname = argv[i] + 15;
if (dirname == '\0') {
fprintf(stderr, "Error: invalid overlay option\n");
exit(1);
}
cfg.overlay_dir = expand_home(dirname, cfg.homedir);
}
else {
fprintf(stderr, "Error: overlayfs feature is disabled in Firejail configuration file\n");
exit(1);
}
}
#endif
else if (strcmp(argv[i], "--overlay-tmpfs") == 0) {
if (checkcfg(CFG_OVERLAYFS)) {
if (cfg.chrootdir) {
fprintf(stderr, "Error: --overlay and --chroot options are mutually exclusive\n");
exit(1);
}
struct stat s;
if (stat("/proc/sys/kernel/grsecurity", &s) == 0) {
fprintf(stderr, "Error: --overlay option is not available on Grsecurity systems\n");
exit(1);
}
arg_overlay = 1;
}
else {
fprintf(stderr, "Error: overlayfs feature is disabled in Firejail configuration file\n");
exit(1);
}
}
#endif
else if (strncmp(argv[i], "--profile=", 10) == 0) {
if (arg_noprofile) {
fprintf(stderr, "Error: --noprofile and --profile options are mutually exclusive\n");
exit(1);
}
char *ppath = expand_home(argv[i] + 10, cfg.homedir);
if (!ppath)
errExit("strdup");
invalid_filename(ppath);
if (is_dir(ppath) || is_link(ppath) || strstr(ppath, "..")) {
fprintf(stderr, "Error: invalid profile file\n");
exit(1);
}
if (access(ppath, R_OK)) {
fprintf(stderr, "Error: cannot access profile file\n");
return 1;
}
profile_read(ppath);
custom_profile = 1;
free(ppath);
}
else if (strncmp(argv[i], "--profile-path=", 15) == 0) {
if (arg_noprofile) {
fprintf(stderr, "Error: --noprofile and --profile-path options are mutually exclusive\n");
exit(1);
}
custom_profile_dir = expand_home(argv[i] + 15, cfg.homedir);
invalid_filename(custom_profile_dir);
if (!is_dir(custom_profile_dir) || is_link(custom_profile_dir) || strstr(custom_profile_dir, "..")) {
fprintf(stderr, "Error: invalid profile path\n");
exit(1);
}
if (access(custom_profile_dir, R_OK)) {
fprintf(stderr, "Error: cannot access profile directory\n");
return 1;
}
}
else if (strcmp(argv[i], "--noprofile") == 0) {
if (custom_profile) {
fprintf(stderr, "Error: --profile and --noprofile options are mutually exclusive\n");
exit(1);
}
arg_noprofile = 1;
}
else if (strncmp(argv[i], "--ignore=", 9) == 0) {
if (custom_profile) {
fprintf(stderr, "Error: please use --profile after --ignore\n");
exit(1);
}
if (*(argv[i] + 9) == '\0') {
fprintf(stderr, "Error: invalid ignore option\n");
exit(1);
}
int j;
for (j = 0; j < MAX_PROFILE_IGNORE; j++) {
if (cfg.profile_ignore[j] == NULL)
break;
}
if (j >= MAX_PROFILE_IGNORE) {
fprintf(stderr, "Error: maximum %d --ignore options are permitted\n", MAX_PROFILE_IGNORE);
exit(1);
}
else
cfg.profile_ignore[j] = argv[i] + 9;
}
#ifdef HAVE_CHROOT
else if (strncmp(argv[i], "--chroot=", 9) == 0) {
if (checkcfg(CFG_CHROOT)) {
if (arg_overlay) {
fprintf(stderr, "Error: --overlay and --chroot options are mutually exclusive\n");
exit(1);
}
struct stat s;
if (stat("/proc/sys/kernel/grsecurity", &s) == 0) {
fprintf(stderr, "Error: --chroot option is not available on Grsecurity systems\n");
exit(1);
}
invalid_filename(argv[i] + 9);
cfg.chrootdir = argv[i] + 9;
if (*cfg.chrootdir == '~') {
char *tmp;
if (asprintf(&tmp, "%s%s", cfg.homedir, cfg.chrootdir + 1) == -1)
errExit("asprintf");
cfg.chrootdir = tmp;
}
if (strstr(cfg.chrootdir, "..") || !is_dir(cfg.chrootdir) || is_link(cfg.chrootdir)) {
fprintf(stderr, "Error: invalid directory %s\n", cfg.chrootdir);
return 1;
}
char *rpath = realpath(cfg.chrootdir, NULL);
if (rpath == NULL || strcmp(rpath, "/") == 0) {
fprintf(stderr, "Error: invalid chroot directory\n");
exit(1);
}
free(rpath);
if (fs_check_chroot_dir(cfg.chrootdir)) {
fprintf(stderr, "Error: invalid chroot\n");
exit(1);
}
}
else {
fprintf(stderr, "Error: --chroot feature is disabled in Firejail configuration file\n");
exit(1);
}
}
#endif
else if (strcmp(argv[i], "--writable-etc") == 0) {
if (cfg.etc_private_keep) {
fprintf(stderr, "Error: --private-etc and --writable-etc are mutually exclusive\n");
exit(1);
}
arg_writable_etc = 1;
}
else if (strcmp(argv[i], "--writable-var") == 0) {
arg_writable_var = 1;
}
else if (strcmp(argv[i], "--private") == 0) {
arg_private = 1;
}
else if (strncmp(argv[i], "--private=", 10) == 0) {
if (cfg.home_private_keep) {
fprintf(stderr, "Error: a private list of files was already defined with --private-home option.\n");
exit(1);
}
cfg.home_private = argv[i] + 10;
if (*cfg.home_private == '\0') {
fprintf(stderr, "Error: invalid private option\n");
exit(1);
}
fs_check_private_dir();
if (strcmp(cfg.home_private, cfg.homedir) == 0) {
free(cfg.home_private);
cfg.home_private = NULL;
}
arg_private = 1;
}
#ifdef HAVE_PRIVATE_HOME
else if (strncmp(argv[i], "--private-home=", 15) == 0) {
if (checkcfg(CFG_PRIVATE_HOME)) {
if (cfg.home_private) {
fprintf(stderr, "Error: a private home directory was already defined with --private option.\n");
exit(1);
}
cfg.home_private_keep = argv[i] + 15;
fs_check_home_list();
arg_private = 1;
}
else {
fprintf(stderr, "Error: --private-home feature is disabled in Firejail configuration file\n");
exit(1);
}
}
#endif
else if (strcmp(argv[i], "--private-dev") == 0) {
arg_private_dev = 1;
}
else if (strncmp(argv[i], "--private-etc=", 14) == 0) {
if (arg_writable_etc) {
fprintf(stderr, "Error: --private-etc and --writable-etc are mutually exclusive\n");
exit(1);
}
cfg.etc_private_keep = argv[i] + 14;
if (*cfg.etc_private_keep == '\0') {
fprintf(stderr, "Error: invalid private-etc option\n");
exit(1);
}
fs_check_etc_list();
arg_private_etc = 1;
}
else if (strncmp(argv[i], "--private-bin=", 14) == 0) {
cfg.bin_private_keep = argv[i] + 14;
if (*cfg.bin_private_keep == '\0') {
fprintf(stderr, "Error: invalid private-bin option\n");
exit(1);
}
arg_private_bin = 1;
fs_check_bin_list();
}
else if (strcmp(argv[i], "--private-tmp") == 0) {
arg_private_tmp = 1;
}
else if (strncmp(argv[i], "--name=", 7) == 0) {
cfg.name = argv[i] + 7;
if (strlen(cfg.name) == 0) {
fprintf(stderr, "Error: please provide a name for sandbox\n");
return 1;
}
}
else if (strncmp(argv[i], "--hostname=", 11) == 0) {
cfg.hostname = argv[i] + 11;
if (strlen(cfg.hostname) == 0) {
fprintf(stderr, "Error: please provide a hostname for sandbox\n");
return 1;
}
}
else if (strcmp(argv[i], "--nogroups") == 0)
arg_nogroups = 1;
#ifdef HAVE_USERNS
else if (strcmp(argv[i], "--noroot") == 0) {
if (checkcfg(CFG_USERNS))
check_user_namespace();
else {
fprintf(stderr, "Error: --noroot feature is disabled in Firejail configuration file\n");
exit(1);
}
}
#endif
else if (strcmp(argv[i], "--nonewprivs") == 0) {
arg_nonewprivs = 1;
}
else if (strncmp(argv[i], "--env=", 6) == 0)
env_store(argv[i] + 6, SETENV);
else if (strncmp(argv[i], "--rmenv=", 8) == 0)
env_store(argv[i] + 8, RMENV);
else if (strcmp(argv[i], "--nosound") == 0) {
arg_nosound = 1;
}
else if (strcmp(argv[i], "--no3d") == 0) {
arg_no3d = 1;
}
#ifdef HAVE_NETWORK
else if (strncmp(argv[i], "--interface=", 12) == 0) {
if (checkcfg(CFG_NETWORK)) {
#ifdef HAVE_NETWORK_RESTRICTED
if (getuid() != 0) {
fprintf(stderr, "Error: --interface is allowed only to root user\n");
exit(1);
}
#endif
if (checkcfg(CFG_RESTRICTED_NETWORK) && getuid() != 0) {
fprintf(stderr, "Error: --interface is allowed only to root user\n");
exit(1);
}
if (arg_nonetwork) {
fprintf(stderr, "Error: --network=none and --interface are incompatible\n");
exit(1);
}
if (strcmp(argv[i] + 12, "lo") == 0) {
fprintf(stderr, "Error: cannot use lo device in --interface command\n");
exit(1);
}
int ifindex = if_nametoindex(argv[i] + 12);
if (ifindex <= 0) {
fprintf(stderr, "Error: cannot find interface %s\n", argv[i] + 12);
exit(1);
}
Interface *intf;
if (cfg.interface0.configured == 0)
intf = &cfg.interface0;
else if (cfg.interface1.configured == 0)
intf = &cfg.interface1;
else if (cfg.interface2.configured == 0)
intf = &cfg.interface2;
else if (cfg.interface3.configured == 0)
intf = &cfg.interface3;
else {
fprintf(stderr, "Error: maximum 4 interfaces are allowed\n");
return 1;
}
intf->dev = strdup(argv[i] + 12);
if (!intf->dev)
errExit("strdup");
if (net_get_if_addr(intf->dev, &intf->ip, &intf->mask, intf->mac, &intf->mtu)) {
if (!arg_quiet || arg_debug)
fprintf(stderr, "Warning: interface %s is not configured\n", intf->dev);
}
intf->configured = 1;
}
else {
fprintf(stderr, "Error: networking features are disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--net=", 6) == 0) {
if (checkcfg(CFG_NETWORK)) {
if (strcmp(argv[i] + 6, "none") == 0) {
arg_nonetwork = 1;
cfg.bridge0.configured = 0;
cfg.bridge1.configured = 0;
cfg.bridge2.configured = 0;
cfg.bridge3.configured = 0;
cfg.interface0.configured = 0;
cfg.interface1.configured = 0;
cfg.interface2.configured = 0;
cfg.interface3.configured = 0;
continue;
}
#ifdef HAVE_NETWORK_RESTRICTED
if (getuid() != 0) {
fprintf(stderr, "Error: only --net=none is allowed to non-root users\n");
exit(1);
}
#endif
if (checkcfg(CFG_RESTRICTED_NETWORK) && getuid() != 0) {
fprintf(stderr, "Error: only --net=none is allowed to non-root users\n");
exit(1);
}
if (strcmp(argv[i] + 6, "lo") == 0) {
fprintf(stderr, "Error: cannot attach to lo device\n");
exit(1);
}
Bridge *br;
if (cfg.bridge0.configured == 0)
br = &cfg.bridge0;
else if (cfg.bridge1.configured == 0)
br = &cfg.bridge1;
else if (cfg.bridge2.configured == 0)
br = &cfg.bridge2;
else if (cfg.bridge3.configured == 0)
br = &cfg.bridge3;
else {
fprintf(stderr, "Error: maximum 4 network devices are allowed\n");
return 1;
}
net_configure_bridge(br, argv[i] + 6);
}
else {
fprintf(stderr, "Error: networking features are disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--veth-name=", 12) == 0) {
if (checkcfg(CFG_NETWORK)) {
Bridge *br = last_bridge_configured();
if (br == NULL) {
fprintf(stderr, "Error: no network device configured\n");
exit(1);
}
br->veth_name = strdup(argv[i] + 12);
if (br->veth_name == NULL)
errExit("strdup");
if (*br->veth_name == '\0') {
fprintf(stderr, "Error: no veth-name configured\n");
exit(1);
}
}
else {
fprintf(stderr, "Error: networking features are disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strcmp(argv[i], "--scan") == 0) {
if (checkcfg(CFG_NETWORK)) {
arg_scan = 1;
}
else {
fprintf(stderr, "Error: networking features are disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--iprange=", 10) == 0) {
if (checkcfg(CFG_NETWORK)) {
Bridge *br = last_bridge_configured();
if (br == NULL) {
fprintf(stderr, "Error: no network device configured\n");
return 1;
}
if (br->iprange_start || br->iprange_end) {
fprintf(stderr, "Error: cannot configure the IP range twice for the same interface\n");
return 1;
}
char *firstip = argv[i] + 10;
char *secondip = firstip;
while (*secondip != '\0') {
if (*secondip == ',')
break;
secondip++;
}
if (*secondip == '\0') {
fprintf(stderr, "Error: invalid IP range\n");
return 1;
}
*secondip = '\0';
secondip++;
if (atoip(firstip, &br->iprange_start) || atoip(secondip, &br->iprange_end) ||
br->iprange_start >= br->iprange_end) {
fprintf(stderr, "Error: invalid IP range\n");
return 1;
}
if (in_netrange(br->iprange_start, br->ip, br->mask) || in_netrange(br->iprange_end, br->ip, br->mask)) {
fprintf(stderr, "Error: IP range addresses not in network range\n");
return 1;
}
}
else {
fprintf(stderr, "Error: networking features are disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--mac=", 6) == 0) {
if (checkcfg(CFG_NETWORK)) {
Bridge *br = last_bridge_configured();
if (br == NULL) {
fprintf(stderr, "Error: no network device configured\n");
exit(1);
}
if (mac_not_zero(br->macsandbox)) {
fprintf(stderr, "Error: cannot configure the MAC address twice for the same interface\n");
exit(1);
}
if (atomac(argv[i] + 6, br->macsandbox)) {
fprintf(stderr, "Error: invalid MAC address\n");
exit(1);
}
}
else {
fprintf(stderr, "Error: networking features are disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--mtu=", 6) == 0) {
if (checkcfg(CFG_NETWORK)) {
Bridge *br = last_bridge_configured();
if (br == NULL) {
fprintf(stderr, "Error: no network device configured\n");
exit(1);
}
if (sscanf(argv[i] + 6, "%d", &br->mtu) != 1 || br->mtu < 576 || br->mtu > 9198) {
fprintf(stderr, "Error: invalid mtu value\n");
exit(1);
}
}
else {
fprintf(stderr, "Error: networking features are disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--ip=", 5) == 0) {
if (checkcfg(CFG_NETWORK)) {
Bridge *br = last_bridge_configured();
if (br == NULL) {
fprintf(stderr, "Error: no network device configured\n");
exit(1);
}
if (br->arg_ip_none || br->ipsandbox) {
fprintf(stderr, "Error: cannot configure the IP address twice for the same interface\n");
exit(1);
}
if (strcmp(argv[i] + 5, "none") == 0)
br->arg_ip_none = 1;
else {
if (atoip(argv[i] + 5, &br->ipsandbox)) {
fprintf(stderr, "Error: invalid IP address\n");
exit(1);
}
}
}
else {
fprintf(stderr, "Error: networking features are disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--ip6=", 6) == 0) {
if (checkcfg(CFG_NETWORK)) {
Bridge *br = last_bridge_configured();
if (br == NULL) {
fprintf(stderr, "Error: no network device configured\n");
exit(1);
}
if (br->arg_ip_none || br->ip6sandbox) {
fprintf(stderr, "Error: cannot configure the IP address twice for the same interface\n");
exit(1);
}
br->ip6sandbox = argv[i] + 6;
}
else {
fprintf(stderr, "Error: networking features are disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--defaultgw=", 12) == 0) {
if (checkcfg(CFG_NETWORK)) {
if (atoip(argv[i] + 12, &cfg.defaultgw)) {
fprintf(stderr, "Error: invalid IP address\n");
exit(1);
}
}
else {
fprintf(stderr, "Error: networking features are disabled in Firejail configuration file\n");
exit(1);
}
}
#endif
else if (strncmp(argv[i], "--dns=", 6) == 0) {
uint32_t dns;
if (atoip(argv[i] + 6, &dns)) {
fprintf(stderr, "Error: invalid DNS server IP address\n");
return 1;
}
if (cfg.dns1 == 0)
cfg.dns1 = dns;
else if (cfg.dns2 == 0)
cfg.dns2 = dns;
else if (cfg.dns3 == 0)
cfg.dns3 = dns;
else {
fprintf(stderr, "Error: up to 3 DNS servers can be specified\n");
return 1;
}
}
#ifdef HAVE_NETWORK
else if (strcmp(argv[i], "--netfilter") == 0) {
#ifdef HAVE_NETWORK_RESTRICTED
if (getuid() != 0) {
fprintf(stderr, "Error: --netfilter is only allowed for root\n");
exit(1);
}
#endif
if (checkcfg(CFG_RESTRICTED_NETWORK) && getuid() != 0) {
fprintf(stderr, "Error: --netfilter is only allowed for root\n");
exit(1);
}
if (checkcfg(CFG_NETWORK)) {
arg_netfilter = 1;
}
else {
fprintf(stderr, "Error: networking features are disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--netfilter=", 12) == 0) {
#ifdef HAVE_NETWORK_RESTRICTED
if (getuid() != 0) {
fprintf(stderr, "Error: --netfilter is only allowed for root\n");
exit(1);
}
#endif
if (checkcfg(CFG_RESTRICTED_NETWORK) && getuid() != 0) {
fprintf(stderr, "Error: --netfilter is only allowed for root\n");
exit(1);
}
if (checkcfg(CFG_NETWORK)) {
arg_netfilter = 1;
arg_netfilter_file = argv[i] + 12;
check_netfilter_file(arg_netfilter_file);
}
else {
fprintf(stderr, "Error: networking features are disabled in Firejail configuration file\n");
exit(1);
}
}
else if (strncmp(argv[i], "--netfilter6=", 13) == 0) {
if (checkcfg(CFG_NETWORK)) {
arg_netfilter6 = 1;
arg_netfilter6_file = argv[i] + 13;
check_netfilter_file(arg_netfilter6_file);
}
else {
fprintf(stderr, "Error: networking features are disabled in Firejail configuration file\n");
exit(1);
}
}
#endif
else if (strcmp(argv[i], "--audit") == 0) {
if (asprintf(&arg_audit_prog, "%s/firejail/faudit", LIBDIR) == -1)
errExit("asprintf");
arg_audit = 1;
}
else if (strncmp(argv[i], "--audit=", 8) == 0) {
if (strlen(argv[i] + 8) == 0) {
fprintf(stderr, "Error: invalid audit program\n");
exit(1);
}
arg_audit_prog = strdup(argv[i] + 8);
if (!arg_audit_prog)
errExit("strdup");
arg_audit = 1;
}
else if (strcmp(argv[i], "--appimage") == 0)
arg_appimage = 1;
else if (strcmp(argv[i], "--csh") == 0) {
if (arg_shell_none) {
fprintf(stderr, "Error: --shell=none was already specified.\n");
return 1;
}
if (cfg.shell) {
fprintf(stderr, "Error: only one default user shell can be specified\n");
return 1;
}
cfg.shell = "/bin/csh";
}
else if (strcmp(argv[i], "--zsh") == 0) {
if (arg_shell_none) {
fprintf(stderr, "Error: --shell=none was already specified.\n");
return 1;
}
if (cfg.shell) {
fprintf(stderr, "Error: only one default user shell can be specified\n");
return 1;
}
cfg.shell = "/bin/zsh";
}
else if (strcmp(argv[i], "--shell=none") == 0) {
arg_shell_none = 1;
if (cfg.shell) {
fprintf(stderr, "Error: a shell was already specified\n");
return 1;
}
}
else if (strncmp(argv[i], "--shell=", 8) == 0) {
if (arg_shell_none) {
fprintf(stderr, "Error: --shell=none was already specified.\n");
return 1;
}
invalid_filename(argv[i] + 8);
if (cfg.shell) {
fprintf(stderr, "Error: only one user shell can be specified\n");
return 1;
}
cfg.shell = argv[i] + 8;
if (is_dir(cfg.shell) || strstr(cfg.shell, "..")) {
fprintf(stderr, "Error: invalid shell\n");
exit(1);
}
if(cfg.chrootdir) {
char *shellpath;
if (asprintf(&shellpath, "%s%s", cfg.chrootdir, cfg.shell) == -1)
errExit("asprintf");
if (access(shellpath, R_OK)) {
fprintf(stderr, "Error: cannot access shell file in chroot\n");
exit(1);
}
free(shellpath);
} else if (access(cfg.shell, R_OK)) {
fprintf(stderr, "Error: cannot access shell file\n");
exit(1);
}
}
else if (strcmp(argv[i], "-c") == 0) {
arg_command = 1;
if (i == (argc - 1)) {
fprintf(stderr, "Error: option -c requires an argument\n");
return 1;
}
}
else if (strcmp(argv[i], "--x11=none") == 0) {
arg_x11_block = 1;
}
#ifdef HAVE_X11
else if (strcmp(argv[i], "--x11=xorg") == 0) {
if (checkcfg(CFG_X11))
arg_x11_xorg = 1;
else {
fprintf(stderr, "Error: --x11 feature is disabled in Firejail configuration file\n");
exit(1);
}
}
#endif
else if (strncmp(argv[i], "--join-or-start=", 16) == 0) {
cfg.name = argv[i] + 16;
if (strlen(cfg.name) == 0) {
fprintf(stderr, "Error: please provide a name for sandbox\n");
return 1;
}
}
else if (strcmp(argv[i], "--") == 0) {
arg_doubledash = 1;
i++;
if (i >= argc) {
fprintf(stderr, "Error: program name not found\n");
exit(1);
}
extract_command_name(i, argv);
prog_index = i;
break;
}
else {
if (*argv[i] == '-') {
fprintf(stderr, "Error: invalid %s command line option\n", argv[i]);
return 1;
}
if (arg_appimage) {
cfg.command_name = strdup(argv[i]);
if (!cfg.command_name)
errExit("strdup");
}
else
extract_command_name(i, argv);
prog_index = i;
break;
}
}
if (prog_index == -1 && arg_shell_none) {
fprintf(stderr, "shell=none configured, but no program specified\n");
exit(1);
}
if (arg_trace && arg_tracelog) {
if (!arg_quiet || arg_debug)
fprintf(stderr, "Warning: --trace and --tracelog are mutually exclusive; --tracelog disabled\n");
}
if (getenv("FIREJAIL_X11"))
mask_x11_abstract_socket = 1;
if (arg_noroot) {
if (arg_overlay) {
fprintf(stderr, "Error: --overlay and --noroot are mutually exclusive.\n");
exit(1);
}
else if (cfg.chrootdir) {
fprintf(stderr, "Error: --chroot and --noroot are mutually exclusive.\n");
exit(1);
}
}
logargs(argc, argv);
if (fullargc) {
char *msg;
if (asprintf(&msg, "user %s entering restricted shell", cfg.username) == -1)
errExit("asprintf");
logmsg(msg);
free(msg);
}
if (!arg_shell_none && !cfg.shell) {
cfg.shell = guess_shell();
if (!cfg.shell) {
fprintf(stderr, "Error: unable to guess your shell, please set explicitly by using --shell option.\n");
exit(1);
}
if (arg_debug)
printf("Autoselecting %s as shell\n", cfg.shell);
}
if (prog_index == -1 && cfg.shell) {
cfg.command_line = cfg.shell;
cfg.window_title = cfg.shell;
cfg.command_name = cfg.shell;
}
else if (arg_appimage) {
if (arg_debug)
printf("Configuring appimage environment\n");
appimage_set(cfg.command_name);
cfg.window_title = "appimage";
}
else {
build_cmdline(&cfg.command_line, &cfg.window_title, argc, argv, prog_index);
}
/* else {
fprintf(stderr, "Error: command must be specified when --shell=none used.\n");
exit(1);
}*/
assert(cfg.command_name);
if (arg_debug)
printf("Command name #%s#\n", cfg.command_name);
if (!arg_noprofile) {
if (!custom_profile) {
char *usercfgdir;
if (asprintf(&usercfgdir, "%s/.config/firejail", cfg.homedir) == -1)
errExit("asprintf");
int rv = profile_find(cfg.command_name, usercfgdir);
free(usercfgdir);
custom_profile = rv;
}
if (!custom_profile) {
int rv;
if (custom_profile_dir)
rv = profile_find(cfg.command_name, custom_profile_dir);
else
rv = profile_find(cfg.command_name, SYSCONFDIR);
custom_profile = rv;
}
}
if (!custom_profile && !arg_noprofile) {
if (cfg.chrootdir) {
if (!arg_quiet || arg_debug)
fprintf(stderr, "Warning: default profile disabled by --chroot option\n");
}
else if (arg_overlay) {
if (!arg_quiet || arg_debug)
fprintf(stderr, "Warning: default profile disabled by --overlay option\n");
}
else {
char *profile_name = DEFAULT_USER_PROFILE;
if (getuid() == 0)
profile_name = DEFAULT_ROOT_PROFILE;
if (arg_debug)
printf("Attempting to find %s.profile...\n", profile_name);
char *usercfgdir;
if (asprintf(&usercfgdir, "%s/.config/firejail", cfg.homedir) == -1)
errExit("asprintf");
custom_profile = profile_find(profile_name, usercfgdir);
free(usercfgdir);
if (!custom_profile) {
if (custom_profile_dir)
custom_profile = profile_find(profile_name, custom_profile_dir);
else
custom_profile = profile_find(profile_name, SYSCONFDIR);
}
if (!custom_profile) {
fprintf(stderr, "Error: no default.profile installed\n");
exit(1);
}
if (custom_profile && !arg_quiet)
printf("\n** Note: you can use --noprofile to disable %s.profile **\n\n", profile_name);
}
}
if (arg_x11_block)
x11_block();
net_check_cfg();
if (any_bridge_configured()) {
EUID_ROOT();
lockfd = open(RUN_NETWORK_LOCK_FILE, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
if (lockfd != -1) {
int rv = fchown(lockfd, 0, 0);
(void) rv;
flock(lockfd, LOCK_EX);
}
check_network(&cfg.bridge0);
check_network(&cfg.bridge1);
check_network(&cfg.bridge2);
check_network(&cfg.bridge3);
network_set_run_file(sandbox_pid);
EUID_USER();
}
if (pipe(parent_to_child_fds) < 0)
errExit("pipe");
if (pipe(child_to_parent_fds) < 0)
errExit("pipe");
if (arg_noroot && arg_overlay) {
if (!arg_quiet || arg_debug)
fprintf(stderr, "Warning: --overlay and --noroot are mutually exclusive, noroot disabled\n");
arg_noroot = 0;
}
else if (arg_noroot && cfg.chrootdir) {
if (!arg_quiet || arg_debug)
fprintf(stderr, "Warning: --chroot and --noroot are mutually exclusive, noroot disabled\n");
arg_noroot = 0;
}
EUID_ROOT();
if (cfg.name)
set_name_file(sandbox_pid);
int display = x11_display();
if (display > 0)
set_x11_file(sandbox_pid, display);
EUID_USER();
int flags = CLONE_NEWNS | CLONE_NEWPID | CLONE_NEWUTS | SIGCHLD;
if (getuid() == 0 || arg_ipc) {
flags |= CLONE_NEWIPC;
if (arg_debug)
printf("Enabling IPC namespace\n");
}
if (any_bridge_configured() || any_interface_configured() || arg_nonetwork) {
flags |= CLONE_NEWNET;
}
else if (arg_debug)
printf("Using the local network stack\n");
EUID_ROOT();
child = clone(sandbox,
child_stack + STACK_SIZE,
flags,
NULL);
if (child == -1)
errExit("clone");
EUID_USER();
if (!arg_command && !arg_quiet) {
printf("Parent pid %u, child pid %u\n", sandbox_pid, child);
if (getuid() == 0) // only for root
printf("The new log directory is /proc/%d/root/var/log\n", child);
}
if (!arg_nonetwork) {
EUID_ROOT();
pid_t net_child = fork();
if (net_child < 0)
errExit("fork");
if (net_child == 0) {
if (setreuid(0, 0))
errExit("setreuid");
if (setregid(0, 0))
errExit("setregid");
network_main(child);
if (arg_debug)
printf("Host network configured\n");
_exit(0);
}
waitpid(net_child, NULL, 0);
EUID_USER();
}
close(parent_to_child_fds[0]);
close(child_to_parent_fds[1]);
notify_other(parent_to_child_fds[1]);
wait_for_other(child_to_parent_fds[0]);
close(child_to_parent_fds[0]);
if (arg_noroot) {
char *map_path;
if (asprintf(&map_path, "/proc/%d/uid_map", child) == -1)
errExit("asprintf");
char *map;
uid_t uid = getuid();
if (asprintf(&map, "%d %d 1", uid, uid) == -1)
errExit("asprintf");
EUID_ROOT();
update_map(map, map_path);
EUID_USER();
free(map);
free(map_path);
if (asprintf(&map_path, "/proc/%d/gid_map", child) == -1)
errExit("asprintf");
char gidmap[1024];
char *ptr = gidmap;
*ptr = '\0';
gid_t gid = getgid();
sprintf(ptr, "%d %d 1\n", gid, gid);
ptr += strlen(ptr);
gid_t g = get_group_id("tty");
if (g) {
sprintf(ptr, "%d %d 1\n", g, g);
ptr += strlen(ptr);
}
g = get_group_id("audio");
if (g) {
sprintf(ptr, "%d %d 1\n", g, g);
ptr += strlen(ptr);
}
g = get_group_id("video");
if (g) {
sprintf(ptr, "%d %d 1\n", g, g);
ptr += strlen(ptr);
}
g = get_group_id("games");
if (g) {
sprintf(ptr, "%d %d 1\n", g, g);
}
EUID_ROOT();
update_map(gidmap, map_path);
EUID_USER();
free(map_path);
}
notify_other(parent_to_child_fds[1]);
close(parent_to_child_fds[1]);
EUID_ROOT();
if (lockfd != -1) {
flock(lockfd, LOCK_UN);
close(lockfd);
}
signal (SIGINT, my_handler);
signal (SIGTERM, my_handler);
EUID_USER();
int status = 0;
waitpid(child, &status, 0);
#ifdef HAVE_SECCOMP
if (cfg.seccomp_list_errno) {
for (i = 0; i < highest_errno; i++)
free(cfg.seccomp_list_errno[i]);
free(cfg.seccomp_list_errno);
}
#endif
if (cfg.profile) {
ProfileEntry *prf = cfg.profile;
while (prf != NULL) {
ProfileEntry *next = prf->next;
free(prf->data);
free(prf->link);
free(prf);
prf = next;
}
}
if (WIFEXITED(status)){
myexit(WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
myexit(WTERMSIG(status));
} else {
myexit(0);
}
return 0;
}
Commit Message: security fix
CWE ID: | 0 | 16,845 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: Response CreateContextErrorResponse() {
return Response::Error("Could not connect to the context");
}
Commit Message: DevTools: speculative fix for crash in NetworkHandler::Disable
This keeps BrowserContext* and StoragePartition* instead of
RenderProcessHost* in an attemp to resolve UAF of RenderProcessHost
upon closure of DevTools front-end.
Bug: 801117, 783067, 780694
Change-Id: I6c2cca60cc0c29f0949d189cf918769059f80c1b
Reviewed-on: https://chromium-review.googlesource.com/876657
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531157}
CWE ID: CWE-20 | 0 | 9,506 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void Document::DidInsertText(const CharacterData& text,
unsigned offset,
unsigned length) {
for (Range* range : ranges_)
range->DidInsertText(text, offset, length);
}
Commit Message: Cleanup and remove dead code in SetFocusedElement
This early-out was added in:
https://crrev.com/ce8ea3446283965c7eabab592cbffe223b1cf2bc
Back then, we applied fragment focus in LayoutUpdated() which could
cause this issue. This got cleaned up in:
https://crrev.com/45236fd563e9df53dc45579be1f3d0b4784885a2
so that focus is no longer applied after layout.
+Cleanup: Goto considered harmful
Bug: 795381
Change-Id: Ifeb4d2e03e872fd48cca6720b1d4de36ad1ecbb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1524417
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#641101}
CWE ID: CWE-416 | 0 | 22,936 |
Analyze the following 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 HttpProxyClientSocket::OnIOComplete(int result) {
DCHECK_NE(STATE_NONE, next_state_);
DCHECK_NE(STATE_DONE, next_state_);
int rv = DoLoop(result);
if (rv != ERR_IO_PENDING)
DoCallback(rv);
}
Commit Message: Sanitize headers in Proxy Authentication Required responses
BUG=431504
Review URL: https://codereview.chromium.org/769043003
Cr-Commit-Position: refs/heads/master@{#310014}
CWE ID: CWE-19 | 0 | 15,877 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: SPL_METHOD(SplHeap, valid)
{
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(intern->heap->count != 0);
}
Commit Message:
CWE ID: | 0 | 25,357 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int ttusbdecfe_dvbt_set_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
u8 b[] = { 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0xff,
0x00, 0x00, 0x00, 0xff };
__be32 freq = htonl(p->frequency / 1000);
memcpy(&b[4], &freq, sizeof (u32));
state->config->send_command(fe, 0x71, sizeof(b), b, NULL, NULL);
return 0;
}
Commit Message: [media] ttusb-dec: buffer overflow in ioctl
We need to add a limit check here so we don't overflow the buffer.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
CWE ID: CWE-119 | 0 | 10,671 |
Analyze the following 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_ret_devn_params(gx_device *pdev)
{
pdf14_device *p14dev = (pdf14_device *)pdev;
return(&(p14dev->devn_params));
}
Commit Message:
CWE ID: CWE-476 | 0 | 19,404 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
{
kvm_x86_ops->vcpu_put(vcpu);
kvm_put_guest_fpu(vcpu);
vcpu->arch.last_host_tsc = rdtsc();
}
Commit Message: KVM: x86: Reload pit counters for all channels when restoring state
Currently if userspace restores the pit counters with a count of 0
on channels 1 or 2 and the guest attempts to read the count on those
channels, then KVM will perform a mod of 0 and crash. This will ensure
that 0 values are converted to 65536 as per the spec.
This is CVE-2015-7513.
Signed-off-by: Andy Honig <ahonig@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
CWE ID: | 0 | 8,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: pmcraid_allocate_host_rrqs(struct pmcraid_instance *pinstance)
{
int i, buffer_size;
buffer_size = HRRQ_ENTRY_SIZE * PMCRAID_MAX_CMD;
for (i = 0; i < pinstance->num_hrrq; i++) {
pinstance->hrrq_start[i] =
pci_alloc_consistent(
pinstance->pdev,
buffer_size,
&(pinstance->hrrq_start_bus_addr[i]));
if (pinstance->hrrq_start[i] == 0) {
pmcraid_err("pci_alloc failed for hrrq vector : %d\n",
i);
pmcraid_release_host_rrqs(pinstance, i);
return -ENOMEM;
}
memset(pinstance->hrrq_start[i], 0, buffer_size);
pinstance->hrrq_curr[i] = pinstance->hrrq_start[i];
pinstance->hrrq_end[i] =
pinstance->hrrq_start[i] + PMCRAID_MAX_CMD - 1;
pinstance->host_toggle_bit[i] = 1;
spin_lock_init(&pinstance->hrrq_lock[i]);
}
return 0;
}
Commit Message: [SCSI] pmcraid: reject negative request size
There's a code path in pmcraid that can be reached via device ioctl that
causes all sorts of ugliness, including heap corruption or triggering the
OOM killer due to consecutive allocation of large numbers of pages.
First, the user can call pmcraid_chr_ioctl(), with a type
PMCRAID_PASSTHROUGH_IOCTL. This calls through to
pmcraid_ioctl_passthrough(). Next, a pmcraid_passthrough_ioctl_buffer
is copied in, and the request_size variable is set to
buffer->ioarcb.data_transfer_length, which is an arbitrary 32-bit
signed value provided by the user. If a negative value is provided
here, bad things can happen. For example,
pmcraid_build_passthrough_ioadls() is called with this request_size,
which immediately calls pmcraid_alloc_sglist() with a negative size.
The resulting math on allocating a scatter list can result in an
overflow in the kzalloc() call (if num_elem is 0, the sglist will be
smaller than expected), or if num_elem is unexpectedly large the
subsequent loop will call alloc_pages() repeatedly, a high number of
pages will be allocated and the OOM killer might be invoked.
It looks like preventing this value from being negative in
pmcraid_ioctl_passthrough() would be sufficient.
Signed-off-by: Dan Rosenberg <drosenberg@vsecurity.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
CWE ID: CWE-189 | 0 | 8,630 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void ip_mc_rejoin_groups(struct in_device *in_dev)
{
#ifdef CONFIG_IP_MULTICAST
struct ip_mc_list *im;
int type;
for_each_pmc_rcu(in_dev, im) {
if (im->multiaddr == IGMP_ALL_HOSTS)
continue;
/* a failover is happening and switches
* must be notified immediately
*/
if (IGMP_V1_SEEN(in_dev))
type = IGMP_HOST_MEMBERSHIP_REPORT;
else if (IGMP_V2_SEEN(in_dev))
type = IGMPV2_HOST_MEMBERSHIP_REPORT;
else
type = IGMPV3_HOST_MEMBERSHIP_REPORT;
igmp_send_report(in_dev, im, type);
}
#endif
}
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 | 28,045 |
Analyze the following 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 Browser::ShouldCloseWindow() {
if (!CanCloseWithInProgressDownloads())
return false;
if (HasCompletedUnloadProcessing())
return IsClosingPermitted();
is_attempting_to_close_browser_ = true;
if (!TabsNeedBeforeUnloadFired())
return IsClosingPermitted();
ProcessPendingTabs();
return false;
}
Commit Message: Implement a bubble that appears at the top of the screen when a tab enters
fullscreen mode via webkitRequestFullScreen(), telling the user how to exit
fullscreen.
This is implemented as an NSView rather than an NSWindow because the floating
chrome that appears in presentation mode should overlap the bubble.
Content-initiated fullscreen mode makes use of 'presentation mode' on the Mac:
the mode in which the UI is hidden, accessible by moving the cursor to the top
of the screen. On Snow Leopard, this mode is synonymous with fullscreen mode.
On Lion, however, fullscreen mode does not imply presentation mode: in
non-presentation fullscreen mode, the chrome is permanently shown. It is
possible to switch between presentation mode and fullscreen mode using the
presentation mode UI control.
When a tab initiates fullscreen mode on Lion, we enter presentation mode if not
in presentation mode already. When the user exits fullscreen mode using Chrome
UI (i.e. keyboard shortcuts, menu items, buttons, switching tabs, etc.) we
return the user to the mode they were in before the tab entered fullscreen.
BUG=14471
TEST=Enter fullscreen mode using webkitRequestFullScreen. You should see a bubble pop down from the top of the screen.
Need to test the Lion logic somehow, with no Lion trybots.
BUG=96883
Original review http://codereview.chromium.org/7890056/
TBR=thakis
Review URL: http://codereview.chromium.org/7920024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101624 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-119 | 0 | 27,316 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void RenderWidgetHostImpl::OnTouchEventAck(
const TouchEventWithLatencyInfo& event,
InputEventAckState ack_result) {
latency_tracker_.OnInputEventAck(event.event, &event.latency);
if (touch_emulator_ &&
touch_emulator_->HandleTouchEventAck(event.event, ack_result)) {
return;
}
if (view_)
view_->ProcessAckedTouchEvent(event, ack_result);
}
Commit Message: Check that RWHI isn't deleted manually while owned by a scoped_ptr in RVHI
BUG=590284
Review URL: https://codereview.chromium.org/1747183002
Cr-Commit-Position: refs/heads/master@{#378844}
CWE ID: | 0 | 6,599 |
Analyze the following 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 gdi_Glyph_New(rdpContext* context, const rdpGlyph* glyph)
{
BYTE* data;
gdiGlyph* gdi_glyph;
if (!context || !glyph)
return FALSE;
gdi_glyph = (gdiGlyph*) glyph;
gdi_glyph->hdc = gdi_GetDC();
if (!gdi_glyph->hdc)
return FALSE;
gdi_glyph->hdc->format = PIXEL_FORMAT_MONO;
data = freerdp_glyph_convert(glyph->cx, glyph->cy, glyph->aj);
if (!data)
{
gdi_DeleteDC(gdi_glyph->hdc);
return FALSE;
}
gdi_glyph->bitmap = gdi_CreateBitmap(glyph->cx, glyph->cy, PIXEL_FORMAT_MONO,
data);
if (!gdi_glyph->bitmap)
{
gdi_DeleteDC(gdi_glyph->hdc);
_aligned_free(data);
return FALSE;
}
gdi_SelectObject(gdi_glyph->hdc, (HGDIOBJECT) gdi_glyph->bitmap);
gdi_glyph->org_bitmap = NULL;
return TRUE;
}
Commit Message: Fixed CVE-2018-8787
Thanks to Eyal Itkin from Check Point Software Technologies.
CWE ID: CWE-190 | 0 | 22,691 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: const WTF::Vector<PopupItem*>& PopupContainer:: popupData() const
{
return m_listBox->items();
}
Commit Message: [REGRESSION] Refreshed autofill popup renders garbage
https://bugs.webkit.org/show_bug.cgi?id=83255
http://code.google.com/p/chromium/issues/detail?id=118374
The code used to update only the PopupContainer coordinates as if they were the coordinates relative
to the root view. Instead, a WebWidget positioned relative to the screen origin holds the PopupContainer,
so it is the WebWidget that should be positioned in PopupContainer::refresh(), and the PopupContainer's
location should be (0, 0) (and their sizes should always be equal).
Reviewed by Kent Tamura.
No new tests, as the popup appearance is not testable in WebKit.
* platform/chromium/PopupContainer.cpp:
(WebCore::PopupContainer::layoutAndCalculateWidgetRect): Variable renamed.
(WebCore::PopupContainer::showPopup): Use m_originalFrameRect rather than frameRect()
for passing into chromeClient.
(WebCore::PopupContainer::showInRect): Set up the correct frameRect() for the container.
(WebCore::PopupContainer::refresh): Resize the container and position the WebWidget correctly.
* platform/chromium/PopupContainer.h:
(PopupContainer):
git-svn-id: svn://svn.chromium.org/blink/trunk@113418 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-119 | 0 | 5,426 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: QuotaTask::~QuotaTask() {
}
Commit Message: Quota double-delete fix
BUG=142310
Review URL: https://chromiumcodereview.appspot.com/10832407
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152532 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: CWE-399 | 0 | 20,671 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: bitgetbit(PG_FUNCTION_ARGS)
{
VarBit *arg1 = PG_GETARG_VARBIT_P(0);
int32 n = PG_GETARG_INT32(1);
int bitlen;
bits8 *p;
int byteNo,
bitNo;
bitlen = VARBITLEN(arg1);
if (n < 0 || n >= bitlen)
ereport(ERROR,
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
errmsg("bit index %d out of valid range (0..%d)",
n, bitlen - 1)));
p = VARBITS(arg1);
byteNo = n / BITS_PER_BYTE;
bitNo = BITS_PER_BYTE - 1 - (n % BITS_PER_BYTE);
if (p[byteNo] & (1 << bitNo))
PG_RETURN_INT32(1);
else
PG_RETURN_INT32(0);
}
Commit Message: Predict integer overflow to avoid buffer overruns.
Several functions, mostly type input functions, calculated an allocation
size such that the calculation wrapped to a small positive value when
arguments implied a sufficiently-large requirement. Writes past the end
of the inadvertent small allocation followed shortly thereafter.
Coverity identified the path_in() vulnerability; code inspection led to
the rest. In passing, add check_stack_depth() to prevent stack overflow
in related functions.
Back-patch to 8.4 (all supported versions). The non-comment hstore
changes touch code that did not exist in 8.4, so that part stops at 9.0.
Noah Misch and Heikki Linnakangas, reviewed by Tom Lane.
Security: CVE-2014-0064
CWE ID: CWE-189 | 0 | 14,752 |
Analyze the following 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 s64 cpu_rt_runtime_read(struct cgroup_subsys_state *css,
struct cftype *cft)
{
return sched_group_rt_runtime(css_tg(css));
}
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 | 18,789 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static long btrfs_ioctl_balance_progress(struct btrfs_root *root,
void __user *arg)
{
struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_ioctl_balance_args *bargs;
int ret = 0;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
mutex_lock(&fs_info->balance_mutex);
if (!fs_info->balance_ctl) {
ret = -ENOTCONN;
goto out;
}
bargs = kzalloc(sizeof(*bargs), GFP_NOFS);
if (!bargs) {
ret = -ENOMEM;
goto out;
}
update_ioctl_balance_args(fs_info, 1, bargs);
if (copy_to_user(arg, bargs, sizeof(*bargs)))
ret = -EFAULT;
kfree(bargs);
out:
mutex_unlock(&fs_info->balance_mutex);
return ret;
}
Commit Message: Btrfs: fix hash overflow handling
The handling for directory crc hash overflows was fairly obscure,
split_leaf returns EOVERFLOW when we try to extend the item and that is
supposed to bubble up to userland. For a while it did so, but along the
way we added better handling of errors and forced the FS readonly if we
hit IO errors during the directory insertion.
Along the way, we started testing only for EEXIST and the EOVERFLOW case
was dropped. The end result is that we may force the FS readonly if we
catch a directory hash bucket overflow.
This fixes a few problem spots. First I add tests for EOVERFLOW in the
places where we can safely just return the error up the chain.
btrfs_rename is harder though, because it tries to insert the new
directory item only after it has already unlinked anything the rename
was going to overwrite. Rather than adding very complex logic, I added
a helper to test for the hash overflow case early while it is still safe
to bail out.
Snapshot and subvolume creation had a similar problem, so they are using
the new helper now too.
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Reported-by: Pascal Junod <pascal@junod.info>
CWE ID: CWE-310 | 0 | 3,892 |
Analyze the following 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 RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) {
host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location_in_dip));
}
Commit Message: Introduce XGetImage() for GrabWindowSnapshot() in ChromeOS.
BUG=119492
TEST=manually done
Review URL: https://chromiumcodereview.appspot.com/10386124
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137556 0039d316-1c4b-4281-b951-d872f2087c98
CWE ID: | 0 | 11,931 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void fanout_release_data(struct packet_fanout *f)
{
switch (f->type) {
case PACKET_FANOUT_CBPF:
case PACKET_FANOUT_EBPF:
__fanout_set_data_bpf(f, NULL);
};
}
Commit Message: packet: fix race condition in packet_set_ring
When packet_set_ring creates a ring buffer it will initialize a
struct timer_list if the packet version is TPACKET_V3. This value
can then be raced by a different thread calling setsockopt to
set the version to TPACKET_V1 before packet_set_ring has finished.
This leads to a use-after-free on a function pointer in the
struct timer_list when the socket is closed as the previously
initialized timer will not be deleted.
The bug is fixed by taking lock_sock(sk) in packet_setsockopt when
changing the packet version while also taking the lock at the start
of packet_set_ring.
Fixes: f6fb8f100b80 ("af-packet: TPACKET_V3 flexible buffer implementation.")
Signed-off-by: Philip Pettersson <philip.pettersson@gmail.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
CWE ID: CWE-416 | 0 | 6,087 |
Analyze the following 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 RenderFrameImpl::MaybeSetDownloadFramePolicy(
bool is_opener_navigation,
const blink::WebURLRequest& request,
const blink::WebSecurityOrigin& current_origin,
bool has_download_sandbox_flag,
bool blocking_downloads_in_sandbox_without_user_activation_enabled,
bool from_ad,
NavigationDownloadPolicy* download_policy) {
if (is_opener_navigation &&
!request.RequestorOrigin().CanAccess(current_origin)) {
download_policy->SetDisallowed(NavigationDownloadType::kOpenerCrossOrigin);
}
if (has_download_sandbox_flag && !request.HasUserGesture()) {
if (blocking_downloads_in_sandbox_without_user_activation_enabled) {
download_policy->SetDisallowed(NavigationDownloadType::kSandboxNoGesture);
} else {
download_policy->SetAllowed(NavigationDownloadType::kSandboxNoGesture);
}
}
if (from_ad) {
if (!request.HasUserGesture()) {
if (base::FeatureList::IsEnabled(
blink::features::
kBlockingDownloadsInAdFrameWithoutUserActivation)) {
download_policy->SetDisallowed(
NavigationDownloadType::kAdFrameNoGesture);
} else {
download_policy->SetAllowed(NavigationDownloadType::kAdFrameNoGesture);
}
} else {
download_policy->SetAllowed(NavigationDownloadType::kAdFrameGesture);
}
}
}
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 | 1,234 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: UINT CSoundFile::PackSample(int &sample, int next)
{
UINT i = 0;
int delta = next - sample;
if (delta >= 0)
{
for (i=0; i<7; i++) if (delta <= (int)CompressionTable[i+1]) break;
} else
{
for (i=8; i<15; i++) if (delta >= (int)CompressionTable[i+1]) break;
}
sample += (int)CompressionTable[i];
return i;
}
Commit Message:
CWE ID: | 0 | 9,447 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: unix_sck_send_ping(hsm_com_client_hdl_t *hdl, int timeout)
{
hsm_com_ping_data_t msg;
memset(&msg,0,sizeof(msg));
msg.header.cmd = HSM_COM_CMD_PING;
msg.header.ver = HSM_COM_VER;
msg.header.trans_id = hdl->trans_id++;
msg.header.payload_len = 0;
if(unix_sck_send_msg(hdl, (char*)&msg, sizeof(msg), (char*)&msg,
sizeof(msg), timeout) != sizeof(msg))
{
close(hdl->client_fd);
hdl->client_state = HSM_COM_C_STATE_IN;
return HSM_COM_BAD;
}
if(msg.header.resp_code == HSM_COM_RESP_OK){
return HSM_COM_OK;
}
return HSM_COM_BAD;
}
Commit Message: Fix scripts and code that use well-known tmp files.
CWE ID: CWE-362 | 0 | 25,403 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void limitedToOnlyAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue);
CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
imp->setAttribute(HTMLNames::limitedtoonlyattributeAttr, cppValue);
}
Commit Message: document.location bindings fix
BUG=352374
R=jochen@chromium.org
Review URL: https://codereview.chromium.org/196343011
git-svn-id: svn://svn.chromium.org/blink/trunk@169176 bbb929c8-8fbe-4397-9dbb-9b2b20218538
CWE ID: CWE-399 | 0 | 14,214 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static void deprecatedAttrAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), UseCounter::Attribute);
TestObjectV8Internal::deprecatedAttrAttributeGetter(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 | 23,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: int get_files_in_directory(const char *path, char ***list) {
_cleanup_closedir_ DIR *d = NULL;
size_t bufsize = 0, n = 0;
_cleanup_strv_free_ char **l = NULL;
assert(path);
/* Returns all files in a directory in *list, and the number
* of files as return value. If list is NULL returns only the
* number. */
d = opendir(path);
if (!d)
return -errno;
for (;;) {
struct dirent *de;
errno = 0;
de = readdir(d);
if (!de && errno != 0)
return -errno;
if (!de)
break;
dirent_ensure_type(d, de);
if (!dirent_is_file(de))
continue;
if (list) {
/* one extra slot is needed for the terminating NULL */
if (!GREEDY_REALLOC(l, bufsize, n + 2))
return -ENOMEM;
l[n] = strdup(de->d_name);
if (!l[n])
return -ENOMEM;
l[++n] = NULL;
} else
n++;
}
if (list) {
*list = l;
l = NULL; /* avoid freeing */
}
return n;
}
Commit Message: util-lib: use MODE_INVALID as invalid value for mode_t everywhere
CWE ID: CWE-264 | 0 | 19,037 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: void smhd_del(GF_Box *s)
{
GF_SoundMediaHeaderBox *ptr = (GF_SoundMediaHeaderBox *)s;
if (ptr == NULL ) return;
gf_free(ptr);
}
Commit Message: fixed 2 possible heap overflows (inc. #1088)
CWE ID: CWE-125 | 0 | 18,087 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: gfx::NativeView WebContentsImpl::GetContentNativeView() {
return view_->GetContentNativeView();
}
Commit Message: Don't call WebContents::DownloadImage() callback if the WebContents were deleted
BUG=583718
Review URL: https://codereview.chromium.org/1685343004
Cr-Commit-Position: refs/heads/master@{#375700}
CWE ID: | 0 | 7,302 |
Analyze the following 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 CrostiniUpgrader::OnUpgrade(CrostiniResult result) {
if (result != CrostiniResult::SUCCESS) {
LOG(ERROR) << "OnUpgrade result " << static_cast<int>(result);
for (auto& observer : upgrader_observers_) {
observer.OnUpgradeFailed();
}
return;
}
for (auto& observer : upgrader_observers_) {
observer.OnUpgradeSucceeded();
}
}
Commit Message: Revert "Creates a WebUI-based Crostini Upgrader"
This reverts commit 29c8bb394dd8b8c03e006efb39ec77fc42f96900.
Reason for revert:
Findit (https://goo.gl/kROfz5) identified CL at revision 717476 as the
culprit for failures in the build cycles as shown on:
https://analysis.chromium.org/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzI5YzhiYjM5NGRkOGI4YzAzZTAwNmVmYjM5ZWM3N2ZjNDJmOTY5MDAM
Sample Failed Build: https://ci.chromium.org/b/8896211200981346592
Sample Failed Step: compile
Original change's description:
> Creates a WebUI-based Crostini Upgrader
>
> The UI is behind the new crostini-webui-upgrader flag
> (currently disabled by default)
>
> The main areas for review are
>
> calamity@:
> html/js - chrome/browser/chromeos/crostini_upgrader/
> mojo and webui glue classes - chrome/browser/ui/webui/crostini_upgrader/
>
> davidmunro@
> crostini business logic - chrome/browser/chromeos/crostini/
>
> In this CL, the optional container backup stage is stubbed, and will be
> in a subsequent CL.
>
> A suite of unit/browser tests are also currently lacking. I intend them for
> follow-up CLs.
>
>
> Bug: 930901
> Change-Id: Ic52c5242e6c57232ffa6be5d6af65aaff5e8f4ff
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900520
> Commit-Queue: Nicholas Verne <nverne@chromium.org>
> Reviewed-by: Sam McNally <sammc@chromium.org>
> Reviewed-by: calamity <calamity@chromium.org>
> Reviewed-by: Ken Rockot <rockot@google.com>
> Cr-Commit-Position: refs/heads/master@{#717476}
Change-Id: I704f549216a7d1dc21942fbf6cf4ab9a1d600380
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 930901
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1928159
Cr-Commit-Position: refs/heads/master@{#717481}
CWE ID: CWE-20 | 0 | 7,598 |
Analyze the following 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 md_geninit(void)
{
pr_debug("md: sizeof(mdp_super_t) = %d\n", (int)sizeof(mdp_super_t));
proc_create("mdstat", S_IRUGO, NULL, &md_seq_fops);
}
Commit Message: md: use kzalloc() when bitmap is disabled
In drivers/md/md.c get_bitmap_file() uses kmalloc() for creating a
mdu_bitmap_file_t called "file".
5769 file = kmalloc(sizeof(*file), GFP_NOIO);
5770 if (!file)
5771 return -ENOMEM;
This structure is copied to user space at the end of the function.
5786 if (err == 0 &&
5787 copy_to_user(arg, file, sizeof(*file)))
5788 err = -EFAULT
But if bitmap is disabled only the first byte of "file" is initialized
with zero, so it's possible to read some bytes (up to 4095) of kernel
space memory from user space. This is an information leak.
5775 /* bitmap disabled, zero the first byte and copy out */
5776 if (!mddev->bitmap_info.file)
5777 file->pathname[0] = '\0';
Signed-off-by: Benjamin Randazzo <benjamin@randazzo.fr>
Signed-off-by: NeilBrown <neilb@suse.com>
CWE ID: CWE-200 | 0 | 10,353 |
Analyze the following code, commit message, and CWE ID. Determine whether it has a vulnerability. If it does, return '1'; if it doesn't, return '0'. | Code: static int __cpuinit sched_cpu_active(struct notifier_block *nfb,
unsigned long action, void *hcpu)
{
switch (action & ~CPU_TASKS_FROZEN) {
case CPU_ONLINE:
case CPU_DOWN_FAILED:
set_cpu_active((long)hcpu, true);
return NOTIFY_OK;
default:
return NOTIFY_DONE;
}
}
Commit Message: Sched: fix skip_clock_update optimization
idle_balance() drops/retakes rq->lock, leaving the previous task
vulnerable to set_tsk_need_resched(). Clear it after we return
from balancing instead, and in setup_thread_stack() as well, so
no successfully descheduled or never scheduled task has it set.
Need resched confused the skip_clock_update logic, which assumes
that the next call to update_rq_clock() will come nearly immediately
after being set. Make the optimization robust against the waking
a sleeper before it sucessfully deschedules case by checking that
the current task has not been dequeued before setting the flag,
since it is that useless clock update we're trying to save, and
clear unconditionally in schedule() proper instead of conditionally
in put_prev_task().
Signed-off-by: Mike Galbraith <efault@gmx.de>
Reported-by: Bjoern B. Brandenburg <bbb.lst@gmail.com>
Tested-by: Yong Zhang <yong.zhang0@gmail.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: stable@kernel.org
LKML-Reference: <1291802742.1417.9.camel@marge.simson.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
CWE ID: | 0 | 27,563 |
Analyze the following 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 RList * get_java_bin_obj_list(RAnal *anal) {
RBinJavaObj *bin_obj = (RBinJavaObj * )get_java_bin_obj(anal);
return r_bin_java_get_bin_obj_list_thru_obj (bin_obj);
}
Commit Message: Fix #10296 - Heap out of bounds read in java_switch_op()
CWE ID: CWE-125 | 0 | 28,351 |
Analyze the following 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 equalizer_set_preset(equalizer_context_t *context, int preset)
{
int i;
ALOGV("%s: preset: %d", __func__, preset);
context->preset = preset;
for (i=0; i<NUM_EQ_BANDS; i++)
context->band_levels[i] =
equalizer_band_presets_level[i + preset * NUM_EQ_BANDS];
offload_eq_set_preset(&(context->offload_eq), preset);
offload_eq_set_bands_level(&(context->offload_eq),
NUM_EQ_BANDS,
equalizer_band_presets_freq,
context->band_levels);
if(context->ctl)
offload_eq_send_params(context->ctl, &context->offload_eq,
OFFLOAD_SEND_EQ_ENABLE_FLAG |
OFFLOAD_SEND_EQ_PRESET);
return 0;
}
Commit Message: Fix security vulnerability: Equalizer command might allow negative indexes
Bug: 32247948
Bug: 32438598
Bug: 32436341
Test: use POC on bug or cts security test
Change-Id: I56a92582687599b5b313dea1abcb8bcb19c7fc0e
(cherry picked from commit 3f37d4ef89f4f0eef9e201c5a91b7b2c77ed1071)
(cherry picked from commit ceb7b2d7a4c4cb8d03f166c61f5c7551c6c760aa)
CWE ID: CWE-200 | 0 | 25,237 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.