code
stringlengths 12
2.05k
| label
int64 0
1
| programming_language
stringclasses 9
values | cwe_id
stringlengths 6
14
| cwe_name
stringlengths 5
103
⌀ | description
stringlengths 36
1.23k
⌀ | url
stringlengths 36
48
⌀ | label_name
stringclasses 2
values |
---|---|---|---|---|---|---|---|
static void __net_init sctp_ctrlsock_exit(struct net *net)
{
/* Free the control endpoint. */
inet_ctl_sock_destroy(net->sctp.ctl_sock);
}
| 1 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
safe
|
static void __init netlink_add_usersock_entry(void)
{
struct listeners *listeners;
int groups = 32;
listeners = kzalloc(sizeof(*listeners) + NLGRPSZ(groups), GFP_KERNEL);
if (!listeners)
panic("netlink_add_usersock_entry: Cannot allocate listeners\n");
netlink_table_grab();
nl_table[NETLINK_USERSOCK].groups = groups;
rcu_assign_pointer(nl_table[NETLINK_USERSOCK].listeners, listeners);
nl_table[NETLINK_USERSOCK].module = THIS_MODULE;
nl_table[NETLINK_USERSOCK].registered = 1;
nl_table[NETLINK_USERSOCK].nl_nonroot = NL_NONROOT_SEND;
netlink_table_ungrab();
}
| 1 |
C
|
CWE-284
|
Improper Access Control
|
The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
|
https://cwe.mitre.org/data/definitions/284.html
|
safe
|
static int crypto_skcipher_init_tfm(struct crypto_tfm *tfm)
{
struct crypto_skcipher *skcipher = __crypto_skcipher_cast(tfm);
struct skcipher_alg *alg = crypto_skcipher_alg(skcipher);
if (tfm->__crt_alg->cra_type == &crypto_blkcipher_type)
return crypto_init_skcipher_ops_blkcipher(tfm);
if (tfm->__crt_alg->cra_type == &crypto_ablkcipher_type ||
tfm->__crt_alg->cra_type == &crypto_givcipher_type)
return crypto_init_skcipher_ops_ablkcipher(tfm);
skcipher->setkey = skcipher_setkey;
skcipher->encrypt = alg->encrypt;
skcipher->decrypt = alg->decrypt;
skcipher->ivsize = alg->ivsize;
skcipher->keysize = alg->max_keysize;
if (alg->exit)
skcipher->base.exit = crypto_skcipher_exit_tfm;
if (alg->init)
return alg->init(skcipher);
return 0;
}
| 1 |
C
|
CWE-476
|
NULL Pointer Dereference
|
A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.
|
https://cwe.mitre.org/data/definitions/476.html
|
safe
|
int _mkp_stage_30(struct plugin *p,
struct client_session *cs,
struct session_request *sr)
{
mk_ptr_t referer;
(void) p;
(void) cs;
PLUGIN_TRACE("[FD %i] Mandril validating URL", cs->socket);
if (mk_security_check_url(sr->uri_processed) < 0) {
PLUGIN_TRACE("[FD %i] Close connection, blocked URL", cs->socket);
mk_api->header_set_http_status(sr, MK_CLIENT_FORBIDDEN);
return MK_PLUGIN_RET_CLOSE_CONX;
}
PLUGIN_TRACE("[FD %d] Mandril validating hotlinking", cs->socket);
referer = mk_api->header_get(&sr->headers_toc, "Referer", strlen("Referer"));
if (mk_security_check_hotlink(sr->uri_processed, sr->host, referer) < 0) {
PLUGIN_TRACE("[FD %i] Close connection, deny hotlinking.", cs->socket);
mk_api->header_set_http_status(sr, MK_CLIENT_FORBIDDEN);
return MK_PLUGIN_RET_CLOSE_CONX;
}
return MK_PLUGIN_RET_NOT_ME;
}
| 1 |
C
|
CWE-264
|
Permissions, Privileges, and Access Controls
|
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
|
https://cwe.mitre.org/data/definitions/264.html
|
safe
|
static void userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,
struct userfaultfd_wait_queue *ewq)
{
struct userfaultfd_ctx *release_new_ctx;
if (WARN_ON_ONCE(current->flags & PF_EXITING))
goto out;
ewq->ctx = ctx;
init_waitqueue_entry(&ewq->wq, current);
release_new_ctx = NULL;
spin_lock(&ctx->event_wqh.lock);
/*
* After the __add_wait_queue the uwq is visible to userland
* through poll/read().
*/
__add_wait_queue(&ctx->event_wqh, &ewq->wq);
for (;;) {
set_current_state(TASK_KILLABLE);
if (ewq->msg.event == 0)
break;
if (READ_ONCE(ctx->released) ||
fatal_signal_pending(current)) {
/*
* &ewq->wq may be queued in fork_event, but
* __remove_wait_queue ignores the head
* parameter. It would be a problem if it
* didn't.
*/
__remove_wait_queue(&ctx->event_wqh, &ewq->wq);
if (ewq->msg.event == UFFD_EVENT_FORK) {
struct userfaultfd_ctx *new;
new = (struct userfaultfd_ctx *)
(unsigned long)
ewq->msg.arg.reserved.reserved1;
release_new_ctx = new;
}
break;
}
spin_unlock(&ctx->event_wqh.lock);
wake_up_poll(&ctx->fd_wqh, EPOLLIN);
schedule();
spin_lock(&ctx->event_wqh.lock);
}
__set_current_state(TASK_RUNNING);
spin_unlock(&ctx->event_wqh.lock);
if (release_new_ctx) {
struct vm_area_struct *vma;
struct mm_struct *mm = release_new_ctx->mm;
/* the various vma->vm_userfaultfd_ctx still points to it */
down_write(&mm->mmap_sem);
/* no task can run (and in turn coredump) yet */
VM_WARN_ON(!mmget_still_valid(mm));
for (vma = mm->mmap; vma; vma = vma->vm_next)
if (vma->vm_userfaultfd_ctx.ctx == release_new_ctx) {
vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
vma->vm_flags &= ~(VM_UFFD_WP | VM_UFFD_MISSING);
}
up_write(&mm->mmap_sem);
userfaultfd_ctx_put(release_new_ctx);
}
/*
* ctx may go away after this if the userfault pseudo fd is
* already released.
*/
out:
WRITE_ONCE(ctx->mmap_changing, false);
userfaultfd_ctx_put(ctx);
}
| 1 |
C
|
CWE-667
|
Improper Locking
|
The software does not properly acquire or release a lock on a resource, leading to unexpected resource state changes and behaviors.
|
https://cwe.mitre.org/data/definitions/667.html
|
safe
|
int fit_check_format(const void *fit, ulong size)
{
int ret;
/* A FIT image must be a valid FDT */
ret = fdt_check_header(fit);
if (ret) {
log_debug("Wrong FIT format: not a flattened device tree (err=%d)\n",
ret);
return -ENOEXEC;
}
if (CONFIG_IS_ENABLED(FIT_FULL_CHECK)) {
/*
* If we are not given the size, make do wtih calculating it.
* This is not as secure, so we should consider a flag to
* control this.
*/
if (size == IMAGE_SIZE_INVAL)
size = fdt_totalsize(fit);
ret = fdt_check_full(fit, size);
if (ret) {
log_debug("FIT check error %d\n", ret);
return -EINVAL;
}
}
/* mandatory / node 'description' property */
if (!fdt_getprop(fit, 0, FIT_DESC_PROP, NULL)) {
log_debug("Wrong FIT format: no description\n");
return -ENOMSG;
}
if (IMAGE_ENABLE_TIMESTAMP) {
/* mandatory / node 'timestamp' property */
if (!fdt_getprop(fit, 0, FIT_TIMESTAMP_PROP, NULL)) {
log_debug("Wrong FIT format: no timestamp\n");
return -ENODATA;
}
}
/* mandatory subimages parent '/images' node */
if (fdt_path_offset(fit, FIT_IMAGES_PATH) < 0) {
log_debug("Wrong FIT format: no images parent node\n");
return -ENOENT;
}
return 0;
}
| 0 |
C
|
NVD-CWE-noinfo
| null | null | null |
vulnerable
|
header_put_le_8byte (SF_PRIVATE *psf, sf_count_t x)
{ psf->header.ptr [psf->header.indx++] = x ;
psf->header.ptr [psf->header.indx++] = (x >> 8) ;
psf->header.ptr [psf->header.indx++] = (x >> 16) ;
psf->header.ptr [psf->header.indx++] = (x >> 24) ;
psf->header.ptr [psf->header.indx++] = (x >> 32) ;
psf->header.ptr [psf->header.indx++] = (x >> 40) ;
psf->header.ptr [psf->header.indx++] = (x >> 48) ;
psf->header.ptr [psf->header.indx++] = (x >> 56) ;
} /* header_put_le_8byte */
| 1 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
safe
|
static BOOL update_read_synchronize(rdpUpdate* update, wStream* s)
{
WINPR_UNUSED(update);
return Stream_SafeSeek(s, 2); /* pad2Octets (2 bytes) */
/**
* The Synchronize Update is an artifact from the
* T.128 protocol and should be ignored.
*/
}
| 1 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
safe
|
static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, const uint8_t *buf, int size)
{
GetBitContext gb;
PutBitContext pb;
MPEG4AudioConfig m4ac;
int off, ret;
ret = init_get_bits8(&gb, buf, size);
if (ret < 0)
return ret;
off = avpriv_mpeg4audio_get_config2(&m4ac, buf, size, 1, s);
if (off < 0)
return off;
skip_bits_long(&gb, off);
adts->objecttype = m4ac.object_type - 1;
adts->sample_rate_index = m4ac.sampling_index;
adts->channel_conf = m4ac.chan_config;
if (adts->objecttype > 3U) {
av_log(s, AV_LOG_ERROR, "MPEG-4 AOT %d is not allowed in ADTS\n", adts->objecttype+1);
return AVERROR_INVALIDDATA;
}
if (adts->sample_rate_index == 15) {
av_log(s, AV_LOG_ERROR, "Escape sample rate index illegal in ADTS\n");
return AVERROR_INVALIDDATA;
}
if (get_bits(&gb, 1)) {
av_log(s, AV_LOG_ERROR, "960/120 MDCT window is not allowed in ADTS\n");
return AVERROR_INVALIDDATA;
}
if (get_bits(&gb, 1)) {
av_log(s, AV_LOG_ERROR, "Scalable configurations are not allowed in ADTS\n");
return AVERROR_INVALIDDATA;
}
if (get_bits(&gb, 1)) {
av_log(s, AV_LOG_ERROR, "Extension flag is not allowed in ADTS\n");
return AVERROR_INVALIDDATA;
}
if (!adts->channel_conf) {
init_put_bits(&pb, adts->pce_data, MAX_PCE_SIZE);
put_bits(&pb, 3, 5); //ID_PCE
adts->pce_size = (ff_copy_pce_data(&pb, &gb) + 3) / 8;
flush_put_bits(&pb);
}
adts->write_adts = 1;
return 0;
}
| 1 |
C
|
CWE-252
|
Unchecked Return Value
|
The software does not check the return value from a method or function, which can prevent it from detecting unexpected states and conditions.
|
https://cwe.mitre.org/data/definitions/252.html
|
safe
|
hugetlbfs_fill_super(struct super_block *sb, void *data, int silent)
{
struct inode * inode;
struct dentry * root;
int ret;
struct hugetlbfs_config config;
struct hugetlbfs_sb_info *sbinfo;
save_mount_options(sb, data);
config.nr_blocks = -1; /* No limit on size by default */
config.nr_inodes = -1; /* No limit on number of inodes by default */
config.uid = current_fsuid();
config.gid = current_fsgid();
config.mode = 0755;
config.hstate = &default_hstate;
ret = hugetlbfs_parse_options(data, &config);
if (ret)
return ret;
sbinfo = kmalloc(sizeof(struct hugetlbfs_sb_info), GFP_KERNEL);
if (!sbinfo)
return -ENOMEM;
sb->s_fs_info = sbinfo;
sbinfo->hstate = config.hstate;
spin_lock_init(&sbinfo->stat_lock);
sbinfo->max_blocks = config.nr_blocks;
sbinfo->free_blocks = config.nr_blocks;
sbinfo->max_inodes = config.nr_inodes;
sbinfo->free_inodes = config.nr_inodes;
sb->s_maxbytes = MAX_LFS_FILESIZE;
sb->s_blocksize = huge_page_size(config.hstate);
sb->s_blocksize_bits = huge_page_shift(config.hstate);
sb->s_magic = HUGETLBFS_MAGIC;
sb->s_op = &hugetlbfs_ops;
sb->s_time_gran = 1;
inode = hugetlbfs_get_root(sb, &config);
if (!inode)
goto out_free;
root = d_alloc_root(inode);
if (!root) {
iput(inode);
goto out_free;
}
sb->s_root = root;
return 0;
out_free:
kfree(sbinfo);
return -ENOMEM;
}
| 0 |
C
|
CWE-399
|
Resource Management Errors
|
Weaknesses in this category are related to improper management of system resources.
|
https://cwe.mitre.org/data/definitions/399.html
|
vulnerable
|
static void __exit ipgre_fini(void)
{
rtnl_link_unregister(&ipgre_tap_ops);
rtnl_link_unregister(&ipgre_link_ops);
if (inet_del_protocol(&ipgre_protocol, IPPROTO_GRE) < 0)
printk(KERN_INFO "ipgre close: can't remove protocol\n");
unregister_pernet_device(&ipgre_net_ops);
}
| 1 |
C
|
NVD-CWE-Other
|
Other
|
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
|
https://nvd.nist.gov/vuln/categories
|
safe
|
PHP_NAMED_FUNCTION(zif_locale_set_default)
{
char* locale_name = NULL;
int len=0;
if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s",
&locale_name ,&len ) == FAILURE)
{
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
"locale_set_default: unable to parse input params", 0 TSRMLS_CC );
RETURN_FALSE;
}
if(len == 0) {
locale_name = (char *)uloc_getDefault() ;
len = strlen(locale_name);
}
zend_alter_ini_entry(LOCALE_INI_NAME, sizeof(LOCALE_INI_NAME), locale_name, len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
RETURN_TRUE;
}
| 0 |
C
|
CWE-125
|
Out-of-bounds Read
|
The software reads data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/125.html
|
vulnerable
|
static int jas_iccgetuint(jas_stream_t *in, int n, jas_ulonglong *val)
{
int i;
int c;
jas_ulonglong v;
v = 0;
for (i = n; i > 0; --i) {
if ((c = jas_stream_getc(in)) == EOF)
return -1;
v = (v << 8) | c;
}
*val = v;
return 0;
}
| 1 |
C
|
CWE-190
|
Integer Overflow or Wraparound
|
The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
|
https://cwe.mitre.org/data/definitions/190.html
|
safe
|
static void perf_event_for_each(struct perf_event *event,
void (*func)(struct perf_event *))
{
struct perf_event_context *ctx = event->ctx;
struct perf_event *sibling;
WARN_ON_ONCE(ctx->parent_ctx);
mutex_lock(&ctx->mutex);
event = event->group_leader;
perf_event_for_each_child(event, func);
list_for_each_entry(sibling, &event->sibling_list, group_entry)
perf_event_for_each_child(sibling, func);
mutex_unlock(&ctx->mutex);
}
| 0 |
C
|
CWE-264
|
Permissions, Privileges, and Access Controls
|
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
|
https://cwe.mitre.org/data/definitions/264.html
|
vulnerable
|
mcs_recv_connect_response(STREAM mcs_data)
{
UNUSED(mcs_data);
uint8 result;
int length;
STREAM s;
RD_BOOL is_fastpath;
uint8 fastpath_hdr;
logger(Protocol, Debug, "%s()", __func__);
s = iso_recv(&is_fastpath, &fastpath_hdr);
if (s == NULL)
return False;
ber_parse_header(s, MCS_CONNECT_RESPONSE, &length);
ber_parse_header(s, BER_TAG_RESULT, &length);
in_uint8(s, result);
if (result != 0)
{
logger(Protocol, Error, "mcs_recv_connect_response(), result=%d", result);
return False;
}
ber_parse_header(s, BER_TAG_INTEGER, &length);
in_uint8s(s, length); /* connect id */
mcs_parse_domain_params(s);
ber_parse_header(s, BER_TAG_OCTET_STRING, &length);
sec_process_mcs_data(s);
/*
if (length > mcs_data->size)
{
logger(Protocol, Error, "mcs_recv_connect_response(), expected length=%d, got %d",length, mcs_data->size);
length = mcs_data->size;
}
in_uint8a(s, mcs_data->data, length);
mcs_data->p = mcs_data->data;
mcs_data->end = mcs_data->data + length;
*/
return s_check_end(s);
}
| 0 |
C
|
CWE-191
|
Integer Underflow (Wrap or Wraparound)
|
The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.
|
https://cwe.mitre.org/data/definitions/191.html
|
vulnerable
|
ber_parse_header(STREAM s, int tagval, int *length)
{
int tag, len;
if (tagval > 0xff)
{
in_uint16_be(s, tag);
}
else
{
in_uint8(s, tag);
}
if (tag != tagval)
{
logger(Core, Error, "ber_parse_header(), expected tag %d, got %d", tagval, tag);
return False;
}
in_uint8(s, len);
if (len & 0x80)
{
len &= ~0x80;
*length = 0;
while (len--)
next_be(s, *length);
}
else
*length = len;
return s_check(s);
}
| 0 |
C
|
CWE-125
|
Out-of-bounds Read
|
The software reads data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/125.html
|
vulnerable
|
static inline int add_post_vars(zval *arr, post_var_data_t *vars, zend_bool eof TSRMLS_DC)
{
uint64_t max_vars = PG(max_input_vars);
vars->ptr = vars->str.c;
vars->end = vars->str.c + vars->str.len;
while (add_post_var(arr, vars, eof TSRMLS_CC)) {
if (++vars->cnt > max_vars) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
"Input variables exceeded %" PRIu64 ". "
"To increase the limit change max_input_vars in php.ini.",
max_vars);
return FAILURE;
}
}
if (!eof) {
memmove(vars->str.c, vars->ptr, vars->str.len = vars->end - vars->ptr);
}
return SUCCESS;
}
| 0 |
C
|
CWE-400
|
Uncontrolled Resource Consumption
|
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
|
https://cwe.mitre.org/data/definitions/400.html
|
vulnerable
|
static struct usb_host_interface *uas_find_uas_alt_setting(
struct usb_interface *intf)
{
int i;
for (i = 0; i < intf->num_altsetting; i++) {
struct usb_host_interface *alt = &intf->altsetting[i];
if (uas_is_interface(alt))
return alt;
}
return NULL;
}
| 1 |
C
|
CWE-125
|
Out-of-bounds Read
|
The software reads data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/125.html
|
safe
|
mrb_proc_s_new(mrb_state *mrb, mrb_value proc_class)
{
mrb_value blk;
mrb_value proc;
struct RProc *p;
/* Calling Proc.new without a block is not implemented yet */
mrb_get_args(mrb, "&!", &blk);
p = MRB_OBJ_ALLOC(mrb, MRB_TT_PROC, mrb_class_ptr(proc_class));
mrb_proc_copy(p, mrb_proc_ptr(blk));
proc = mrb_obj_value(p);
mrb_funcall_with_block(mrb, proc, MRB_SYM(initialize), 0, NULL, proc);
if (!MRB_PROC_STRICT_P(p) &&
mrb->c->ci > mrb->c->cibase && MRB_PROC_ENV(p) == mrb->c->ci[-1].u.env) {
p->flags |= MRB_PROC_ORPHAN;
}
return proc;
}
| 0 |
C
|
CWE-476
|
NULL Pointer Dereference
|
A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.
|
https://cwe.mitre.org/data/definitions/476.html
|
vulnerable
|
void nfs4_close_sync(struct path *path, struct nfs4_state *state, mode_t mode)
{
__nfs4_close(path, state, mode, 1);
}
| 0 |
C
|
NVD-CWE-noinfo
| null | null | null |
vulnerable
|
static int muscle_list_files(sc_card_t *card, u8 *buf, size_t bufLen)
{
muscle_private_t* priv = MUSCLE_DATA(card);
mscfs_t *fs = priv->fs;
int x;
int count = 0;
mscfs_check_cache(priv->fs);
for(x = 0; x < fs->cache.size; x++) {
u8* oid= fs->cache.array[x].objectId.id;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
"FILE: %02X%02X%02X%02X\n",
oid[0],oid[1],oid[2],oid[3]);
if(0 == memcmp(fs->currentPath, oid, 2)) {
buf[0] = oid[2];
buf[1] = oid[3];
if(buf[0] == 0x00 && buf[1] == 0x00) continue; /* No directories/null names outside of root */
buf += 2;
count+=2;
}
}
return count;
}
| 0 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
vulnerable
|
static void scsi_read_complete(void * opaque, int ret)
{
SCSIDiskReq *r = (SCSIDiskReq *)opaque;
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
int n;
if (r->req.aiocb != NULL) {
r->req.aiocb = NULL;
bdrv_acct_done(s->bs, &r->acct);
}
if (ret) {
if (scsi_handle_rw_error(r, -ret, SCSI_REQ_STATUS_RETRY_READ)) {
return;
}
}
DPRINTF("Data ready tag=0x%x len=%zd\n", r->req.tag, r->iov.iov_len);
n = r->iov.iov_len / 512;
r->sector += n;
r->sector_count -= n;
scsi_req_data(&r->req, r->iov.iov_len);
}
| 0 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
vulnerable
|
int __close_fd_get_file(unsigned int fd, struct file **res)
{
struct files_struct *files = current->files;
struct file *file;
struct fdtable *fdt;
spin_lock(&files->file_lock);
fdt = files_fdtable(files);
if (fd >= fdt->max_fds)
goto out_unlock;
file = fdt->fd[fd];
if (!file)
goto out_unlock;
rcu_assign_pointer(fdt->fd[fd], NULL);
__put_unused_fd(files, fd);
spin_unlock(&files->file_lock);
get_file(file);
*res = file;
return filp_close(file, files);
out_unlock:
spin_unlock(&files->file_lock);
*res = NULL;
return -ENOENT;
}
| 0 |
C
|
CWE-416
|
Use After Free
|
Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.
|
https://cwe.mitre.org/data/definitions/416.html
|
vulnerable
|
static int pit_ioport_read(struct kvm_io_device *this,
gpa_t addr, int len, void *data)
{
struct kvm_pit *pit = dev_to_pit(this);
struct kvm_kpit_state *pit_state = &pit->pit_state;
struct kvm *kvm = pit->kvm;
int ret, count;
struct kvm_kpit_channel_state *s;
if (!pit_in_range(addr))
return -EOPNOTSUPP;
addr &= KVM_PIT_CHANNEL_MASK;
if (addr == 3)
return 0;
s = &pit_state->channels[addr];
mutex_lock(&pit_state->lock);
if (s->status_latched) {
s->status_latched = 0;
ret = s->status;
} else if (s->count_latched) {
switch (s->count_latched) {
default:
case RW_STATE_LSB:
ret = s->latched_count & 0xff;
s->count_latched = 0;
break;
case RW_STATE_MSB:
ret = s->latched_count >> 8;
s->count_latched = 0;
break;
case RW_STATE_WORD0:
ret = s->latched_count & 0xff;
s->count_latched = RW_STATE_MSB;
break;
}
} else {
switch (s->read_state) {
default:
case RW_STATE_LSB:
count = pit_get_count(kvm, addr);
ret = count & 0xff;
break;
case RW_STATE_MSB:
count = pit_get_count(kvm, addr);
ret = (count >> 8) & 0xff;
break;
case RW_STATE_WORD0:
count = pit_get_count(kvm, addr);
ret = count & 0xff;
s->read_state = RW_STATE_WORD1;
break;
case RW_STATE_WORD1:
count = pit_get_count(kvm, addr);
ret = (count >> 8) & 0xff;
s->read_state = RW_STATE_WORD0;
break;
}
}
if (len > sizeof(ret))
len = sizeof(ret);
memcpy(data, (char *)&ret, len);
mutex_unlock(&pit_state->lock);
return 0;
}
| 1 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
safe
|
static void parseContentMinify(HttpRoute *route, cchar *key, MprJson *prop)
{
MprJson *child;
int ji;
for (ITERATE_CONFIG(route, prop, child, ji)) {
/*
Compressed and minified is handled in parseContentCompress
*/
if (mprGetJson(route->config, sfmt("app.http.content.compress[@ = '%s']", child->value)) == 0) {
httpAddRouteMapping(route, child->value, "min.${1}");
}
}
}
| 0 |
C
|
NVD-CWE-Other
|
Other
|
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
|
https://nvd.nist.gov/vuln/categories
|
vulnerable
|
videobuf_vm_close(struct vm_area_struct *vma)
{
struct videobuf_mapping *map = vma->vm_private_data;
struct videobuf_queue *q = map->q;
int i;
dprintk(2,"vm_close %p [count=%d,vma=%08lx-%08lx]\n",map,
map->count,vma->vm_start,vma->vm_end);
map->count--;
if (0 == map->count) {
dprintk(1,"munmap %p q=%p\n",map,q);
mutex_lock(&q->lock);
for (i = 0; i < VIDEO_MAX_FRAME; i++) {
if (NULL == q->bufs[i])
continue;
if (q->bufs[i]->map != map)
continue;
q->ops->buf_release(q,q->bufs[i]);
q->bufs[i]->map = NULL;
q->bufs[i]->baddr = 0;
}
mutex_unlock(&q->lock);
kfree(map);
}
return;
}
| 0 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
vulnerable
|
int gnutls_x509_ext_import_proxy(const gnutls_datum_t * ext, int *pathlen,
char **policyLanguage, char **policy,
size_t * sizeof_policy)
{
ASN1_TYPE c2 = ASN1_TYPE_EMPTY;
int result;
gnutls_datum_t value = { NULL, 0 };
if ((result = asn1_create_element
(_gnutls_get_pkix(), "PKIX1.ProxyCertInfo",
&c2)) != ASN1_SUCCESS) {
gnutls_assert();
return _gnutls_asn2err(result);
}
result = _asn1_strict_der_decode(&c2, ext->data, ext->size, NULL);
if (result != ASN1_SUCCESS) {
gnutls_assert();
result = _gnutls_asn2err(result);
goto cleanup;
}
if (pathlen) {
result = _gnutls_x509_read_uint(c2, "pCPathLenConstraint",
(unsigned int *)
pathlen);
if (result == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND)
*pathlen = -1;
else if (result != GNUTLS_E_SUCCESS) {
gnutls_assert();
result = _gnutls_asn2err(result);
goto cleanup;
}
}
result = _gnutls_x509_read_value(c2, "proxyPolicy.policyLanguage",
&value);
if (result < 0) {
gnutls_assert();
goto cleanup;
}
if (policyLanguage) {
*policyLanguage = (char *)value.data;
} else {
gnutls_free(value.data);
value.data = NULL;
}
result = _gnutls_x509_read_value(c2, "proxyPolicy.policy", &value);
if (result == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND) {
if (policy)
*policy = NULL;
if (sizeof_policy)
*sizeof_policy = 0;
} else if (result < 0) {
gnutls_assert();
goto cleanup;
} else {
if (policy) {
*policy = (char *)value.data;
value.data = NULL;
}
if (sizeof_policy)
*sizeof_policy = value.size;
}
result = 0;
cleanup:
gnutls_free(value.data);
asn1_delete_structure(&c2);
return result;
}
| 0 |
C
|
CWE-415
|
Double Free
|
The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.
|
https://cwe.mitre.org/data/definitions/415.html
|
vulnerable
|
static void rose_loopback_timer(unsigned long param)
{
struct sk_buff *skb;
struct net_device *dev;
rose_address *dest;
struct sock *sk;
unsigned short frametype;
unsigned int lci_i, lci_o;
while ((skb = skb_dequeue(&loopback_queue)) != NULL) {
lci_i = ((skb->data[0] << 8) & 0xF00) + ((skb->data[1] << 0) & 0x0FF);
frametype = skb->data[2];
dest = (rose_address *)(skb->data + 4);
lci_o = ROSE_DEFAULT_MAXVC + 1 - lci_i;
skb_reset_transport_header(skb);
sk = rose_find_socket(lci_o, rose_loopback_neigh);
if (sk) {
if (rose_process_rx_frame(sk, skb) == 0)
kfree_skb(skb);
continue;
}
if (frametype == ROSE_CALL_REQUEST) {
if ((dev = rose_dev_get(dest)) != NULL) {
if (rose_rx_call_request(skb, dev, rose_loopback_neigh, lci_o) == 0)
kfree_skb(skb);
} else {
kfree_skb(skb);
}
} else {
kfree_skb(skb);
}
}
}
| 0 |
C
|
CWE-20
|
Improper Input Validation
|
The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly.
|
https://cwe.mitre.org/data/definitions/20.html
|
vulnerable
|
static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
u64 param3, u64 param4)
{
int rc;
u64 base_addr, size;
if (get_securelevel() > 0)
return -EPERM;
/* If user manually set "flags", make sure it is legal */
if (flags && (flags &
~(SETWA_FLAGS_APICID|SETWA_FLAGS_MEM|SETWA_FLAGS_PCIE_SBDF)))
return -EINVAL;
/*
* We need extra sanity checks for memory errors.
* Other types leap directly to injection.
*/
/* ensure param1/param2 existed */
if (!(param_extension || acpi5))
goto inject;
/* ensure injection is memory related */
if (type & ACPI5_VENDOR_BIT) {
if (vendor_flags != SETWA_FLAGS_MEM)
goto inject;
} else if (!(type & MEM_ERROR_MASK) && !(flags & SETWA_FLAGS_MEM))
goto inject;
/*
* Disallow crazy address masks that give BIOS leeway to pick
* injection address almost anywhere. Insist on page or
* better granularity and that target address is normal RAM or
* NVDIMM.
*/
base_addr = param1 & param2;
size = ~param2 + 1;
if (((param2 & PAGE_MASK) != PAGE_MASK) ||
((region_intersects(base_addr, size, IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE)
!= REGION_INTERSECTS) &&
(region_intersects(base_addr, size, IORESOURCE_MEM, IORES_DESC_PERSISTENT_MEMORY)
!= REGION_INTERSECTS)))
return -EINVAL;
inject:
mutex_lock(&einj_mutex);
rc = __einj_error_inject(type, flags, param1, param2, param3, param4);
mutex_unlock(&einj_mutex);
return rc;
}
| 1 |
C
|
CWE-74
|
Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
|
The software constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.
|
https://cwe.mitre.org/data/definitions/74.html
|
safe
|
static int proc_sys_readdir(struct file *file, struct dir_context *ctx)
{
struct ctl_table_header *head = grab_header(file_inode(file));
struct ctl_table_header *h = NULL;
struct ctl_table *entry;
struct ctl_dir *ctl_dir;
unsigned long pos;
if (IS_ERR(head))
return PTR_ERR(head);
ctl_dir = container_of(head, struct ctl_dir, header);
if (!dir_emit_dots(file, ctx))
goto out;
pos = 2;
for (first_entry(ctl_dir, &h, &entry); h; next_entry(&h, &entry)) {
if (!scan(h, entry, &pos, file, ctx)) {
sysctl_head_finish(h);
break;
}
}
out:
sysctl_head_finish(head);
return 0;
}
| 1 |
C
|
CWE-20
|
Improper Input Validation
|
The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly.
|
https://cwe.mitre.org/data/definitions/20.html
|
safe
|
static ssize_t _epoll_write(oe_fd_t* epoll_, const void* buf, size_t count)
{
ssize_t ret = -1;
epoll_t* epoll = _cast_epoll(epoll_);
oe_errno = 0;
/* Call the host. */
if (oe_syscall_write_ocall(&ret, epoll->host_fd, buf, count) != OE_OK)
OE_RAISE_ERRNO(OE_EINVAL);
done:
return ret;
}
| 0 |
C
|
NVD-CWE-Other
|
Other
|
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
|
https://nvd.nist.gov/vuln/categories
|
vulnerable
|
static Jsi_RC NumberToFixedCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr)
{
char buf[100];
int prec = 0, skip = 0;
Jsi_Number num;
Jsi_Value *v;
ChkStringN(_this, funcPtr, v);
Jsi_Value *pa = Jsi_ValueArrayIndex(interp, args, skip);
if (pa && Jsi_GetIntFromValue(interp, pa, &prec) != JSI_OK)
return JSI_ERROR;
if (prec<0) prec = 0;
Jsi_GetDoubleFromValue(interp, v, &num);
snprintf(buf, sizeof(buf), "%.*" JSI_NUMFFMT, prec, num);
Jsi_ValueMakeStringDup(interp, ret, buf);
return JSI_OK;
}
| 0 |
C
|
CWE-120
|
Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')
|
The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.
|
https://cwe.mitre.org/data/definitions/120.html
|
vulnerable
|
mcs_parse_domain_params(STREAM s)
{
int length;
ber_parse_header(s, MCS_TAG_DOMAIN_PARAMS, &length);
in_uint8s(s, length);
return s_check(s);
}
| 0 |
C
|
CWE-125
|
Out-of-bounds Read
|
The software reads data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/125.html
|
vulnerable
|
static void dhcps_initialize_message(struct dhcp_msg *dhcp_message_repository)
{
dhcp_message_repository->op = DHCP_MESSAGE_OP_REPLY;
dhcp_message_repository->htype = DHCP_MESSAGE_HTYPE;
dhcp_message_repository->hlen = DHCP_MESSAGE_HLEN;
dhcp_message_repository->hops = 0;
memcpy((char *)dhcp_recorded_xid, (char *) dhcp_message_repository->xid,
sizeof(dhcp_message_repository->xid));
dhcp_message_repository->secs = 0;
dhcp_message_repository->flags = htons(BOOTP_BROADCAST);
memcpy((char *)dhcp_message_repository->yiaddr,
(char *)&dhcps_allocated_client_address,
sizeof(dhcp_message_repository->yiaddr));
memset((char *)dhcp_message_repository->ciaddr, 0,
sizeof(dhcp_message_repository->ciaddr));
memset((char *)dhcp_message_repository->siaddr, 0,
sizeof(dhcp_message_repository->siaddr));
memset((char *)dhcp_message_repository->giaddr, 0,
sizeof(dhcp_message_repository->giaddr));
memset((char *)dhcp_message_repository->sname, 0,
sizeof(dhcp_message_repository->sname));
memset((char *)dhcp_message_repository->file, 0,
sizeof(dhcp_message_repository->file));
memset((char *)dhcp_message_repository->options, 0,
dhcp_message_total_options_lenth);
memcpy((char *)dhcp_message_repository->options, (char *)dhcp_magic_cookie,
sizeof(dhcp_magic_cookie));
}
| 0 |
C
|
NVD-CWE-noinfo
| null | null | null |
vulnerable
|
eval_lambda(
char_u **arg,
typval_T *rettv,
evalarg_T *evalarg,
int verbose) // give error messages
{
int evaluate = evalarg != NULL
&& (evalarg->eval_flags & EVAL_EVALUATE);
typval_T base = *rettv;
int ret;
rettv->v_type = VAR_UNKNOWN;
if (**arg == '{')
{
// ->{lambda}()
ret = get_lambda_tv(arg, rettv, FALSE, evalarg);
}
else
{
// ->(lambda)()
++*arg;
ret = eval1(arg, rettv, evalarg);
*arg = skipwhite_and_linebreak(*arg, evalarg);
if (**arg == ')')
{
++*arg;
}
else
{
emsg(_(e_missing_closing_paren));
ret = FAIL;
}
}
if (ret != OK)
return FAIL;
else if (**arg != '(')
{
if (verbose)
{
if (*skipwhite(*arg) == '(')
emsg(_(e_nowhitespace));
else
semsg(_(e_missing_parenthesis_str), "lambda");
}
clear_tv(rettv);
ret = FAIL;
}
else
ret = call_func_rettv(arg, evalarg, rettv, evaluate, NULL, &base);
// Clear the funcref afterwards, so that deleting it while
// evaluating the arguments is possible (see test55).
if (evaluate)
clear_tv(&base);
return ret;
}
| 1 |
C
|
CWE-122
|
Heap-based Buffer Overflow
|
A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().
|
https://cwe.mitre.org/data/definitions/122.html
|
safe
|
epass2003_sm_unwrap_apdu(struct sc_card *card, struct sc_apdu *sm, struct sc_apdu *plain)
{
int r;
size_t len = 0;
epass2003_exdata *exdata = NULL;
if (!card->drv_data)
return SC_ERROR_INVALID_ARGUMENTS;
exdata = (epass2003_exdata *)card->drv_data;
LOG_FUNC_CALLED(card->ctx);
r = sc_check_sw(card, sm->sw1, sm->sw2);
if (r == SC_SUCCESS) {
if (exdata->sm) {
len = plain->resplen;
if (0 != decrypt_response(card, sm->resp, sm->resplen, plain->resp, &len))
return SC_ERROR_CARD_CMD_FAILED;
}
else {
memcpy(plain->resp, sm->resp, sm->resplen);
len = sm->resplen;
}
}
plain->resplen = len;
plain->sw1 = sm->sw1;
plain->sw2 = sm->sw2;
sc_log(card->ctx,
"unwrapped APDU: resplen %"SC_FORMAT_LEN_SIZE_T"u, SW %02X%02X",
plain->resplen, plain->sw1, plain->sw2);
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
}
| 1 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
safe
|
static int nr_recvmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t size, int flags)
{
struct sock *sk = sock->sk;
struct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name;
size_t copied;
struct sk_buff *skb;
int er;
/*
* This works for seqpacket too. The receiver has ordered the queue for
* us! We do one quick check first though
*/
lock_sock(sk);
if (sk->sk_state != TCP_ESTABLISHED) {
release_sock(sk);
return -ENOTCONN;
}
/* Now we can treat all alike */
if ((skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &er)) == NULL) {
release_sock(sk);
return er;
}
skb_reset_transport_header(skb);
copied = skb->len;
if (copied > size) {
copied = size;
msg->msg_flags |= MSG_TRUNC;
}
er = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
if (er < 0) {
skb_free_datagram(sk, skb);
release_sock(sk);
return er;
}
if (sax != NULL) {
memset(sax, 0, sizeof(*sax));
sax->sax25_family = AF_NETROM;
skb_copy_from_linear_data_offset(skb, 7, sax->sax25_call.ax25_call,
AX25_ADDR_LEN);
}
msg->msg_namelen = sizeof(*sax);
skb_free_datagram(sk, skb);
release_sock(sk);
return copied;
}
| 0 |
C
|
CWE-20
|
Improper Input Validation
|
The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly.
|
https://cwe.mitre.org/data/definitions/20.html
|
vulnerable
|
void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data)
{
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint32_t val = data;
if (addr + sizeof(val) > vdev->config_len) {
return;
}
stl_p(vdev->config + addr, val);
if (k->set_config) {
k->set_config(vdev, vdev->config);
}
}
| 1 |
C
|
CWE-269
|
Improper Privilege Management
|
The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.
|
https://cwe.mitre.org/data/definitions/269.html
|
safe
|
static int pppoe_recvmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *m, size_t total_len, int flags)
{
struct sock *sk = sock->sk;
struct sk_buff *skb;
int error = 0;
if (sk->sk_state & PPPOX_BOUND) {
error = -EIO;
goto end;
}
skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
flags & MSG_DONTWAIT, &error);
if (error < 0)
goto end;
m->msg_namelen = 0;
if (skb) {
total_len = min_t(size_t, total_len, skb->len);
error = skb_copy_datagram_iovec(skb, 0, m->msg_iov, total_len);
if (error == 0) {
consume_skb(skb);
return total_len;
}
}
kfree_skb(skb);
end:
return error;
}
| 0 |
C
|
CWE-20
|
Improper Input Validation
|
The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly.
|
https://cwe.mitre.org/data/definitions/20.html
|
vulnerable
|
static int muscle_list_files(sc_card_t *card, u8 *buf, size_t bufLen)
{
muscle_private_t* priv = MUSCLE_DATA(card);
mscfs_t *fs = priv->fs;
int x;
int count = 0;
mscfs_check_cache(priv->fs);
for(x = 0; x < fs->cache.size; x++) {
u8* oid= fs->cache.array[x].objectId.id;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
"FILE: %02X%02X%02X%02X\n",
oid[0],oid[1],oid[2],oid[3]);
if(0 == memcmp(fs->currentPath, oid, 2)) {
buf[0] = oid[2];
buf[1] = oid[3];
if(buf[0] == 0x00 && buf[1] == 0x00) continue; /* No directories/null names outside of root */
buf += 2;
count+=2;
}
}
return count;
}
| 0 |
C
|
CWE-415
|
Double Free
|
The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations.
|
https://cwe.mitre.org/data/definitions/415.html
|
vulnerable
|
gen_hash(codegen_scope *s, node *tree, int val, int limit)
{
int slimit = GEN_VAL_STACK_MAX;
if (cursp() >= GEN_LIT_ARY_MAX) slimit = INT16_MAX;
int len = 0;
mrb_bool update = FALSE;
while (tree) {
if (nint(tree->car->car->car) == NODE_KW_REST_ARGS) {
if (len > 0) {
pop_n(len*2);
if (!update) {
genop_2(s, OP_HASH, cursp(), len);
}
else {
pop();
genop_2(s, OP_HASHADD, cursp(), len);
}
push();
}
codegen(s, tree->car->cdr, val);
if (len > 0 || update) {
pop(); pop();
genop_1(s, OP_HASHCAT, cursp());
push();
}
update = TRUE;
len = 0;
}
else {
codegen(s, tree->car->car, val);
codegen(s, tree->car->cdr, val);
len++;
}
tree = tree->cdr;
if (val && cursp() >= slimit) {
pop_n(len*2);
if (!update) {
genop_2(s, OP_HASH, cursp(), len);
}
else {
pop();
genop_2(s, OP_HASHADD, cursp(), len);
}
push();
update = TRUE;
len = 0;
}
}
if (update) {
if (len > 0) {
pop_n(len*2+1);
genop_2(s, OP_HASHADD, cursp(), len);
push();
}
return -1; /* variable length */
}
if (update) return -1;
return len;
}
| 0 |
C
|
CWE-476
|
NULL Pointer Dereference
|
A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.
|
https://cwe.mitre.org/data/definitions/476.html
|
vulnerable
|
TfLiteIntArray* TfLiteIntArrayCreate(int size) {
TfLiteIntArray* ret =
(TfLiteIntArray*)malloc(TfLiteIntArrayGetSizeInBytes(size));
ret->size = size;
return ret;
}
| 0 |
C
|
CWE-190
|
Integer Overflow or Wraparound
|
The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
|
https://cwe.mitre.org/data/definitions/190.html
|
vulnerable
|
bool f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext)
{
bool ret = __f2fs_init_extent_tree(inode, i_ext);
if (!F2FS_I(inode)->extent_tree)
set_inode_flag(inode, FI_NO_EXTENT);
return ret;
}
| 1 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
safe
|
static int __key_instantiate_and_link(struct key *key,
struct key_preparsed_payload *prep,
struct key *keyring,
struct key *authkey,
struct assoc_array_edit **_edit)
{
int ret, awaken;
key_check(key);
key_check(keyring);
awaken = 0;
ret = -EBUSY;
mutex_lock(&key_construction_mutex);
/* can't instantiate twice */
if (key->state == KEY_IS_UNINSTANTIATED) {
/* instantiate the key */
ret = key->type->instantiate(key, prep);
if (ret == 0) {
/* mark the key as being instantiated */
atomic_inc(&key->user->nikeys);
mark_key_instantiated(key, 0);
if (test_and_clear_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags))
awaken = 1;
/* and link it into the destination keyring */
if (keyring) {
if (test_bit(KEY_FLAG_KEEP, &keyring->flags))
set_bit(KEY_FLAG_KEEP, &key->flags);
__key_link(key, _edit);
}
/* disable the authorisation key */
if (authkey)
key_revoke(authkey);
if (prep->expiry != TIME_T_MAX) {
key->expiry = prep->expiry;
key_schedule_gc(prep->expiry + key_gc_delay);
}
}
}
mutex_unlock(&key_construction_mutex);
/* wake up anyone waiting for a key to be constructed */
if (awaken)
wake_up_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT);
return ret;
}
| 1 |
C
|
CWE-20
|
Improper Input Validation
|
The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly.
|
https://cwe.mitre.org/data/definitions/20.html
|
safe
|
get_html_data (MAPI_Attr *a)
{
VarLenData **body = XCALLOC(VarLenData*, a->num_values + 1);
int j;
for (j = 0; j < a->num_values; j++)
{
if (a->type == szMAPI_BINARY) {
body[j] = XMALLOC(VarLenData, 1);
body[j]->len = a->values[j].len;
body[j]->data = CHECKED_XCALLOC(unsigned char, a->values[j].len);
memmove (body[j]->data, a->values[j].data.buf, body[j]->len);
}
}
return body;
}
| 1 |
C
|
CWE-125
|
Out-of-bounds Read
|
The software reads data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/125.html
|
safe
|
static int crypto_aead_report(struct sk_buff *skb, struct crypto_alg *alg)
{
struct crypto_report_aead raead;
struct aead_alg *aead = &alg->cra_aead;
snprintf(raead.type, CRYPTO_MAX_ALG_NAME, "%s", "aead");
snprintf(raead.geniv, CRYPTO_MAX_ALG_NAME, "%s",
aead->geniv ?: "<built-in>");
raead.blocksize = alg->cra_blocksize;
raead.maxauthsize = aead->maxauthsize;
raead.ivsize = aead->ivsize;
if (nla_put(skb, CRYPTOCFGA_REPORT_AEAD,
sizeof(struct crypto_report_aead), &raead))
goto nla_put_failure;
return 0;
nla_put_failure:
return -EMSGSIZE;
}
| 0 |
C
|
CWE-310
|
Cryptographic Issues
|
Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.
|
https://cwe.mitre.org/data/definitions/310.html
|
vulnerable
|
static void ikev2_parent_inR1outI2_continue(struct pluto_crypto_req_cont *pcrc,
struct pluto_crypto_req *r,
err_t ugh)
{
struct dh_continuation *dh = (struct dh_continuation *)pcrc;
struct msg_digest *md = dh->md;
struct state *const st = md->st;
stf_status e;
DBG(DBG_CONTROLMORE,
DBG_log("ikev2 parent inR1outI2: calculating g^{xy}, sending I2"));
if (st == NULL) {
loglog(RC_LOG_SERIOUS,
"%s: Request was disconnected from state",
__FUNCTION__);
if (dh->md)
release_md(dh->md);
return;
}
/* XXX should check out ugh */
passert(ugh == NULL);
passert(cur_state == NULL);
passert(st != NULL);
passert(st->st_suspended_md == dh->md);
set_suspended(st, NULL); /* no longer connected or suspended */
set_cur_state(st);
st->st_calculating = FALSE;
e = ikev2_parent_inR1outI2_tail(pcrc, r);
if (dh->md != NULL) {
complete_v2_state_transition(&dh->md, e);
if (dh->md)
release_md(dh->md);
}
reset_globals();
passert(GLOBALS_ARE_RESET());
}
| 0 |
C
|
CWE-20
|
Improper Input Validation
|
The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly.
|
https://cwe.mitre.org/data/definitions/20.html
|
vulnerable
|
static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{
struct cp2112_device *dev = gpiochip_get_data(chip);
struct hid_device *hdev = dev->hdev;
u8 *buf = dev->in_out_buffer;
unsigned long flags;
int ret;
spin_lock_irqsave(&dev->lock, flags);
buf[0] = CP2112_GPIO_SET;
buf[1] = value ? 0xff : 0;
buf[2] = 1 << offset;
ret = hid_hw_raw_request(hdev, CP2112_GPIO_SET, buf,
CP2112_GPIO_SET_LENGTH, HID_FEATURE_REPORT,
HID_REQ_SET_REPORT);
if (ret < 0)
hid_err(hdev, "error setting GPIO values: %d\n", ret);
spin_unlock_irqrestore(&dev->lock, flags);
}
| 0 |
C
|
CWE-404
|
Improper Resource Shutdown or Release
|
The program does not release or incorrectly releases a resource before it is made available for re-use.
|
https://cwe.mitre.org/data/definitions/404.html
|
vulnerable
|
static int follow_dotdot(struct nameidata *nd)
{
if (!nd->root.mnt)
set_root(nd);
while(1) {
struct dentry *old = nd->path.dentry;
if (nd->path.dentry == nd->root.dentry &&
nd->path.mnt == nd->root.mnt) {
break;
}
if (nd->path.dentry != nd->path.mnt->mnt_root) {
/* rare case of legitimate dget_parent()... */
nd->path.dentry = dget_parent(nd->path.dentry);
dput(old);
if (unlikely(!path_connected(&nd->path)))
return -ENOENT;
break;
}
if (!follow_up(&nd->path))
break;
}
follow_mount(&nd->path);
nd->inode = nd->path.dentry->d_inode;
return 0;
}
| 1 |
C
|
CWE-254
|
7PK - Security Features
|
Software security is not security software. Here we're concerned with topics like authentication, access control, confidentiality, cryptography, and privilege management.
|
https://cwe.mitre.org/data/definitions/254.html
|
safe
|
const char * util_acl_to_str(const sc_acl_entry_t *e)
{
static char line[80], buf[20];
unsigned int acl;
if (e == NULL)
return "N/A";
line[0] = 0;
while (e != NULL) {
acl = e->method;
switch (acl) {
case SC_AC_UNKNOWN:
return "N/A";
case SC_AC_NEVER:
return "NEVR";
case SC_AC_NONE:
return "NONE";
case SC_AC_CHV:
strcpy(buf, "CHV");
if (e->key_ref != SC_AC_KEY_REF_NONE)
sprintf(buf + 3, "%d", e->key_ref);
break;
case SC_AC_TERM:
strcpy(buf, "TERM");
break;
case SC_AC_PRO:
strcpy(buf, "PROT");
break;
case SC_AC_AUT:
strcpy(buf, "AUTH");
if (e->key_ref != SC_AC_KEY_REF_NONE)
sprintf(buf + 4, "%d", e->key_ref);
break;
case SC_AC_SEN:
strcpy(buf, "Sec.Env. ");
if (e->key_ref != SC_AC_KEY_REF_NONE)
sprintf(buf + 3, "#%d", e->key_ref);
break;
case SC_AC_SCB:
strcpy(buf, "Sec.ControlByte ");
if (e->key_ref != SC_AC_KEY_REF_NONE)
sprintf(buf + 3, "Ox%X", e->key_ref);
break;
case SC_AC_IDA:
strcpy(buf, "PKCS#15 AuthID ");
if (e->key_ref != SC_AC_KEY_REF_NONE)
sprintf(buf + 3, "#%d", e->key_ref);
break;
default:
strcpy(buf, "????");
break;
}
strcat(line, buf);
strcat(line, " ");
e = e->next;
}
line[strlen(line)-1] = 0; /* get rid of trailing space */
return line;
}
| 0 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
vulnerable
|
static pyc_object *get_set_object(RBuffer *buffer) {
bool error = false;
ut32 n = get_ut32 (buffer, &error);
if (n > ST32_MAX) {
eprintf ("bad marshal data (set size out of range)\n");
return NULL;
}
if (error) {
return NULL;
}
pyc_object *ret = get_array_object_generic (buffer, n);
if (ret) {
ret->type = TYPE_SET;
}
return ret;
}
| 1 |
C
|
CWE-825
|
Expired Pointer Dereference
|
The program dereferences a pointer that contains a location for memory that was previously valid, but is no longer valid.
|
https://cwe.mitre.org/data/definitions/825.html
|
safe
|
static int db_dict_iter_lookup_key_values(struct db_dict_value_iter *iter)
{
struct db_dict_iter_key *key;
string_t *path;
const char *error;
int ret;
/* sort the keys so that we'll first lookup the keys without
default value. if their lookup fails, the user doesn't exist. */
array_sort(&iter->keys, db_dict_iter_key_cmp);
path = t_str_new(128);
str_append(path, DICT_PATH_SHARED);
array_foreach_modifiable(&iter->keys, key) {
if (!key->used)
continue;
str_truncate(path, strlen(DICT_PATH_SHARED));
ret = var_expand(path, key->key->key, iter->var_expand_table, &error);
if (ret <= 0) {
auth_request_log_error(iter->auth_request, AUTH_SUBSYS_DB,
"Failed to expand key %s: %s", key->key->key, error);
return -1;
}
ret = dict_lookup(iter->conn->dict, iter->pool,
str_c(path), &key->value, &error);
if (ret > 0) {
auth_request_log_debug(iter->auth_request, AUTH_SUBSYS_DB,
"Lookup: %s = %s", str_c(path),
key->value);
} else if (ret < 0) {
auth_request_log_error(iter->auth_request, AUTH_SUBSYS_DB,
"Failed to lookup key %s: %s", str_c(path), error);
return -1;
} else if (key->key->default_value != NULL) {
auth_request_log_debug(iter->auth_request, AUTH_SUBSYS_DB,
"Lookup: %s not found, using default value %s",
str_c(path), key->key->default_value);
key->value = key->key->default_value;
} else {
return 0;
}
}
return 1;
}
| 0 |
C
|
CWE-20
|
Improper Input Validation
|
The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly.
|
https://cwe.mitre.org/data/definitions/20.html
|
vulnerable
|
static int snd_seq_ioctl_create_port(struct snd_seq_client *client, void *arg)
{
struct snd_seq_port_info *info = arg;
struct snd_seq_client_port *port;
struct snd_seq_port_callback *callback;
int port_idx;
/* it is not allowed to create the port for an another client */
if (info->addr.client != client->number)
return -EPERM;
port = snd_seq_create_port(client, (info->flags & SNDRV_SEQ_PORT_FLG_GIVEN_PORT) ? info->addr.port : -1);
if (port == NULL)
return -ENOMEM;
if (client->type == USER_CLIENT && info->kernel) {
port_idx = port->addr.port;
snd_seq_port_unlock(port);
snd_seq_delete_port(client, port_idx);
return -EINVAL;
}
if (client->type == KERNEL_CLIENT) {
if ((callback = info->kernel) != NULL) {
if (callback->owner)
port->owner = callback->owner;
port->private_data = callback->private_data;
port->private_free = callback->private_free;
port->event_input = callback->event_input;
port->c_src.open = callback->subscribe;
port->c_src.close = callback->unsubscribe;
port->c_dest.open = callback->use;
port->c_dest.close = callback->unuse;
}
}
info->addr = port->addr;
snd_seq_set_port_info(port, info);
snd_seq_system_client_ev_port_start(port->addr.client, port->addr.port);
snd_seq_port_unlock(port);
return 0;
}
| 1 |
C
|
CWE-362
|
Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
|
The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.
|
https://cwe.mitre.org/data/definitions/362.html
|
safe
|
create_pty_only(term_T *term, jobopt_T *opt)
{
create_vterm(term, term->tl_rows, term->tl_cols);
term->tl_job = job_alloc();
if (term->tl_job == NULL)
return FAIL;
++term->tl_job->jv_refcount;
/* behave like the job is already finished */
term->tl_job->jv_status = JOB_FINISHED;
return mch_create_pty_channel(term->tl_job, opt);
}
| 0 |
C
|
CWE-476
|
NULL Pointer Dereference
|
A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.
|
https://cwe.mitre.org/data/definitions/476.html
|
vulnerable
|
void SavePayload(size_t handle, uint32_t *payload, uint32_t index)
{
mp4object *mp4 = (mp4object *)handle;
if (mp4 == NULL) return;
uint32_t *MP4buffer = NULL;
if (index < mp4->indexcount && mp4->mediafp && payload)
{
LONGSEEK(mp4->mediafp, mp4->metaoffsets[index], SEEK_SET);
fwrite(payload, 1, mp4->metasizes[index], mp4->mediafp);
}
return;
}
| 0 |
C
|
CWE-125
|
Out-of-bounds Read
|
The software reads data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/125.html
|
vulnerable
|
static void parseLanguages(HttpRoute *route, cchar *key, MprJson *prop)
{
MprJson *child;
cchar *path, *prefix, *suffix;
int ji;
for (ITERATE_CONFIG(route, prop, child, ji)) {
if ((prefix = mprReadJson(child, "prefix")) != 0) {
httpAddRouteLanguageSuffix(route, child->name, child->value, HTTP_LANG_BEFORE);
}
if ((suffix = mprReadJson(child, "suffix")) != 0) {
httpAddRouteLanguageSuffix(route, child->name, child->value, HTTP_LANG_AFTER);
}
if ((path = mprReadJson(child, "path")) != 0) {
httpAddRouteLanguageDir(route, child->name, mprGetAbsPath(path));
}
if (smatch(mprReadJson(child, "default"), "default")) {
httpSetRouteDefaultLanguage(route, child->name);
}
}
}
| 1 |
C
|
NVD-CWE-Other
|
Other
|
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
|
https://nvd.nist.gov/vuln/categories
|
safe
|
SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
unsigned int, flags, struct sockaddr __user *, addr,
int __user *, addr_len)
{
struct socket *sock;
struct iovec iov;
struct msghdr msg;
struct sockaddr_storage address;
int err, err2;
int fput_needed;
if (size > INT_MAX)
size = INT_MAX;
sock = sockfd_lookup_light(fd, &err, &fput_needed);
if (!sock)
goto out;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_iovlen = 1;
msg.msg_iov = &iov;
iov.iov_len = size;
iov.iov_base = ubuf;
msg.msg_name = (struct sockaddr *)&address;
msg.msg_namelen = sizeof(address);
if (sock->file->f_flags & O_NONBLOCK)
flags |= MSG_DONTWAIT;
err = sock_recvmsg(sock, &msg, size, flags);
if (err >= 0 && addr != NULL) {
err2 = move_addr_to_user(&address,
msg.msg_namelen, addr, addr_len);
if (err2 < 0)
err = err2;
}
fput_light(sock->file, fput_needed);
out:
return err;
}
| 0 |
C
|
CWE-20
|
Improper Input Validation
|
The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly.
|
https://cwe.mitre.org/data/definitions/20.html
|
vulnerable
|
int ovl_setattr(struct dentry *dentry, struct iattr *attr)
{
int err;
struct dentry *upperdentry;
err = ovl_want_write(dentry);
if (err)
goto out;
upperdentry = ovl_dentry_upper(dentry);
if (upperdentry) {
mutex_lock(&upperdentry->d_inode->i_mutex);
err = notify_change(upperdentry, attr, NULL);
mutex_unlock(&upperdentry->d_inode->i_mutex);
} else {
err = ovl_copy_up_last(dentry, attr, false);
}
ovl_drop_write(dentry);
out:
return err;
}
| 0 |
C
|
CWE-264
|
Permissions, Privileges, and Access Controls
|
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
|
https://cwe.mitre.org/data/definitions/264.html
|
vulnerable
|
static int flakey_ioctl(struct dm_target *ti, unsigned int cmd, unsigned long arg)
{
struct flakey_c *fc = ti->private;
return __blkdev_driver_ioctl(fc->dev->bdev, fc->dev->mode, cmd, arg);
}
| 0 |
C
|
CWE-264
|
Permissions, Privileges, and Access Controls
|
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
|
https://cwe.mitre.org/data/definitions/264.html
|
vulnerable
|
ppp_hdlc(netdissect_options *ndo,
const u_char *p, int length)
{
u_char *b, *t, c;
const u_char *s;
int i, proto;
const void *se;
if (length <= 0)
return;
b = (u_char *)malloc(length);
if (b == NULL)
return;
/*
* Unescape all the data into a temporary, private, buffer.
* Do this so that we dont overwrite the original packet
* contents.
*/
for (s = p, t = b, i = length; i > 0 && ND_TTEST(*s); i--) {
c = *s++;
if (c == 0x7d) {
if (i <= 1 || !ND_TTEST(*s))
break;
i--;
c = *s++ ^ 0x20;
}
*t++ = c;
}
se = ndo->ndo_snapend;
ndo->ndo_snapend = t;
length = t - b;
/* now lets guess about the payload codepoint format */
if (length < 1)
goto trunc;
proto = *b; /* start with a one-octet codepoint guess */
switch (proto) {
case PPP_IP:
ip_print(ndo, b + 1, length - 1);
goto cleanup;
case PPP_IPV6:
ip6_print(ndo, b + 1, length - 1);
goto cleanup;
default: /* no luck - try next guess */
break;
}
if (length < 2)
goto trunc;
proto = EXTRACT_16BITS(b); /* next guess - load two octets */
switch (proto) {
case (PPP_ADDRESS << 8 | PPP_CONTROL): /* looks like a PPP frame */
if (length < 4)
goto trunc;
proto = EXTRACT_16BITS(b+2); /* load the PPP proto-id */
handle_ppp(ndo, proto, b + 4, length - 4);
break;
default: /* last guess - proto must be a PPP proto-id */
handle_ppp(ndo, proto, b + 2, length - 2);
break;
}
cleanup:
ndo->ndo_snapend = se;
free(b);
return;
trunc:
ndo->ndo_snapend = se;
free(b);
ND_PRINT((ndo, "[|ppp]"));
}
| 1 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
safe
|
static char *print_value(cJSON *item,int depth,int fmt,printbuffer *p)
{
char *out=0;
if (!item) return 0;
if (p)
{
switch ((item->type)&255)
{
case cJSON_NULL: {out=ensure(p,5); if (out) strcpy(out,"null"); break;}
case cJSON_False: {out=ensure(p,6); if (out) strcpy(out,"false"); break;}
case cJSON_True: {out=ensure(p,5); if (out) strcpy(out,"true"); break;}
case cJSON_Number: out=print_number(item,p);break;
case cJSON_String: out=print_string(item,p);break;
case cJSON_Array: out=print_array(item,depth,fmt,p);break;
case cJSON_Object: out=print_object(item,depth,fmt,p);break;
}
}
else
{
switch ((item->type)&255)
{
case cJSON_NULL: out=cJSON_strdup("null"); break;
case cJSON_False: out=cJSON_strdup("false");break;
case cJSON_True: out=cJSON_strdup("true"); break;
case cJSON_Number: out=print_number(item,0);break;
case cJSON_String: out=print_string(item,0);break;
case cJSON_Array: out=print_array(item,depth,fmt,0);break;
case cJSON_Object: out=print_object(item,depth,fmt,0);break;
}
}
return out;
}
| 1 |
C
|
CWE-120
|
Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')
|
The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.
|
https://cwe.mitre.org/data/definitions/120.html
|
safe
|
asmlinkage void do_ade(struct pt_regs *regs)
{
unsigned int __user *pc;
mm_segment_t seg;
perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS,
1, regs, regs->cp0_badvaddr);
/*
* Did we catch a fault trying to load an instruction?
* Or are we running in MIPS16 mode?
*/
if ((regs->cp0_badvaddr == regs->cp0_epc) || (regs->cp0_epc & 0x1))
goto sigbus;
pc = (unsigned int __user *) exception_epc(regs);
if (user_mode(regs) && !test_thread_flag(TIF_FIXADE))
goto sigbus;
if (unaligned_action == UNALIGNED_ACTION_SIGNAL)
goto sigbus;
else if (unaligned_action == UNALIGNED_ACTION_SHOW)
show_registers(regs);
/*
* Do branch emulation only if we didn't forward the exception.
* This is all so but ugly ...
*/
seg = get_fs();
if (!user_mode(regs))
set_fs(KERNEL_DS);
emulate_load_store_insn(regs, (void __user *)regs->cp0_badvaddr, pc);
set_fs(seg);
return;
sigbus:
die_if_kernel("Kernel unaligned instruction access", regs);
force_sig(SIGBUS, current);
/*
* XXX On return from the signal handler we should advance the epc
*/
}
| 1 |
C
|
CWE-400
|
Uncontrolled Resource Consumption
|
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
|
https://cwe.mitre.org/data/definitions/400.html
|
safe
|
static int on_part_data_end(multipart_parser *parser)
{
multipart_parser_data_t *data = NULL;
ogs_assert(parser);
data = multipart_parser_get_data(parser);
ogs_assert(data);
data->num_of_part++;
return 0;
}
| 0 |
C
|
CWE-787
|
Out-of-bounds Write
|
The software writes data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/787.html
|
vulnerable
|
TIFFFlushData1(TIFF* tif)
{
if (tif->tif_rawcc > 0 && tif->tif_flags & TIFF_BUF4WRITE ) {
if (!isFillOrder(tif, tif->tif_dir.td_fillorder) &&
(tif->tif_flags & TIFF_NOBITREV) == 0)
TIFFReverseBits((uint8*)tif->tif_rawdata,
tif->tif_rawcc);
if (!TIFFAppendToStrip(tif,
isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip,
tif->tif_rawdata, tif->tif_rawcc))
{
/* We update those variables even in case of error since there's */
/* code that doesn't really check the return code of this */
/* function */
tif->tif_rawcc = 0;
tif->tif_rawcp = tif->tif_rawdata;
return (0);
}
tif->tif_rawcc = 0;
tif->tif_rawcp = tif->tif_rawdata;
}
return (1);
}
| 1 |
C
|
CWE-787
|
Out-of-bounds Write
|
The software writes data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/787.html
|
safe
|
SPL_METHOD(GlobIterator, count)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (php_stream_is(intern->u.dir.dirp ,&php_glob_stream_ops)) {
RETURN_LONG(php_glob_stream_get_count(intern->u.dir.dirp, NULL));
} else {
/* should not happen */
php_error_docref(NULL TSRMLS_CC, E_ERROR, "GlobIterator lost glob state");
}
}
| 0 |
C
|
CWE-190
|
Integer Overflow or Wraparound
|
The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
|
https://cwe.mitre.org/data/definitions/190.html
|
vulnerable
|
PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_nack(
pjmedia_rtcp_session *session,
void *buf,
pj_size_t *length,
unsigned nack_cnt,
const pjmedia_rtcp_fb_nack nack[])
{
pjmedia_rtcp_common *hdr;
pj_uint8_t *p;
unsigned len, i;
PJ_ASSERT_RETURN(session && buf && length && nack_cnt && nack, PJ_EINVAL);
len = (3 + nack_cnt) * 4;
if (len > *length)
return PJ_ETOOSMALL;
/* Build RTCP-FB NACK header */
hdr = (pjmedia_rtcp_common*)buf;
pj_memcpy(hdr, &session->rtcp_rr_pkt.common, sizeof(*hdr));
hdr->pt = RTCP_RTPFB;
hdr->count = 1; /* FMT = 1 */
hdr->length = pj_htons((pj_uint16_t)(len/4 - 1));
/* Build RTCP-FB NACK FCI */
p = (pj_uint8_t*)hdr + sizeof(*hdr);
for (i = 0; i < nack_cnt; ++i) {
pj_uint16_t val;
val = pj_htons((pj_uint16_t)nack[i].pid);
pj_memcpy(p, &val, 2);
val = pj_htons(nack[i].blp);
pj_memcpy(p+2, &val, 2);
p += 4;
}
/* Finally */
*length = len;
return PJ_SUCCESS;
}
| 0 |
C
|
CWE-125
|
Out-of-bounds Read
|
The software reads data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/125.html
|
vulnerable
|
static void coerce_reg_to_32(struct bpf_reg_state *reg)
{
/* clear high 32 bits */
reg->var_off = tnum_cast(reg->var_off, 4);
/* Update bounds */
__update_reg_bounds(reg);
}
| 0 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
vulnerable
|
ParseNameValue(const char * buffer, int bufsize,
struct NameValueParserData * data)
{
struct xmlparser parser;
memset(data, 0, sizeof(struct NameValueParserData));
/* init xmlparser object */
parser.xmlstart = buffer;
parser.xmlsize = bufsize;
parser.data = data;
parser.starteltfunc = NameValueParserStartElt;
parser.endeltfunc = NameValueParserEndElt;
parser.datafunc = NameValueParserGetData;
parser.attfunc = 0;
parsexml(&parser);
}
| 1 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
safe
|
static void parseResources(HttpRoute *route, cchar *key, MprJson *prop)
{
MprJson *child, *groups, *singletons, *sets;
int ji;
if ((sets = mprGetJsonObj(prop, "sets")) != 0) {
for (ITERATE_CONFIG(route, sets, child, ji)) {
httpAddRouteSet(route, child->value);
}
}
if ((groups = mprGetJsonObj(prop, "groups")) != 0) {
for (ITERATE_CONFIG(route, groups, child, ji)) {
httpAddResourceGroup(route, route->serverPrefix, child->value);
}
}
if ((singletons = mprGetJsonObj(prop, "singletons")) != 0) {
for (ITERATE_CONFIG(route, singletons, child, ji)) {
httpAddResource(route, route->serverPrefix, child->value);
}
}
}
| 0 |
C
|
NVD-CWE-Other
|
Other
|
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
|
https://nvd.nist.gov/vuln/categories
|
vulnerable
|
static int llc_ui_getname(struct socket *sock, struct sockaddr *uaddr,
int *uaddrlen, int peer)
{
struct sockaddr_llc sllc;
struct sock *sk = sock->sk;
struct llc_sock *llc = llc_sk(sk);
int rc = -EBADF;
memset(&sllc, 0, sizeof(sllc));
lock_sock(sk);
if (sock_flag(sk, SOCK_ZAPPED))
goto out;
*uaddrlen = sizeof(sllc);
if (peer) {
rc = -ENOTCONN;
if (sk->sk_state != TCP_ESTABLISHED)
goto out;
if(llc->dev)
sllc.sllc_arphrd = llc->dev->type;
sllc.sllc_sap = llc->daddr.lsap;
memcpy(&sllc.sllc_mac, &llc->daddr.mac, IFHWADDRLEN);
} else {
rc = -EINVAL;
if (!llc->sap)
goto out;
sllc.sllc_sap = llc->sap->laddr.lsap;
if (llc->dev) {
sllc.sllc_arphrd = llc->dev->type;
memcpy(&sllc.sllc_mac, llc->dev->dev_addr,
IFHWADDRLEN);
}
}
rc = 0;
sllc.sllc_family = AF_LLC;
memcpy(uaddr, &sllc, sizeof(sllc));
out:
release_sock(sk);
return rc;
}
| 1 |
C
|
CWE-200
|
Exposure of Sensitive Information to an Unauthorized Actor
|
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
|
https://cwe.mitre.org/data/definitions/200.html
|
safe
|
spnego_gss_process_context_token(
OM_uint32 *minor_status,
const gss_ctx_id_t context_handle,
const gss_buffer_t token_buffer)
{
OM_uint32 ret;
spnego_gss_ctx_id_t sc = (spnego_gss_ctx_id_t)context_handle;
/* SPNEGO doesn't have its own context tokens. */
if (!sc->opened)
return (GSS_S_DEFECTIVE_TOKEN);
ret = gss_process_context_token(minor_status,
sc->ctx_handle,
token_buffer);
return (ret);
}
| 1 |
C
|
CWE-763
|
Release of Invalid Pointer or Reference
|
The application attempts to return a memory resource to the system, but calls the wrong release function or calls the appropriate release function incorrectly.
|
https://cwe.mitre.org/data/definitions/763.html
|
safe
|
static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
{
struct crypto_report_blkcipher rblkcipher;
strncpy(rblkcipher.type, "givcipher", sizeof(rblkcipher.type));
strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<built-in>",
sizeof(rblkcipher.geniv));
rblkcipher.blocksize = alg->cra_blocksize;
rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize;
rblkcipher.max_keysize = alg->cra_ablkcipher.max_keysize;
rblkcipher.ivsize = alg->cra_ablkcipher.ivsize;
if (nla_put(skb, CRYPTOCFGA_REPORT_BLKCIPHER,
sizeof(struct crypto_report_blkcipher), &rblkcipher))
goto nla_put_failure;
return 0;
nla_put_failure:
return -EMSGSIZE;
}
| 1 |
C
|
CWE-310
|
Cryptographic Issues
|
Weaknesses in this category are related to the design and implementation of data confidentiality and integrity. Frequently these deal with the use of encoding techniques, encryption libraries, and hashing algorithms. The weaknesses in this category could lead to a degradation of the quality data if they are not addressed.
|
https://cwe.mitre.org/data/definitions/310.html
|
safe
|
process(register int code, unsigned char** fill)
{
int incode;
static unsigned char firstchar;
if (code == clear) {
codesize = datasize + 1;
codemask = (1 << codesize) - 1;
avail = clear + 2;
oldcode = -1;
return 1;
}
if (oldcode == -1) {
if (code >= clear) {
fprintf(stderr, "bad input: code=%d is larger than clear=%d\n",code, clear);
return 0;
}
*(*fill)++ = suffix[code];
firstchar = oldcode = code;
return 1;
}
if (code > avail) {
fprintf(stderr, "code %d too large for %d\n", code, avail);
return 0;
}
incode = code;
if (code == avail) { /* the first code is always < avail */
*stackp++ = firstchar;
code = oldcode;
}
while (code > clear) {
*stackp++ = suffix[code];
code = prefix[code];
}
*stackp++ = firstchar = suffix[code];
prefix[avail] = oldcode;
suffix[avail] = firstchar;
avail++;
if (((avail & codemask) == 0) && (avail < 4096)) {
codesize++;
codemask += avail;
}
oldcode = incode;
do {
*(*fill)++ = *--stackp;
} while (stackp > stack);
return 1;
}
| 1 |
C
|
CWE-119
|
Improper Restriction of Operations within the Bounds of a Memory Buffer
|
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
|
https://cwe.mitre.org/data/definitions/119.html
|
safe
|
static int xen_evtchn_cpu_prepare(unsigned int cpu)
{
int ret = 0;
xen_cpu_init_eoi(cpu);
if (evtchn_ops->percpu_init)
ret = evtchn_ops->percpu_init(cpu);
return ret;
}
| 1 |
C
|
NVD-CWE-noinfo
| null | null | null |
safe
|
spnego_gss_wrap_aead(OM_uint32 *minor_status,
gss_ctx_id_t context_handle,
int conf_req_flag,
gss_qop_t qop_req,
gss_buffer_t input_assoc_buffer,
gss_buffer_t input_payload_buffer,
int *conf_state,
gss_buffer_t output_message_buffer)
{
OM_uint32 ret;
spnego_gss_ctx_id_t sc = (spnego_gss_ctx_id_t)context_handle;
if (sc->ctx_handle == GSS_C_NO_CONTEXT)
return (GSS_S_NO_CONTEXT);
ret = gss_wrap_aead(minor_status,
sc->ctx_handle,
conf_req_flag,
qop_req,
input_assoc_buffer,
input_payload_buffer,
conf_state,
output_message_buffer);
return (ret);
}
| 1 |
C
|
CWE-763
|
Release of Invalid Pointer or Reference
|
The application attempts to return a memory resource to the system, but calls the wrong release function or calls the appropriate release function incorrectly.
|
https://cwe.mitre.org/data/definitions/763.html
|
safe
|
static int proc_sys_readdir(struct file *file, struct dir_context *ctx)
{
struct ctl_table_header *head = grab_header(file_inode(file));
struct ctl_table_header *h = NULL;
struct ctl_table *entry;
struct ctl_dir *ctl_dir;
unsigned long pos;
if (IS_ERR(head))
return PTR_ERR(head);
ctl_dir = container_of(head, struct ctl_dir, header);
if (!dir_emit_dots(file, ctx))
return 0;
pos = 2;
for (first_entry(ctl_dir, &h, &entry); h; next_entry(&h, &entry)) {
if (!scan(h, entry, &pos, file, ctx)) {
sysctl_head_finish(h);
break;
}
}
sysctl_head_finish(head);
return 0;
}
| 0 |
C
|
CWE-399
|
Resource Management Errors
|
Weaknesses in this category are related to improper management of system resources.
|
https://cwe.mitre.org/data/definitions/399.html
|
vulnerable
|
generate_loadvar(
cctx_T *cctx,
assign_dest_T dest,
char_u *name,
lvar_T *lvar,
type_T *type)
{
switch (dest)
{
case dest_option:
case dest_func_option:
generate_LOAD(cctx, ISN_LOADOPT, 0, name, type);
break;
case dest_global:
if (vim_strchr(name, AUTOLOAD_CHAR) == NULL)
{
if (name[2] == NUL)
generate_instr_type(cctx, ISN_LOADGDICT, &t_dict_any);
else
generate_LOAD(cctx, ISN_LOADG, 0, name + 2, type);
}
else
generate_LOAD(cctx, ISN_LOADAUTO, 0, name, type);
break;
case dest_buffer:
generate_LOAD(cctx, ISN_LOADB, 0, name + 2, type);
break;
case dest_window:
generate_LOAD(cctx, ISN_LOADW, 0, name + 2, type);
break;
case dest_tab:
generate_LOAD(cctx, ISN_LOADT, 0, name + 2, type);
break;
case dest_script:
compile_load_scriptvar(cctx,
name + (name[1] == ':' ? 2 : 0), NULL, NULL);
break;
case dest_env:
// Include $ in the name here
generate_LOAD(cctx, ISN_LOADENV, 0, name, type);
break;
case dest_reg:
generate_LOAD(cctx, ISN_LOADREG, name[1], NULL, &t_string);
break;
case dest_vimvar:
generate_LOADV(cctx, name + 2);
break;
case dest_local:
if (cctx->ctx_skip != SKIP_YES)
{
if (lvar->lv_from_outer > 0)
generate_LOADOUTER(cctx, lvar->lv_idx, lvar->lv_from_outer,
type);
else
generate_LOAD(cctx, ISN_LOAD, lvar->lv_idx, NULL, type);
}
break;
case dest_expr:
// list or dict value should already be on the stack.
break;
}
}
| 1 |
C
|
CWE-476
|
NULL Pointer Dereference
|
A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.
|
https://cwe.mitre.org/data/definitions/476.html
|
safe
|
static int uio_mmap_physical(struct vm_area_struct *vma)
{
struct uio_device *idev = vma->vm_private_data;
int mi = uio_find_mem_index(vma);
struct uio_mem *mem;
if (mi < 0)
return -EINVAL;
mem = idev->info->mem + mi;
if (vma->vm_end - vma->vm_start > mem->size)
return -EINVAL;
vma->vm_ops = &uio_physical_vm_ops;
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
/*
* We cannot use the vm_iomap_memory() helper here,
* because vma->vm_pgoff is the map index we looked
* up above in uio_find_mem_index(), rather than an
* actual page offset into the mmap.
*
* So we just do the physical mmap without a page
* offset.
*/
return remap_pfn_range(vma,
vma->vm_start,
mem->addr >> PAGE_SHIFT,
vma->vm_end - vma->vm_start,
vma->vm_page_prot);
}
| 1 |
C
|
CWE-189
|
Numeric Errors
|
Weaknesses in this category are related to improper calculation or conversion of numbers.
|
https://cwe.mitre.org/data/definitions/189.html
|
safe
|
SPL_METHOD(RecursiveDirectoryIterator, getSubPath)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (intern->u.dir.sub_path) {
RETURN_STRINGL(intern->u.dir.sub_path, intern->u.dir.sub_path_len, 1);
} else {
RETURN_STRINGL("", 0, 1);
}
}
| 0 |
C
|
CWE-190
|
Integer Overflow or Wraparound
|
The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
|
https://cwe.mitre.org/data/definitions/190.html
|
vulnerable
|
struct clock_source *dce110_clock_source_create(
struct dc_context *ctx,
struct dc_bios *bios,
enum clock_source_id id,
const struct dce110_clk_src_regs *regs,
bool dp_clk_src)
{
struct dce110_clk_src *clk_src =
kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
if (!clk_src)
return NULL;
if (dce110_clk_src_construct(clk_src, ctx, bios, id,
regs, &cs_shift, &cs_mask)) {
clk_src->base.dp_clk_src = dp_clk_src;
return &clk_src->base;
}
kfree(clk_src);
BREAK_TO_DEBUGGER();
return NULL;
}
| 1 |
C
|
CWE-401
|
Missing Release of Memory after Effective Lifetime
|
The software does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory.
|
https://cwe.mitre.org/data/definitions/401.html
|
safe
|
void* chk_malloc(size_t bytes)
{
size_t size = bytes + CHK_OVERHEAD_SIZE;
if (size < bytes) { // Overflow.
return NULL;
}
uint8_t* buffer = (uint8_t*) dlmalloc(size);
if (buffer) {
memset(buffer, CHK_SENTINEL_VALUE, bytes + CHK_OVERHEAD_SIZE);
size_t offset = dlmalloc_usable_size(buffer) - sizeof(size_t);
*(size_t *)(buffer + offset) = bytes;
buffer += CHK_SENTINEL_HEAD_SIZE;
}
return buffer;
}
| 1 |
C
|
CWE-189
|
Numeric Errors
|
Weaknesses in this category are related to improper calculation or conversion of numbers.
|
https://cwe.mitre.org/data/definitions/189.html
|
safe
|
static struct ip_options *ip_options_get_alloc(const int optlen)
{
return kzalloc(sizeof(struct ip_options) + ((optlen + 3) & ~3),
GFP_KERNEL);
}
| 0 |
C
|
CWE-362
|
Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
|
The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.
|
https://cwe.mitre.org/data/definitions/362.html
|
vulnerable
|
static inline __must_check bool pipe_buf_get(struct pipe_inode_info *pipe,
struct pipe_buffer *buf)
{
return buf->ops->get(pipe, buf);
}
| 1 |
C
|
CWE-416
|
Use After Free
|
Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.
|
https://cwe.mitre.org/data/definitions/416.html
|
safe
|
kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args)
{
if (args->flags & ~(KVM_IRQFD_FLAG_DEASSIGN | KVM_IRQFD_FLAG_RESAMPLE))
return -EINVAL;
if (args->gsi >= KVM_MAX_IRQ_ROUTES)
return -EINVAL;
if (args->flags & KVM_IRQFD_FLAG_DEASSIGN)
return kvm_irqfd_deassign(kvm, args);
return kvm_irqfd_assign(kvm, args);
}
| 1 |
C
|
CWE-20
|
Improper Input Validation
|
The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly.
|
https://cwe.mitre.org/data/definitions/20.html
|
safe
|
unsigned long insn_get_seg_base(struct pt_regs *regs, int seg_reg_idx)
{
struct desc_struct desc;
short sel;
sel = get_segment_selector(regs, seg_reg_idx);
if (sel < 0)
return -1L;
if (v8086_mode(regs))
/*
* Base is simply the segment selector shifted 4
* bits to the right.
*/
return (unsigned long)(sel << 4);
if (user_64bit_mode(regs)) {
/*
* Only FS or GS will have a base address, the rest of
* the segments' bases are forced to 0.
*/
unsigned long base;
if (seg_reg_idx == INAT_SEG_REG_FS)
rdmsrl(MSR_FS_BASE, base);
else if (seg_reg_idx == INAT_SEG_REG_GS)
/*
* swapgs was called at the kernel entry point. Thus,
* MSR_KERNEL_GS_BASE will have the user-space GS base.
*/
rdmsrl(MSR_KERNEL_GS_BASE, base);
else
base = 0;
return base;
}
/* In protected mode the segment selector cannot be null. */
if (!sel)
return -1L;
if (!get_desc(&desc, sel))
return -1L;
return get_desc_base(&desc);
}
| 1 |
C
|
CWE-362
|
Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
|
The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.
|
https://cwe.mitre.org/data/definitions/362.html
|
safe
|
f_pyeval(typval_T *argvars, typval_T *rettv)
{
char_u *str;
char_u buf[NUMBUFLEN];
if (check_restricted() || check_secure())
return;
if (p_pyx == 0)
p_pyx = 2;
str = tv_get_string_buf(&argvars[0], buf);
do_pyeval(str, rettv);
}
| 1 |
C
|
CWE-78
|
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
|
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
|
https://cwe.mitre.org/data/definitions/78.html
|
safe
|
SPL_METHOD(SplFileObject, ftruncate)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
long size;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &size) == FAILURE) {
return;
}
if (!php_stream_truncate_supported(intern->u.file.stream)) {
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Can't truncate file %s", intern->file_name);
RETURN_FALSE;
}
RETURN_BOOL(0 == php_stream_truncate_set_size(intern->u.file.stream, size));
} /* }}} */
| 1 |
C
|
CWE-190
|
Integer Overflow or Wraparound
|
The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
|
https://cwe.mitre.org/data/definitions/190.html
|
safe
|
mISDN_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t len, int flags)
{
struct sk_buff *skb;
struct sock *sk = sock->sk;
struct sockaddr_mISDN *maddr;
int copied, err;
if (*debug & DEBUG_SOCKET)
printk(KERN_DEBUG "%s: len %d, flags %x ch.nr %d, proto %x\n",
__func__, (int)len, flags, _pms(sk)->ch.nr,
sk->sk_protocol);
if (flags & (MSG_OOB))
return -EOPNOTSUPP;
if (sk->sk_state == MISDN_CLOSED)
return 0;
skb = skb_recv_datagram(sk, flags, flags & MSG_DONTWAIT, &err);
if (!skb)
return err;
if (msg->msg_namelen >= sizeof(struct sockaddr_mISDN)) {
msg->msg_namelen = sizeof(struct sockaddr_mISDN);
maddr = (struct sockaddr_mISDN *)msg->msg_name;
maddr->family = AF_ISDN;
maddr->dev = _pms(sk)->dev->id;
if ((sk->sk_protocol == ISDN_P_LAPD_TE) ||
(sk->sk_protocol == ISDN_P_LAPD_NT)) {
maddr->channel = (mISDN_HEAD_ID(skb) >> 16) & 0xff;
maddr->tei = (mISDN_HEAD_ID(skb) >> 8) & 0xff;
maddr->sapi = mISDN_HEAD_ID(skb) & 0xff;
} else {
maddr->channel = _pms(sk)->ch.nr;
maddr->sapi = _pms(sk)->ch.addr & 0xFF;
maddr->tei = (_pms(sk)->ch.addr >> 8) & 0xFF;
}
} else {
if (msg->msg_namelen)
printk(KERN_WARNING "%s: too small namelen %d\n",
__func__, msg->msg_namelen);
msg->msg_namelen = 0;
}
copied = skb->len + MISDN_HEADER_LEN;
if (len < copied) {
if (flags & MSG_PEEK)
atomic_dec(&skb->users);
else
skb_queue_head(&sk->sk_receive_queue, skb);
return -ENOSPC;
}
memcpy(skb_push(skb, MISDN_HEADER_LEN), mISDN_HEAD_P(skb),
MISDN_HEADER_LEN);
err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
mISDN_sock_cmsg(sk, msg, skb);
skb_free_datagram(sk, skb);
return err ? : copied;
}
| 0 |
C
|
CWE-20
|
Improper Input Validation
|
The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly.
|
https://cwe.mitre.org/data/definitions/20.html
|
vulnerable
|
win_alloc_lines(win_T *wp)
{
wp->w_lines_valid = 0;
wp->w_lines = ALLOC_CLEAR_MULT(wline_T, Rows );
if (wp->w_lines == NULL)
return FAIL;
return OK;
}
| 0 |
C
|
CWE-125
|
Out-of-bounds Read
|
The software reads data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/125.html
|
vulnerable
|
static StkId rethook (lua_State *L, CallInfo *ci, StkId firstres, int nres) {
ptrdiff_t oldtop = savestack(L, L->top); /* hook may change top */
int delta = 0;
if (isLuacode(ci)) {
Proto *p = clLvalue(s2v(ci->func))->p;
if (p->is_vararg)
delta = ci->u.l.nextraargs + p->numparams + 1;
if (L->top < ci->top)
L->top = ci->top; /* correct top to run hook */
}
if (L->hookmask & LUA_MASKRET) { /* is return hook on? */
int ftransfer;
ci->func += delta; /* if vararg, back to virtual 'func' */
ftransfer = cast(unsigned short, firstres - ci->func);
luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres); /* call it */
ci->func -= delta;
}
if (isLua(ci->previous))
L->oldpc = ci->previous->u.l.savedpc; /* update 'oldpc' */
return restorestack(L, oldtop);
}
| 0 |
C
|
NVD-CWE-Other
|
Other
|
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
|
https://nvd.nist.gov/vuln/categories
|
vulnerable
|
l2tp_msgtype_print(netdissect_options *ndo, const u_char *dat)
{
const uint16_t *ptr = (const uint16_t *)dat;
ND_PRINT((ndo, "%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
EXTRACT_16BITS(ptr))));
}
| 0 |
C
|
CWE-125
|
Out-of-bounds Read
|
The software reads data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/125.html
|
vulnerable
|
snmp_api_set_string(snmp_varbind_t *varbind, uint32_t *oid, char *string)
{
snmp_api_replace_oid(varbind, oid);
varbind->value_type = BER_DATA_TYPE_OCTET_STRING;
varbind->value.string.string = string;
varbind->value.string.length = strlen(string);
}
| 0 |
C
|
CWE-125
|
Out-of-bounds Read
|
The software reads data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/125.html
|
vulnerable
|
static int __key_instantiate_and_link(struct key *key,
struct key_preparsed_payload *prep,
struct key *keyring,
struct key *authkey,
struct assoc_array_edit **_edit)
{
int ret, awaken;
key_check(key);
key_check(keyring);
awaken = 0;
ret = -EBUSY;
mutex_lock(&key_construction_mutex);
/* can't instantiate twice */
if (!test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) {
/* instantiate the key */
ret = key->type->instantiate(key, prep);
if (ret == 0) {
/* mark the key as being instantiated */
atomic_inc(&key->user->nikeys);
set_bit(KEY_FLAG_INSTANTIATED, &key->flags);
if (test_and_clear_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags))
awaken = 1;
/* and link it into the destination keyring */
if (keyring) {
if (test_bit(KEY_FLAG_KEEP, &keyring->flags))
set_bit(KEY_FLAG_KEEP, &key->flags);
__key_link(key, _edit);
}
/* disable the authorisation key */
if (authkey)
key_revoke(authkey);
if (prep->expiry != TIME_T_MAX) {
key->expiry = prep->expiry;
key_schedule_gc(prep->expiry + key_gc_delay);
}
}
}
mutex_unlock(&key_construction_mutex);
/* wake up anyone waiting for a key to be constructed */
if (awaken)
wake_up_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT);
return ret;
}
| 0 |
C
|
CWE-20
|
Improper Input Validation
|
The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly.
|
https://cwe.mitre.org/data/definitions/20.html
|
vulnerable
|
get_word_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* This version is for reading raw-word-format PPM files with any maxval */
{
ppm_source_ptr source = (ppm_source_ptr)sinfo;
register JSAMPROW ptr;
register U_CHAR *bufferptr;
register JSAMPLE *rescale = source->rescale;
JDIMENSION col;
unsigned int maxval = source->maxval;
if (!ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width))
ERREXIT(cinfo, JERR_INPUT_EOF);
ptr = source->pub.buffer[0];
bufferptr = source->iobuffer;
for (col = cinfo->image_width; col > 0; col--) {
register unsigned int temp;
temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++);
if (temp > maxval)
ERREXIT(cinfo, JERR_PPM_TOOLARGE);
*ptr++ = rescale[temp];
temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++);
if (temp > maxval)
ERREXIT(cinfo, JERR_PPM_TOOLARGE);
*ptr++ = rescale[temp];
temp = UCH(*bufferptr++) << 8;
temp |= UCH(*bufferptr++);
if (temp > maxval)
ERREXIT(cinfo, JERR_PPM_TOOLARGE);
*ptr++ = rescale[temp];
}
return 1;
}
| 0 |
C
|
CWE-125
|
Out-of-bounds Read
|
The software reads data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/125.html
|
vulnerable
|
char *cJSON_Print(cJSON *item) {return print_value(item,0,1,0);}
| 1 |
C
|
CWE-120
|
Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')
|
The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.
|
https://cwe.mitre.org/data/definitions/120.html
|
safe
|
sysLocation_handler(snmp_varbind_t *varbind, uint32_t *oid)
{
snmp_api_set_string(varbind, oid, "");
}
| 0 |
C
|
CWE-125
|
Out-of-bounds Read
|
The software reads data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/125.html
|
vulnerable
|
netsnmp_mibindex_lookup( const char *dirname )
{
int i;
static char tmpbuf[300];
for (i=0; i<_mibindex; i++) {
if ( _mibindexes[i] &&
strcmp( _mibindexes[i], dirname ) == 0) {
snprintf(tmpbuf, sizeof(tmpbuf), "%s/mib_indexes/%d",
get_persistent_directory(), i);
tmpbuf[sizeof(tmpbuf)-1] = 0;
DEBUGMSGTL(("mibindex", "lookup: %s (%d) %s\n", dirname, i, tmpbuf ));
return tmpbuf;
}
}
DEBUGMSGTL(("mibindex", "lookup: (none)\n"));
return NULL;
}
| 0 |
C
|
CWE-59
|
Improper Link Resolution Before File Access ('Link Following')
|
The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.
|
https://cwe.mitre.org/data/definitions/59.html
|
vulnerable
|
ast_for_async_funcdef(struct compiling *c, const node *n, asdl_seq *decorator_seq)
{
/* async_funcdef: ASYNC funcdef */
REQ(n, async_funcdef);
REQ(CHILD(n, 0), ASYNC);
REQ(CHILD(n, 1), funcdef);
return ast_for_funcdef_impl(c, CHILD(n, 1), decorator_seq,
1 /* is_async */);
}
| 0 |
C
|
CWE-125
|
Out-of-bounds Read
|
The software reads data past the end, or before the beginning, of the intended buffer.
|
https://cwe.mitre.org/data/definitions/125.html
|
vulnerable
|
static int rtl8xxxu_submit_int_urb(struct ieee80211_hw *hw)
{
struct rtl8xxxu_priv *priv = hw->priv;
struct urb *urb;
u32 val32;
int ret;
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb)
return -ENOMEM;
usb_fill_int_urb(urb, priv->udev, priv->pipe_interrupt,
priv->int_buf, USB_INTR_CONTENT_LENGTH,
rtl8xxxu_int_complete, priv, 1);
usb_anchor_urb(urb, &priv->int_anchor);
ret = usb_submit_urb(urb, GFP_KERNEL);
if (ret) {
usb_unanchor_urb(urb);
usb_free_urb(urb);
goto error;
}
val32 = rtl8xxxu_read32(priv, REG_USB_HIMR);
val32 |= USB_HIMR_CPWM;
rtl8xxxu_write32(priv, REG_USB_HIMR, val32);
error:
return ret;
}
| 1 |
C
|
CWE-401
|
Missing Release of Memory after Effective Lifetime
|
The software does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory.
|
https://cwe.mitre.org/data/definitions/401.html
|
safe
|
static int sd_compat_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
struct scsi_device *sdev = scsi_disk(bdev->bd_disk)->device;
/*
* If we are in the middle of error recovery, don't let anyone
* else try and use this device. Also, if error recovery fails, it
* may try and take the device offline, in which case all further
* access to the device is prohibited.
*/
if (!scsi_block_when_processing_errors(sdev))
return -ENODEV;
if (sdev->host->hostt->compat_ioctl) {
int ret;
ret = sdev->host->hostt->compat_ioctl(sdev, cmd, (void __user *)arg);
return ret;
}
/*
* Let the static ioctl translation table take care of it.
*/
return -ENOIOCTLCMD;
}
| 0 |
C
|
CWE-264
|
Permissions, Privileges, and Access Controls
|
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
|
https://cwe.mitre.org/data/definitions/264.html
|
vulnerable
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.