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 int tipc_nl_compat_link_dump(struct tipc_nl_compat_msg *msg,
struct nlattr **attrs)
{
struct nlattr *link[TIPC_NLA_LINK_MAX + 1];
struct tipc_link_info link_info;
int err;
if (!attrs[TIPC_NLA_LINK])
return -EINVAL;
err = nla_parse_nested(link, TIPC_NLA_LINK_MAX, attrs[TIPC_NLA_LINK],
NULL);
if (err)
return err;
link_info.dest = nla_get_flag(link[TIPC_NLA_LINK_DEST]);
link_info.up = htonl(nla_get_flag(link[TIPC_NLA_LINK_UP]));
nla_strlcpy(link_info.str, nla_data(link[TIPC_NLA_LINK_NAME]),
TIPC_MAX_LINK_NAME);
return tipc_add_tlv(msg->rep, TIPC_TLV_LINK_INFO,
&link_info, sizeof(link_info));
}
| 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
|
static int gasp_source_id(__be32 *p)
{
return be32_to_cpu(p[0]) >> 16;
}
| 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
|
int handle_popc(u32 insn, struct pt_regs *regs)
{
u64 value;
int ret, i, rd = ((insn >> 25) & 0x1f);
int from_kernel = (regs->tstate & TSTATE_PRIV) != 0;
perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, regs, 0);
if (insn & 0x2000) {
maybe_flush_windows(0, 0, rd, from_kernel);
value = sign_extend_imm13(insn);
} else {
maybe_flush_windows(0, insn & 0x1f, rd, from_kernel);
value = fetch_reg(insn & 0x1f, regs);
}
for (ret = 0, i = 0; i < 16; i++) {
ret += popc_helper[value & 0xf];
value >>= 4;
}
if (rd < 16) {
if (rd)
regs->u_regs[rd] = ret;
} else {
if (test_thread_flag(TIF_32BIT)) {
struct reg_window32 __user *win32;
win32 = (struct reg_window32 __user *)((unsigned long)((u32)regs->u_regs[UREG_FP]));
put_user(ret, &win32->locals[rd - 16]);
} else {
struct reg_window __user *win;
win = (struct reg_window __user *)(regs->u_regs[UREG_FP] + STACK_BIAS);
put_user(ret, &win->locals[rd - 16]);
}
}
advance(regs);
return 1;
}
| 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 void umount_tree(struct mount *mnt, enum umount_tree_flags how)
{
LIST_HEAD(tmp_list);
struct mount *p;
if (how & UMOUNT_PROPAGATE)
propagate_mount_unlock(mnt);
/* Gather the mounts to umount */
for (p = mnt; p; p = next_mnt(p, mnt)) {
p->mnt.mnt_flags |= MNT_UMOUNT;
list_move(&p->mnt_list, &tmp_list);
}
/* Hide the mounts from mnt_mounts */
list_for_each_entry(p, &tmp_list, mnt_list) {
list_del_init(&p->mnt_child);
}
/* Add propogated mounts to the tmp_list */
if (how & UMOUNT_PROPAGATE)
propagate_umount(&tmp_list);
while (!list_empty(&tmp_list)) {
bool disconnect;
p = list_first_entry(&tmp_list, struct mount, mnt_list);
list_del_init(&p->mnt_expire);
list_del_init(&p->mnt_list);
__touch_mnt_namespace(p->mnt_ns);
p->mnt_ns = NULL;
if (how & UMOUNT_SYNC)
p->mnt.mnt_flags |= MNT_SYNC_UMOUNT;
disconnect = disconnect_mount(p, how);
pin_insert_group(&p->mnt_umount, &p->mnt_parent->mnt,
disconnect ? &unmounted : NULL);
if (mnt_has_parent(p)) {
mnt_add_count(p->mnt_parent, -1);
if (!disconnect) {
/* Don't forget about p */
list_add_tail(&p->mnt_child, &p->mnt_parent->mnt_mounts);
} else {
umount_mnt(p);
}
}
change_mnt_propagation(p, MS_PRIVATE);
}
}
| 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
|
fep_client_open (const char *address)
{
FepClient *client;
struct sockaddr_un sun;
ssize_t sun_len;
int retval;
if (!address)
address = getenv ("LIBFEP_CONTROL_SOCK");
if (!address)
return NULL;
if (strlen (address) + 1 >= sizeof(sun.sun_path))
{
fep_log (FEP_LOG_LEVEL_WARNING,
"unix domain socket path too long: %d + 1 >= %d",
strlen (address),
sizeof (sun.sun_path));
free (address);
return NULL;
}
client = xzalloc (sizeof(FepClient));
client->filter_running = false;
client->messages = NULL;
memset (&sun, 0, sizeof(struct sockaddr_un));
sun.sun_family = AF_UNIX;
#ifdef __linux__
sun.sun_path[0] = '\0';
memcpy (sun.sun_path + 1, address, strlen (address));
sun_len = offsetof (struct sockaddr_un, sun_path) + strlen (address) + 1;
#else
memcpy (sun.sun_path, address, strlen (address));
sun_len = sizeof (struct sockaddr_un);
#endif
client->control = socket (AF_UNIX, SOCK_STREAM, 0);
if (client->control < 0)
{
free (client);
return NULL;
}
retval = connect (client->control,
(const struct sockaddr *) &sun,
sun_len);
if (retval < 0)
{
close (client->control);
free (client);
return NULL;
}
return client;
}
| 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 pppol2tp_setsockopt(struct socket *sock, int level, int optname,
char __user *optval, unsigned int optlen)
{
struct sock *sk = sock->sk;
struct l2tp_session *session;
struct l2tp_tunnel *tunnel;
struct pppol2tp_session *ps;
int val;
int err;
if (level != SOL_PPPOL2TP)
return udp_prot.setsockopt(sk, level, optname, optval, optlen);
if (optlen < sizeof(int))
return -EINVAL;
if (get_user(val, (int __user *)optval))
return -EFAULT;
err = -ENOTCONN;
if (sk->sk_user_data == NULL)
goto end;
/* Get session context from the socket */
err = -EBADF;
session = pppol2tp_sock_to_session(sk);
if (session == NULL)
goto end;
/* Special case: if session_id == 0x0000, treat as operation on tunnel
*/
ps = l2tp_session_priv(session);
if ((session->session_id == 0) &&
(session->peer_session_id == 0)) {
err = -EBADF;
tunnel = l2tp_sock_to_tunnel(ps->tunnel_sock);
if (tunnel == NULL)
goto end_put_sess;
err = pppol2tp_tunnel_setsockopt(sk, tunnel, optname, val);
sock_put(ps->tunnel_sock);
} else
err = pppol2tp_session_setsockopt(sk, session, optname, val);
err = 0;
end_put_sess:
sock_put(sk);
end:
return err;
}
| 0 |
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
|
vulnerable
|
int multiplyCheckOverflow(int a, int b, int *result)
{
#if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow))
return __builtin_mul_overflow(a, b, result);
#else
if (firstBitSet(a)+firstBitSet(b)>31) // int is signed, so we can't use 32 bits
return true;
*result = a * b;
return false;
#endif
}
| 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 free_user(struct kref *ref)
{
struct ipmi_user *user = container_of(ref, struct ipmi_user, refcount);
cleanup_srcu_struct(&user->release_barrier);
kfree(user);
}
| 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
|
static void generateTable(int argc, char **argv)
{
Edi *edi;
cchar *field;
char *typeString;
int rc, i, type;
app->table = app->table ? app->table : sclone(argv[0]);
if ((edi = app->eroute->edi) == 0) {
fail("Database not defined");
return;
}
edi->flags |= EDI_SUPPRESS_SAVE;
if ((rc = ediAddTable(edi, app->table)) < 0) {
if (rc != MPR_ERR_ALREADY_EXISTS) {
fail("Cannot add table '%s'", app->table);
}
} else {
if ((rc = ediAddColumn(edi, app->table, "id", EDI_TYPE_INT, EDI_AUTO_INC | EDI_INDEX | EDI_KEY)) != 0) {
fail("Cannot add column 'id'");
}
}
for (i = 1; i < argc && !app->error; i++) {
field = stok(sclone(argv[i]), ":", &typeString);
if ((type = ediParseTypeString(typeString)) < 0) {
fail("Unknown type '%s' for field '%s'", typeString, field);
break;
}
if ((rc = ediAddColumn(edi, app->table, field, type, 0)) != 0) {
if (rc != MPR_ERR_ALREADY_EXISTS) {
fail("Cannot add column '%s'", field);
break;
} else {
ediChangeColumn(edi, app->table, field, type, 0);
}
}
}
edi->flags &= ~EDI_SUPPRESS_SAVE;
ediSave(edi);
qtrace("Update", "Database schema");
}
| 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
|
void ntlm_free_message_fields_buffer(NTLM_MESSAGE_FIELDS* fields)
{
if (fields)
{
if (fields->Buffer)
{
free(fields->Buffer);
fields->Len = 0;
fields->MaxLen = 0;
fields->Buffer = NULL;
fields->BufferOffset = 0;
}
}
}
| 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
|
void __init proc_root_init(void)
{
struct vfsmount *mnt;
int err;
proc_init_inodecache();
err = register_filesystem(&proc_fs_type);
if (err)
return;
mnt = kern_mount_data(&proc_fs_type, &init_pid_ns);
if (IS_ERR(mnt)) {
unregister_filesystem(&proc_fs_type);
return;
}
init_pid_ns.proc_mnt = mnt;
proc_symlink("mounts", NULL, "self/mounts");
proc_net_init();
#ifdef CONFIG_SYSVIPC
proc_mkdir("sysvipc", NULL);
#endif
proc_mkdir("fs", NULL);
proc_mkdir("driver", NULL);
proc_mkdir("fs/nfsd", NULL); /* somewhere for the nfsd filesystem to be mounted */
#if defined(CONFIG_SUN_OPENPROMFS) || defined(CONFIG_SUN_OPENPROMFS_MODULE)
/* just give it a mountpoint */
proc_mkdir("openprom", NULL);
#endif
proc_tty_init();
#ifdef CONFIG_PROC_DEVICETREE
proc_device_tree_init();
#endif
proc_mkdir("bus", NULL);
proc_sys_init();
}
| 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 inline void init_fs_pin(struct fs_pin *p, void (*kill)(struct fs_pin *))
{
init_waitqueue_head(&p->wait);
INIT_HLIST_NODE(&p->s_list);
INIT_HLIST_NODE(&p->m_list);
p->kill = kill;
}
| 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
|
static int vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{
struct v4l2_loopback_device *dev = v4l2loopback_getdevice(file);
int labellen = (sizeof(cap->card) < sizeof(dev->card_label)) ?
sizeof(cap->card) :
sizeof(dev->card_label);
int device_nr =
((struct v4l2loopback_private *)video_get_drvdata(dev->vdev))
->device_nr;
__u32 capabilities = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
strlcpy(cap->driver, "v4l2 loopback", sizeof(cap->driver));
snprintf(cap->card, labellen, dev->card_label);
snprintf(cap->bus_info, sizeof(cap->bus_info),
"platform:v4l2loopback-%03d", device_nr);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0)
/* since 3.1.0, the v4l2-core system is supposed to set the version */
cap->version = V4L2LOOPBACK_VERSION_CODE;
#endif
#ifdef V4L2_CAP_VIDEO_M2M
capabilities |= V4L2_CAP_VIDEO_M2M;
#endif /* V4L2_CAP_VIDEO_M2M */
if (dev->announce_all_caps) {
capabilities |= V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT;
} else {
if (dev->ready_for_capture) {
capabilities |= V4L2_CAP_VIDEO_CAPTURE;
}
if (dev->ready_for_output) {
capabilities |= V4L2_CAP_VIDEO_OUTPUT;
}
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
dev->vdev->device_caps =
#endif /* >=linux-4.7.0 */
cap->device_caps = cap->capabilities = capabilities;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
cap->capabilities |= V4L2_CAP_DEVICE_CAPS;
#endif
memset(cap->reserved, 0, sizeof(cap->reserved));
return 0;
}
| 0 |
C
|
CWE-134
|
Use of Externally-Controlled Format String
|
The software uses a function that accepts a format string as an argument, but the format string originates from an external source.
|
https://cwe.mitre.org/data/definitions/134.html
|
vulnerable
|
static int ax25_recvmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t size, int flags)
{
struct sock *sk = sock->sk;
struct sk_buff *skb;
int copied;
int err = 0;
lock_sock(sk);
/*
* This works for seqpacket too. The receiver has ordered the
* queue for us! We do one quick check first though
*/
if (sk->sk_type == SOCK_SEQPACKET && sk->sk_state != TCP_ESTABLISHED) {
err = -ENOTCONN;
goto out;
}
/* Now we can treat all alike */
skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
flags & MSG_DONTWAIT, &err);
if (skb == NULL)
goto out;
if (!ax25_sk(sk)->pidincl)
skb_pull(skb, 1); /* Remove PID */
skb_reset_transport_header(skb);
copied = skb->len;
if (copied > size) {
copied = size;
msg->msg_flags |= MSG_TRUNC;
}
skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
if (msg->msg_name) {
ax25_digi digi;
ax25_address src;
const unsigned char *mac = skb_mac_header(skb);
struct sockaddr_ax25 *sax = msg->msg_name;
memset(sax, 0, sizeof(struct full_sockaddr_ax25));
ax25_addr_parse(mac + 1, skb->data - mac - 1, &src, NULL,
&digi, NULL, NULL);
sax->sax25_family = AF_AX25;
/* We set this correctly, even though we may not let the
application know the digi calls further down (because it
did NOT ask to know them). This could get political... **/
sax->sax25_ndigis = digi.ndigi;
sax->sax25_call = src;
if (sax->sax25_ndigis != 0) {
int ct;
struct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)sax;
for (ct = 0; ct < digi.ndigi; ct++)
fsa->fsa_digipeater[ct] = digi.calls[ct];
}
msg->msg_namelen = sizeof(struct full_sockaddr_ax25);
}
skb_free_datagram(sk, skb);
err = copied;
out:
release_sock(sk);
return err;
}
| 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 void f2fs_put_super(struct super_block *sb)
{
struct f2fs_sb_info *sbi = F2FS_SB(sb);
int i;
f2fs_quota_off_umount(sb);
/* prevent remaining shrinker jobs */
mutex_lock(&sbi->umount_mutex);
/*
* We don't need to do checkpoint when superblock is clean.
* But, the previous checkpoint was not done by umount, it needs to do
* clean checkpoint again.
*/
if (is_sbi_flag_set(sbi, SBI_IS_DIRTY) ||
!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) {
struct cp_control cpc = {
.reason = CP_UMOUNT,
};
write_checkpoint(sbi, &cpc);
}
/* be sure to wait for any on-going discard commands */
f2fs_wait_discard_bios(sbi, true);
if (f2fs_discard_en(sbi) && !sbi->discard_blks) {
struct cp_control cpc = {
.reason = CP_UMOUNT | CP_TRIMMED,
};
write_checkpoint(sbi, &cpc);
}
/* write_checkpoint can update stat informaion */
f2fs_destroy_stats(sbi);
/*
* normally superblock is clean, so we need to release this.
* In addition, EIO will skip do checkpoint, we need this as well.
*/
release_ino_entry(sbi, true);
f2fs_leave_shrinker(sbi);
mutex_unlock(&sbi->umount_mutex);
/* our cp_error case, we can wait for any writeback page */
f2fs_flush_merged_writes(sbi);
iput(sbi->node_inode);
iput(sbi->meta_inode);
/* destroy f2fs internal modules */
destroy_node_manager(sbi);
destroy_segment_manager(sbi);
kfree(sbi->ckpt);
f2fs_unregister_sysfs(sbi);
sb->s_fs_info = NULL;
if (sbi->s_chksum_driver)
crypto_free_shash(sbi->s_chksum_driver);
kfree(sbi->raw_super);
destroy_device_list(sbi);
mempool_destroy(sbi->write_io_dummy);
#ifdef CONFIG_QUOTA
for (i = 0; i < MAXQUOTAS; i++)
kfree(sbi->s_qf_names[i]);
#endif
destroy_percpu_info(sbi);
for (i = 0; i < NR_PAGE_TYPE; i++)
kfree(sbi->write_io[i]);
kfree(sbi);
}
| 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
|
rpki_rtr_print(netdissect_options *ndo, register const u_char *pptr, register u_int len)
{
u_int tlen, pdu_type, pdu_len;
const u_char *tptr;
const rpki_rtr_pdu *pdu_header;
tptr = pptr;
tlen = len;
if (!ndo->ndo_vflag) {
ND_PRINT((ndo, ", RPKI-RTR"));
return;
}
while (tlen >= sizeof(rpki_rtr_pdu)) {
ND_TCHECK2(*tptr, sizeof(rpki_rtr_pdu));
pdu_header = (const rpki_rtr_pdu *)tptr;
pdu_type = pdu_header->pdu_type;
pdu_len = EXTRACT_32BITS(pdu_header->length);
ND_TCHECK2(*tptr, pdu_len);
/* infinite loop check */
if (!pdu_type || !pdu_len) {
break;
}
if (tlen < pdu_len) {
goto trunc;
}
/*
* Print the PDU.
*/
if (rpki_rtr_pdu_print(ndo, tptr, 8))
goto trunc;
tlen -= pdu_len;
tptr += pdu_len;
}
return;
trunc:
ND_PRINT((ndo, "\n\t%s", tstr));
}
| 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 filter_frame(AVFilterLink *inlink, AVFrame *in)
{
GradFunContext *s = inlink->dst->priv;
AVFilterLink *outlink = inlink->dst->outputs[0];
AVFrame *out;
int p, direct;
if (av_frame_is_writable(in)) {
direct = 1;
out = in;
} else {
direct = 0;
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out) {
av_frame_free(&in);
return AVERROR(ENOMEM);
}
av_frame_copy_props(out, in);
}
for (p = 0; p < 4 && in->data[p]; p++) {
int w = inlink->w;
int h = inlink->h;
int r = s->radius;
if (p) {
w = s->chroma_w;
h = s->chroma_h;
r = s->chroma_r;
}
if (FFMIN(w, h) > 2 * r)
filter(s, out->data[p], in->data[p], w, h, out->linesize[p], in->linesize[p], r);
else if (out->data[p] != in->data[p])
av_image_copy_plane(out->data[p], out->linesize[p], in->data[p], in->linesize[p], w, h);
}
if (!direct)
av_frame_free(&in);
return ff_filter_frame(outlink, out);
}
| 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
|
SPL_METHOD(RecursiveDirectoryIterator, getSubPathname)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
char *sub_name;
int len;
char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (intern->u.dir.sub_path) {
len = spprintf(&sub_name, 0, "%s%c%s", intern->u.dir.sub_path, slash, intern->u.dir.entry.d_name);
RETURN_STRINGL(sub_name, len, 0);
} else {
RETURN_STRING(intern->u.dir.entry.d_name, 1);
}
}
| 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
|
translate_hex_string(char *s, char *saved_orphan)
{
int c1 = *saved_orphan;
char *start = s;
char *t = s;
for (; *s; s++) {
if (isspace(*s))
continue;
if (c1) {
*t++ = (hexval(c1) << 4) + hexval(*s);
c1 = 0;
} else
c1 = *s;
}
*saved_orphan = c1;
return t - start;
}
| 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 mpage_put_bnr_to_bhs(struct mpage_da_data *mpd, sector_t logical,
struct buffer_head *exbh)
{
struct inode *inode = mpd->inode;
struct address_space *mapping = inode->i_mapping;
int blocks = exbh->b_size >> inode->i_blkbits;
sector_t pblock = exbh->b_blocknr, cur_logical;
struct buffer_head *head, *bh;
pgoff_t index, end;
struct pagevec pvec;
int nr_pages, i;
index = logical >> (PAGE_CACHE_SHIFT - inode->i_blkbits);
end = (logical + blocks - 1) >> (PAGE_CACHE_SHIFT - inode->i_blkbits);
cur_logical = index << (PAGE_CACHE_SHIFT - inode->i_blkbits);
pagevec_init(&pvec, 0);
while (index <= end) {
/* XXX: optimize tail */
nr_pages = pagevec_lookup(&pvec, mapping, index, PAGEVEC_SIZE);
if (nr_pages == 0)
break;
for (i = 0; i < nr_pages; i++) {
struct page *page = pvec.pages[i];
index = page->index;
if (index > end)
break;
index++;
BUG_ON(!PageLocked(page));
BUG_ON(PageWriteback(page));
BUG_ON(!page_has_buffers(page));
bh = page_buffers(page);
head = bh;
/* skip blocks out of the range */
do {
if (cur_logical >= logical)
break;
cur_logical++;
} while ((bh = bh->b_this_page) != head);
do {
if (cur_logical >= logical + blocks)
break;
if (buffer_delay(bh) ||
buffer_unwritten(bh)) {
BUG_ON(bh->b_bdev != inode->i_sb->s_bdev);
if (buffer_delay(bh)) {
clear_buffer_delay(bh);
bh->b_blocknr = pblock;
} else {
/*
* unwritten already should have
* blocknr assigned. Verify that
*/
clear_buffer_unwritten(bh);
BUG_ON(bh->b_blocknr != pblock);
}
} else if (buffer_mapped(bh))
BUG_ON(bh->b_blocknr != pblock);
if (buffer_uninit(exbh))
set_buffer_uninit(bh);
cur_logical++;
pblock++;
} while ((bh = bh->b_this_page) != head);
}
pagevec_release(&pvec);
}
}
| 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
|
zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)
{
spl_filesystem_iterator *iterator;
spl_filesystem_object *dir_object;
if (by_ref) {
zend_error(E_ERROR, "An iterator cannot be used with foreach by reference");
}
dir_object = (spl_filesystem_object*)zend_object_store_get_object(object TSRMLS_CC);
iterator = spl_filesystem_object_to_iterator(dir_object);
/* initialize iterator if it wasn't gotten before */
if (iterator->intern.data == NULL) {
iterator->intern.data = object;
iterator->intern.funcs = &spl_filesystem_dir_it_funcs;
/* ->current must be initialized; rewind doesn't set it and valid
* doesn't check whether it's set */
iterator->current = object;
}
zval_add_ref(&object);
return (zend_object_iterator*)iterator;
}
| 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 int http_buf_read(URLContext *h, uint8_t *buf, int size)
{
HTTPContext *s = h->priv_data;
int len;
/* read bytes from input buffer first */
len = s->buf_end - s->buf_ptr;
if (len > 0) {
if (len > size)
len = size;
memcpy(buf, s->buf_ptr, len);
s->buf_ptr += len;
} else {
uint64_t target_end = s->end_off ? s->end_off : s->filesize;
if ((!s->willclose || s->chunksize == UINT64_MAX) && s->off >= target_end)
return AVERROR_EOF;
len = ffurl_read(s->hd, buf, size);
if (!len && (!s->willclose || s->chunksize == UINT64_MAX) && s->off < target_end) {
av_log(h, AV_LOG_ERROR,
"Stream ends prematurely at %"PRIu64", should be %"PRIu64"\n",
s->off, target_end
);
return AVERROR(EIO);
}
}
if (len > 0) {
s->off += len;
if (s->chunksize > 0)
s->chunksize -= len;
}
return len;
}
| 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 uio_mmap_physical(struct vm_area_struct *vma)
{
struct uio_device *idev = vma->vm_private_data;
int mi = uio_find_mem_index(vma);
if (mi < 0)
return -EINVAL;
vma->vm_ops = &uio_physical_vm_ops;
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
return remap_pfn_range(vma,
vma->vm_start,
idev->info->mem[mi].addr >> PAGE_SHIFT,
vma->vm_end - vma->vm_start,
vma->vm_page_prot);
}
| 0 |
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
|
vulnerable
|
filter_session_io(struct io *io, int evt, void *arg)
{
struct filter_session *fs = arg;
char *line = NULL;
ssize_t len;
log_trace(TRACE_IO, "filter session: %p: %s %s", fs, io_strevent(evt),
io_strio(io));
switch (evt) {
case IO_DATAIN:
nextline:
line = io_getline(fs->io, &len);
/* No complete line received */
if (line == NULL)
return;
filter_data(fs->id, line);
goto nextline;
case IO_DISCONNECTED:
io_free(fs->io);
fs->io = NULL;
break;
}
}
| 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
|
static __u8 *nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev,
struct rf_tech_specific_params_nfcb_poll *nfcb_poll,
__u8 *data)
{
nfcb_poll->sensb_res_len = min_t(__u8, *data++, NFC_SENSB_RES_MAXSIZE);
pr_debug("sensb_res_len %d\n", nfcb_poll->sensb_res_len);
memcpy(nfcb_poll->sensb_res, data, nfcb_poll->sensb_res_len);
data += nfcb_poll->sensb_res_len;
return data;
}
| 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
|
SPL_METHOD(SplFileObject, eof)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(php_stream_eof(intern->u.file.stream));
} /* }}} */
| 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
|
static int uas_switch_interface(struct usb_device *udev,
struct usb_interface *intf)
{
struct usb_host_interface *alt;
alt = uas_find_uas_alt_setting(intf);
if (!alt)
return -ENODEV;
return usb_set_interface(udev, alt->desc.bInterfaceNumber,
alt->desc.bAlternateSetting);
}
| 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
|
cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb_vol *vol)
{
struct cifsSesInfo *ses;
write_lock(&cifs_tcp_ses_lock);
list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
switch (server->secType) {
case Kerberos:
if (vol->linux_uid != ses->linux_uid)
continue;
break;
default:
/* anything else takes username/password */
if (strncmp(ses->userName, vol->username,
MAX_USERNAME_SIZE))
continue;
if (strlen(vol->username) != 0 &&
strncmp(ses->password, vol->password,
MAX_PASSWORD_SIZE))
continue;
}
++ses->ses_count;
write_unlock(&cifs_tcp_ses_lock);
return ses;
}
write_unlock(&cifs_tcp_ses_lock);
return NULL;
}
| 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 int rfcomm_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t size, int flags)
{
struct sock *sk = sock->sk;
struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
int len;
if (test_and_clear_bit(RFCOMM_DEFER_SETUP, &d->flags)) {
rfcomm_dlc_accept(d);
msg->msg_namelen = 0;
return 0;
}
len = bt_sock_stream_recvmsg(iocb, sock, msg, size, flags);
lock_sock(sk);
if (!(flags & MSG_PEEK) && len > 0)
atomic_sub(len, &sk->sk_rmem_alloc);
if (atomic_read(&sk->sk_rmem_alloc) <= (sk->sk_rcvbuf >> 2))
rfcomm_dlc_unthrottle(rfcomm_pi(sk)->dlc);
release_sock(sk);
return len;
}
| 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 get_evtchn_to_irq(evtchn_port_t evtchn)
{
if (evtchn >= xen_evtchn_max_channels())
return -1;
if (evtchn_to_irq[EVTCHN_ROW(evtchn)] == NULL)
return -1;
return READ_ONCE(evtchn_to_irq[EVTCHN_ROW(evtchn)][EVTCHN_COL(evtchn)]);
}
| 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 jas_iccgetuint32(jas_stream_t *in, jas_iccuint32_t *val)
{
jas_ulonglong tmp;
if (jas_iccgetuint(in, 4, &tmp))
return -1;
*val = tmp;
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
|
int btrfs_scrub_progress(struct btrfs_fs_info *fs_info, u64 devid,
struct btrfs_scrub_progress *progress)
{
struct btrfs_device *dev;
struct scrub_ctx *sctx = NULL;
mutex_lock(&fs_info->fs_devices->device_list_mutex);
dev = btrfs_find_device(fs_info->fs_devices, devid, NULL, NULL);
if (dev)
sctx = dev->scrub_ctx;
if (sctx)
memcpy(progress, &sctx->stat, sizeof(*progress));
mutex_unlock(&fs_info->fs_devices->device_list_mutex);
return dev ? (sctx ? 0 : -ENOTCONN) : -ENODEV;
}
| 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
|
dump_keywords(vector_t *keydump, int level, FILE *fp)
{
unsigned int i;
keyword_t *keyword_vec;
char file_name[21];
if (!level) {
snprintf(file_name, sizeof(file_name), "/tmp/keywords.%d", getpid());
fp = fopen(file_name, "w");
if (!fp)
return;
}
for (i = 0; i < vector_size(keydump); i++) {
keyword_vec = vector_slot(keydump, i);
fprintf(fp, "%*sKeyword : %s (%s)\n", level * 2, "", keyword_vec->string, keyword_vec->active ? "active": "disabled");
if (keyword_vec->sub)
dump_keywords(keyword_vec->sub, level + 1, fp);
}
if (!level)
fclose(fp);
}
| 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
|
static int perf_event_read_group(struct perf_event *event,
u64 read_format, char __user *buf)
{
struct perf_event *leader = event->group_leader, *sub;
int n = 0, size = 0, ret = -EFAULT;
struct perf_event_context *ctx = leader->ctx;
u64 values[5];
u64 count, enabled, running;
mutex_lock(&ctx->mutex);
count = perf_event_read_value(leader, &enabled, &running);
values[n++] = 1 + leader->nr_siblings;
if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
values[n++] = enabled;
if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
values[n++] = running;
values[n++] = count;
if (read_format & PERF_FORMAT_ID)
values[n++] = primary_event_id(leader);
size = n * sizeof(u64);
if (copy_to_user(buf, values, size))
goto unlock;
ret = size;
list_for_each_entry(sub, &leader->sibling_list, group_entry) {
n = 0;
values[n++] = perf_event_read_value(sub, &enabled, &running);
if (read_format & PERF_FORMAT_ID)
values[n++] = primary_event_id(sub);
size = n * sizeof(u64);
if (copy_to_user(buf + ret, values, size)) {
ret = -EFAULT;
goto unlock;
}
ret += size;
}
unlock:
mutex_unlock(&ctx->mutex);
return ret;
}
| 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
|
dtls1_process_buffered_records(SSL *s)
{
pitem *item;
item = pqueue_peek(s->d1->unprocessed_rcds.q);
if (item)
{
/* Check if epoch is current. */
if (s->d1->unprocessed_rcds.epoch != s->d1->r_epoch)
return(1); /* Nothing to do. */
/* Process all the records. */
while (pqueue_peek(s->d1->unprocessed_rcds.q))
{
dtls1_get_unprocessed_record(s);
if ( ! dtls1_process_record(s))
return(0);
if(dtls1_buffer_record(s, &(s->d1->processed_rcds),
s->s3->rrec.seq_num)<0)
return -1;
}
}
/* sync epoch numbers once all the unprocessed records
* have been processed */
s->d1->processed_rcds.epoch = s->d1->r_epoch;
s->d1->unprocessed_rcds.epoch = s->d1->r_epoch + 1;
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 get_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data)
{
int ret;
ret = usb_control_msg(pegasus->usb, usb_rcvctrlpipe(pegasus->usb, 0),
PEGASUS_REQ_GET_REGS, PEGASUS_REQT_READ, 0,
indx, data, size, 1000);
if (ret < 0)
netif_dbg(pegasus, drv, pegasus->net,
"%s returned %d\n", __func__, ret);
return ret;
}
| 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 put_ucounts(struct ucounts *ucounts)
{
unsigned long flags;
spin_lock_irqsave(&ucounts_lock, flags);
ucounts->count -= 1;
if (!ucounts->count)
hlist_del_init(&ucounts->node);
else
ucounts = NULL;
spin_unlock_irqrestore(&ucounts_lock, flags);
kfree(ucounts);
}
| 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
|
gnutls_ocsp_resp_check_crt(gnutls_ocsp_resp_t resp,
unsigned int indx, gnutls_x509_crt_t crt)
{
int ret;
gnutls_digest_algorithm_t digest;
gnutls_datum_t rdn_hash = { NULL, 0 }, rserial = {
NULL, 0};
gnutls_datum_t cserial = { NULL, 0 };
gnutls_datum_t dn = { NULL, 0 };
uint8_t cdn_hash[MAX_HASH_SIZE];
size_t t, hash_len;
ret =
gnutls_ocsp_resp_get_single(resp, indx, &digest, &rdn_hash,
NULL, &rserial, NULL, NULL, NULL,
NULL, NULL);
if (ret < 0)
return gnutls_assert_val(ret);
if (rserial.size == 0 || digest == GNUTLS_DIG_UNKNOWN) {
ret = gnutls_assert_val(GNUTLS_E_OCSP_RESPONSE_ERROR);
goto cleanup;
}
hash_len = _gnutls_hash_get_algo_len(hash_to_entry(digest));
if (hash_len != rdn_hash.size) {
ret = gnutls_assert_val(GNUTLS_E_OCSP_RESPONSE_ERROR);
goto cleanup;
}
cserial.size = rserial.size;
cserial.data = gnutls_malloc(cserial.size);
if (cserial.data == NULL) {
ret = gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
goto cleanup;
}
t = cserial.size;
ret = gnutls_x509_crt_get_serial(crt, cserial.data, &t);
if (ret < 0) {
gnutls_assert();
goto cleanup;
}
cserial.size = t;
if (rserial.size != cserial.size
|| memcmp(cserial.data, rserial.data, rserial.size) != 0) {
ret = GNUTLS_E_OCSP_RESPONSE_ERROR;
gnutls_assert();
goto cleanup;
}
ret = gnutls_x509_crt_get_raw_issuer_dn(crt, &dn);
if (ret < 0) {
gnutls_assert();
goto cleanup;
}
ret = _gnutls_hash_fast(digest, dn.data, dn.size, cdn_hash);
if (ret < 0) {
gnutls_assert();
goto cleanup;
}
if (memcmp(cdn_hash, rdn_hash.data, hash_len) != 0) {
ret = GNUTLS_E_OCSP_RESPONSE_ERROR;
gnutls_assert();
goto cleanup;
}
ret = 0;
cleanup:
gnutls_free(rdn_hash.data);
gnutls_free(rserial.data);
gnutls_free(cserial.data);
gnutls_free(dn.data);
return ret;
}
| 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
|
char *strdup(const char *s1)
{
char *s2 = 0;
if (s1) {
size_t len = strlen(s1) + 1;
s2 = malloc(len);
memcpy(s2, s1, len);
}
return s2;
}
| 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
|
char *curl_easy_unescape(CURL *handle, const char *string, int length,
int *olen)
{
int alloc = (length?length:(int)strlen(string))+1;
char *ns = malloc(alloc);
unsigned char in;
int strindex=0;
unsigned long hex;
CURLcode res;
if(!ns)
return NULL;
while(--alloc > 0) {
in = *string;
if(('%' == in) && ISXDIGIT(string[1]) && ISXDIGIT(string[2])) {
/* this is two hexadecimal digits following a '%' */
char hexstr[3];
char *ptr;
hexstr[0] = string[1];
hexstr[1] = string[2];
hexstr[2] = 0;
hex = strtoul(hexstr, &ptr, 16);
in = curlx_ultouc(hex); /* this long is never bigger than 255 anyway */
res = Curl_convert_from_network(handle, &in, 1);
if(res) {
/* Curl_convert_from_network calls failf if unsuccessful */
free(ns);
return NULL;
}
string+=2;
alloc-=2;
}
ns[strindex++] = in;
string++;
}
ns[strindex]=0; /* terminate it */
if(olen)
/* store output size */
*olen = strindex;
return ns;
}
| 0 |
C
|
CWE-89
|
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
|
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
|
https://cwe.mitre.org/data/definitions/89.html
|
vulnerable
|
_prolog_error(batch_job_launch_msg_t *req, int rc)
{
char *err_name_ptr, err_name[256], path_name[MAXPATHLEN];
char *fmt_char;
int fd;
if (req->std_err || req->std_out) {
if (req->std_err)
strncpy(err_name, req->std_err, sizeof(err_name));
else
strncpy(err_name, req->std_out, sizeof(err_name));
if ((fmt_char = strchr(err_name, (int) '%')) &&
(fmt_char[1] == 'j') && !strchr(fmt_char+1, (int) '%')) {
char tmp_name[256];
fmt_char[1] = 'u';
snprintf(tmp_name, sizeof(tmp_name), err_name,
req->job_id);
strncpy(err_name, tmp_name, sizeof(err_name));
}
} else {
snprintf(err_name, sizeof(err_name), "slurm-%u.out",
req->job_id);
}
err_name_ptr = err_name;
if (err_name_ptr[0] == '/')
snprintf(path_name, MAXPATHLEN, "%s", err_name_ptr);
else if (req->work_dir)
snprintf(path_name, MAXPATHLEN, "%s/%s",
req->work_dir, err_name_ptr);
else
snprintf(path_name, MAXPATHLEN, "/%s", err_name_ptr);
if ((fd = open(path_name, (O_CREAT|O_APPEND|O_WRONLY), 0644)) == -1) {
error("Unable to open %s: %s", path_name,
slurm_strerror(errno));
return;
}
snprintf(err_name, sizeof(err_name),
"Error running slurm prolog: %d\n", WEXITSTATUS(rc));
safe_write(fd, err_name, strlen(err_name));
if (fchown(fd, (uid_t) req->uid, (gid_t) req->gid) == -1) {
snprintf(err_name, sizeof(err_name),
"Couldn't change fd owner to %u:%u: %m\n",
req->uid, req->gid);
}
rwfail:
close(fd);
}
| 0 |
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
|
vulnerable
|
static inline int verify_replay(struct xfrm_usersa_info *p,
struct nlattr **attrs)
{
struct nlattr *rt = attrs[XFRMA_REPLAY_ESN_VAL];
struct xfrm_replay_state_esn *rs;
if (p->flags & XFRM_STATE_ESN) {
if (!rt)
return -EINVAL;
rs = nla_data(rt);
if (rs->bmp_len > XFRMA_REPLAY_ESN_MAX / sizeof(rs->bmp[0]) / 8)
return -EINVAL;
if (nla_len(rt) < xfrm_replay_state_esn_len(rs) &&
nla_len(rt) != sizeof(*rs))
return -EINVAL;
}
if (!rt)
return 0;
if (p->id.proto != IPPROTO_ESP)
return -EINVAL;
if (p->replay_window != 0)
return -EINVAL;
return 0;
}
| 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
|
static int caif_seqpkt_recvmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *m, size_t len, int flags)
{
struct sock *sk = sock->sk;
struct sk_buff *skb;
int ret;
int copylen;
ret = -EOPNOTSUPP;
if (m->msg_flags&MSG_OOB)
goto read_error;
m->msg_namelen = 0;
skb = skb_recv_datagram(sk, flags, 0 , &ret);
if (!skb)
goto read_error;
copylen = skb->len;
if (len < copylen) {
m->msg_flags |= MSG_TRUNC;
copylen = len;
}
ret = skb_copy_datagram_iovec(skb, 0, m->msg_iov, copylen);
if (ret)
goto out_free;
ret = (flags & MSG_TRUNC) ? skb->len : copylen;
out_free:
skb_free_datagram(sk, skb);
caif_check_flow_release(sk);
return ret;
read_error:
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
|
static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t buflen)
{
struct page *pages[NFS4ACL_MAXPAGES] = {NULL, };
struct nfs_getaclargs args = {
.fh = NFS_FH(inode),
.acl_pages = pages,
.acl_len = buflen,
};
struct nfs_getaclres res = {
.acl_len = buflen,
};
void *resp_buf;
struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_GETACL],
.rpc_argp = &args,
.rpc_resp = &res,
};
int ret = -ENOMEM, npages, i, acl_len = 0;
npages = (buflen + PAGE_SIZE - 1) >> PAGE_SHIFT;
/* As long as we're doing a round trip to the server anyway,
* let's be prepared for a page of acl data. */
if (npages == 0)
npages = 1;
for (i = 0; i < npages; i++) {
pages[i] = alloc_page(GFP_KERNEL);
if (!pages[i])
goto out_free;
}
if (npages > 1) {
/* for decoding across pages */
res.acl_scratch = alloc_page(GFP_KERNEL);
if (!res.acl_scratch)
goto out_free;
}
args.acl_len = npages * PAGE_SIZE;
args.acl_pgbase = 0;
/* Let decode_getfacl know not to fail if the ACL data is larger than
* the page we send as a guess */
if (buf == NULL)
res.acl_flags |= NFS4_ACL_LEN_REQUEST;
resp_buf = page_address(pages[0]);
dprintk("%s buf %p buflen %zu npages %d args.acl_len %zu\n",
__func__, buf, buflen, npages, args.acl_len);
ret = nfs4_call_sync(NFS_SERVER(inode)->client, NFS_SERVER(inode),
&msg, &args.seq_args, &res.seq_res, 0);
if (ret)
goto out_free;
acl_len = res.acl_len - res.acl_data_offset;
if (acl_len > args.acl_len)
nfs4_write_cached_acl(inode, NULL, acl_len);
else
nfs4_write_cached_acl(inode, resp_buf + res.acl_data_offset,
acl_len);
if (buf) {
ret = -ERANGE;
if (acl_len > buflen)
goto out_free;
_copy_from_pages(buf, pages, res.acl_data_offset,
res.acl_len);
}
ret = acl_len;
out_free:
for (i = 0; i < npages; i++)
if (pages[i])
__free_page(pages[i]);
if (res.acl_scratch)
__free_page(res.acl_scratch);
return ret;
}
| 0 |
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
|
vulnerable
|
int perf_event_refresh(struct perf_event *event, int refresh)
{
/*
* not supported on inherited events
*/
if (event->attr.inherit || !is_sampling_event(event))
return -EINVAL;
atomic_add(refresh, &event->event_limit);
perf_event_enable(event);
return 0;
}
| 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
|
ga_copy_string(garray_T *gap, char_u *p)
{
char_u *cp = vim_strsave(p);
if (cp == NULL)
return FAIL;
if (ga_grow(gap, 1) == FAIL)
{
vim_free(cp);
return FAIL;
}
((char_u **)(gap->ga_data))[gap->ga_len++] = cp;
return OK;
}
| 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
|
int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
{
u16 offset = sizeof(struct ipv6hdr);
unsigned int packet_len = skb_tail_pointer(skb) -
skb_network_header(skb);
int found_rhdr = 0;
*nexthdr = &ipv6_hdr(skb)->nexthdr;
while (offset <= packet_len) {
struct ipv6_opt_hdr *exthdr;
switch (**nexthdr) {
case NEXTHDR_HOP:
break;
case NEXTHDR_ROUTING:
found_rhdr = 1;
break;
case NEXTHDR_DEST:
#if IS_ENABLED(CONFIG_IPV6_MIP6)
if (ipv6_find_tlv(skb, offset, IPV6_TLV_HAO) >= 0)
break;
#endif
if (found_rhdr)
return offset;
break;
default:
return offset;
}
if (offset + sizeof(struct ipv6_opt_hdr) > packet_len)
return -EINVAL;
exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) +
offset);
offset += ipv6_optlen(exthdr);
*nexthdr = &exthdr->nexthdr;
}
return -EINVAL;
}
| 0 |
C
|
CWE-835
|
Loop with Unreachable Exit Condition ('Infinite Loop')
|
The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.
|
https://cwe.mitre.org/data/definitions/835.html
|
vulnerable
|
static int xfrm_dump_policy_done(struct netlink_callback *cb)
{
struct xfrm_policy_walk *walk = (struct xfrm_policy_walk *) &cb->args[1];
struct net *net = sock_net(cb->skb->sk);
xfrm_policy_walk_done(walk, net);
return 0;
}
| 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 ssize_t k90_show_current_profile(struct device *dev,
struct device_attribute *attr,
char *buf)
{
int ret;
struct usb_interface *usbif = to_usb_interface(dev->parent);
struct usb_device *usbdev = interface_to_usbdev(usbif);
int current_profile;
char *data;
data = kmalloc(8, GFP_KERNEL);
if (!data)
return -ENOMEM;
ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0),
K90_REQUEST_STATUS,
USB_DIR_IN | USB_TYPE_VENDOR |
USB_RECIP_DEVICE, 0, 0, data, 8,
USB_CTRL_SET_TIMEOUT);
if (ret < 0) {
dev_warn(dev, "Failed to get K90 initial state (error %d).\n",
ret);
ret = -EIO;
goto out;
}
current_profile = data[7];
if (current_profile < 1 || current_profile > 3) {
dev_warn(dev, "Read invalid current profile: %02hhx.\n",
data[7]);
ret = -EIO;
goto out;
}
ret = snprintf(buf, PAGE_SIZE, "%d\n", current_profile);
out:
kfree(data);
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
|
SPL_METHOD(SplFileObject, setCsvControl)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
char delimiter = ',', enclosure = '"', escape='\\';
char *delim = NULL, *enclo = NULL, *esc = NULL;
int d_len = 0, e_len = 0, esc_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sss", &delim, &d_len, &enclo, &e_len, &esc, &esc_len) == SUCCESS) {
switch(ZEND_NUM_ARGS())
{
case 3:
if (esc_len != 1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "escape must be a character");
RETURN_FALSE;
}
escape = esc[0];
/* no break */
case 2:
if (e_len != 1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "enclosure must be a character");
RETURN_FALSE;
}
enclosure = enclo[0];
/* no break */
case 1:
if (d_len != 1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "delimiter must be a character");
RETURN_FALSE;
}
delimiter = delim[0];
/* no break */
case 0:
break;
}
intern->u.file.delimiter = delimiter;
intern->u.file.enclosure = enclosure;
intern->u.file.escape = escape;
}
}
| 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
|
gplotAddPlot(GPLOT *gplot,
NUMA *nax,
NUMA *nay,
l_int32 plotstyle,
const char *plottitle)
{
char buf[L_BUF_SIZE];
char emptystring[] = "";
char *datastr, *title;
l_int32 n, i;
l_float32 valx, valy, startx, delx;
SARRAY *sa;
PROCNAME("gplotAddPlot");
if (!gplot)
return ERROR_INT("gplot not defined", procName, 1);
if (!nay)
return ERROR_INT("nay not defined", procName, 1);
if (plotstyle < 0 || plotstyle >= NUM_GPLOT_STYLES)
return ERROR_INT("invalid plotstyle", procName, 1);
if ((n = numaGetCount(nay)) == 0)
return ERROR_INT("no points to plot", procName, 1);
if (nax && (n != numaGetCount(nax)))
return ERROR_INT("nax and nay sizes differ", procName, 1);
if (n == 1 && plotstyle == GPLOT_LINES) {
L_INFO("only 1 pt; changing style to points\n", procName);
plotstyle = GPLOT_POINTS;
}
/* Save plotstyle and plottitle */
numaGetParameters(nay, &startx, &delx);
numaAddNumber(gplot->plotstyles, plotstyle);
if (plottitle) {
title = stringNew(plottitle);
sarrayAddString(gplot->plottitles, title, L_INSERT);
} else {
sarrayAddString(gplot->plottitles, emptystring, L_COPY);
}
/* Generate and save data filename */
gplot->nplots++;
snprintf(buf, L_BUF_SIZE, "%s.data.%d", gplot->rootname, gplot->nplots);
sarrayAddString(gplot->datanames, buf, L_COPY);
/* Generate data and save as a string */
sa = sarrayCreate(n);
for (i = 0; i < n; i++) {
if (nax)
numaGetFValue(nax, i, &valx);
else
valx = startx + i * delx;
numaGetFValue(nay, i, &valy);
snprintf(buf, L_BUF_SIZE, "%f %f\n", valx, valy);
sarrayAddString(sa, buf, L_COPY);
}
datastr = sarrayToString(sa, 0);
sarrayAddString(gplot->plotdata, datastr, L_INSERT);
sarrayDestroy(&sa);
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
|
static void scsi_write_data(SCSIRequest *req)
{
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint32_t n;
/* No data transfer may already be in progress */
assert(r->req.aiocb == NULL);
if (r->req.cmd.mode != SCSI_XFER_TO_DEV) {
DPRINTF("Data transfer direction invalid\n");
scsi_write_complete(r, -EINVAL);
return;
}
n = r->iov.iov_len / 512;
if (n) {
if (s->tray_open) {
scsi_write_complete(r, -ENOMEDIUM);
}
qemu_iovec_init_external(&r->qiov, &r->iov, 1);
bdrv_acct_start(s->bs, &r->acct, n * BDRV_SECTOR_SIZE, BDRV_ACCT_WRITE);
r->req.aiocb = bdrv_aio_writev(s->bs, r->sector, &r->qiov, n,
scsi_write_complete, r);
if (r->req.aiocb == NULL) {
scsi_write_complete(r, -ENOMEM);
}
} else {
/* Invoke completion routine to fetch data from host. */
scsi_write_complete(r, 0);
}
}
| 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
|
string_modifier_check(struct magic_set *ms, struct magic *m)
{
if ((ms->flags & MAGIC_CHECK) == 0)
return 0;
if ((m->type != FILE_REGEX || (m->str_flags & REGEX_LINE_COUNT) == 0) &&
(m->type != FILE_PSTRING && (m->str_flags & PSTRING_LEN) != 0)) {
file_magwarn(ms,
"'/BHhLl' modifiers are only allowed for pascal strings\n");
return -1;
}
switch (m->type) {
case FILE_BESTRING16:
case FILE_LESTRING16:
if (m->str_flags != 0) {
file_magwarn(ms,
"no modifiers allowed for 16-bit strings\n");
return -1;
}
break;
case FILE_STRING:
case FILE_PSTRING:
if ((m->str_flags & REGEX_OFFSET_START) != 0) {
file_magwarn(ms,
"'/%c' only allowed on regex and search\n",
CHAR_REGEX_OFFSET_START);
return -1;
}
break;
case FILE_SEARCH:
if (m->str_range == 0) {
file_magwarn(ms,
"missing range; defaulting to %d\n",
STRING_DEFAULT_RANGE);
m->str_range = STRING_DEFAULT_RANGE;
return -1;
}
break;
case FILE_REGEX:
if ((m->str_flags & STRING_COMPACT_WHITESPACE) != 0) {
file_magwarn(ms, "'/%c' not allowed on regex\n",
CHAR_COMPACT_WHITESPACE);
return -1;
}
if ((m->str_flags & STRING_COMPACT_OPTIONAL_WHITESPACE) != 0) {
file_magwarn(ms, "'/%c' not allowed on regex\n",
CHAR_COMPACT_OPTIONAL_WHITESPACE);
return -1;
}
break;
default:
file_magwarn(ms, "coding error: m->type=%d\n",
m->type);
return -1;
}
return 0;
}
| 1 |
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
|
safe
|
obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena)
{
PyObject* tmp = NULL;
identifier arg;
expr_ty value;
if (exists_not_none(obj, &PyId_arg)) {
int res;
tmp = _PyObject_GetAttrId(obj, &PyId_arg);
if (tmp == NULL) goto failed;
res = obj2ast_identifier(tmp, &arg, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
arg = NULL;
}
if (_PyObject_HasAttrId(obj, &PyId_value)) {
int res;
tmp = _PyObject_GetAttrId(obj, &PyId_value);
if (tmp == NULL) goto failed;
res = obj2ast_expr(tmp, &value, arena);
if (res != 0) goto failed;
Py_CLEAR(tmp);
} else {
PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
return 1;
}
*out = keyword(arg, value, arena);
return 0;
failed:
Py_XDECREF(tmp);
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
|
void ves_icall_System_Threading_InternalThread_Thread_free_internal (MonoInternalThread *this, HANDLE thread)
{
MONO_ARCH_SAVE_REGS;
THREAD_DEBUG (g_message ("%s: Closing thread %p, handle %p", __func__, this, thread));
if (thread)
CloseHandle (thread);
if (this->synch_cs) {
CRITICAL_SECTION *synch_cs = this->synch_cs;
this->synch_cs = NULL;
DeleteCriticalSection (synch_cs);
g_free (synch_cs);
}
if (this->name) {
void *name = this->name;
this->name = NULL;
g_free (name);
}
}
| 1 |
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
|
safe
|
void test_path_dotgit__dotgit_modules_symlink(void)
{
cl_assert_equal_b(true, git_path_isvalid(NULL, ".gitmodules", 0, GIT_PATH_REJECT_DOT_GIT_HFS|GIT_PATH_REJECT_DOT_GIT_NTFS));
cl_assert_equal_b(false, git_path_isvalid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_HFS));
cl_assert_equal_b(false, git_path_isvalid(NULL, ".gitmodules", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
cl_assert_equal_b(false, git_path_isvalid(NULL, ".gitmodules . .::$DATA", S_IFLNK, GIT_PATH_REJECT_DOT_GIT_NTFS));
}
| 1 |
C
|
CWE-706
|
Use of Incorrectly-Resolved Name or Reference
|
The software uses a name or reference to access a resource, but the name/reference resolves to a resource that is outside of the intended control sphere.
|
https://cwe.mitre.org/data/definitions/706.html
|
safe
|
cfm_network_addr_print(netdissect_options *ndo,
register const u_char *tptr, const u_int length)
{
u_int network_addr_type;
u_int hexdump = FALSE;
/*
* Altough AFIs are tpically 2 octects wide,
* 802.1ab specifies that this field width
* is only once octet
*/
if (length < 1) {
ND_PRINT((ndo, "\n\t Network Address Type (invalid, no data"));
return hexdump;
}
/* The calling function must make any due ND_TCHECK calls. */
network_addr_type = *tptr;
ND_PRINT((ndo, "\n\t Network Address Type %s (%u)",
tok2str(af_values, "Unknown", network_addr_type),
network_addr_type));
/*
* Resolve the passed in Address.
*/
switch(network_addr_type) {
case AFNUM_INET:
if (length != 1 + 4) {
ND_PRINT((ndo, "(invalid IPv4 address length %u)", length - 1));
hexdump = TRUE;
break;
}
ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr + 1)));
break;
case AFNUM_INET6:
if (length != 1 + 16) {
ND_PRINT((ndo, "(invalid IPv6 address length %u)", length - 1));
hexdump = TRUE;
break;
}
ND_PRINT((ndo, ", %s", ip6addr_string(ndo, tptr + 1)));
break;
default:
hexdump = TRUE;
break;
}
return hexdump;
}
| 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
|
GetStartupData(HANDLE pipe, STARTUP_DATA *sud)
{
size_t size, len;
BOOL ret = FALSE;
WCHAR *data = NULL;
DWORD bytes, read;
bytes = PeekNamedPipeAsync(pipe, 1, &exit_event);
if (bytes == 0)
{
MsgToEventLog(M_SYSERR, TEXT("PeekNamedPipeAsync failed"));
ReturnLastError(pipe, L"PeekNamedPipeAsync");
goto out;
}
size = bytes / sizeof(*data);
if (size == 0)
{
MsgToEventLog(M_SYSERR, TEXT("malformed startup data: 1 byte received"));
ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_event);
goto out;
}
data = malloc(bytes);
if (data == NULL)
{
MsgToEventLog(M_SYSERR, TEXT("malloc failed"));
ReturnLastError(pipe, L"malloc");
goto out;
}
read = ReadPipeAsync(pipe, data, bytes, 1, &exit_event);
if (bytes != read)
{
MsgToEventLog(M_SYSERR, TEXT("ReadPipeAsync failed"));
ReturnLastError(pipe, L"ReadPipeAsync");
goto out;
}
if (data[size - 1] != 0)
{
MsgToEventLog(M_ERR, TEXT("Startup data is not NULL terminated"));
ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_event);
goto out;
}
sud->directory = data;
len = wcslen(sud->directory) + 1;
size -= len;
if (size <= 0)
{
MsgToEventLog(M_ERR, TEXT("Startup data ends at working directory"));
ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_event);
goto out;
}
sud->options = sud->directory + len;
len = wcslen(sud->options) + 1;
size -= len;
if (size <= 0)
{
MsgToEventLog(M_ERR, TEXT("Startup data ends at command line options"));
ReturnError(pipe, ERROR_STARTUP_DATA, L"GetStartupData", 1, &exit_event);
goto out;
}
sud->std_input = sud->options + len;
data = NULL; /* don't free data */
ret = TRUE;
out:
free(data);
return ret;
}
| 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
|
PHP_FUNCTION(locale_get_display_region)
{
get_icu_disp_value_src_php( LOC_REGION_TAG , INTERNAL_FUNCTION_PARAM_PASSTHRU );
}
| 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
|
PJ_DEF(pj_status_t) pjsip_endpt_send_request_stateless(pjsip_endpoint *endpt,
pjsip_tx_data *tdata,
void *token,
pjsip_send_callback cb)
{
pjsip_host_info dest_info;
pjsip_send_state *stateless_data;
pj_status_t status;
PJ_ASSERT_RETURN(endpt && tdata, PJ_EINVAL);
/* Get destination name to contact. */
status = pjsip_process_route_set(tdata, &dest_info);
if (status != PJ_SUCCESS)
return status;
/* Keep stateless data. */
stateless_data = PJ_POOL_ZALLOC_T(tdata->pool, pjsip_send_state);
stateless_data->token = token;
stateless_data->endpt = endpt;
stateless_data->tdata = tdata;
stateless_data->app_cb = cb;
/* If destination info has not been initialized (this applies for most
* all requests except CANCEL), resolve destination host. The processing
* then resumed when the resolving callback is called. For CANCEL, the
* destination info must have been copied from the original INVITE so
* proceed to sending the request directly.
*/
if (tdata->dest_info.addr.count == 0) {
/* Copy the destination host name to TX data */
pj_strdup(tdata->pool, &tdata->dest_info.name, &dest_info.addr.host);
pjsip_endpt_resolve( endpt, tdata->pool, &dest_info, stateless_data,
&stateless_send_resolver_callback);
} else {
PJ_LOG(5,(THIS_FILE, "%s: skipping target resolution because "
"address is already set",
pjsip_tx_data_get_info(tdata)));
stateless_send_resolver_callback(PJ_SUCCESS, stateless_data,
&tdata->dest_info.addr);
}
return PJ_SUCCESS;
}
| 0 |
C
|
CWE-297
|
Improper Validation of Certificate with Host Mismatch
|
The software communicates with a host that provides a certificate, but the software does not properly ensure that the certificate is actually associated with that host.
|
https://cwe.mitre.org/data/definitions/297.html
|
vulnerable
|
static int get_rdrand_seed()
{
DEBUG_SEED("get_rdrand_seed");
int _eax;
// rdrand eax
__asm__ __volatile__("1: .byte 0x0F\n"
" .byte 0xC7\n"
" .byte 0xF0\n"
" jnc 1b;\n"
: "=a" (_eax));
return _eax;
}
| 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 inline long div_ll_X_l_rem(long long divs, long div, long *rem)
{
long dum2;
asm("divl %2":"=a"(dum2), "=d"(*rem)
: "rm"(div), "A"(divs));
return dum2;
}
| 0 |
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
|
vulnerable
|
ast_for_async_stmt(struct compiling *c, const node *n)
{
/* async_stmt: ASYNC (funcdef | with_stmt | for_stmt) */
REQ(n, async_stmt);
REQ(CHILD(n, 0), ASYNC);
switch (TYPE(CHILD(n, 1))) {
case funcdef:
return ast_for_funcdef_impl(c, CHILD(n, 1), NULL,
1 /* is_async */);
case with_stmt:
return ast_for_with_stmt(c, CHILD(n, 1),
1 /* is_async */);
case for_stmt:
return ast_for_for_stmt(c, CHILD(n, 1),
1 /* is_async */);
default:
PyErr_Format(PyExc_SystemError,
"invalid async stament: %s",
STR(CHILD(n, 1)));
return NULL;
}
}
| 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
|
horizontalDifference8(unsigned char *ip, int n, int stride,
unsigned short *wp, uint16 *From8)
{
register int r1, g1, b1, a1, r2, g2, b2, a2, mask;
#undef CLAMP
#define CLAMP(v) (From8[(v)])
mask = CODE_MASK;
if (n >= stride) {
if (stride == 3) {
r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);
b2 = wp[2] = CLAMP(ip[2]);
n -= 3;
while (n > 0) {
n -= 3;
r1 = CLAMP(ip[3]); wp[3] = (uint16)((r1-r2) & mask); r2 = r1;
g1 = CLAMP(ip[4]); wp[4] = (uint16)((g1-g2) & mask); g2 = g1;
b1 = CLAMP(ip[5]); wp[5] = (uint16)((b1-b2) & mask); b2 = b1;
wp += 3;
ip += 3;
}
} else if (stride == 4) {
r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]);
b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]);
n -= 4;
while (n > 0) {
n -= 4;
r1 = CLAMP(ip[4]); wp[4] = (uint16)((r1-r2) & mask); r2 = r1;
g1 = CLAMP(ip[5]); wp[5] = (uint16)((g1-g2) & mask); g2 = g1;
b1 = CLAMP(ip[6]); wp[6] = (uint16)((b1-b2) & mask); b2 = b1;
a1 = CLAMP(ip[7]); wp[7] = (uint16)((a1-a2) & mask); a2 = a1;
wp += 4;
ip += 4;
}
} else {
REPEAT(stride, wp[0] = CLAMP(ip[0]); wp++; ip++)
n -= stride;
while (n > 0) {
REPEAT(stride,
wp[0] = (uint16)((CLAMP(ip[0])-CLAMP(ip[-stride])) & mask);
wp++; ip++)
n -= stride;
}
}
}
}
| 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
|
do_local_notify(xmlNode * notify_src, const char *client_id,
gboolean sync_reply, gboolean from_peer)
{
/* send callback to originating child */
cib_client_t *client_obj = NULL;
int local_rc = pcmk_ok;
if (client_id != NULL) {
client_obj = g_hash_table_lookup(client_list, client_id);
} else {
crm_trace("No client to sent the response to. F_CIB_CLIENTID not set.");
}
if (client_obj == NULL) {
local_rc = -ECONNRESET;
} else {
int rid = 0;
if(sync_reply) {
CRM_LOG_ASSERT(client_obj->request_id);
rid = client_obj->request_id;
client_obj->request_id = 0;
crm_trace("Sending response %d to %s %s",
rid, client_obj->name, from_peer?"(originator of delegated request)":"");
} else {
crm_trace("Sending an event to %s %s",
client_obj->name, from_peer?"(originator of delegated request)":"");
}
if (client_obj->ipc && crm_ipcs_send(client_obj->ipc, rid, notify_src, !sync_reply) < 0) {
local_rc = -ENOMSG;
#ifdef HAVE_GNUTLS_GNUTLS_H
} else if (client_obj->session) {
crm_send_remote_msg(client_obj->session, notify_src, client_obj->encrypted);
#endif
} else if(client_obj->ipc == NULL) {
crm_err("Unknown transport for %s", client_obj->name);
}
}
if (local_rc != pcmk_ok && client_obj != NULL) {
crm_warn("%sSync reply to %s failed: %s",
sync_reply ? "" : "A-",
client_obj ? client_obj->name : "<unknown>", pcmk_strerror(local_rc));
}
}
| 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
|
CAMLprim value caml_alloc_dummy_float (value size)
{
mlsize_t wosize = Long_val(size) * Double_wosize;
if (wosize == 0) return Atom(0);
return caml_alloc (wosize, 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
|
void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
int status)
{
struct dwc3 *dwc = dep->dwc;
req->started = false;
list_del(&req->list);
req->remaining = 0;
if (req->request.status == -EINPROGRESS)
req->request.status = status;
if (req->trb)
usb_gadget_unmap_request_by_dev(dwc->sysdev,
&req->request, req->direction);
req->trb = NULL;
trace_dwc3_gadget_giveback(req);
spin_unlock(&dwc->lock);
usb_gadget_giveback_request(&dep->endpoint, &req->request);
spin_lock(&dwc->lock);
if (dep->number > 1)
pm_runtime_put(dwc->dev);
}
| 0 |
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
|
vulnerable
|
static void ion_free_nolock(struct ion_client *client, struct ion_handle *handle)
{
bool valid_handle;
BUG_ON(client != handle->client);
valid_handle = ion_handle_validate(client, handle);
if (!valid_handle) {
WARN(1, "%s: invalid handle passed to free.\n", __func__);
return;
}
ion_handle_put_nolock(handle);
}
| 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
|
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 != ')')
{
emsg(_(e_missing_closing_paren));
return FAIL;
}
if (rettv->v_type != VAR_STRING && rettv->v_type != VAR_FUNC
&& rettv->v_type != VAR_PARTIAL)
{
emsg(_(e_string_or_function_required_for_arrow_parens_expr));
return FAIL;
}
++*arg;
}
if (ret != OK)
return FAIL;
if (**arg != '(')
{
if (verbose)
{
if (*skipwhite(*arg) == '(')
emsg(_(e_no_white_space_allowed_before_parenthesis));
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-823
|
Use of Out-of-range Pointer Offset
|
The program performs pointer arithmetic on a valid pointer, but it uses an offset that can point outside of the intended range of valid memory locations for the resulting pointer.
|
https://cwe.mitre.org/data/definitions/823.html
|
safe
|
static punycode_uint decode_digit(punycode_uint cp)
{
return cp - 48 < 10 ? cp - 22 : cp - 65 < 26 ? cp - 65 :
cp - 97 < 26 ? cp - 97 : base;
}
| 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
|
static struct ib_ucontext *hns_roce_alloc_ucontext(struct ib_device *ib_dev,
struct ib_udata *udata)
{
int ret = 0;
struct hns_roce_ucontext *context;
struct hns_roce_ib_alloc_ucontext_resp resp;
struct hns_roce_dev *hr_dev = to_hr_dev(ib_dev);
resp.qp_tab_size = hr_dev->caps.num_qps;
context = kmalloc(sizeof(*context), GFP_KERNEL);
if (!context)
return ERR_PTR(-ENOMEM);
ret = hns_roce_uar_alloc(hr_dev, &context->uar);
if (ret)
goto error_fail_uar_alloc;
if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_RECORD_DB) {
INIT_LIST_HEAD(&context->page_list);
mutex_init(&context->page_mutex);
}
ret = ib_copy_to_udata(udata, &resp, sizeof(resp));
if (ret)
goto error_fail_copy_to_udata;
return &context->ibucontext;
error_fail_copy_to_udata:
hns_roce_uar_free(hr_dev, &context->uar);
error_fail_uar_alloc:
kfree(context);
return ERR_PTR(ret);
}
| 0 |
C
|
CWE-665
|
Improper Initialization
|
The software does not initialize or incorrectly initializes a resource, which might leave the resource in an unexpected state when it is accessed or used.
|
https://cwe.mitre.org/data/definitions/665.html
|
vulnerable
|
void read_sequence_header(decoder_info_t *decoder_info, stream_t *stream) {
decoder_info->width = get_flc(16, stream);
decoder_info->height = get_flc(16, stream);
decoder_info->log2_sb_size = get_flc(3, stream);
decoder_info->log2_sb_size = clip(decoder_info->log2_sb_size, log2i(MIN_BLOCK_SIZE), log2i(MAX_SB_SIZE));
decoder_info->pb_split = get_flc(1, stream);
decoder_info->tb_split_enable = get_flc(1, stream);
decoder_info->max_num_ref = get_flc(2, stream) + 1;
decoder_info->interp_ref = get_flc(2, stream);
decoder_info->max_delta_qp = get_flc(1, stream);
decoder_info->deblocking = get_flc(1, stream);
decoder_info->clpf = get_flc(1, stream);
decoder_info->use_block_contexts = get_flc(1, stream);
decoder_info->bipred = get_flc(2, stream);
decoder_info->qmtx = get_flc(1, stream);
if (decoder_info->qmtx) {
decoder_info->qmtx_offset = get_flc(6, stream) - 32;
}
decoder_info->subsample = get_flc(2, stream);
decoder_info->subsample = // 0: 400 1: 420 2: 422 3: 444
(decoder_info->subsample & 1) * 20 + (decoder_info->subsample & 2) * 22 +
((decoder_info->subsample & 3) == 3) * 2 + 400;
decoder_info->num_reorder_pics = get_flc(4, stream);
if (decoder_info->subsample != 400) {
decoder_info->cfl_intra = get_flc(1, stream);
decoder_info->cfl_inter = get_flc(1, stream);
}
decoder_info->bitdepth = get_flc(1, stream) ? 10 : 8;
if (decoder_info->bitdepth == 10)
decoder_info->bitdepth += 2 * get_flc(1, stream);
decoder_info->input_bitdepth = get_flc(1, stream) ? 10 : 8;
if (decoder_info->input_bitdepth == 10)
decoder_info->input_bitdepth += 2 * get_flc(1, stream);
}
| 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
|
int xt_check_entry_offsets(const void *base,
const char *elems,
unsigned int target_offset,
unsigned int next_offset)
{
long size_of_base_struct = elems - (const char *)base;
const struct xt_entry_target *t;
const char *e = base;
/* target start is within the ip/ip6/arpt_entry struct */
if (target_offset < size_of_base_struct)
return -EINVAL;
if (target_offset + sizeof(*t) > next_offset)
return -EINVAL;
t = (void *)(e + target_offset);
if (t->u.target_size < sizeof(*t))
return -EINVAL;
if (target_offset + t->u.target_size > next_offset)
return -EINVAL;
if (strcmp(t->u.user.name, XT_STANDARD_TARGET) == 0 &&
target_offset + sizeof(struct xt_standard_target) != next_offset)
return -EINVAL;
return 0;
}
| 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
|
void pdf_get_version(FILE *fp, pdf_t *pdf)
{
char *header, *c;
header = get_header(fp);
/* Locate version string start and make sure we dont go past header */
if ((c = strstr(header, "%PDF-")) &&
(c + strlen("%PDF-M.m") + 2))
{
pdf->pdf_major_version = atoi(c + strlen("%PDF-"));
pdf->pdf_minor_version = atoi(c + strlen("%PDF-M."));
}
free(header);
}
| 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
|
void jbd2_journal_lock_updates(journal_t *journal)
{
DEFINE_WAIT(wait);
jbd2_might_wait_for_commit(journal);
write_lock(&journal->j_state_lock);
++journal->j_barrier_count;
/* Wait until there are no reserved handles */
if (atomic_read(&journal->j_reserved_credits)) {
write_unlock(&journal->j_state_lock);
wait_event(journal->j_wait_reserved,
atomic_read(&journal->j_reserved_credits) == 0);
write_lock(&journal->j_state_lock);
}
/* Wait until there are no running t_updates */
jbd2_journal_wait_updates(journal);
write_unlock(&journal->j_state_lock);
/*
* We have now established a barrier against other normal updates, but
* we also need to barrier against other jbd2_journal_lock_updates() calls
* to make sure that we serialise special journal-locked operations
* too.
*/
mutex_lock(&journal->j_barrier);
}
| 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
|
void Huff_Compress(msg_t *mbuf, int offset) {
int i, ch, size;
byte seq[65536];
byte* buffer;
huff_t huff;
size = mbuf->cursize - offset;
buffer = mbuf->data+ + offset;
if (size<=0) {
return;
}
Com_Memset(&huff, 0, sizeof(huff_t));
// Add the NYT (not yet transmitted) node into the tree/list */
huff.tree = huff.lhead = huff.loc[NYT] = &(huff.nodeList[huff.blocNode++]);
huff.tree->symbol = NYT;
huff.tree->weight = 0;
huff.lhead->next = huff.lhead->prev = NULL;
huff.tree->parent = huff.tree->left = huff.tree->right = NULL;
seq[0] = (size>>8);
seq[1] = size&0xff;
bloc = 16;
for (i=0; i<size; i++ ) {
ch = buffer[i];
Huff_transmit(&huff, ch, seq); /* Transmit symbol */
Huff_addRef(&huff, (byte)ch); /* Do update */
}
bloc += 8; // next byte
mbuf->cursize = (bloc>>3) + offset;
Com_Memcpy(mbuf->data+offset, seq, (bloc>>3));
}
| 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 int mailimf_group_parse(const char * message, size_t length,
size_t * indx,
struct mailimf_group ** result)
{
size_t cur_token;
char * display_name;
struct mailimf_mailbox_list * mailbox_list;
struct mailimf_group * group;
int r;
int res;
clist * list;
cur_token = * indx;
mailbox_list = NULL;
r = mailimf_display_name_parse(message, length, &cur_token, &display_name);
if (r != MAILIMF_NO_ERROR) {
res = r;
goto err;
}
r = mailimf_colon_parse(message, length, &cur_token);
if (r != MAILIMF_NO_ERROR) {
res = r;
goto free_display_name;
}
r = mailimf_mailbox_list_parse(message, length, &cur_token, &mailbox_list);
switch (r) {
case MAILIMF_NO_ERROR:
break;
case MAILIMF_ERROR_PARSE:
r = mailimf_cfws_parse(message, length, &cur_token);
if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) {
res = r;
goto free_display_name;
}
list = clist_new();
if (list == NULL) {
res = MAILIMF_ERROR_MEMORY;
goto free_display_name;
}
mailbox_list = mailimf_mailbox_list_new(list);
if (mailbox_list == NULL) {
res = MAILIMF_ERROR_MEMORY;
clist_free(list);
goto free_display_name;
}
break;
default:
res = r;
goto free_display_name;
}
r = mailimf_semi_colon_parse(message, length, &cur_token);
if (r != MAILIMF_NO_ERROR) {
res = r;
goto free_mailbox_list;
}
group = mailimf_group_new(display_name, mailbox_list);
if (group == NULL) {
res = MAILIMF_ERROR_MEMORY;
goto free_mailbox_list;
}
* indx = cur_token;
* result = group;
return MAILIMF_NO_ERROR;
free_mailbox_list:
if (mailbox_list != NULL) {
mailimf_mailbox_list_free(mailbox_list);
}
free_display_name:
mailimf_display_name_free(display_name);
err:
return res;
}
| 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
|
void ext4_xattr_destroy_cache(struct mb2_cache *cache)
{
if (cache)
mb2_cache_destroy(cache);
}
| 1 |
C
|
CWE-19
|
Data Processing Errors
|
Weaknesses in this category are typically found in functionality that processes data. Data processing is the manipulation of input to retrieve or save information.
|
https://cwe.mitre.org/data/definitions/19.html
|
safe
|
ext2_xattr_cache_insert(struct mb2_cache *cache, struct buffer_head *bh)
{
__u32 hash = le32_to_cpu(HDR(bh)->h_hash);
int error;
error = mb2_cache_entry_create(cache, GFP_NOFS, hash, bh->b_blocknr);
if (error) {
if (error == -EBUSY) {
ea_bdebug(bh, "already in cache (%d cache entries)",
atomic_read(&ext2_xattr_cache->c_entry_count));
error = 0;
}
} else
ea_bdebug(bh, "inserting [%x]", (int)hash);
return error;
}
| 1 |
C
|
CWE-19
|
Data Processing Errors
|
Weaknesses in this category are typically found in functionality that processes data. Data processing is the manipulation of input to retrieve or save information.
|
https://cwe.mitre.org/data/definitions/19.html
|
safe
|
static int er_supported(ERContext *s)
{
if(s->avctx->hwaccel && s->avctx->hwaccel->decode_slice ||
!s->cur_pic.f ||
s->cur_pic.field_picture ||
s->avctx->profile == FF_PROFILE_MPEG4_SIMPLE_STUDIO
)
return 0;
return 1;
}
| 0 |
C
|
CWE-617
|
Reachable Assertion
|
The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary.
|
https://cwe.mitre.org/data/definitions/617.html
|
vulnerable
|
static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
struct dst_entry *dst,
const struct flowi6 *fl6)
{
struct ipv6_pinfo *np = inet6_sk(sk);
struct rt6_info *rt;
if (!dst)
goto out;
if (dst->ops->family != AF_INET6) {
dst_release(dst);
return NULL;
}
rt = (struct rt6_info *)dst;
/* Yes, checking route validity in not connected
* case is not very simple. Take into account,
* that we do not support routing by source, TOS,
* and MSG_DONTROUTE --ANK (980726)
*
* 1. ip6_rt_check(): If route was host route,
* check that cached destination is current.
* If it is network route, we still may
* check its validity using saved pointer
* to the last used address: daddr_cache.
* We do not want to save whole address now,
* (because main consumer of this service
* is tcp, which has not this problem),
* so that the last trick works only on connected
* sockets.
* 2. oif also should be the same.
*/
if (ip6_rt_check(&rt->rt6i_dst, &fl6->daddr, np->daddr_cache) ||
#ifdef CONFIG_IPV6_SUBTREES
ip6_rt_check(&rt->rt6i_src, &fl6->saddr, np->saddr_cache) ||
#endif
(fl6->flowi6_oif && fl6->flowi6_oif != dst->dev->ifindex)) {
dst_release(dst);
dst = NULL;
}
out:
return dst;
}
| 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 int ipxitf_ioctl(unsigned int cmd, void __user *arg)
{
int rc = -EINVAL;
struct ifreq ifr;
int val;
switch (cmd) {
case SIOCSIFADDR: {
struct sockaddr_ipx *sipx;
struct ipx_interface_definition f;
rc = -EFAULT;
if (copy_from_user(&ifr, arg, sizeof(ifr)))
break;
sipx = (struct sockaddr_ipx *)&ifr.ifr_addr;
rc = -EINVAL;
if (sipx->sipx_family != AF_IPX)
break;
f.ipx_network = sipx->sipx_network;
memcpy(f.ipx_device, ifr.ifr_name,
sizeof(f.ipx_device));
memcpy(f.ipx_node, sipx->sipx_node, IPX_NODE_LEN);
f.ipx_dlink_type = sipx->sipx_type;
f.ipx_special = sipx->sipx_special;
if (sipx->sipx_action == IPX_DLTITF)
rc = ipxitf_delete(&f);
else
rc = ipxitf_create(&f);
break;
}
case SIOCGIFADDR: {
struct sockaddr_ipx *sipx;
struct ipx_interface *ipxif;
struct net_device *dev;
rc = -EFAULT;
if (copy_from_user(&ifr, arg, sizeof(ifr)))
break;
sipx = (struct sockaddr_ipx *)&ifr.ifr_addr;
dev = __dev_get_by_name(&init_net, ifr.ifr_name);
rc = -ENODEV;
if (!dev)
break;
ipxif = ipxitf_find_using_phys(dev,
ipx_map_frame_type(sipx->sipx_type));
rc = -EADDRNOTAVAIL;
if (!ipxif)
break;
sipx->sipx_family = AF_IPX;
sipx->sipx_network = ipxif->if_netnum;
memcpy(sipx->sipx_node, ipxif->if_node,
sizeof(sipx->sipx_node));
rc = 0;
if (copy_to_user(arg, &ifr, sizeof(ifr)))
rc = -EFAULT;
ipxitf_put(ipxif);
break;
}
case SIOCAIPXITFCRT:
rc = -EFAULT;
if (get_user(val, (unsigned char __user *) arg))
break;
rc = 0;
ipxcfg_auto_create_interfaces = val;
break;
case SIOCAIPXPRISLT:
rc = -EFAULT;
if (get_user(val, (unsigned char __user *) arg))
break;
rc = 0;
ipxcfg_set_auto_select(val);
break;
}
return rc;
}
| 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
|
static void handle_action(HttpRequest req, HttpResponse res) {
char *name = req->url;
Service_T s = Util_getService(++name);
if (! s) {
send_error(req, res, SC_NOT_FOUND, "There is no service named \"%s\"", name ? name : "");
return;
}
const char *action = get_parameter(req, "action");
if (action) {
if (is_readonly(req)) {
send_error(req, res, SC_FORBIDDEN, "You do not have sufficient privileges to access this page");
return;
}
Action_Type doaction = Util_getAction(action);
if (doaction == Action_Ignored) {
send_error(req, res, SC_BAD_REQUEST, "Invalid action \"%s\"", action);
return;
}
s->doaction = doaction;
const char *token = get_parameter(req, "token");
if (token) {
FREE(s->token);
s->token = Str_dup(token);
}
LogInfo("'%s' %s on user request\n", s->name, action);
Run.flags |= Run_ActionPending; /* set the global flag */
do_wakeupcall();
}
do_service(req, res, s);
}
| 0 |
C
|
CWE-352
|
Cross-Site Request Forgery (CSRF)
|
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
|
https://cwe.mitre.org/data/definitions/352.html
|
vulnerable
|
void cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (!(item->type&cJSON_StringIsConst) && item->string) cJSON_free(item->string);item->string=(char*)string;item->type|=cJSON_StringIsConst;cJSON_AddItemToArray(object,item);}
| 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
|
static char *tls_text_name(X509_NAME *name, int nid)
{
int pos;
X509_NAME_ENTRY *entry;
ASN1_STRING *entry_str;
int utf8_length;
unsigned char *utf8_value;
char *result;
if (name == 0 || (pos = X509_NAME_get_index_by_NID(name, nid, -1)) < 0) {
return NULL;
}
entry = X509_NAME_get_entry(name, pos);
g_return_val_if_fail(entry != NULL, NULL);
entry_str = X509_NAME_ENTRY_get_data(entry);
g_return_val_if_fail(entry_str != NULL, NULL);
/* Convert everything into UTF-8. It's up to OpenSSL to do something
reasonable when converting ASCII formats that contain non-ASCII
content. */
if ((utf8_length = ASN1_STRING_to_UTF8(&utf8_value, entry_str)) < 0) {
g_warning("Error decoding ASN.1 type=%d", ASN1_STRING_type(entry_str));
return NULL;
}
if (has_internal_nul((char *)utf8_value, utf8_length)) {
g_warning("NUL character in hostname in certificate");
OPENSSL_free(utf8_value);
return NULL;
}
result = g_strdup((char *) utf8_value);
OPENSSL_free(utf8_value);
return result;
}
| 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
|
_dl_dst_substitute (struct link_map *l, const char *name, char *result,
int is_path)
{
const char *const start = name;
char *last_elem, *wp;
/* Now fill the result path. While copying over the string we keep
track of the start of the last path element. When we come accross
a DST we copy over the value or (if the value is not available)
leave the entire path element out. */
last_elem = wp = result;
do
{
if (*name == '$')
{
const char *repl;
size_t len;
/* Note that it is no bug that the strings in the first two `strncmp'
calls are longer than the sequence which is actually tested. */
if ((((strncmp (&name[1], "ORIGIN}", 6) == 0 && (len = 7) != 0)
|| (strncmp (&name[1], "PLATFORM}", 8) == 0 && (len = 9) != 0))
&& (name[len] == '\0' || name[len] == '/'
|| (is_path && name[len] == ':')))
|| (name[1] == '{'
&& ((strncmp (&name[2], "ORIGIN}", 7) == 0 && (len = 9) != 0)
|| (strncmp (&name[2], "PLATFORM}", 9) == 0
&& (len = 11) != 0))))
{
repl = ((len == 7 || name[2] == 'O')
? (__libc_enable_secure
&& ((name[len] != '\0'
&& (!is_path || name[len] != ':'))
|| (name != start
&& (!is_path || name[-1] != ':')))
? NULL : l->l_origin)
: _dl_platform);
if (repl != NULL && repl != (const char *) -1)
{
wp = __stpcpy (wp, repl);
name += len;
}
else
{
/* We cannot use this path element, the value of the
replacement is unknown. */
wp = last_elem;
name += len;
while (*name != '\0' && (!is_path || *name != ':'))
++name;
}
}
else
/* No DST we recognize. */
*wp++ = *name++;
}
else if (is_path && *name == ':')
{
*wp++ = *name++;
last_elem = wp;
}
else
*wp++ = *name++;
}
while (*name != '\0');
*wp = '\0';
return result;
}
| 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
|
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;
strncpy(raead.type, "aead", sizeof(raead.type));
strncpy(raead.geniv, aead->geniv ?: "<built-in>", sizeof(raead.geniv));
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;
}
| 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
|
xbstream_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat)
{
ds_file_t *file;
ds_stream_file_t *stream_file;
ds_stream_ctxt_t *stream_ctxt;
ds_ctxt_t *dest_ctxt;
xb_wstream_t *xbstream;
xb_wstream_file_t *xbstream_file;
xb_ad(ctxt->pipe_ctxt != NULL);
dest_ctxt = ctxt->pipe_ctxt;
stream_ctxt = (ds_stream_ctxt_t *) ctxt->ptr;
pthread_mutex_lock(&stream_ctxt->mutex);
if (stream_ctxt->dest_file == NULL) {
stream_ctxt->dest_file = ds_open(dest_ctxt, path, mystat);
if (stream_ctxt->dest_file == NULL) {
return NULL;
}
}
pthread_mutex_unlock(&stream_ctxt->mutex);
file = (ds_file_t *) my_malloc(sizeof(ds_file_t) +
sizeof(ds_stream_file_t),
MYF(MY_FAE));
stream_file = (ds_stream_file_t *) (file + 1);
xbstream = stream_ctxt->xbstream;
xbstream_file = xb_stream_write_open(xbstream, path, mystat,
stream_ctxt,
my_xbstream_write_callback);
if (xbstream_file == NULL) {
msg("xb_stream_write_open() failed.");
goto err;
}
stream_file->xbstream_file = xbstream_file;
stream_file->stream_ctxt = stream_ctxt;
file->ptr = stream_file;
file->path = stream_ctxt->dest_file->path;
return file;
err:
if (stream_ctxt->dest_file) {
ds_close(stream_ctxt->dest_file);
stream_ctxt->dest_file = NULL;
}
my_free(file);
return NULL;
}
| 0 |
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
|
vulnerable
|
aodv_extension(netdissect_options *ndo,
const struct aodv_ext *ep, u_int length)
{
const struct aodv_hello *ah;
ND_TCHECK(*ep);
switch (ep->type) {
case AODV_EXT_HELLO:
ah = (const struct aodv_hello *)(const void *)ep;
ND_TCHECK(*ah);
if (length < sizeof(struct aodv_hello))
goto trunc;
if (ep->length < 4) {
ND_PRINT((ndo, "\n\text HELLO - bad length %u", ep->length));
break;
}
ND_PRINT((ndo, "\n\text HELLO %ld ms",
(unsigned long)EXTRACT_32BITS(&ah->interval)));
break;
default:
ND_PRINT((ndo, "\n\text %u %u", ep->type, ep->length));
break;
}
return;
trunc:
ND_PRINT((ndo, " [|hello]"));
}
| 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 void make_response(struct xen_blkif_ring *ring, u64 id,
unsigned short op, int st)
{
struct blkif_response *resp;
unsigned long flags;
union blkif_back_rings *blk_rings;
int notify;
spin_lock_irqsave(&ring->blk_ring_lock, flags);
blk_rings = &ring->blk_rings;
/* Place on the response ring for the relevant domain. */
switch (ring->blkif->blk_protocol) {
case BLKIF_PROTOCOL_NATIVE:
resp = RING_GET_RESPONSE(&blk_rings->native,
blk_rings->native.rsp_prod_pvt);
break;
case BLKIF_PROTOCOL_X86_32:
resp = RING_GET_RESPONSE(&blk_rings->x86_32,
blk_rings->x86_32.rsp_prod_pvt);
break;
case BLKIF_PROTOCOL_X86_64:
resp = RING_GET_RESPONSE(&blk_rings->x86_64,
blk_rings->x86_64.rsp_prod_pvt);
break;
default:
BUG();
}
resp->id = id;
resp->operation = op;
resp->status = st;
blk_rings->common.rsp_prod_pvt++;
RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&blk_rings->common, notify);
spin_unlock_irqrestore(&ring->blk_ring_lock, flags);
if (notify)
notify_remote_via_irq(ring->irq);
}
| 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
|
sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data)
{ SF_PRIVATE *psf ;
/* Make sure we have a valid set ot virtual pointers. */
if (sfvirtual->get_filelen == NULL || sfvirtual->seek == NULL || sfvirtual->tell == NULL)
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
snprintf (sf_parselog, sizeof (sf_parselog), "Bad vio_get_filelen / vio_seek / vio_tell in SF_VIRTUAL_IO struct.\n") ;
return NULL ;
} ;
if ((mode == SFM_READ || mode == SFM_RDWR) && sfvirtual->read == NULL)
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
snprintf (sf_parselog, sizeof (sf_parselog), "Bad vio_read in SF_VIRTUAL_IO struct.\n") ;
return NULL ;
} ;
if ((mode == SFM_WRITE || mode == SFM_RDWR) && sfvirtual->write == NULL)
{ sf_errno = SFE_BAD_VIRTUAL_IO ;
snprintf (sf_parselog, sizeof (sf_parselog), "Bad vio_write in SF_VIRTUAL_IO struct.\n") ;
return NULL ;
} ;
if ((psf = psf_allocate ()) == NULL)
{ sf_errno = SFE_MALLOC_FAILED ;
return NULL ;
} ;
psf_init_files (psf) ;
psf->virtual_io = SF_TRUE ;
psf->vio = *sfvirtual ;
psf->vio_user_data = user_data ;
psf->file.mode = mode ;
return psf_open_file (psf, sfinfo) ;
} /* sf_open_virtual */
| 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
|
int tipc_nl_publ_dump(struct sk_buff *skb, struct netlink_callback *cb)
{
int err;
u32 tsk_portid = cb->args[0];
u32 last_publ = cb->args[1];
u32 done = cb->args[2];
struct net *net = sock_net(skb->sk);
struct tipc_sock *tsk;
if (!tsk_portid) {
struct nlattr **attrs;
struct nlattr *sock[TIPC_NLA_SOCK_MAX + 1];
err = tipc_nlmsg_parse(cb->nlh, &attrs);
if (err)
return err;
if (!attrs[TIPC_NLA_SOCK])
return -EINVAL;
err = nla_parse_nested(sock, TIPC_NLA_SOCK_MAX,
attrs[TIPC_NLA_SOCK],
tipc_nl_sock_policy);
if (err)
return err;
if (!sock[TIPC_NLA_SOCK_REF])
return -EINVAL;
tsk_portid = nla_get_u32(sock[TIPC_NLA_SOCK_REF]);
}
if (done)
return 0;
tsk = tipc_sk_lookup(net, tsk_portid);
if (!tsk)
return -EINVAL;
lock_sock(&tsk->sk);
err = __tipc_nl_list_sk_publ(skb, cb, tsk, &last_publ);
if (!err)
done = 1;
release_sock(&tsk->sk);
sock_put(&tsk->sk);
cb->args[0] = tsk_portid;
cb->args[1] = last_publ;
cb->args[2] = done;
return skb->len;
}
| 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
|
static void nsc_encode_sse2(NSC_CONTEXT* context, const BYTE* data,
UINT32 scanline)
{
nsc_encode_argb_to_aycocg_sse2(context, data, scanline);
if (context->ChromaSubsamplingLevel > 0)
{
nsc_encode_subsampling_sse2(context);
}
}
| 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
|
static void __evtchn_fifo_handle_events(unsigned cpu,
struct evtchn_loop_ctrl *ctrl)
{
struct evtchn_fifo_control_block *control_block;
unsigned long ready;
unsigned q;
control_block = per_cpu(cpu_control_block, cpu);
ready = xchg(&control_block->ready, 0);
while (ready) {
q = find_first_bit(&ready, EVTCHN_FIFO_MAX_QUEUES);
consume_one_event(cpu, ctrl, control_block, q, &ready);
ready |= xchg(&control_block->ready, 0);
}
}
| 1 |
C
|
NVD-CWE-noinfo
| null | null | null |
safe
|
static int pn_recvmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, size_t len, int noblock,
int flags, int *addr_len)
{
struct sk_buff *skb = NULL;
struct sockaddr_pn sa;
int rval = -EOPNOTSUPP;
int copylen;
if (flags & ~(MSG_PEEK|MSG_TRUNC|MSG_DONTWAIT|MSG_NOSIGNAL|
MSG_CMSG_COMPAT))
goto out_nofree;
skb = skb_recv_datagram(sk, flags, noblock, &rval);
if (skb == NULL)
goto out_nofree;
pn_skb_get_src_sockaddr(skb, &sa);
copylen = skb->len;
if (len < copylen) {
msg->msg_flags |= MSG_TRUNC;
copylen = len;
}
rval = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copylen);
if (rval) {
rval = -EFAULT;
goto out;
}
rval = (flags & MSG_TRUNC) ? skb->len : copylen;
if (msg->msg_name != NULL) {
memcpy(msg->msg_name, &sa, sizeof(sa));
*addr_len = sizeof(sa);
}
out:
skb_free_datagram(sk, skb);
out_nofree:
return rval;
}
| 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
|
void dmar_free_irte(const struct intr_source *intr_src, uint16_t index)
{
struct dmar_drhd_rt *dmar_unit;
union dmar_ir_entry *ir_table, *ir_entry;
union pci_bdf sid;
if (intr_src->is_msi) {
dmar_unit = device_to_dmaru((uint8_t)intr_src->src.msi.bits.b, intr_src->src.msi.fields.devfun);
} else {
dmar_unit = ioapic_to_dmaru(intr_src->src.ioapic_id, &sid);
}
if (is_dmar_unit_valid(dmar_unit, sid)) {
ir_table = (union dmar_ir_entry *)hpa2hva(dmar_unit->ir_table_addr);
ir_entry = ir_table + index;
ir_entry->bits.remap.present = 0x0UL;
iommu_flush_cache(ir_entry, sizeof(union dmar_ir_entry));
dmar_invalid_iec(dmar_unit, index, 0U, false);
if (!is_irte_reserved(dmar_unit, index)) {
spinlock_obtain(&dmar_unit->lock);
bitmap_clear_nolock(index & 0x3FU, &dmar_unit->irte_alloc_bitmap[index >> 6U]);
spinlock_release(&dmar_unit->lock);
}
}
}
| 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
|
R_API RCmdAliasVal *r_cmd_alias_get(RCmd *cmd, const char *k) {
r_return_val_if_fail (cmd && cmd->aliases && k, NULL);
return ht_pp_find(cmd->aliases, k, NULL);
}
| 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
|
void gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
{
int c, dc;
int x, y;
int tox, toy;
int ncR, ncG, ncB;
toy = dstY;
for (y = srcY; y < (srcY + h); y++) {
tox = dstX;
for (x = srcX; x < (srcX + w); x++) {
int nc;
c = gdImageGetPixel(src, x, y);
/* Added 7/24/95: support transparent copies */
if (gdImageGetTransparent(src) == c) {
tox++;
continue;
}
/* If it's the same image, mapping is trivial */
if (dst == src) {
nc = c;
} else {
dc = gdImageGetPixel(dst, tox, toy);
ncR = (int)(gdImageRed (src, c) * (pct / 100.0) + gdImageRed (dst, dc) * ((100 - pct) / 100.0));
ncG = (int)(gdImageGreen (src, c) * (pct / 100.0) + gdImageGreen (dst, dc) * ((100 - pct) / 100.0));
ncB = (int)(gdImageBlue (src, c) * (pct / 100.0) + gdImageBlue (dst, dc) * ((100 - pct) / 100.0));
/* Find a reasonable color */
nc = gdImageColorResolve (dst, ncR, ncG, ncB);
}
gdImageSetPixel (dst, tox, toy, nc);
tox++;
}
toy++;
}
}
| 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
|
void gitn_box_del(GF_Box *s)
{
u32 i;
GroupIdToNameBox *ptr = (GroupIdToNameBox *)s;
if (ptr == NULL) return;
for (i=0; i<ptr->nb_entries; i++) {
if (ptr->entries[i].name) gf_free(ptr->entries[i].name);
}
if (ptr->entries) gf_free(ptr->entries);
gf_free(ptr);
| 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
|
PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */
{
const char *p, *q;
char *name;
const char *endptr = val + vallen;
zval *current;
int namelen;
int has_value;
php_unserialize_data_t var_hash;
PHP_VAR_UNSERIALIZE_INIT(var_hash);
p = val;
while (p < endptr) {
zval **tmp;
q = p;
while (*q != PS_DELIMITER) {
if (++q >= endptr) goto break_outer_loop;
}
if (p[0] == PS_UNDEF_MARKER) {
p++;
has_value = 0;
} else {
has_value = 1;
}
namelen = q - p;
name = estrndup(p, namelen);
q++;
if (zend_hash_find(&EG(symbol_table), name, namelen + 1, (void **) &tmp) == SUCCESS) {
if ((Z_TYPE_PP(tmp) == IS_ARRAY && Z_ARRVAL_PP(tmp) == &EG(symbol_table)) || *tmp == PS(http_session_vars)) {
goto skip;
}
}
if (has_value) {
ALLOC_INIT_ZVAL(current);
if (php_var_unserialize(¤t, (const unsigned char **) &q, (const unsigned char *) endptr, &var_hash TSRMLS_CC)) {
php_set_session_var(name, namelen, current, &var_hash TSRMLS_CC);
} else {
var_push_dtor_no_addref(&var_hash, ¤t);
efree(name);
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return FAILURE;
}
var_push_dtor_no_addref(&var_hash, ¤t);
}
PS_ADD_VARL(name, namelen);
skip:
efree(name);
p = q;
}
break_outer_loop:
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return SUCCESS;
}
| 0 |
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
|
vulnerable
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.