func
stringlengths
0
484k
target
int64
0
1
cwe
listlengths
0
4
project
stringclasses
799 values
commit_id
stringlengths
40
40
hash
float64
1,215,700,430,453,689,100,000,000B
340,281,914,521,452,260,000,000,000,000B
size
int64
1
24k
message
stringlengths
0
13.3k
**/ Tfloat linear_atXY(const float fx, const float fy, const int z=0, const int c=0) const { if (is_empty()) throw CImgInstanceException(_cimg_instance "linear_atXY(): Empty instance.", cimg_instance); return _linear_atXY(fx,fy,z,c);
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
130,523,629,342,364,540,000,000,000,000,000,000,000
8
Fix other issues in 'CImg<T>::load_bmp()'.
static int vsock_dgram_recvmsg(struct kiocb *kiocb, struct socket *sock, struct msghdr *msg, size_t len, int flags) { return transport->dgram_dequeue(kiocb, vsock_sk(sock->sk), msg, len, flags); }
0
[ "CWE-20", "CWE-269" ]
linux
f3d3342602f8bcbf37d7c46641cb9bca7618eb1c
163,319,492,540,851,040,000,000,000,000,000,000,000
6
net: rework recvmsg handler msg_name and msg_namelen logic This patch now always passes msg->msg_namelen as 0. recvmsg handlers must set msg_namelen to the proper size <= sizeof(struct sockaddr_storage) to return msg_name to the user. This prevents numerous uninitialized memory leaks we had in the recvmsg handlers and makes it harder for new code to accidentally leak uninitialized memory. Optimize for the case recvfrom is called with NULL as address. We don't need to copy the address at all, so set it to NULL before invoking the recvmsg handler. We can do so, because all the recvmsg handlers must cope with the case a plain read() is called on them. read() also sets msg_name to NULL. Also document these changes in include/linux/net.h as suggested by David Miller. Changes since RFC: Set msg->msg_name = NULL if user specified a NULL in msg_name but had a non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't affect sendto as it would bail out earlier while trying to copy-in the address. It also more naturally reflects the logic by the callers of verify_iovec. With this change in place I could remove " if (!uaddr || msg_sys->msg_namelen == 0) msg->msg_name = NULL ". This change does not alter the user visible error logic as we ignore msg_namelen as long as msg_name is NULL. Also remove two unnecessary curly brackets in ___sys_recvmsg and change comments to netdev style. Cc: David Miller <[email protected]> Suggested-by: Eric Dumazet <[email protected]> Signed-off-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
GF_Err styl_dump(GF_Box *a, FILE * trace) { u32 i; GF_TextStyleBox*p = (GF_TextStyleBox*)a; gf_isom_box_dump_start(a, "TextStyleBox", trace); fprintf(trace, ">\n"); for (i=0; i<p->entry_count; i++) tx3g_dump_style(trace, &p->styles[i]); if (!p->size) { fprintf(trace, "<StyleRecord startChar=\"\" endChar=\"\" fontID=\"\" styles=\"Normal|Bold|Italic|Underlined\" fontSize=\"\" textColor=\"\" />\n"); } gf_isom_box_dump_done("TextStyleBox", a, trace); return GF_OK; }
0
[ "CWE-125" ]
gpac
bceb03fd2be95097a7b409ea59914f332fb6bc86
198,907,773,239,060,070,000,000,000,000,000,000,000
13
fixed 2 possible heap overflows (inc. #1088)
static struct io_buffer *io_buffer_select(struct io_kiocb *req, size_t *len, int bgid, struct io_buffer *kbuf, bool needs_lock) { struct io_buffer *head; if (req->flags & REQ_F_BUFFER_SELECTED) return kbuf; io_ring_submit_lock(req->ctx, needs_lock); lockdep_assert_held(&req->ctx->uring_lock); head = idr_find(&req->ctx->io_buffer_idr, bgid); if (head) { if (!list_empty(&head->list)) { kbuf = list_last_entry(&head->list, struct io_buffer, list); list_del(&kbuf->list); } else { kbuf = head; idr_remove(&req->ctx->io_buffer_idr, bgid); } if (*len > kbuf->len) *len = kbuf->len; } else { kbuf = ERR_PTR(-ENOBUFS); } io_ring_submit_unlock(req->ctx, needs_lock); return kbuf; }
0
[]
linux
0f2122045b946241a9e549c2a76cea54fa58a7ff
214,766,790,776,496,280,000,000,000,000,000,000,000
33
io_uring: don't rely on weak ->files references Grab actual references to the files_struct. To avoid circular references issues due to this, we add a per-task note that keeps track of what io_uring contexts a task has used. When the tasks execs or exits its assigned files, we cancel requests based on this tracking. With that, we can grab proper references to the files table, and no longer need to rely on stashing away ring_fd and ring_file to check if the ring_fd may have been closed. Cc: [email protected] # v5.5+ Reviewed-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
static int lru_pull_tail(const int orig_id, const int cur_lru, const uint64_t total_bytes, uint8_t flags) { item *it = NULL; int id = orig_id; int removed = 0; if (id == 0) return 0; int tries = 5; item *search; item *next_it; void *hold_lock = NULL; unsigned int move_to_lru = 0; uint64_t limit = 0; id |= cur_lru; pthread_mutex_lock(&lru_locks[id]); search = tails[id]; /* We walk up *only* for locked items, and if bottom is expired. */ for (; tries > 0 && search != NULL; tries--, search=next_it) { /* we might relink search mid-loop, so search->prev isn't reliable */ next_it = search->prev; if (search->nbytes == 0 && search->nkey == 0 && search->it_flags == 1) { /* We are a crawler, ignore it. */ if (flags & LRU_PULL_CRAWL_BLOCKS) { pthread_mutex_unlock(&lru_locks[id]); return 0; } tries++; continue; } uint32_t hv = hash(ITEM_key(search), search->nkey); /* Attempt to hash item lock the "search" item. If locked, no * other callers can incr the refcount. Also skip ourselves. */ if ((hold_lock = item_trylock(hv)) == NULL) continue; /* Now see if the item is refcount locked */ if (refcount_incr(&search->refcount) != 2) { /* Note pathological case with ref'ed items in tail. * Can still unlink the item, but it won't be reusable yet */ itemstats[id].lrutail_reflocked++; /* In case of refcount leaks, enable for quick workaround. */ /* WARNING: This can cause terrible corruption */ if (settings.tail_repair_time && search->time + settings.tail_repair_time < current_time) { itemstats[id].tailrepairs++; search->refcount = 1; /* This will call item_remove -> item_free since refcnt is 1 */ do_item_unlink_nolock(search, hv); item_trylock_unlock(hold_lock); continue; } } /* Expired or flushed */ if ((search->exptime != 0 && search->exptime < current_time) || item_is_flushed(search)) { itemstats[id].reclaimed++; if ((search->it_flags & ITEM_FETCHED) == 0) { itemstats[id].expired_unfetched++; } /* refcnt 2 -> 1 */ do_item_unlink_nolock(search, hv); /* refcnt 1 -> 0 -> item_free */ do_item_remove(search); item_trylock_unlock(hold_lock); removed++; /* If all we're finding are expired, can keep going */ continue; } /* If we're HOT_LRU or WARM_LRU and over size limit, send to COLD_LRU. * If we're COLD_LRU, send to WARM_LRU unless we need to evict */ switch (cur_lru) { case HOT_LRU: limit = total_bytes * settings.hot_lru_pct / 100; case WARM_LRU: if (limit == 0) limit = total_bytes * settings.warm_lru_pct / 100; if (sizes_bytes[id] > limit) { itemstats[id].moves_to_cold++; move_to_lru = COLD_LRU; do_item_unlink_q(search); it = search; removed++; break; } else if ((search->it_flags & ITEM_ACTIVE) != 0) { /* Only allow ACTIVE relinking if we're not too large. */ itemstats[id].moves_within_lru++; search->it_flags &= ~ITEM_ACTIVE; do_item_update_nolock(search); do_item_remove(search); item_trylock_unlock(hold_lock); } else { /* Don't want to move to COLD, not active, bail out */ it = search; } break; case COLD_LRU: it = search; /* No matter what, we're stopping */ if (flags & LRU_PULL_EVICT) { if (settings.evict_to_free == 0) { /* Don't think we need a counter for this. It'll OOM. */ break; } itemstats[id].evicted++; itemstats[id].evicted_time = current_time - search->time; if (search->exptime != 0) itemstats[id].evicted_nonzero++; if ((search->it_flags & ITEM_FETCHED) == 0) { itemstats[id].evicted_unfetched++; } LOGGER_LOG(NULL, LOG_EVICTIONS, LOGGER_EVICTION, search); do_item_unlink_nolock(search, hv); removed++; if (settings.slab_automove == 2) { slabs_reassign(-1, orig_id); } } else if ((search->it_flags & ITEM_ACTIVE) != 0 && settings.lru_maintainer_thread) { itemstats[id].moves_to_warm++; search->it_flags &= ~ITEM_ACTIVE; move_to_lru = WARM_LRU; do_item_unlink_q(search); removed++; } break; } if (it != NULL) break; } pthread_mutex_unlock(&lru_locks[id]); if (it != NULL) { if (move_to_lru) { it->slabs_clsid = ITEM_clsid(it); it->slabs_clsid |= move_to_lru; item_link_q(it); } do_item_remove(it); item_trylock_unlock(hold_lock); } return removed; }
0
[ "CWE-190" ]
memcached
bd578fc34b96abe0f8d99c1409814a09f51ee71c
205,124,052,305,799,020,000,000,000,000,000,000,000
148
CVE reported by cisco talos
static int __init bpf_lwt_init(void) { return lwtunnel_encap_add_ops(&bpf_encap_ops, LWTUNNEL_ENCAP_BPF); }
0
[]
net
6c8991f41546c3c472503dff1ea9daaddf9331c2
219,951,558,046,515,940,000,000,000,000,000,000,000
4
net: ipv6_stub: use ip6_dst_lookup_flow instead of ip6_dst_lookup ipv6_stub uses the ip6_dst_lookup function to allow other modules to perform IPv6 lookups. However, this function skips the XFRM layer entirely. All users of ipv6_stub->ip6_dst_lookup use ip_route_output_flow (via the ip_route_output_key and ip_route_output helpers) for their IPv4 lookups, which calls xfrm_lookup_route(). This patch fixes this inconsistent behavior by switching the stub to ip6_dst_lookup_flow, which also calls xfrm_lookup_route(). This requires some changes in all the callers, as these two functions take different arguments and have different return types. Fixes: 5f81bd2e5d80 ("ipv6: export a stub for IPv6 symbols used by vxlan") Reported-by: Xiumei Mu <[email protected]> Signed-off-by: Sabrina Dubroca <[email protected]> Signed-off-by: David S. Miller <[email protected]>
onig_get_callout_start_func(regex_t* reg, int callout_num) { /* If used for callouts of contents, return 0. */ CalloutListEntry* e; e = onig_reg_callout_list_at(reg, callout_num); return e->start_func; }
0
[ "CWE-476" ]
oniguruma
850bd9b0d8186eb1637722b46b12656814ab4ad2
227,118,708,053,105,080,000,000,000,000,000,000,000
8
fix #87: Read unknown address in onig_error_code_to_str()
copy_class(mrb_state *mrb, mrb_value dst, mrb_value src) { struct RClass *dc = mrb_class_ptr(dst); struct RClass *sc = mrb_class_ptr(src); /* if the origin is not the same as the class, then the origin and the current class need to be copied */ if (sc->flags & MRB_FLAG_IS_PREPENDED) { struct RClass *c0 = sc->super; struct RClass *c1 = dc; /* copy prepended iclasses */ while (!(c0->flags & MRB_FLAG_IS_ORIGIN)) { c1->super = mrb_class_ptr(mrb_obj_dup(mrb, mrb_obj_value(c0))); c1 = c1->super; c0 = c0->super; } c1->super = mrb_class_ptr(mrb_obj_dup(mrb, mrb_obj_value(c0))); c1->super->flags |= MRB_FLAG_IS_ORIGIN; } if (sc->mt) { dc->mt = kh_copy(mt, mrb, sc->mt); } else { dc->mt = kh_init(mt, mrb); } dc->super = sc->super; MRB_SET_INSTANCE_TT(dc, MRB_INSTANCE_TT(sc)); }
0
[ "CWE-824" ]
mruby
b64ce17852b180dfeea81cf458660be41a78974d
196,737,554,629,942,780,000,000,000,000,000,000,000
28
Should not call `initialize_copy` for `TT_ICLASS`; fix #4027 Since `TT_ICLASS` is a internal object that should never be revealed to Ruby world.
const x509_cert *ssl_get_peer_cert( const ssl_context *ssl ) { if( ssl == NULL || ssl->session == NULL ) return NULL; return ssl->session->peer_cert; }
0
[ "CWE-310" ]
polarssl
4582999be608c9794d4518ae336b265084db9f93
184,586,653,148,011,730,000,000,000,000,000,000,000
7
Fixed timing difference resulting from badly formatted padding.
finish_newstyle_options (uint64_t *exportsize, const char *exportname_in, uint32_t exportnamelen) { GET_CONN; /* Since the exportname string passed here comes directly out of the * NBD protocol make a temporary copy of the exportname into a * \0-terminated buffer. */ CLEANUP_FREE char *exportname = strndup (exportname_in, exportnamelen); if (exportname == NULL) { nbdkit_error ("strndup: %m"); return -1; } /* The NBD spec says that if the client later uses NBD_OPT_GO on a * different export, then the context from the earlier * NBD_OPT_SET_META_CONTEXT is not usable so discard it. */ if (conn->exportname_from_set_meta_context && strcmp (conn->exportname_from_set_meta_context, exportname) != 0) { debug ("newstyle negotiation: NBD_OPT_SET_META_CONTEXT export name \"%s\" " "≠ final client exportname \"%s\", " "so discarding the previous context", conn->exportname_from_set_meta_context, exportname); conn->meta_context_base_allocation = false; } if (protocol_common_open (exportsize, &conn->eflags, exportname) == -1) return -1; debug ("newstyle negotiation: flags: export 0x%x", conn->eflags); return 0; }
0
[ "CWE-924" ]
nbdkit
09a13dafb7bb3a38ab52eb5501cba786365ba7fd
93,355,634,710,270,430,000,000,000,000,000,000,000
34
server: CVE-2021-3716 reset structured replies on starttls https://nostarttls.secvuln.info/ pointed out a series of CVEs in common implementation flaw in various SMTP and IMAP clients and servers, all with a common thread of improperly caching plaintext state across the STARTTLS encryption boundary; and recommended that other protocols with a STARTTLS operation perform a similar audit. It turns out that nbdkit has the same vulnerability in regards to the NBD protocol: when nbdkit is run in opportunistic TLS mode, an attacker is able to inject a plaintext NBD_OPT_STRUCTURED_REPLY before proxying everything else a client sends to the server; if the server then acts on that plaintext request (as nbdkit did before this patch), then the server ends up sending structured replies to at least NBD_CMD_READ, even though the client was assuming that the transition to TLS has ruled out a MitM attack. On the bright side, nbdkit's behavior on a second NBD_OPT_STRUCTURED_REPLY was to still reply with success, so a client that always requests structured replies after starting TLS sees no difference in behavior (that is, qemu 2.12 and later are immune) (had nbdkit given an error to the second request, that may have caused confusion to more clients). And there is always the mitigation of using --tls=require, which lets nbdkit reject the MitM message pre-encryption. However, nbd-client 3.15 to the present do not understand structured replies, and I have confirmed that a MitM attacker can thus cause a denial-of-service attack that does not trigger until the client does its first encrypted NBD_CMD_READ. The NBD spec has been recently tightened to declare the nbdkit behavior to be a security hole: https://github.com/NetworkBlockDevice/nbd/commit/77e55378096aa
ins_need_undo_get(void) { return ins_need_undo; }
0
[]
vim
98a336dd497d3422e7efeef9f24cc9e25aeb8a49
289,189,782,547,178,900,000,000,000,000,000,000,000
4
patch 8.2.0133: invalid memory access with search command Problem: Invalid memory access with search command. Solution: When :normal runs out of characters in bracketed paste mode break out of the loop.(closes #5511)
sctp_xmit_t sctp_packet_transmit_chunk(struct sctp_packet *packet, struct sctp_chunk *chunk, int one_packet) { sctp_xmit_t retval; int error = 0; SCTP_DEBUG_PRINTK("%s: packet:%p chunk:%p\n", __func__, packet, chunk); switch ((retval = (sctp_packet_append_chunk(packet, chunk)))) { case SCTP_XMIT_PMTU_FULL: if (!packet->has_cookie_echo) { error = sctp_packet_transmit(packet); if (error < 0) chunk->skb->sk->sk_err = -error; /* If we have an empty packet, then we can NOT ever * return PMTU_FULL. */ if (!one_packet) retval = sctp_packet_append_chunk(packet, chunk); } break; case SCTP_XMIT_RWND_FULL: case SCTP_XMIT_OK: case SCTP_XMIT_NAGLE_DELAY: break; } return retval; }
0
[]
linux
196d67593439b03088913227093e374235596e33
295,660,278,013,436,550,000,000,000,000,000,000,000
34
sctp: Add support to per-association statistics via a new SCTP_GET_ASSOC_STATS call The current SCTP stack is lacking a mechanism to have per association statistics. This is an implementation modeled after OpenSolaris' SCTP_GET_ASSOC_STATS. Userspace part will follow on lksctp if/when there is a general ACK on this. V4: - Move ipackets++ before q->immediate.func() for consistency reasons - Move sctp_max_rto() at the end of sctp_transport_update_rto() to avoid returning bogus RTO values - return asoc->rto_min when max_obs_rto value has not changed V3: - Increase ictrlchunks in sctp_assoc_bh_rcv() as well - Move ipackets++ to sctp_inq_push() - return 0 when no rto updates took place since the last call V2: - Implement partial retrieval of stat struct to cope for future expansion - Kill the rtxpackets counter as it cannot be precise anyway - Rename outseqtsns to outofseqtsns to make it clearer that these are out of sequence unexpected TSNs - Move asoc->ipackets++ under a lock to avoid potential miscounts - Fold asoc->opackets++ into the already existing asoc check - Kill unneeded (q->asoc) test when increasing rtxchunks - Do not count octrlchunks if sending failed (SCTP_XMIT_OK != 0) - Don't count SHUTDOWNs as SACKs - Move SCTP_GET_ASSOC_STATS to the private space API - Adjust the len check in sctp_getsockopt_assoc_stats() to allow for future struct growth - Move association statistics in their own struct - Update idupchunks when we send a SACK with dup TSNs - return min_rto in max_rto when RTO has not changed. Also return the transport when max_rto last changed. Signed-off: Michele Baldessari <[email protected]> Acked-by: Vlad Yasevich <[email protected]> Signed-off-by: David S. Miller <[email protected]>
find_book_view (EBookBackendLDAP *bl) { EDataBookView *view = NULL; GList *list; list = e_book_backend_list_views (E_BOOK_BACKEND (bl)); if (list != NULL) { /* FIXME Drop the EDataBookView reference for backward- * compatibility, but at some point the LDAP backend * should learn to expect a new reference from this * function and clean up after itself. Currently * this is not thread-safe. */ view = E_DATA_BOOK_VIEW (list->data); g_list_free_full (list, (GDestroyNotify) g_object_unref); } return view; }
0
[]
evolution-data-server
34bad61738e2127736947ac50e0c7969cc944972
169,197,335,249,554,210,000,000,000,000,000,000,000
19
Bug 796174 - strcat() considered unsafe for buffer overflow
rsvg_acquire_base64_resource (const char *data, GError ** error) { GByteArray *array = NULL; gsize data_len, written_len; int state = 0; guint save = 0; rsvg_return_val_if_fail (data != NULL, NULL, error); while (*data) if (*data++ == ',') break; data_len = strlen (data); array = g_byte_array_sized_new (data_len / 4 * 3); written_len = g_base64_decode_step (data, data_len, array->data, &state, &save); g_byte_array_set_size (array, written_len); return array; }
0
[]
librsvg
34c95743ca692ea0e44778e41a7c0a129363de84
78,517,402,200,713,660,000,000,000,000,000,000,000
21
Store node type separately in RsvgNode The node name (formerly RsvgNode:type) cannot be used to infer the sub-type of RsvgNode that we're dealing with, since for unknown elements we put type = node-name. This lead to a (potentially exploitable) crash e.g. when the element name started with "fe" which tricked the old code into considering it as a RsvgFilterPrimitive. CVE-2011-3146 https://bugzilla.gnome.org/show_bug.cgi?id=658014
PHP_FUNCTION(openssl_pkcs12_export) { X509 * cert = NULL; BIO * bio_out; PKCS12 * p12 = NULL; zval * zcert = NULL, *zout = NULL, *zpkey, *args = NULL; EVP_PKEY *priv_key = NULL; long certresource, keyresource; char * pass; int pass_len; char * friendly_name = NULL; zval ** item; STACK_OF(X509) *ca = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzzs|a", &zcert, &zout, &zpkey, &pass, &pass_len, &args) == FAILURE) return; RETVAL_FALSE; cert = php_openssl_x509_from_zval(&zcert, 0, &certresource TSRMLS_CC); if (cert == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get cert from parameter 1"); return; } priv_key = php_openssl_evp_from_zval(&zpkey, 0, "", 1, &keyresource TSRMLS_CC); if (priv_key == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get private key from parameter 3"); goto cleanup; } if (cert && !X509_check_private_key(cert, priv_key)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "private key does not correspond to cert"); goto cleanup; } /* parse extra config from args array, promote this to an extra function */ if (args && zend_hash_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name"), (void**)&item) == SUCCESS) friendly_name = Z_STRVAL_PP(item); if (args && zend_hash_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts"), (void**)&item) == SUCCESS) ca = php_array_to_X509_sk(item TSRMLS_CC); /* end parse extra config */ p12 = PKCS12_create(pass, friendly_name, priv_key, cert, ca, 0, 0, 0, 0, 0); bio_out = BIO_new(BIO_s_mem()); if (i2d_PKCS12_bio(bio_out, p12)) { BUF_MEM *bio_buf; zval_dtor(zout); BIO_get_mem_ptr(bio_out, &bio_buf); ZVAL_STRINGL(zout, bio_buf->data, bio_buf->length, 1); RETVAL_TRUE; } BIO_free(bio_out); PKCS12_free(p12); php_sk_X509_free(ca); cleanup: if (keyresource == -1 && priv_key) { EVP_PKEY_free(priv_key); } if (certresource == -1 && cert) { X509_free(cert); } }
0
[ "CWE-20" ]
php-src
2874696a5a8d46639d261571f915c493cd875897
117,887,529,027,971,220,000,000,000,000,000,000,000
68
Fix CVE-2013-4073 - handling of certs with null bytes
void arch_cpu_idle_exit(void) { ledtrig_cpu(CPU_LED_IDLE_END); }
0
[ "CWE-284", "CWE-264" ]
linux
a4780adeefd042482f624f5e0d577bf9cdcbb760
91,124,645,195,973,960,000,000,000,000,000,000,000
4
ARM: 7735/2: Preserve the user r/w register TPIDRURW on context switch and fork Since commit 6a1c53124aa1 the user writeable TLS register was zeroed to prevent it from being used as a covert channel between two tasks. There are more and more applications coming to Windows RT, Wine could support them, but mostly they expect to have the thread environment block (TEB) in TPIDRURW. This patch preserves that register per thread instead of clearing it. Unlike the TPIDRURO, which is already switched, the TPIDRURW can be updated from userspace so needs careful treatment in the case that we modify TPIDRURW and call fork(). To avoid this we must always read TPIDRURW in copy_thread. Signed-off-by: André Hentschel <[email protected]> Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Jonathan Austin <[email protected]> Signed-off-by: Russell King <[email protected]>
INST_HANDLER (las) { // LAS Z, Rd int d = ((buf[0] >> 4) & 0xf) | ((buf[1] & 0x1) << 4); // read memory from RAMPZ:Z __generic_ld_st (op, "ram", 'z', 1, 0, 0, 0); // 0: Read (RAMPZ:Z) ESIL_A ("r%d,|,", d); // 0: (Z) | Rd ESIL_A ("DUP,r%d,=,", d); // Rd = [0] __generic_ld_st (op, "ram", 'z', 1, 0, 0, 1); // Store in RAM }
0
[ "CWE-125" ]
radare2
041e53cab7ca33481ae45ecd65ad596976d78e68
236,611,070,086,723,800,000,000,000,000,000,000,000
9
Fix crash in anal.avr
TEST(UriSuite, TestUriUserInfoHostPort1) { // User info with ":", no port UriParserStateA stateA; UriUriA uriA; stateA.uri = &uriA; // 0 4 0 3 0 7 01 0 9 const char * const input = "http" "://" "abc:def" "@" "localhost"; ASSERT_TRUE(0 == uriParseUriA(&stateA, input)); ASSERT_TRUE(uriA.userInfo.first == input + 4 + 3); ASSERT_TRUE(uriA.userInfo.afterLast == input + 4 + 3 + 7); ASSERT_TRUE(uriA.hostText.first == input + 4 + 3 + 7 + 1); ASSERT_TRUE(uriA.hostText.afterLast == input + 4 + 3 + 7 + 1 + 9); ASSERT_TRUE(uriA.portText.first == NULL); ASSERT_TRUE(uriA.portText.afterLast == NULL); uriFreeUriMembersA(&uriA); }
0
[ "CWE-125" ]
uriparser
cef25028de5ff872c2e1f0a6c562eb3ea9ecbce4
184,202,791,516,172,350,000,000,000,000,000,000,000
17
Fix uriParse*Ex* out-of-bounds read
static void flush_entryatt(annotate_state_t *state) { if (!state->attvalues) return; /* nothing to flush */ state->callback(state->lastname, state->lastuid, state->lastentry, state->attvalues, state->callback_rock); freeattvalues(state->attvalues); state->attvalues = NULL; }
0
[ "CWE-732" ]
cyrus-imapd
621f9e41465b521399f691c241181300fab55995
76,021,451,074,969,630,000,000,000,000,000,000,000
13
annotate: don't allow everyone to write shared server entries
__must_hold(wqe->lock) { struct io_wqe_acct *acct = io_wqe_get_acct(worker); struct io_wqe *wqe = worker->wqe; if (!(worker->flags & IO_WORKER_F_UP)) return; if (atomic_dec_and_test(&acct->nr_running) && io_acct_run_queue(acct)) { atomic_inc(&acct->nr_running); atomic_inc(&wqe->wq->worker_refs); io_queue_worker_create(worker, acct, create_worker_cb); } }
0
[ "CWE-200" ]
linux
713b9825a4c47897f66ad69409581e7734a8728e
339,090,009,910,580,630,000,000,000,000,000,000,000
14
io-wq: fix cancellation on create-worker failure WARNING: CPU: 0 PID: 10392 at fs/io_uring.c:1151 req_ref_put_and_test fs/io_uring.c:1151 [inline] WARNING: CPU: 0 PID: 10392 at fs/io_uring.c:1151 req_ref_put_and_test fs/io_uring.c:1146 [inline] WARNING: CPU: 0 PID: 10392 at fs/io_uring.c:1151 io_req_complete_post+0xf5b/0x1190 fs/io_uring.c:1794 Modules linked in: Call Trace: tctx_task_work+0x1e5/0x570 fs/io_uring.c:2158 task_work_run+0xe0/0x1a0 kernel/task_work.c:164 tracehook_notify_signal include/linux/tracehook.h:212 [inline] handle_signal_work kernel/entry/common.c:146 [inline] exit_to_user_mode_loop kernel/entry/common.c:172 [inline] exit_to_user_mode_prepare+0x232/0x2a0 kernel/entry/common.c:209 __syscall_exit_to_user_mode_work kernel/entry/common.c:291 [inline] syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:302 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x44/0xae When io_wqe_enqueue() -> io_wqe_create_worker() fails, we can't just call io_run_cancel() to clean up the request, it's already enqueued via io_wqe_insert_work() and will be executed either by some other worker during cancellation (e.g. in io_wq_put_and_exit()). Reported-by: Hao Sun <[email protected]> Fixes: 3146cba99aa28 ("io-wq: make worker creation resilient against signals") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/93b9de0fcf657affab0acfd675d4abcd273ee863.1631092071.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
int cpia2_usb_stream_start(struct camera_data *cam, unsigned int alternate) { int ret; int old_alt; if(cam->streaming) return 0; if (cam->flush) { int i; DBG("Flushing buffers\n"); for(i=0; i<cam->num_frames; ++i) { cam->buffers[i].status = FRAME_EMPTY; cam->buffers[i].length = 0; } cam->curbuff = &cam->buffers[0]; cam->workbuff = cam->curbuff->next; cam->flush = false; } old_alt = cam->params.camera_state.stream_mode; cam->params.camera_state.stream_mode = 0; ret = cpia2_usb_change_streaming_alternate(cam, alternate); if (ret < 0) { int ret2; ERR("cpia2_usb_change_streaming_alternate() = %d!\n", ret); cam->params.camera_state.stream_mode = old_alt; ret2 = set_alternate(cam, USBIF_CMDONLY); if (ret2 < 0) { ERR("cpia2_usb_change_streaming_alternate(%d) =%d has already failed. Then tried to call set_alternate(USBIF_CMDONLY) = %d.\n", alternate, ret, ret2); } } else { cam->frame_count = 0; cam->streaming = 1; ret = cpia2_usb_stream_resume(cam); } return ret; }
0
[ "CWE-416" ]
linux
eff73de2b1600ad8230692f00bc0ab49b166512a
26,507,993,111,895,484,000,000,000,000,000,000,000
39
media: cpia2_usb: first wake up, then free in disconnect Kasan reported a use after free in cpia2_usb_disconnect() It first freed everything and then woke up those waiting. The reverse order is correct. Fixes: 6c493f8b28c67 ("[media] cpia2: major overhaul to get it in a working state again") Signed-off-by: Oliver Neukum <[email protected]> Reported-by: [email protected] Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
GF_ISOMAVCType gf_isom_get_avc_svc_type(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex) { u32 type; GF_TrackBox *trak; GF_MPEGVisualSampleEntryBox *entry; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !trak->Media || !trak->Media->handler || !DescriptionIndex) return GF_ISOM_AVCTYPE_NONE; if (!gf_isom_is_video_handler_type(trak->Media->handler->handlerType)) return GF_ISOM_AVCTYPE_NONE; entry = (GF_MPEGVisualSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, DescriptionIndex-1); if (!entry) return GF_ISOM_AVCTYPE_NONE; type = entry->type; if (type == GF_ISOM_BOX_TYPE_ENCV) { GF_ProtectionSchemeInfoBox *sinf = (GF_ProtectionSchemeInfoBox *) gf_isom_box_find_child(entry->child_boxes, GF_ISOM_BOX_TYPE_SINF); if (sinf && sinf->original_format) type = sinf->original_format->data_format; } else if (type == GF_ISOM_BOX_TYPE_RESV) { if (entry->rinf && entry->rinf->original_format) type = entry->rinf->original_format->data_format; } switch (type) { case GF_ISOM_BOX_TYPE_AVC1: case GF_ISOM_BOX_TYPE_AVC2: case GF_ISOM_BOX_TYPE_AVC3: case GF_ISOM_BOX_TYPE_AVC4: case GF_ISOM_BOX_TYPE_SVC1: case GF_ISOM_BOX_TYPE_MVC1: break; default: return GF_ISOM_AVCTYPE_NONE; } if (entry->avc_config && !entry->svc_config && !entry->mvc_config) return GF_ISOM_AVCTYPE_AVC_ONLY; if (entry->avc_config && entry->svc_config) return GF_ISOM_AVCTYPE_AVC_SVC; if (entry->avc_config && entry->mvc_config) return GF_ISOM_AVCTYPE_AVC_MVC; if (!entry->avc_config && entry->svc_config) return GF_ISOM_AVCTYPE_SVC_ONLY; if (!entry->avc_config && entry->mvc_config) return GF_ISOM_AVCTYPE_MVC_ONLY; return GF_ISOM_AVCTYPE_NONE; }
0
[ "CWE-401" ]
gpac
0a85029d694f992f3631e2f249e4999daee15cbf
227,435,620,295,001,650,000,000,000,000,000,000,000
41
fixed #1785 (fuzz)
void dm_put(struct mapped_device *md) { atomic_dec(&md->holders); }
0
[ "CWE-362" ]
linux
b9a41d21dceadf8104812626ef85dc56ee8a60ed
139,779,970,552,504,610,000,000,000,000,000,000,000
4
dm: fix race between dm_get_from_kobject() and __dm_destroy() The following BUG_ON was hit when testing repeat creation and removal of DM devices: kernel BUG at drivers/md/dm.c:2919! CPU: 7 PID: 750 Comm: systemd-udevd Not tainted 4.1.44 Call Trace: [<ffffffff81649e8b>] dm_get_from_kobject+0x34/0x3a [<ffffffff81650ef1>] dm_attr_show+0x2b/0x5e [<ffffffff817b46d1>] ? mutex_lock+0x26/0x44 [<ffffffff811df7f5>] sysfs_kf_seq_show+0x83/0xcf [<ffffffff811de257>] kernfs_seq_show+0x23/0x25 [<ffffffff81199118>] seq_read+0x16f/0x325 [<ffffffff811de994>] kernfs_fop_read+0x3a/0x13f [<ffffffff8117b625>] __vfs_read+0x26/0x9d [<ffffffff8130eb59>] ? security_file_permission+0x3c/0x44 [<ffffffff8117bdb8>] ? rw_verify_area+0x83/0xd9 [<ffffffff8117be9d>] vfs_read+0x8f/0xcf [<ffffffff81193e34>] ? __fdget_pos+0x12/0x41 [<ffffffff8117c686>] SyS_read+0x4b/0x76 [<ffffffff817b606e>] system_call_fastpath+0x12/0x71 The bug can be easily triggered, if an extra delay (e.g. 10ms) is added between the test of DMF_FREEING & DMF_DELETING and dm_get() in dm_get_from_kobject(). To fix it, we need to ensure the test of DMF_FREEING & DMF_DELETING and dm_get() are done in an atomic way, so _minor_lock is used. The other callers of dm_get() have also been checked to be OK: some callers invoke dm_get() under _minor_lock, some callers invoke it under _hash_lock, and dm_start_request() invoke it after increasing md->open_count. Cc: [email protected] Signed-off-by: Hou Tao <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
mlx5_tx_packet_multi_tso(struct mlx5_txq_data *restrict txq, struct mlx5_txq_local *restrict loc, unsigned int olx) { struct mlx5_wqe *restrict wqe; unsigned int ds, dlen, inlen, ntcp, vlan = 0; /* * Calculate data length to be inlined to estimate * the required space in WQE ring buffer. */ dlen = rte_pktmbuf_pkt_len(loc->mbuf); if (MLX5_TXOFF_CONFIG(VLAN) && loc->mbuf->ol_flags & PKT_TX_VLAN_PKT) vlan = sizeof(struct rte_vlan_hdr); inlen = loc->mbuf->l2_len + vlan + loc->mbuf->l3_len + loc->mbuf->l4_len; if (unlikely((!inlen || !loc->mbuf->tso_segsz))) return MLX5_TXCMP_CODE_ERROR; if (loc->mbuf->ol_flags & PKT_TX_TUNNEL_MASK) inlen += loc->mbuf->outer_l2_len + loc->mbuf->outer_l3_len; /* Packet must contain all TSO headers. */ if (unlikely(inlen > MLX5_MAX_TSO_HEADER || inlen <= MLX5_ESEG_MIN_INLINE_SIZE || inlen > (dlen + vlan))) return MLX5_TXCMP_CODE_ERROR; assert(inlen >= txq->inlen_mode); /* * Check whether there are enough free WQEBBs: * - Control Segment * - Ethernet Segment * - First Segment of inlined Ethernet data * - ... data continued ... * - Data Segments of pointer/min inline type */ ds = NB_SEGS(loc->mbuf) + 2 + (inlen - MLX5_ESEG_MIN_INLINE_SIZE + MLX5_WSEG_SIZE + MLX5_WSEG_SIZE - 1) / MLX5_WSEG_SIZE; if (unlikely(loc->wqe_free < ((ds + 3) / 4))) return MLX5_TXCMP_CODE_EXIT; /* Check for maximal WQE size. */ if (unlikely((MLX5_WQE_SIZE_MAX / MLX5_WSEG_SIZE) < ((ds + 3) / 4))) return MLX5_TXCMP_CODE_ERROR; #ifdef MLX5_PMD_SOFT_COUNTERS /* Update sent data bytes/packets counters. */ ntcp = (dlen - (inlen - vlan) + loc->mbuf->tso_segsz - 1) / loc->mbuf->tso_segsz; /* * One will be added for mbuf itself * at the end of the mlx5_tx_burst from * loc->pkts_sent field. */ --ntcp; txq->stats.opackets += ntcp; txq->stats.obytes += dlen + vlan + ntcp * inlen; #endif wqe = txq->wqes + (txq->wqe_ci & txq->wqe_m); loc->wqe_last = wqe; mlx5_tx_cseg_init(txq, loc, wqe, 0, MLX5_OPCODE_TSO, olx); ds = mlx5_tx_mseg_build(txq, loc, wqe, vlan, inlen, 1, olx); wqe->cseg.sq_ds = rte_cpu_to_be_32(txq->qp_num_8s | ds); txq->wqe_ci += (ds + 3) / 4; loc->wqe_free -= (ds + 3) / 4; return MLX5_TXCMP_CODE_MULTI; }
0
[]
dpdk-stable
8b090f2664e9d014cd8fa0fde90597aaf4349e7e
263,781,570,603,793,120,000,000,000,000,000,000,000
65
net/mlx5: fix Rx queue recovery mechanism The local variables are getting inconsistent in data receiving routines after queue error recovery. Receive queue consumer index is getting wrong, need to reset one to the size of the queue (as RQ was fully replenished in recovery procedure). In MPRQ case, also the local consumed strd variable should be reset. CVE-2022-28199 Fixes: 88c0733 ("net/mlx5: extend Rx completion with error handling") Signed-off-by: Alexander Kozyrev <[email protected]> Signed-off-by: Matan Azrad <[email protected]>
coolkey_get_access(sc_card_t *card, sc_cardctl_coolkey_object_t *obj, unsigned int *access_ptr) { return coolkey_set_bool_flags(card, obj, access_ptr, access_table, access_table_size); }
0
[]
OpenSC
7114fb71b54ddfe06ce5dfdab013f4c38f129d14
169,866,823,288,793,870,000,000,000,000,000,000,000
4
coolkey: Initialize potentially uninitialized memory Thanks oss-fuzz https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28855
ms_escher_read_AlignRule (MSEscherState *state, MSEscherHeader *h) { return FALSE; }
0
[ "CWE-119" ]
gnumeric
b5480b69345b3c6d56ee0ed9c9e9880bb2a08cdc
333,249,964,401,524,820,000,000,000,000,000,000,000
4
xls: fuzzed file crash.
xfs_inode_item_format( struct xfs_log_item *lip, struct xfs_log_vec *lv) { struct xfs_inode_log_item *iip = INODE_ITEM(lip); struct xfs_inode *ip = iip->ili_inode; struct xfs_inode_log_format *ilf; struct xfs_log_iovec *vecp = NULL; ASSERT(ip->i_d.di_version > 1); ilf = xlog_prepare_iovec(lv, &vecp, XLOG_REG_TYPE_IFORMAT); ilf->ilf_type = XFS_LI_INODE; ilf->ilf_ino = ip->i_ino; ilf->ilf_blkno = ip->i_imap.im_blkno; ilf->ilf_len = ip->i_imap.im_len; ilf->ilf_boffset = ip->i_imap.im_boffset; ilf->ilf_fields = XFS_ILOG_CORE; ilf->ilf_size = 2; /* format + core */ xlog_finish_iovec(lv, vecp, sizeof(struct xfs_inode_log_format)); xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ICORE, &ip->i_d, xfs_icdinode_size(ip->i_d.di_version)); xfs_inode_item_format_data_fork(iip, ilf, lv, &vecp); if (XFS_IFORK_Q(ip)) { xfs_inode_item_format_attr_fork(iip, ilf, lv, &vecp); } else { iip->ili_fields &= ~(XFS_ILOG_ADATA | XFS_ILOG_ABROOT | XFS_ILOG_AEXT); } /* update the format with the exact fields we actually logged */ ilf->ilf_fields |= (iip->ili_fields & ~XFS_ILOG_TIMESTAMP); }
0
[ "CWE-19" ]
linux
fc0561cefc04e7803c0f6501ca4f310a502f65b8
191,247,298,810,818,800,000,000,000,000,000,000,000
36
xfs: optimise away log forces on timestamp updates for fdatasync xfs: timestamp updates cause excessive fdatasync log traffic Sage Weil reported that a ceph test workload was writing to the log on every fdatasync during an overwrite workload. Event tracing showed that the only metadata modification being made was the timestamp updates during the write(2) syscall, but fdatasync(2) is supposed to ignore them. The key observation was that the transactions in the log all looked like this: INODE: #regs: 4 ino: 0x8b flags: 0x45 dsize: 32 And contained a flags field of 0x45 or 0x85, and had data and attribute forks following the inode core. This means that the timestamp updates were triggering dirty relogging of previously logged parts of the inode that hadn't yet been flushed back to disk. There are two parts to this problem. The first is that XFS relogs dirty regions in subsequent transactions, so it carries around the fields that have been dirtied since the last time the inode was written back to disk, not since the last time the inode was forced into the log. The second part is that on v5 filesystems, the inode change count update during inode dirtying also sets the XFS_ILOG_CORE flag, so on v5 filesystems this makes a timestamp update dirty the entire inode. As a result when fdatasync is run, it looks at the dirty fields in the inode, and sees more than just the timestamp flag, even though the only metadata change since the last fdatasync was just the timestamps. Hence we force the log on every subsequent fdatasync even though it is not needed. To fix this, add a new field to the inode log item that tracks changes since the last time fsync/fdatasync forced the log to flush the changes to the journal. This flag is updated when we dirty the inode, but we do it before updating the change count so it does not carry the "core dirty" flag from timestamp updates. The fields are zeroed when the inode is marked clean (due to writeback/freeing) or when an fsync/datasync forces the log. Hence if we only dirty the timestamps on the inode between fsync/fdatasync calls, the fdatasync will not trigger another log force. Over 100 runs of the test program: Ext4 baseline: runtime: 1.63s +/- 0.24s avg lat: 1.59ms +/- 0.24ms iops: ~2000 XFS, vanilla kernel: runtime: 2.45s +/- 0.18s avg lat: 2.39ms +/- 0.18ms log forces: ~400/s iops: ~1000 XFS, patched kernel: runtime: 1.49s +/- 0.26s avg lat: 1.46ms +/- 0.25ms log forces: ~30/s iops: ~1500 Reported-by: Sage Weil <[email protected]> Signed-off-by: Dave Chinner <[email protected]> Reviewed-by: Brian Foster <[email protected]> Signed-off-by: Dave Chinner <[email protected]>
void CLASS scale_colors() { unsigned bottom, right, size, row, col, ur, uc, i, x, y, c, sum[8]; int val, dark, sat; double dsum[8], dmin, dmax; float scale_mul[4], fr, fc; ushort *img=0, *pix; #ifdef LIBRAW_LIBRARY_BUILD RUN_CALLBACK(LIBRAW_PROGRESS_SCALE_COLORS,0,2); #endif if (user_mul[0]) memcpy (pre_mul, user_mul, sizeof pre_mul); if (use_auto_wb || (use_camera_wb && cam_mul[0] == -1)) { memset (dsum, 0, sizeof dsum); bottom = MIN (greybox[1]+greybox[3], height); right = MIN (greybox[0]+greybox[2], width); for (row=greybox[1]; row < bottom; row += 8) for (col=greybox[0]; col < right; col += 8) { memset (sum, 0, sizeof sum); for (y=row; y < row+8 && y < bottom; y++) for (x=col; x < col+8 && x < right; x++) FORC4 { if (filters) { c = fcol(y,x); val = BAYER2(y,x); } else val = image[y*width+x][c]; if (val > maximum-25) goto skip_block; if ((val -= cblack[c]) < 0) val = 0; sum[c] += val; sum[c+4]++; if (filters) break; } FORC(8) dsum[c] += sum[c]; skip_block: ; } FORC4 if (dsum[c]) pre_mul[c] = dsum[c+4] / dsum[c]; } if (use_camera_wb && cam_mul[0] != -1) { memset (sum, 0, sizeof sum); for (row=0; row < 8; row++) for (col=0; col < 8; col++) { c = FC(row,col); if ((val = white[row][col] - cblack[c]) > 0) sum[c] += val; sum[c+4]++; } #ifdef LIBRAW_LIBRARY_BUILD if(load_raw == &LibRaw::nikon_load_sraw) { // Nikon sRAW: camera WB already applied: pre_mul[0]=pre_mul[1]=pre_mul[2]=pre_mul[3]=1.0; } else #endif if (sum[0] && sum[1] && sum[2] && sum[3]) FORC4 pre_mul[c] = (float) sum[c+4] / sum[c]; else if (cam_mul[0] && cam_mul[2]) memcpy (pre_mul, cam_mul, sizeof pre_mul); else { #ifdef LIBRAW_LIBRARY_BUILD imgdata.process_warnings |= LIBRAW_WARN_BAD_CAMERA_WB; #endif #ifdef DCRAW_VERBOSE fprintf (stderr,_("%s: Cannot use camera white balance.\n"), ifname); #endif } } #ifdef LIBRAW_LIBRARY_BUILD // Nikon sRAW, daylight if (load_raw == &LibRaw::nikon_load_sraw && !use_camera_wb && !use_auto_wb && cam_mul[0] > 0.001f && cam_mul[1] > 0.001f && cam_mul[2] > 0.001f ) { for(c=0;c<3;c++) pre_mul[c]/=cam_mul[c]; } #endif if (pre_mul[1] == 0) pre_mul[1] = 1; if (pre_mul[3] == 0) pre_mul[3] = colors < 4 ? pre_mul[1] : 1; dark = black; sat = maximum; if (threshold) wavelet_denoise(); maximum -= black; for (dmin=DBL_MAX, dmax=c=0; c < 4; c++) { if (dmin > pre_mul[c]) dmin = pre_mul[c]; if (dmax < pre_mul[c]) dmax = pre_mul[c]; } if (!highlight) dmax = dmin; FORC4 scale_mul[c] = (pre_mul[c] /= dmax) * 65535.0 / maximum; #ifdef DCRAW_VERBOSE if (verbose) { fprintf (stderr, _("Scaling with darkness %d, saturation %d, and\nmultipliers"), dark, sat); FORC4 fprintf (stderr, " %f", pre_mul[c]); fputc ('\n', stderr); } #endif if (filters > 1000 && (cblack[4]+1)/2 == 1 && (cblack[5]+1)/2 == 1) { FORC4 cblack[FC(c/2,c%2)] += cblack[6 + c/2 % cblack[4] * cblack[5] + c%2 % cblack[5]]; cblack[4] = cblack[5] = 0; } size = iheight*iwidth; #ifdef LIBRAW_LIBRARY_BUILD scale_colors_loop(scale_mul); #else for (i=0; i < size*4; i++) { if (!(val = ((ushort *)image)[i])) continue; if (cblack[4] && cblack[5]) val -= cblack[6 + i/4 / iwidth % cblack[4] * cblack[5] + i/4 % iwidth % cblack[5]]; val -= cblack[i & 3]; val *= scale_mul[i & 3]; ((ushort *)image)[i] = CLIP(val); } #endif if ((aber[0] != 1 || aber[2] != 1) && colors == 3) { #ifdef DCRAW_VERBOSE if (verbose) fprintf (stderr,_("Correcting chromatic aberration...\n")); #endif for (c=0; c < 4; c+=2) { if (aber[c] == 1) continue; img = (ushort *) malloc (size * sizeof *img); merror (img, "scale_colors()"); for (i=0; i < size; i++) img[i] = image[i][c]; for (row=0; row < iheight; row++) { ur = fr = (row - iheight*0.5) * aber[c] + iheight*0.5; if (ur > iheight-2) continue; fr -= ur; for (col=0; col < iwidth; col++) { uc = fc = (col - iwidth*0.5) * aber[c] + iwidth*0.5; if (uc > iwidth-2) continue; fc -= uc; pix = img + ur*iwidth + uc; image[row*iwidth+col][c] = (pix[ 0]*(1-fc) + pix[ 1]*fc) * (1-fr) + (pix[iwidth]*(1-fc) + pix[iwidth+1]*fc) * fr; } } free(img); } } #ifdef LIBRAW_LIBRARY_BUILD RUN_CALLBACK(LIBRAW_PROGRESS_SCALE_COLORS,1,2); #endif }
0
[ "CWE-129" ]
LibRaw
89d065424f09b788f443734d44857289489ca9e2
83,545,931,530,672,515,000,000,000,000,000,000,000
154
fixed two more problems found by fuzzer
static void tcf_chain_tp_delete_empty(struct tcf_chain *chain, struct tcf_proto *tp, bool rtnl_held, struct netlink_ext_ack *extack) { struct tcf_chain_info chain_info; struct tcf_proto *tp_iter; struct tcf_proto **pprev; struct tcf_proto *next; mutex_lock(&chain->filter_chain_lock); /* Atomically find and remove tp from chain. */ for (pprev = &chain->filter_chain; (tp_iter = tcf_chain_dereference(*pprev, chain)); pprev = &tp_iter->next) { if (tp_iter == tp) { chain_info.pprev = pprev; chain_info.next = tp_iter->next; WARN_ON(tp_iter->deleting); break; } } /* Verify that tp still exists and no new filters were inserted * concurrently. * Mark tp for deletion if it is empty. */ if (!tp_iter || !tcf_proto_check_delete(tp)) { mutex_unlock(&chain->filter_chain_lock); return; } tcf_proto_signal_destroying(chain, tp); next = tcf_chain_dereference(chain_info.next, chain); if (tp == chain->filter_chain) tcf_chain0_head_change(chain, next); RCU_INIT_POINTER(*chain_info.pprev, next); mutex_unlock(&chain->filter_chain_lock); tcf_proto_put(tp, rtnl_held, extack); }
0
[ "CWE-416" ]
linux
04c2a47ffb13c29778e2a14e414ad4cb5a5db4b5
26,229,935,356,934,977,000,000,000,000,000,000,000
40
net: sched: fix use-after-free in tc_new_tfilter() Whenever tc_new_tfilter() jumps back to replay: label, we need to make sure @q and @chain local variables are cleared again, or risk use-after-free as in [1] For consistency, apply the same fix in tc_ctl_chain() BUG: KASAN: use-after-free in mini_qdisc_pair_swap+0x1b9/0x1f0 net/sched/sch_generic.c:1581 Write of size 8 at addr ffff8880985c4b08 by task syz-executor.4/1945 CPU: 0 PID: 1945 Comm: syz-executor.4 Not tainted 5.17.0-rc1-syzkaller-00495-gff58831fa02d #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0x8d/0x336 mm/kasan/report.c:255 __kasan_report mm/kasan/report.c:442 [inline] kasan_report.cold+0x83/0xdf mm/kasan/report.c:459 mini_qdisc_pair_swap+0x1b9/0x1f0 net/sched/sch_generic.c:1581 tcf_chain_head_change_item net/sched/cls_api.c:372 [inline] tcf_chain0_head_change.isra.0+0xb9/0x120 net/sched/cls_api.c:386 tcf_chain_tp_insert net/sched/cls_api.c:1657 [inline] tcf_chain_tp_insert_unique net/sched/cls_api.c:1707 [inline] tc_new_tfilter+0x1e67/0x2350 net/sched/cls_api.c:2086 rtnetlink_rcv_msg+0x80d/0xb80 net/core/rtnetlink.c:5583 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494 netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline] netlink_unicast+0x539/0x7e0 net/netlink/af_netlink.c:1343 netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1919 sock_sendmsg_nosec net/socket.c:705 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:725 ____sys_sendmsg+0x331/0x810 net/socket.c:2413 ___sys_sendmsg+0xf3/0x170 net/socket.c:2467 __sys_sendmmsg+0x195/0x470 net/socket.c:2553 __do_sys_sendmmsg net/socket.c:2582 [inline] __se_sys_sendmmsg net/socket.c:2579 [inline] __x64_sys_sendmmsg+0x99/0x100 net/socket.c:2579 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f2647172059 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f2645aa5168 EFLAGS: 00000246 ORIG_RAX: 0000000000000133 RAX: ffffffffffffffda RBX: 00007f2647285100 RCX: 00007f2647172059 RDX: 040000000000009f RSI: 00000000200002c0 RDI: 0000000000000006 RBP: 00007f26471cc08d R08: 0000000000000000 R09: 0000000000000000 R10: 9e00000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fffb3f7f02f R14: 00007f2645aa5300 R15: 0000000000022000 </TASK> Allocated by task 1944: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:436 [inline] ____kasan_kmalloc mm/kasan/common.c:515 [inline] ____kasan_kmalloc mm/kasan/common.c:474 [inline] __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524 kmalloc_node include/linux/slab.h:604 [inline] kzalloc_node include/linux/slab.h:726 [inline] qdisc_alloc+0xac/0xa10 net/sched/sch_generic.c:941 qdisc_create.constprop.0+0xce/0x10f0 net/sched/sch_api.c:1211 tc_modify_qdisc+0x4c5/0x1980 net/sched/sch_api.c:1660 rtnetlink_rcv_msg+0x413/0xb80 net/core/rtnetlink.c:5592 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494 netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline] netlink_unicast+0x539/0x7e0 net/netlink/af_netlink.c:1343 netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1919 sock_sendmsg_nosec net/socket.c:705 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:725 ____sys_sendmsg+0x331/0x810 net/socket.c:2413 ___sys_sendmsg+0xf3/0x170 net/socket.c:2467 __sys_sendmmsg+0x195/0x470 net/socket.c:2553 __do_sys_sendmmsg net/socket.c:2582 [inline] __se_sys_sendmmsg net/socket.c:2579 [inline] __x64_sys_sendmmsg+0x99/0x100 net/socket.c:2579 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Freed by task 3609: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:45 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:366 [inline] ____kasan_slab_free+0x130/0x160 mm/kasan/common.c:328 kasan_slab_free include/linux/kasan.h:236 [inline] slab_free_hook mm/slub.c:1728 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1754 slab_free mm/slub.c:3509 [inline] kfree+0xcb/0x280 mm/slub.c:4562 rcu_do_batch kernel/rcu/tree.c:2527 [inline] rcu_core+0x7b8/0x1540 kernel/rcu/tree.c:2778 __do_softirq+0x29b/0x9c2 kernel/softirq.c:558 Last potentially related work creation: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348 __call_rcu kernel/rcu/tree.c:3026 [inline] call_rcu+0xb1/0x740 kernel/rcu/tree.c:3106 qdisc_put_unlocked+0x6f/0x90 net/sched/sch_generic.c:1109 tcf_block_release+0x86/0x90 net/sched/cls_api.c:1238 tc_new_tfilter+0xc0d/0x2350 net/sched/cls_api.c:2148 rtnetlink_rcv_msg+0x80d/0xb80 net/core/rtnetlink.c:5583 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494 netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline] netlink_unicast+0x539/0x7e0 net/netlink/af_netlink.c:1343 netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1919 sock_sendmsg_nosec net/socket.c:705 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:725 ____sys_sendmsg+0x331/0x810 net/socket.c:2413 ___sys_sendmsg+0xf3/0x170 net/socket.c:2467 __sys_sendmmsg+0x195/0x470 net/socket.c:2553 __do_sys_sendmmsg net/socket.c:2582 [inline] __se_sys_sendmmsg net/socket.c:2579 [inline] __x64_sys_sendmmsg+0x99/0x100 net/socket.c:2579 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae The buggy address belongs to the object at ffff8880985c4800 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 776 bytes inside of 1024-byte region [ffff8880985c4800, ffff8880985c4c00) The buggy address belongs to the page: page:ffffea0002617000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x985c0 head:ffffea0002617000 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888010c41dc0 raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 1941, ts 1038999441284, free_ts 1033444432829 prep_new_page mm/page_alloc.c:2434 [inline] get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4165 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5389 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2271 alloc_slab_page mm/slub.c:1799 [inline] allocate_slab mm/slub.c:1944 [inline] new_slab+0x28a/0x3b0 mm/slub.c:2004 ___slab_alloc+0x87c/0xe90 mm/slub.c:3018 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3105 slab_alloc_node mm/slub.c:3196 [inline] slab_alloc mm/slub.c:3238 [inline] __kmalloc+0x2fb/0x340 mm/slub.c:4420 kmalloc include/linux/slab.h:586 [inline] kzalloc include/linux/slab.h:715 [inline] __register_sysctl_table+0x112/0x1090 fs/proc/proc_sysctl.c:1335 neigh_sysctl_register+0x2c8/0x5e0 net/core/neighbour.c:3787 devinet_sysctl_register+0xb1/0x230 net/ipv4/devinet.c:2618 inetdev_init+0x286/0x580 net/ipv4/devinet.c:278 inetdev_event+0xa8a/0x15d0 net/ipv4/devinet.c:1532 notifier_call_chain+0xb5/0x200 kernel/notifier.c:84 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1919 call_netdevice_notifiers_extack net/core/dev.c:1931 [inline] call_netdevice_notifiers net/core/dev.c:1945 [inline] register_netdevice+0x1073/0x1500 net/core/dev.c:9698 veth_newlink+0x59c/0xa90 drivers/net/veth.c:1722 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1352 [inline] free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1404 free_unref_page_prepare mm/page_alloc.c:3325 [inline] free_unref_page+0x19/0x690 mm/page_alloc.c:3404 release_pages+0x748/0x1220 mm/swap.c:956 tlb_batch_pages_flush mm/mmu_gather.c:50 [inline] tlb_flush_mmu_free mm/mmu_gather.c:243 [inline] tlb_flush_mmu+0xe9/0x6b0 mm/mmu_gather.c:250 zap_pte_range mm/memory.c:1441 [inline] zap_pmd_range mm/memory.c:1490 [inline] zap_pud_range mm/memory.c:1519 [inline] zap_p4d_range mm/memory.c:1540 [inline] unmap_page_range+0x1d1d/0x2a30 mm/memory.c:1561 unmap_single_vma+0x198/0x310 mm/memory.c:1606 unmap_vmas+0x16b/0x2f0 mm/memory.c:1638 exit_mmap+0x201/0x670 mm/mmap.c:3178 __mmput+0x122/0x4b0 kernel/fork.c:1114 mmput+0x56/0x60 kernel/fork.c:1135 exit_mm kernel/exit.c:507 [inline] do_exit+0xa3c/0x2a30 kernel/exit.c:793 do_group_exit+0xd2/0x2f0 kernel/exit.c:935 __do_sys_exit_group kernel/exit.c:946 [inline] __se_sys_exit_group kernel/exit.c:944 [inline] __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:944 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Memory state around the buggy address: ffff8880985c4a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880985c4a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8880985c4b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880985c4b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880985c4c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc Fixes: 470502de5bdb ("net: sched: unlock rules update API") Signed-off-by: Eric Dumazet <[email protected]> Cc: Vlad Buslov <[email protected]> Cc: Jiri Pirko <[email protected]> Cc: Cong Wang <[email protected]> Reported-by: syzbot <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
static bool open_match_attributes(connection_struct *conn, uint32 old_dos_attr, uint32 new_dos_attr, mode_t existing_unx_mode, mode_t new_unx_mode, mode_t *returned_unx_mode) { uint32 noarch_old_dos_attr, noarch_new_dos_attr; noarch_old_dos_attr = (old_dos_attr & ~FILE_ATTRIBUTE_ARCHIVE); noarch_new_dos_attr = (new_dos_attr & ~FILE_ATTRIBUTE_ARCHIVE); if((noarch_old_dos_attr == 0 && noarch_new_dos_attr != 0) || (noarch_old_dos_attr != 0 && ((noarch_old_dos_attr & noarch_new_dos_attr) == noarch_old_dos_attr))) { *returned_unx_mode = new_unx_mode; } else { *returned_unx_mode = (mode_t)0; } DEBUG(10,("open_match_attributes: old_dos_attr = 0x%x, " "existing_unx_mode = 0%o, new_dos_attr = 0x%x " "returned_unx_mode = 0%o\n", (unsigned int)old_dos_attr, (unsigned int)existing_unx_mode, (unsigned int)new_dos_attr, (unsigned int)*returned_unx_mode )); /* If we're mapping SYSTEM and HIDDEN ensure they match. */ if (lp_map_system(SNUM(conn)) || lp_store_dos_attributes(SNUM(conn))) { if ((old_dos_attr & FILE_ATTRIBUTE_SYSTEM) && !(new_dos_attr & FILE_ATTRIBUTE_SYSTEM)) { return False; } } if (lp_map_hidden(SNUM(conn)) || lp_store_dos_attributes(SNUM(conn))) { if ((old_dos_attr & FILE_ATTRIBUTE_HIDDEN) && !(new_dos_attr & FILE_ATTRIBUTE_HIDDEN)) { return False; } } return True; }
0
[]
samba
60f922bf1bd8816eacbb32c24793ad1f97a1d9f2
68,120,035,305,596,030,000,000,000,000,000,000,000
42
Fix bug #10229 - No access check verification on stream files. https://bugzilla.samba.org/show_bug.cgi?id=10229 We need to check if the requested access mask could be used to open the underlying file (if it existed), as we're passing in zero for the access mask to the base filename. Signed-off-by: Jeremy Allison <[email protected]> Reviewed-by: Stefan Metzmacher <[email protected]> Reviewed-by: David Disseldorp <[email protected]>
callbacks_window_key_release_event (GtkWidget *widget, GdkEventKey *event) { return TRUE; } /* key_release_event */
0
[ "CWE-200" ]
gerbv
319a8af890e4d0a5c38e6d08f510da8eefc42537
296,627,458,584,073,940,000,000,000,000,000,000,000
4
Remove local alias to parameter array Normalizing access to `gerbv_simplified_amacro_t::parameter` as a step to fix CVE-2021-40402
njs_string_prop(njs_string_prop_t *string, const njs_value_t *value) { size_t size; uintptr_t length; size = value->short_string.size; if (size != NJS_STRING_LONG) { string->start = (u_char *) value->short_string.start; length = value->short_string.length; } else { string->start = (u_char *) value->long_string.data->start; size = value->long_string.size; length = value->long_string.data->length; } string->size = size; string->length = length; return (length == 0) ? size : length; }
0
[]
njs
36f04a3178fcb6da8513cc3dbf35215c2a581b3f
15,578,226,211,660,293,000,000,000,000,000,000,000
22
Fixed String.prototype.replace() with byte strings. This closes #522 issue on Github.
Header headerNew(void) { return headerCreate(NULL, 0); }
0
[ "CWE-125" ]
rpm
8f4b3c3cab8922a2022b9e47c71f1ecf906077ef
193,586,421,570,709,830,000,000,000,000,000,000,000
4
hdrblobInit() needs bounds checks too Users can pass untrusted data to hdrblobInit() and it must be robust against this.
static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum, elf_addr_t e_shoff, int segs) { elf->e_shoff = e_shoff; elf->e_shentsize = sizeof(*shdr4extnum); elf->e_shnum = 1; elf->e_shstrndx = SHN_UNDEF; memset(shdr4extnum, 0, sizeof(*shdr4extnum)); shdr4extnum->sh_type = SHT_NULL; shdr4extnum->sh_size = elf->e_shnum; shdr4extnum->sh_link = elf->e_shstrndx; shdr4extnum->sh_info = segs; }
0
[ "CWE-284", "CWE-264" ]
linux
4e7c22d447bb6d7e37bfe39ff658486ae78e8d77
129,585,599,442,379,780,000,000,000,000,000,000,000
15
x86, mm/ASLR: Fix stack randomization on 64-bit systems The issue is that the stack for processes is not properly randomized on 64 bit architectures due to an integer overflow. The affected function is randomize_stack_top() in file "fs/binfmt_elf.c": static unsigned long randomize_stack_top(unsigned long stack_top) { unsigned int random_variable = 0; if ((current->flags & PF_RANDOMIZE) && !(current->personality & ADDR_NO_RANDOMIZE)) { random_variable = get_random_int() & STACK_RND_MASK; random_variable <<= PAGE_SHIFT; } return PAGE_ALIGN(stack_top) + random_variable; return PAGE_ALIGN(stack_top) - random_variable; } Note that, it declares the "random_variable" variable as "unsigned int". Since the result of the shifting operation between STACK_RND_MASK (which is 0x3fffff on x86_64, 22 bits) and PAGE_SHIFT (which is 12 on x86_64): random_variable <<= PAGE_SHIFT; then the two leftmost bits are dropped when storing the result in the "random_variable". This variable shall be at least 34 bits long to hold the (22+12) result. These two dropped bits have an impact on the entropy of process stack. Concretely, the total stack entropy is reduced by four: from 2^28 to 2^30 (One fourth of expected entropy). This patch restores back the entropy by correcting the types involved in the operations in the functions randomize_stack_top() and stack_maxrandom_size(). The successful fix can be tested with: $ for i in `seq 1 10`; do cat /proc/self/maps | grep stack; done 7ffeda566000-7ffeda587000 rw-p 00000000 00:00 0 [stack] 7fff5a332000-7fff5a353000 rw-p 00000000 00:00 0 [stack] 7ffcdb7a1000-7ffcdb7c2000 rw-p 00000000 00:00 0 [stack] 7ffd5e2c4000-7ffd5e2e5000 rw-p 00000000 00:00 0 [stack] ... Once corrected, the leading bytes should be between 7ffc and 7fff, rather than always being 7fff. Signed-off-by: Hector Marco-Gisbert <[email protected]> Signed-off-by: Ismael Ripoll <[email protected]> [ Rebased, fixed 80 char bugs, cleaned up commit message, added test example and CVE ] Signed-off-by: Kees Cook <[email protected]> Cc: <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Al Viro <[email protected]> Fixes: CVE-2015-1593 Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Borislav Petkov <[email protected]>
flatpak_dir_install_bundle (FlatpakDir *self, GFile *file, const char *remote, char **out_ref, GCancellable *cancellable, GError **error) { g_autofree char *ref = NULL; g_autoptr(GVariant) deploy_data = NULL; g_autoptr(GVariant) metadata = NULL; g_autofree char *origin = NULL; g_auto(GStrv) parts = NULL; g_autofree char *to_checksum = NULL; gboolean gpg_verify; if (!flatpak_dir_check_add_remotes_config_dir (self, error)) return FALSE; if (flatpak_dir_use_system_helper (self, NULL)) { const char *installation = flatpak_dir_get_id (self); if (!flatpak_dir_system_helper_call_install_bundle (self, flatpak_file_get_path_cached (file), 0, remote, installation ? installation : "", &ref, cancellable, error)) return FALSE; if (out_ref) *out_ref = g_steal_pointer (&ref); return TRUE; } if (!flatpak_dir_ensure_repo (self, cancellable, error)) return FALSE; metadata = flatpak_bundle_load (file, &to_checksum, &ref, &origin, NULL, NULL, NULL, NULL, NULL, error); if (metadata == NULL) return FALSE; parts = flatpak_decompose_ref (ref, error); if (parts == NULL) return FALSE; deploy_data = flatpak_dir_get_deploy_data (self, ref, FLATPAK_DEPLOY_VERSION_ANY, cancellable, NULL); if (deploy_data != NULL) { if (strcmp (flatpak_deploy_data_get_commit (deploy_data), to_checksum) == 0) { g_set_error (error, FLATPAK_ERROR, FLATPAK_ERROR_ALREADY_INSTALLED, _("This version of %s is already installed"), parts[1]); return FALSE; } if (strcmp (remote, flatpak_deploy_data_get_origin (deploy_data)) != 0) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, _("Can't change remote during bundle install")); return FALSE; } } if (!ostree_repo_remote_get_gpg_verify (self->repo, remote, &gpg_verify, error)) return FALSE; if (!flatpak_pull_from_bundle (self->repo, file, remote, ref, gpg_verify, cancellable, error)) return FALSE; if (deploy_data != NULL) { g_autofree char *group = g_strdup_printf ("remote \"%s\"", remote); g_autofree char *old_url = NULL; g_autoptr(GKeyFile) new_config = NULL; /* The pull succeeded, and this is an update. So, we need to update the repo config if anything changed */ ostree_repo_remote_get_url (self->repo, remote, &old_url, NULL); if (origin != NULL && (old_url == NULL || strcmp (old_url, origin) != 0)) { if (new_config == NULL) new_config = ostree_repo_copy_config (self->repo); g_key_file_set_value (new_config, group, "url", origin); } if (new_config) { if (!flatpak_dir_cleanup_remote_for_url_change (self, remote, origin, cancellable, error)) return FALSE; if (!ostree_repo_write_config (self->repo, new_config, error)) return FALSE; } } if (deploy_data) { if (!flatpak_dir_deploy_update (self, ref, NULL, NULL, cancellable, error)) return FALSE; } else { if (!flatpak_dir_deploy_install (self, ref, remote, NULL, FALSE, cancellable, error)) return FALSE; } if (out_ref) *out_ref = g_steal_pointer (&ref); return TRUE; }
0
[ "CWE-668" ]
flatpak
cd2142888fc4c199723a0dfca1f15ea8788a5483
231,235,025,522,643,140,000,000,000,000,000,000,000
133
Don't expose /proc when running apply_extra As shown by CVE-2019-5736, it is sometimes possible for the sandbox app to access outside files using /proc/self/exe. This is not typically an issue for flatpak as the sandbox runs as the user which has no permissions to e.g. modify the host files. However, when installing apps using extra-data into the system repo we *do* actually run a sandbox as root. So, in this case we disable mounting /proc in the sandbox, which will neuter attacks like this.
daemon_msg_findallif_req(uint8 ver, struct daemon_slpars *pars, uint32 plen) { char errbuf[PCAP_ERRBUF_SIZE]; // buffer for network errors char errmsgbuf[PCAP_ERRBUF_SIZE]; // buffer for errors to send to the client char sendbuf[RPCAP_NETBUF_SIZE]; // temporary buffer in which data to be sent is buffered int sendbufidx = 0; // index which keeps the number of bytes currently buffered pcap_if_t *alldevs = NULL; // pointer to the header of the interface chain pcap_if_t *d; // temp pointer needed to scan the interface chain struct pcap_addr *address; // pcap structure that keeps a network address of an interface struct rpcap_findalldevs_if *findalldevs_if;// rpcap structure that packet all the data of an interface together uint16 nif = 0; // counts the number of interface listed // Discard the rest of the message; there shouldn't be any payload. if (rpcapd_discard(pars->sockctrl, plen) == -1) { // Network error. return -1; } // Retrieve the device list if (pcap_findalldevs(&alldevs, errmsgbuf) == -1) goto error; if (alldevs == NULL) { if (rpcap_senderror(pars->sockctrl, ver, PCAP_ERR_NOREMOTEIF, "No interfaces found! Make sure libpcap/WinPcap is properly installed" " and you have the right to access to the remote device.", errbuf) == -1) { rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf); return -1; } return 0; } // checks the number of interfaces and it computes the total length of the payload for (d = alldevs; d != NULL; d = d->next) { nif++; if (d->description) plen+= strlen(d->description); if (d->name) plen+= strlen(d->name); plen+= sizeof(struct rpcap_findalldevs_if); for (address = d->addresses; address != NULL; address = address->next) { /* * Send only IPv4 and IPv6 addresses over the wire. */ switch (address->addr->sa_family) { case AF_INET: #ifdef AF_INET6 case AF_INET6: #endif plen+= (sizeof(struct rpcap_sockaddr) * 4); break; default: break; } } } // RPCAP findalldevs command if (sock_bufferize(NULL, sizeof(struct rpcap_header), NULL, &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1) goto error; rpcap_createhdr((struct rpcap_header *) sendbuf, ver, RPCAP_MSG_FINDALLIF_REPLY, nif, plen); // send the interface list for (d = alldevs; d != NULL; d = d->next) { uint16 lname, ldescr; findalldevs_if = (struct rpcap_findalldevs_if *) &sendbuf[sendbufidx]; if (sock_bufferize(NULL, sizeof(struct rpcap_findalldevs_if), NULL, &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1) goto error; memset(findalldevs_if, 0, sizeof(struct rpcap_findalldevs_if)); if (d->description) ldescr = (short) strlen(d->description); else ldescr = 0; if (d->name) lname = (short) strlen(d->name); else lname = 0; findalldevs_if->desclen = htons(ldescr); findalldevs_if->namelen = htons(lname); findalldevs_if->flags = htonl(d->flags); for (address = d->addresses; address != NULL; address = address->next) { /* * Send only IPv4 and IPv6 addresses over the wire. */ switch (address->addr->sa_family) { case AF_INET: #ifdef AF_INET6 case AF_INET6: #endif findalldevs_if->naddr++; break; default: break; } } findalldevs_if->naddr = htons(findalldevs_if->naddr); if (sock_bufferize(d->name, lname, sendbuf, &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_BUFFERIZE, errmsgbuf, PCAP_ERRBUF_SIZE) == -1) goto error; if (sock_bufferize(d->description, ldescr, sendbuf, &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_BUFFERIZE, errmsgbuf, PCAP_ERRBUF_SIZE) == -1) goto error; // send all addresses for (address = d->addresses; address != NULL; address = address->next) { struct rpcap_sockaddr *sockaddr; /* * Send only IPv4 and IPv6 addresses over the wire. */ switch (address->addr->sa_family) { case AF_INET: #ifdef AF_INET6 case AF_INET6: #endif sockaddr = (struct rpcap_sockaddr *) &sendbuf[sendbufidx]; if (sock_bufferize(NULL, sizeof(struct rpcap_sockaddr), NULL, &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1) goto error; daemon_seraddr((struct sockaddr_storage *) address->addr, sockaddr); sockaddr = (struct rpcap_sockaddr *) &sendbuf[sendbufidx]; if (sock_bufferize(NULL, sizeof(struct rpcap_sockaddr), NULL, &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1) goto error; daemon_seraddr((struct sockaddr_storage *) address->netmask, sockaddr); sockaddr = (struct rpcap_sockaddr *) &sendbuf[sendbufidx]; if (sock_bufferize(NULL, sizeof(struct rpcap_sockaddr), NULL, &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1) goto error; daemon_seraddr((struct sockaddr_storage *) address->broadaddr, sockaddr); sockaddr = (struct rpcap_sockaddr *) &sendbuf[sendbufidx]; if (sock_bufferize(NULL, sizeof(struct rpcap_sockaddr), NULL, &sendbufidx, RPCAP_NETBUF_SIZE, SOCKBUF_CHECKONLY, errmsgbuf, PCAP_ERRBUF_SIZE) == -1) goto error; daemon_seraddr((struct sockaddr_storage *) address->dstaddr, sockaddr); break; default: break; } } } // We no longer need the device list. Free it. pcap_freealldevs(alldevs); // Send a final command that says "now send it!" if (sock_send(pars->sockctrl, sendbuf, sendbufidx, errbuf, PCAP_ERRBUF_SIZE) == -1) { rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf); return -1; } return 0; error: if (alldevs) pcap_freealldevs(alldevs); if (rpcap_senderror(pars->sockctrl, ver, PCAP_ERR_FINDALLIF, errmsgbuf, errbuf) == -1) { rpcapd_log(LOGPRIO_ERROR, "Send to client failed: %s", errbuf); return -1; } return 0; }
1
[ "CWE-20", "CWE-703", "CWE-131" ]
libpcap
617b12c0339db4891d117b661982126c495439ea
229,055,541,511,022,480,000,000,000,000,000,000,000
198
Calculate the reply payload length in a local variable. Using the same variable for the remaining request length and the reply length is confusing at best and can cause errors at worst (if the request had extra stuff at the end, so that the variable is non-zero). This addresses Include Security issue I8: [libpcap] Remote Packet Capture Daemon Parameter Reuse.
int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, struct kvm_mp_state *mp_state) { mp_state->mp_state = vcpu->arch.mp_state; return 0; }
0
[ "CWE-200" ]
kvm
831d9d02f9522e739825a51a11e3bc5aa531a905
245,799,063,339,270,950,000,000,000,000,000,000,000
6
KVM: x86: fix information leak to userland Structures kvm_vcpu_events, kvm_debugregs, kvm_pit_state2 and kvm_clock_data are copied to userland with some padding and reserved fields unitialized. It leads to leaking of contents of kernel stack memory. We have to initialize them to zero. In patch v1 Jan Kiszka suggested to fill reserved fields with zeros instead of memset'ting the whole struct. It makes sense as these fields are explicitly marked as padding. No more fields need zeroing. KVM-Stable-Tag. Signed-off-by: Vasiliy Kulikov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
bool load_grammar(const char *s, const Rules &rules) { auto n = strlen(s); return load_grammar(s, n, rules); }
0
[ "CWE-125" ]
cpp-peglib
b3b29ce8f3acf3a32733d930105a17d7b0ba347e
71,628,514,496,487,480,000,000,000,000,000,000,000
4
Fix #122
void visit(Repetition &ope) override { ope.ope_->accept(*this); }
0
[ "CWE-125" ]
cpp-peglib
b3b29ce8f3acf3a32733d930105a17d7b0ba347e
271,048,409,733,802,160,000,000,000,000,000,000,000
1
Fix #122
static int on_body_fill_buffer(http_parser *parser, const char *str, size_t len) { parser_context *ctx = (parser_context *) parser->data; http_subtransport *t = ctx->t; /* If our goal is to replay the request (either an auth failure or * a redirect) then don't bother buffering since we're ignoring the * content anyway. */ if (t->parse_error == PARSE_ERROR_REPLAY) return 0; if (ctx->buf_size < len) { giterr_set(GITERR_NET, "Can't fit data in the buffer"); return t->parse_error = PARSE_ERROR_GENERIC; } memcpy(ctx->buffer, str, len); *(ctx->bytes_read) += len; ctx->buffer += len; ctx->buf_size -= len; return 0; }
0
[ "CWE-284" ]
libgit2
b5c6a1b407b7f8b952bded2789593b68b1876211
252,983,347,752,547,800,000,000,000,000,000,000,000
24
http: check certificate validity before clobbering the error variable
bgp_attr_local_pref (struct bgp_attr_parser_args *args) { struct peer *const peer = args->peer; struct attr *const attr = args->attr; const bgp_size_t length = args->length; /* Length check. */ if (length != 4) { zlog (peer->log, LOG_ERR, "LOCAL_PREF attribute length isn't 4 [%u]", length); return bgp_attr_malformed (args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, args->total); } /* If it is contained in an UPDATE message that is received from an external peer, then this attribute MUST be ignored by the receiving speaker. */ if (peer_sort (peer) == BGP_PEER_EBGP) { stream_forward_getp (peer->ibuf, length); return BGP_ATTR_PARSE_PROCEED; } attr->local_pref = stream_getl (peer->ibuf); /* Set atomic aggregate flag. */ attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); return BGP_ATTR_PARSE_PROCEED; }
0
[]
quagga
8794e8d229dc9fe29ea31424883433d4880ef408
140,668,250,212,576,840,000,000,000,000,000,000,000
32
bgpd: Fix regression in args consolidation, total should be inited from args * bgp_attr.c: (bgp_attr_unknown) total should be initialised from the args.
static CURLcode imap_perform_upgrade_tls(struct connectdata *conn) { CURLcode result = CURLE_OK; struct imap_conn *imapc = &conn->proto.imapc; /* Start the SSL connection */ result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone); if(!result) { if(imapc->state != IMAP_UPGRADETLS) state(conn, IMAP_UPGRADETLS); if(imapc->ssldone) { imap_to_imaps(conn); result = imap_perform_capability(conn); } } return result; }
0
[ "CWE-119" ]
curl
13c9a9ded3ae744a1e11cbc14e9146d9fa427040
41,529,053,053,674,602,000,000,000,000,000,000,000
20
imap: if a FETCH response has no size, don't call write callback CVE-2017-1000257 Reported-by: Brian Carpenter and 0xd34db347 Also detected by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3586
QByteArray CtcpParser::xdelimDequote(const QByteArray &message) { QByteArray dequotedMessage; QByteArray messagepart; QHash<QByteArray, QByteArray>::iterator xdelimquote; for (int i = 0; i < message.size(); i++) { messagepart = message.mid(i, 1); if (i+1 < message.size()) { for (xdelimquote = _ctcpXDelimDequoteHash.begin(); xdelimquote != _ctcpXDelimDequoteHash.end(); ++xdelimquote) { if (message.mid(i, 2) == xdelimquote.key()) { messagepart = xdelimquote.value(); i++; break; } } } dequotedMessage += messagepart; } return dequotedMessage; }
0
[ "CWE-399" ]
quassel
b5e38970ffd55e2dd9f706ce75af9a8d7730b1b8
312,324,195,978,356,800,000,000,000,000,000,000,000
21
Improve the message-splitting algorithm for PRIVMSG and CTCP This introduces a new message splitting algorithm based on QTextBoundaryFinder. It works by first starting with the entire message to be sent, encoding it, and checking to see if it is over the maximum message length. If it is, it uses QTBF to find the word boundary most immediately preceding the maximum length. If no suitable boundary can be found, it falls back to searching for grapheme boundaries. It repeats this process until the entire message has been sent. Unlike what it replaces, the new splitting code is not recursive and cannot cause stack overflows. Additionally, if it is unable to split a string, it will give up gracefully and not crash the core or cause a thread to run away. This patch fixes two bugs. The first is garbage characters caused by accidentally splitting the string in the middle of a multibyte character. Since the new code splits at a character level instead of a byte level, this will no longer be an issue. The second is the core crash caused by sending an overlength CTCP query ("/me") containing only multibyte characters. This bug was caused by the old CTCP splitter using the byte index from lastParamOverrun() as a character index for a QString.
int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev, unsigned pipe, unsigned period, struct scatterlist *sg, int nents, size_t length, gfp_t mem_flags) { int i; int urb_flags; int use_sg; if (!io || !dev || !sg || usb_pipecontrol(pipe) || usb_pipeisoc(pipe) || nents <= 0) return -EINVAL; spin_lock_init(&io->lock); io->dev = dev; io->pipe = pipe; if (dev->bus->sg_tablesize > 0) { use_sg = true; io->entries = 1; } else { use_sg = false; io->entries = nents; } /* initialize all the urbs we'll use */ io->urbs = kmalloc(io->entries * sizeof(*io->urbs), mem_flags); if (!io->urbs) goto nomem; urb_flags = URB_NO_INTERRUPT; if (usb_pipein(pipe)) urb_flags |= URB_SHORT_NOT_OK; for_each_sg(sg, sg, io->entries, i) { struct urb *urb; unsigned len; urb = usb_alloc_urb(0, mem_flags); if (!urb) { io->entries = i; goto nomem; } io->urbs[i] = urb; urb->dev = NULL; urb->pipe = pipe; urb->interval = period; urb->transfer_flags = urb_flags; urb->complete = sg_complete; urb->context = io; urb->sg = sg; if (use_sg) { /* There is no single transfer buffer */ urb->transfer_buffer = NULL; urb->num_sgs = nents; /* A length of zero means transfer the whole sg list */ len = length; if (len == 0) { struct scatterlist *sg2; int j; for_each_sg(sg, sg2, nents, j) len += sg2->length; } } else { /* * Some systems can't use DMA; they use PIO instead. * For their sakes, transfer_buffer is set whenever * possible. */ if (!PageHighMem(sg_page(sg))) urb->transfer_buffer = sg_virt(sg); else urb->transfer_buffer = NULL; len = sg->length; if (length) { len = min_t(size_t, len, length); length -= len; if (length == 0) io->entries = i + 1; } } urb->transfer_buffer_length = len; } io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT; /* transaction state */ io->count = io->entries; io->status = 0; io->bytes = 0; init_completion(&io->complete); return 0; nomem: sg_clean(io); return -ENOMEM; }
0
[ "CWE-119", "CWE-787" ]
linux
2e1c42391ff2556387b3cb6308b24f6f65619feb
202,969,078,627,402,240,000,000,000,000,000,000,000
102
USB: core: harden cdc_parse_cdc_header Andrey Konovalov reported a possible out-of-bounds problem for the cdc_parse_cdc_header function. He writes: It looks like cdc_parse_cdc_header() doesn't validate buflen before accessing buffer[1], buffer[2] and so on. The only check present is while (buflen > 0). So fix this issue up by properly validating the buffer length matches what the descriptor says it is. Reported-by: Andrey Konovalov <[email protected]> Tested-by: Andrey Konovalov <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
static void test_field_misc() { MYSQL_STMT *stmt; MYSQL_RES *result; int rc; myheader("test_field_misc"); rc= mysql_query(mysql, "SELECT @@autocommit"); myquery(rc); result= mysql_store_result(mysql); mytest(result); rc= my_process_result_set(result); DIE_UNLESS(rc == 1); verify_prepare_field(result, 0, "@@autocommit", "", /* field and its org name */ MYSQL_TYPE_LONGLONG, /* field type */ "", "", /* table and its org name */ "", 1, 0); /* db name, length(its bool flag)*/ mysql_free_result(result); stmt= mysql_simple_prepare(mysql, "SELECT @@autocommit"); check_stmt(stmt); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); result= mysql_stmt_result_metadata(stmt); mytest(result); rc= my_process_stmt_result(stmt); DIE_UNLESS(rc == 1); verify_prepare_field(result, 0, "@@autocommit", "", /* field and its org name */ MYSQL_TYPE_LONGLONG, /* field type */ "", "", /* table and its org name */ "", 1, 0); /* db name, length(its bool flag)*/ mysql_free_result(result); mysql_stmt_close(stmt); stmt= mysql_simple_prepare(mysql, "SELECT @@max_error_count"); check_stmt(stmt); result= mysql_stmt_result_metadata(stmt); mytest(result); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); rc= my_process_stmt_result(stmt); DIE_UNLESS(rc == 1); verify_prepare_field(result, 0, "@@max_error_count", "", /* field and its org name */ MYSQL_TYPE_LONGLONG, /* field type */ "", "", /* table and its org name */ /* db name, length */ "", MY_INT64_NUM_DECIMAL_DIGITS , 0); mysql_free_result(result); mysql_stmt_close(stmt); stmt= mysql_simple_prepare(mysql, "SELECT @@max_allowed_packet"); check_stmt(stmt); result= mysql_stmt_result_metadata(stmt); mytest(result); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); DIE_UNLESS(1 == my_process_stmt_result(stmt)); verify_prepare_field(result, 0, "@@max_allowed_packet", "", /* field and its org name */ MYSQL_TYPE_LONGLONG, /* field type */ "", "", /* table and its org name */ /* db name, length */ "", MY_INT64_NUM_DECIMAL_DIGITS, 0); mysql_free_result(result); mysql_stmt_close(stmt); stmt= mysql_simple_prepare(mysql, "SELECT @@sql_warnings"); check_stmt(stmt); result= mysql_stmt_result_metadata(stmt); mytest(result); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); rc= my_process_stmt_result(stmt); DIE_UNLESS(rc == 1); verify_prepare_field(result, 0, "@@sql_warnings", "", /* field and its org name */ MYSQL_TYPE_LONGLONG, /* field type */ "", "", /* table and its org name */ "", 1, 0); /* db name, length */ mysql_free_result(result); mysql_stmt_close(stmt); }
0
[ "CWE-284", "CWE-295" ]
mysql-server
3bd5589e1a5a93f9c224badf983cd65c45215390
312,084,438,890,626,860,000,000,000,000,000,000,000
110
WL#6791 : Redefine client --ssl option to imply enforced encryption # Changed the meaning of the --ssl=1 option of all client binaries to mean force ssl, not try ssl and fail over to eunecrypted # Added a new MYSQL_OPT_SSL_ENFORCE mysql_options() option to specify that an ssl connection is required. # Added a new macro SSL_SET_OPTIONS() to the client SSL handling headers that sets all the relevant SSL options at once. # Revamped all of the current native clients to use the new macro # Removed some Windows line endings. # Added proper handling of the new option into the ssl helper headers. # If SSL is mandatory assume that the media is secure enough for the sha256 plugin to do unencrypted password exchange even before establishing a connection. # Set the default ssl cipher to DHE-RSA-AES256-SHA if none is specified. # updated test cases that require a non-default cipher to spawn a mysql command line tool binary since mysqltest has no support for specifying ciphers. # updated the replication slave connection code to always enforce SSL if any of the SSL config options is present. # test cases added and updated. # added a mysql_get_option() API to return mysql_options() values. Used the new API inside the sha256 plugin. # Fixed compilation warnings because of unused variables. # Fixed test failures (mysql_ssl and bug13115401) # Fixed whitespace issues. # Fully implemented the mysql_get_option() function. # Added a test case for mysql_get_option() # fixed some trailing whitespace issues # fixed some uint/int warnings in mysql_client_test.c # removed shared memory option from non-windows get_options tests # moved MYSQL_OPT_LOCAL_INFILE to the uint options
USBDevice *usbdevice_create(const char *cmdline) { USBBus *bus = usb_bus_find(-1 /* any */); LegacyUSBFactory *f = NULL; GSList *i; char driver[32]; const char *params; int len; params = strchr(cmdline,':'); if (params) { params++; len = params - cmdline; if (len > sizeof(driver)) len = sizeof(driver); pstrcpy(driver, len, cmdline); } else { params = ""; pstrcpy(driver, sizeof(driver), cmdline); } for (i = legacy_usb_factory; i; i = i->next) { f = i->data; if (strcmp(f->usbdevice_name, driver) == 0) { break; } } if (i == NULL) { #if 0 /* no error because some drivers are not converted (yet) */ error_report("usbdevice %s not found", driver); #endif return NULL; } if (!bus) { error_report("Error: no usb bus to attach usbdevice %s, " "please try -machine usb=on and check that " "the machine model supports USB", driver); return NULL; } if (!f->usbdevice_init) { if (*params) { error_report("usbdevice %s accepts no params", driver); return NULL; } return usb_create_simple(bus, f->name); } return f->usbdevice_init(bus, params); }
0
[ "CWE-119" ]
qemu
9f8e9895c504149d7048e9fc5eb5cbb34b16e49a
165,420,604,364,330,230,000,000,000,000,000,000,000
51
usb: sanity check setup_index+setup_len in post_load CVE-2013-4541 s->setup_len and s->setup_index are fed into usb_packet_copy as size/offset into s->data_buf, it's possible for invalid state to exploit this to load arbitrary data. setup_len and setup_index should be checked to make sure they are not negative. Cc: Gerd Hoffmann <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Gerd Hoffmann <[email protected]> Signed-off-by: Juan Quintela <[email protected]>
static inline void queue_me(struct futex_q *q, struct futex_hash_bucket *hb) { int prio; /* * The priority used to register this element is * - either the real thread-priority for the real-time threads * (i.e. threads with a priority lower than MAX_RT_PRIO) * - or MAX_RT_PRIO for non-RT threads. * Thus, all RT-threads are woken first in priority order, and * the others are woken last, in FIFO order. */ prio = min(current->normal_prio, MAX_RT_PRIO); plist_node_init(&q->list, prio); #ifdef CONFIG_DEBUG_PI_LIST q->list.plist.spinlock = &hb->lock; #endif plist_add(&q->list, &hb->chain); q->task = current; spin_unlock(&hb->lock); }
0
[]
linux-2.6
5ecb01cfdf96c5f465192bdb2a4fd4a61a24c6cc
198,218,879,814,111,000,000,000,000,000,000,000,000
22
futex_lock_pi() key refcnt fix This fixes a futex key reference count bug in futex_lock_pi(), where a key's reference count is incremented twice but decremented only once, causing the backing object to not be released. If the futex is created in a temporary file in an ext3 file system, this bug causes the file's inode to become an "undead" orphan, which causes an oops from a BUG_ON() in ext3_put_super() when the file system is unmounted. glibc's test suite is known to trigger this, see <http://bugzilla.kernel.org/show_bug.cgi?id=14256>. The bug is a regression from 2.6.28-git3, namely Peter Zijlstra's 38d47c1b7075bd7ec3881141bb3629da58f88dab "[PATCH] futex: rely on get_user_pages() for shared futexes". That commit made get_futex_key() also increment the reference count of the futex key, and updated its callers to decrement the key's reference count before returning. Unfortunately the normal exit path in futex_lock_pi() wasn't corrected: the reference count is incremented by get_futex_key() and queue_lock(), but the normal exit path only decrements once, via unqueue_me_pi(). The fix is to put_futex_key() after unqueue_me_pi(), since 2.6.31 this is easily done by 'goto out_put_key' rather than 'goto out'. Signed-off-by: Mikael Pettersson <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Acked-by: Darren Hart <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: <[email protected]>
bool Item_field::rename_fields_processor(void *arg) { Item::func_processor_rename *rename= (Item::func_processor_rename*) arg; List_iterator<Create_field> def_it(rename->fields); Create_field *def; while ((def=def_it++)) { if (def->change.str && (!db_name || !db_name[0] || !my_strcasecmp(table_alias_charset, db_name, rename->db_name.str)) && (!table_name || !table_name[0] || !my_strcasecmp(table_alias_charset, table_name, rename->table_name.str)) && !my_strcasecmp(system_charset_info, field_name.str, def->change.str)) { field_name= def->field_name; break; } } return 0; }
0
[ "CWE-416" ]
server
c02ebf3510850ba78a106be9974c94c3b97d8585
18,018,232,562,621,477,000,000,000,000,000,000,000
21
MDEV-24176 Preparations 1. moved fix_vcol_exprs() call to open_table() mysql_alter_table() doesn't do lock_tables() so it cannot win from fix_vcol_exprs() from there. Tests affected: main.default_session 2. Vanilla cleanups and comments.
static void __exit loop_exit(void) { unsigned long range; range = max_loop ? max_loop << part_shift : 1UL << MINORBITS; idr_for_each(&loop_index_idr, &loop_exit_cb, NULL); idr_destroy(&loop_index_idr); blk_unregister_region(MKDEV(LOOP_MAJOR, 0), range); unregister_blkdev(LOOP_MAJOR, "loop"); misc_deregister(&loop_misc); }
0
[ "CWE-416", "CWE-362" ]
linux
ae6650163c66a7eff1acd6eb8b0f752dcfa8eba5
290,229,853,801,819,900,000,000,000,000,000,000,000
14
loop: fix concurrent lo_open/lo_release 范龙飞 reports that KASAN can report a use-after-free in __lock_acquire. The reason is due to insufficient serialization in lo_release(), which will continue to use the loop device even after it has decremented the lo_refcnt to zero. In the meantime, another process can come in, open the loop device again as it is being shut down. Confusion ensues. Reported-by: 范龙飞 <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
static void tstream_tls_pull_done(struct tevent_req *subreq) { struct tstream_context *stream = tevent_req_callback_data(subreq, struct tstream_context); struct tstream_tls *tlss = tstream_context_data(stream, struct tstream_tls); int ret; int sys_errno; tlss->pull.subreq = NULL; ret = tstream_readv_recv(subreq, &sys_errno); TALLOC_FREE(subreq); if (ret == -1) { tlss->error = sys_errno; tstream_tls_retry(stream, false); return; } tstream_tls_retry(stream, false); }
0
[]
samba
22af043d2f20760f27150d7d469c7c7b944c6b55
32,978,054,321,179,766,000,000,000,000,000,000,000
23
CVE-2013-4476: s4:libtls: check for safe permissions of tls private key file (key.pem) If the tls key is not owned by root or has not mode 0600 samba will not start up. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10234 Pair-Programmed-With: Stefan Metzmacher <[email protected]> Signed-off-by: Björn Baumbach <[email protected]> Signed-off-by: Stefan Metzmacher <[email protected]> Reviewed-by: Stefan Metzmacher <[email protected]> Autobuild-User(master): Karolin Seeger <[email protected]> Autobuild-Date(master): Mon Nov 11 13:07:16 CET 2013 on sn-devel-104
static struct port *find_port_by_devt_in_portdev(struct ports_device *portdev, dev_t dev) { struct port *port; unsigned long flags; spin_lock_irqsave(&portdev->ports_lock, flags); list_for_each_entry(port, &portdev->ports, list) { if (port->cdev->dev == dev) { kref_get(&port->kref); goto out; } } port = NULL; out: spin_unlock_irqrestore(&portdev->ports_lock, flags); return port; }
0
[ "CWE-119", "CWE-787" ]
linux
c4baad50297d84bde1a7ad45e50c73adae4a2192
84,993,731,660,233,460,000,000,000,000,000,000,000
19
virtio-console: avoid DMA from stack put_chars() stuffs the buffer it gets into an sg, but that buffer may be on the stack. This breaks with CONFIG_VMAP_STACK=y (for me, it manifested as printks getting turned into NUL bytes). Signed-off-by: Omar Sandoval <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Amit Shah <[email protected]>
static void php_mysqlnd_chg_user_free_mem(void * _packet) { MYSQLND_PACKET_CHG_USER_RESPONSE * p = (MYSQLND_PACKET_CHG_USER_RESPONSE *) _packet; if (p->new_auth_protocol) { mnd_efree(p->new_auth_protocol); p->new_auth_protocol = NULL; } p->new_auth_protocol_len = 0; if (p->new_auth_protocol_data) { mnd_efree(p->new_auth_protocol_data); p->new_auth_protocol_data = NULL; } p->new_auth_protocol_data_len = 0;
0
[ "CWE-120" ]
php-src
58006537fc5f133ae8549efe5118cde418b3ace9
271,441,196,774,582,980,000,000,000,000,000,000,000
16
Fix bug #81719: mysqlnd/pdo password buffer overflow
static int create_problem_dir(GHashTable *problem_info, unsigned pid) { /* Exit if free space is less than 1/4 of MaxCrashReportsSize */ if (g_settings_nMaxCrashReportsSize > 0) { if (low_free_space(g_settings_nMaxCrashReportsSize, g_settings_dump_location)) exit(1); } /* Create temp directory with the problem data. * This directory is renamed to final directory name after * all files have been stored into it. */ gchar *dir_basename = g_hash_table_lookup(problem_info, "basename"); if (!dir_basename) dir_basename = g_hash_table_lookup(problem_info, FILENAME_TYPE); char *path = xasprintf("%s/%s-%s-%u.new", g_settings_dump_location, dir_basename, iso_date_string(NULL), pid); /* This item is useless, don't save it */ g_hash_table_remove(problem_info, "basename"); /* No need to check the path length, as all variables used are limited, * and dd_create() fails if the path is too long. */ struct dump_dir *dd = dd_create(path, g_settings_privatereports ? 0 : client_uid, DEFAULT_DUMP_DIR_MODE); if (!dd) { error_msg_and_die("Error creating problem directory '%s'", path); } dd_create_basic_files(dd, client_uid, NULL); dd_save_text(dd, FILENAME_ABRT_VERSION, VERSION); gpointer gpkey = g_hash_table_lookup(problem_info, FILENAME_CMDLINE); if (!gpkey) { /* Obtain and save the command line. */ char *cmdline = get_cmdline(pid); if (cmdline) { dd_save_text(dd, FILENAME_CMDLINE, cmdline); free(cmdline); } } /* Store id of the user whose application crashed. */ char uid_str[sizeof(long) * 3 + 2]; sprintf(uid_str, "%lu", (long)client_uid); dd_save_text(dd, FILENAME_UID, uid_str); GHashTableIter iter; gpointer gpvalue; g_hash_table_iter_init(&iter, problem_info); while (g_hash_table_iter_next(&iter, &gpkey, &gpvalue)) { dd_save_text(dd, (gchar *) gpkey, (gchar *) gpvalue); } dd_close(dd); /* Not needing it anymore */ g_hash_table_destroy(problem_info); /* Move the completely created problem directory * to final directory. */ char *newpath = xstrndup(path, strlen(path) - strlen(".new")); if (rename(path, newpath) == 0) strcpy(path, newpath); free(newpath); log_notice("Saved problem directory of pid %u to '%s'", pid, path); /* We let the peer know that problem dir was created successfully * _before_ we run potentially long-running post-create. */ printf("HTTP/1.1 201 Created\r\n\r\n"); fflush(NULL); close(STDOUT_FILENO); xdup2(STDERR_FILENO, STDOUT_FILENO); /* paranoia: don't leave stdout fd closed */ /* Trim old problem directories if necessary */ if (g_settings_nMaxCrashReportsSize > 0) { trim_problem_dirs(g_settings_dump_location, g_settings_nMaxCrashReportsSize * (double)(1024*1024), path); } run_post_create(path); /* free(path); */ exit(0); }
0
[ "CWE-59" ]
abrt
3287aa12eb205cff95cdd00d6d6c5c9a4f8f0eca
55,552,207,652,961,720,000,000,000,000,000,000,000
98
daemon: allow only root user to trigger the post-create There is no reason to allow non-root users to trigger this functionality. Regular users can create abrt problems only through abrtd or abrt-dbus and both triggers the post-create. Other hooks run under root user (CCpp, Koops, VMCore, Xorg). Related: #1212861 Signed-off-by: Jakub Filak <[email protected]>
ruby_brace_glob(const char *str, int flags, ruby_glob_func *func, VALUE arg) { return ruby_brace_glob_with_enc(str, flags, func, arg, rb_ascii8bit_encoding()); }
0
[ "CWE-22" ]
ruby
bd5661a3cbb38a8c3a3ea10cd76c88bbef7871b8
38,980,868,164,645,204,000,000,000,000,000,000,000
4
dir.c: check NUL bytes * dir.c (GlobPathValue): should be used in rb_push_glob only. other methods should use FilePathValue. https://hackerone.com/reports/302338 * dir.c (rb_push_glob): expand GlobPathValue git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
static uint32_t pmac_ide_readb (void *opaque,hwaddr addr) { uint8_t retval; MACIOIDEState *d = opaque; addr = (addr & 0xFFF) >> 4; switch (addr) { case 1 ... 7: retval = ide_ioport_read(&d->bus, addr); break; case 8: case 22: retval = ide_status_read(&d->bus, 0); break; default: retval = 0xFF; break; } return retval; }
0
[ "CWE-399" ]
qemu
3251bdcf1c67427d964517053c3d185b46e618e8
218,918,376,404,484,780,000,000,000,000,000,000,000
20
ide: Correct handling of malformed/short PRDTs This impacts both BMDMA and AHCI HBA interfaces for IDE. Currently, we confuse the difference between a PRDT having "0 bytes" and a PRDT having "0 complete sectors." When we receive an incomplete sector, inconsistent error checking leads to an infinite loop wherein the call succeeds, but it didn't give us enough bytes -- leading us to re-call the DMA chain over and over again. This leads to, in the BMDMA case, leaked memory for short PRDTs, and infinite loops and resource usage in the AHCI case. The .prepare_buf() callback is reworked to return the number of bytes that it successfully prepared. 0 is a valid, non-error answer that means the table was empty and described no bytes. -1 indicates an error. Our current implementation uses the io_buffer in IDEState to ultimately describe the size of a prepared scatter-gather list. Even though the AHCI PRDT/SGList can be as large as 256GiB, the AHCI command header limits transactions to just 4GiB. ATA8-ACS3, however, defines the largest transaction to be an LBA48 command that transfers 65,536 sectors. With a 512 byte sector size, this is just 32MiB. Since our current state structures use the int type to describe the size of the buffer, and this state is migrated as int32, we are limited to describing 2GiB buffer sizes unless we change the migration protocol. For this reason, this patch begins to unify the assertions in the IDE pathways that the scatter-gather list provided by either the AHCI PRDT or the PCI BMDMA PRDs can only describe, at a maximum, 2GiB. This should be resilient enough unless we need a sector size that exceeds 32KiB. Further, the likelihood of any guest operating system actually attempting to transfer this much data in a single operation is very slim. To this end, the IDEState variables have been updated to more explicitly clarify our maximum supported size. Callers to the prepare_buf callback have been reworked to understand the new return code, and all versions of the prepare_buf callback have been adjusted accordingly. Lastly, the ahci_populate_sglist helper, relied upon by the AHCI implementation of .prepare_buf() as well as the PCI implementation of the callback have had overflow assertions added to help make clear the reasonings behind the various type changes. [Added %d -> %"PRId64" fix John sent because off_pos changed from int to int64_t. --Stefan] Signed-off-by: John Snow <[email protected]> Reviewed-by: Paolo Bonzini <[email protected]> Message-id: [email protected] Signed-off-by: Stefan Hajnoczi <[email protected]>
gpointer ves_icall_System_Threading_Interlocked_Exchange_IntPtr (gpointer *location, gpointer value) { return InterlockedExchangePointer(location, value); }
0
[ "CWE-399", "CWE-264" ]
mono
722f9890f09aadfc37ae479e7d946d5fc5ef7b91
151,517,026,235,807,340,000,000,000,000,000,000,000
4
Fix access to freed members of a dead thread * threads.c: Fix access to freed members of a dead thread. Found and fixed by Rodrigo Kumpera <[email protected]> Ref: CVE-2011-0992
XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt) { if (parser == NULL) return 0; if (parser->m_parentParser) return XML_SetHashSalt(parser->m_parentParser, hash_salt); /* block after XML_Parse()/XML_ParseBuffer() has been called */ if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) return 0; hash_secret_salt = hash_salt; return 1; }
0
[ "CWE-611" ]
libexpat
c4bf96bb51dd2a1b0e185374362ee136fe2c9d7f
36,234,042,634,467,543,000,000,000,000,000,000,000
13
xmlparse.c: Fix external entity infinite loop bug (CVE-2017-9233)
/* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(date) { const timelib_tzdb *tzdb = DATE_TIMEZONEDB; php_info_print_table_start(); php_info_print_table_row(2, "date/time support", "enabled"); php_info_print_table_row(2, "\"Olson\" Timezone Database Version", tzdb->version); php_info_print_table_row(2, "Timezone Database", php_date_global_timezone_db_enabled ? "external" : "internal"); php_info_print_table_row(2, "Default timezone", guess_timezone(tzdb TSRMLS_CC)); php_info_print_table_end();
0
[]
php-src
bb057498f7457e8b2eba98332a3bad434de4cf12
63,304,932,125,577,780,000,000,000,000,000,000,000
13
Fix #70277: new DateTimeZone($foo) is ignoring text after null byte The DateTimeZone constructors are not binary safe. They're parsing the timezone as string, but discard the length when calling timezone_initialize(). This patch adds a tz_len parameter and a respective check to timezone_initialize().
CImg<T>& operator-=(const t value) { if (is_empty()) return *this; cimg_openmp_for(*this,*ptr - value,524288); return *this; }
0
[ "CWE-770" ]
cimg
619cb58dd90b4e03ac68286c70ed98acbefd1c90
84,562,763,518,050,270,000,000,000,000,000,000,000
5
CImg<>::load_bmp() and CImg<>::load_pandore(): Check that dimensions encoded in file does not exceed file size.
void addReplySubcommandSyntaxError(client *c) { sds cmd = sdsnew((char*) c->argv[0]->ptr); sdstoupper(cmd); addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try %s HELP.", (char*)c->argv[1]->ptr,cmd); sdsfree(cmd); }
0
[ "CWE-770" ]
redis
5674b0057ff2903d43eaff802017eddf37c360f8
290,784,718,142,523,050,000,000,000,000,000,000,000
8
Prevent unauthenticated client from easily consuming lots of memory (CVE-2021-32675) This change sets a low limit for multibulk and bulk length in the protocol for unauthenticated connections, so that they can't easily cause redis to allocate massive amounts of memory by sending just a few characters on the network. The new limits are 10 arguments of 16kb each (instead of 1m of 512mb)
static int request_pre_handler(REQUEST *request) { int rcode; rad_assert(request->magic == REQUEST_MAGIC); rad_assert(request->packet != NULL); request->child_state = REQUEST_RUNNING; /* * Don't decode the packet if it's an internal "fake" * request. Instead, just return so that the caller can * process it. */ if (request->packet->dst_port == 0) { request->username = pairfind(request->packet->vps, PW_USER_NAME); request->password = pairfind(request->packet->vps, PW_USER_PASSWORD); return 1; } #ifdef WITH_PROXY /* * Put the decoded packet into it's proper place. */ if (request->proxy_reply != NULL) { rcode = request->proxy_listener->decode(request->proxy_listener, request); DEBUG_PACKET(request, request->proxy_reply, 0); } else #endif if (request->packet->vps == NULL) { rcode = request->listener->decode(request->listener, request); if (debug_condition) { int result = FALSE; const char *my_debug = debug_condition; /* * Ignore parse errors. */ radius_evaluate_condition(request, RLM_MODULE_OK, 0, &my_debug, 1, &result); if (result) { request->options = 2; request->radlog = radlog_request; } } DEBUG_PACKET(request, request->packet, 0); } else { rcode = 0; } if (rcode < 0) { RDEBUG("%s Dropping packet without response.", fr_strerror()); request->reply->offset = -2; /* bad authenticator */ request->child_state = REQUEST_DONE; return 0; } if (!request->username) { request->username = pairfind(request->packet->vps, PW_USER_NAME); } #ifdef WITH_PROXY if (request->proxy) { return process_proxy_reply(request); } #endif return 1; }
0
[ "CWE-399" ]
freeradius-server
ff94dd35673bba1476594299d31ce8293b8bd223
197,140,585,099,280,300,000,000,000,000,000,000,000
76
Do not delete "old" requests until they are free. If the request is in the queue for 30+ seconds, do NOT delete it. Instead, mark it as "STOP PROCESSING", and do "wait_for_child_to_die", which waits for a child thread to pick it up, and acknowledge that it's done. Once it's marked done, we can finally clean it up. This may be the underlying issue behind bug #35
static ZIPARCHIVE_METHOD(getCommentIndex) { struct zip *intern; zval *self = getThis(); zend_long index, flags = 0; const char * comment; int comment_len = 0; struct zip_stat sb; if (!self) { RETURN_FALSE; } ZIP_FROM_OBJECT(intern, self); if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l", &index, &flags) == FAILURE) { return; } PHP_ZIP_STAT_INDEX(intern, index, 0, sb); comment = zip_get_file_comment(intern, index, &comment_len, (int)flags); RETURN_STRINGL((char *)comment, (zend_long)comment_len); }
0
[ "CWE-190" ]
php-src
3b8d4de300854b3517c7acb239b84f7726c1353c
245,564,168,528,771,200,000,000,000,000,000,000,000
24
Fix bug #71923 - integer overflow in ZipArchive::getFrom*
static void dump_summary (WavpackContext *wpc, char *name, FILE *dst) { uint32_t channel_mask = (uint32_t) WavpackGetChannelMask (wpc); int num_channels = WavpackGetNumChannels (wpc); unsigned char md5_sum [16]; char modes [80]; fprintf (dst, "\n"); if (name && *name != '-') { fprintf (dst, "file name: %s%s\n", name, (WavpackGetMode (wpc) & MODE_WVC) ? " (+wvc)" : ""); fprintf (dst, "file size: %lld bytes\n", (long long) WavpackGetFileSize64 (wpc)); } if ((WavpackGetQualifyMode (wpc) & QMODE_DSD_AUDIO) && !raw_pcm) fprintf (dst, "source: 1-bit DSD at %u Hz\n", WavpackGetNativeSampleRate (wpc)); else fprintf (dst, "source: %d-bit %s at %u Hz\n", WavpackGetBitsPerSample (wpc), (WavpackGetMode (wpc) & MODE_FLOAT) ? "floats" : "ints", WavpackGetSampleRate (wpc)); if (!channel_mask) strcpy (modes, "unassigned speakers"); else if (num_channels == 1 && channel_mask == 0x4) strcpy (modes, "mono"); else if (num_channels == 2 && channel_mask == 0x3) strcpy (modes, "stereo"); else if (num_channels == 4 && channel_mask == 0x33) strcpy (modes, "quad"); else if (num_channels == 6 && channel_mask == 0x3f) strcpy (modes, "5.1 surround"); else if (num_channels == 6 && channel_mask == 0x60f) strcpy (modes, "5.1 surround side"); else if (num_channels == 8 && channel_mask == 0x63f) strcpy (modes, "7.1 surround"); else if (num_channels == 8 && channel_mask == 0x6000003f) strcpy (modes, "5.1 + stereo"); else { int cc = num_channels, si = 0; uint32_t cm = channel_mask; modes [0] = 0; while (cc && cm) { if (cm & 1) { strcat (modes, si < 18 ? speakers [si] : "--"); if (--cc) strcat (modes, ","); } cm >>= 1; si++; } if (cc) strcat (modes, "..."); } fprintf (dst, "channels: %d (%s)\n", num_channels, modes); if (WavpackGetNumSamples64 (wpc) != -1) { double seconds = (double) WavpackGetNumSamples64 (wpc) / WavpackGetSampleRate (wpc); int minutes = (int) floor (seconds / 60.0); int hours = (int) floor (seconds / 3600.0); seconds -= minutes * 60.0; minutes -= (int)(hours * 60.0); fprintf (dst, "duration: %d:%02d:%05.2f\n", hours, minutes, seconds); } modes [0] = 0; if (WavpackGetMode (wpc) & MODE_HYBRID) strcat (modes, "hybrid "); strcat (modes, (WavpackGetMode (wpc) & MODE_LOSSLESS) ? "lossless" : "lossy"); if (WavpackGetMode (wpc) & MODE_FAST) strcat (modes, ", fast"); else if (WavpackGetMode (wpc) & MODE_VERY_HIGH) strcat (modes, ", very high"); else if (WavpackGetMode (wpc) & MODE_HIGH) strcat (modes, ", high"); if (WavpackGetMode (wpc) & MODE_EXTRA) { strcat (modes, ", extra"); if (WavpackGetMode (wpc) & MODE_XMODE) { char xmode[3] = "-0"; xmode [1] = ((WavpackGetMode (wpc) & MODE_XMODE) >> 12) + '0'; strcat (modes, xmode); } } if (WavpackGetMode (wpc) & MODE_SFX) strcat (modes, ", sfx"); if (WavpackGetMode (wpc) & MODE_DNS) strcat (modes, ", dns"); fprintf (dst, "modalities: %s\n", modes); if (WavpackGetRatio (wpc) != 0.0) { fprintf (dst, "compression: %.2f%%\n", 100.0 - (100 * WavpackGetRatio (wpc))); fprintf (dst, "ave bitrate: %d kbps\n", (int) ((WavpackGetAverageBitrate (wpc, TRUE) + 500.0) / 1000.0)); if (WavpackGetMode (wpc) & MODE_WVC) fprintf (dst, "ave lossy bitrate: %d kbps\n", (int) ((WavpackGetAverageBitrate (wpc, FALSE) + 500.0) / 1000.0)); } if (WavpackGetVersion (wpc)) fprintf (dst, "encoder version: %d\n", WavpackGetVersion (wpc)); if (WavpackGetMD5Sum (wpc, md5_sum)) { char md5_string [] = "00000000000000000000000000000000"; int i; for (i = 0; i < 16; ++i) sprintf (md5_string + (i * 2), "%02x", md5_sum [i]); fprintf (dst, "original md5: %s\n", md5_string); } if (summary > 1) { uint32_t header_bytes = WavpackGetWrapperBytes (wpc), trailer_bytes, i; unsigned char *header_data = WavpackGetWrapperData (wpc); char header_name [5]; strcpy (header_name, "????"); for (i = 0; i < 4 && i < header_bytes; ++i) if (header_data [i] >= 0x20 && header_data [i] <= 0x7f) header_name [i] = header_data [i]; WavpackFreeWrapper (wpc); WavpackSeekTrailingWrapper (wpc); trailer_bytes = WavpackGetWrapperBytes (wpc); if (WavpackGetFileFormat (wpc) < NUM_FILE_FORMATS) fprintf (dst, "source format: %s with '%s' extension\n", file_formats [WavpackGetFileFormat (wpc)].format_name, WavpackGetFileExtension (wpc)); else fprintf (dst, "source format: '%s' file\n", WavpackGetFileExtension (wpc)); if (header_bytes && trailer_bytes) { unsigned char *trailer_data = WavpackGetWrapperData (wpc); char trailer_name [5]; strcpy (trailer_name, "????"); for (i = 0; i < 4 && i < trailer_bytes; ++i) if (trailer_data [i] >= 0x20 && trailer_data [i] <= 0x7f) trailer_name [i] = trailer_data [i]; fprintf (dst, "file wrapper: %u + %u bytes (%s, %s)\n", header_bytes, trailer_bytes, header_name, trailer_name); } else if (header_bytes) fprintf (dst, "file wrapper: %u byte %s header\n", header_bytes, header_name); else if (trailer_bytes) fprintf (dst, "file wrapper: %u byte trailer only\n", trailer_bytes); else fprintf (dst, "file wrapper: none stored\n"); } if (WavpackGetMode (wpc) & MODE_VALID_TAG) { int ape_tag = WavpackGetMode (wpc) & MODE_APETAG; int num_binary_items = WavpackGetNumBinaryTagItems (wpc); int num_items = WavpackGetNumTagItems (wpc), i; char *spaces = " "; fprintf (dst, "\n%s tag items: %d\n", ape_tag ? "APEv2" : "ID3v1", num_items + num_binary_items); for (i = 0; i < num_items; ++i) { int item_len, value_len, j; char *item, *value; item_len = WavpackGetTagItemIndexed (wpc, i, NULL, 0); item = malloc (item_len + 1); WavpackGetTagItemIndexed (wpc, i, item, item_len + 1); value_len = WavpackGetTagItem (wpc, item, NULL, 0); value = malloc (value_len * 2 + 1); WavpackGetTagItem (wpc, item, value, value_len + 1); fprintf (dst, "%s:%s", item, strlen (item) < strlen (spaces) ? spaces + strlen (item) : " "); if (ape_tag) { for (j = 0; j < value_len; ++j) if (!value [j]) value [j] = '\\'; if (strchr (value, '\n')) fprintf (dst, "%d-byte multi-line text string\n", value_len); else { dump_UTF8_string (value, dst); fprintf (dst, "\n"); } } else fprintf (dst, "%s\n", value); free (value); free (item); } for (i = 0; i < num_binary_items; ++i) { int item_len, value_len; char *item, fname [256]; item_len = WavpackGetBinaryTagItemIndexed (wpc, i, NULL, 0); item = malloc (item_len + 1); WavpackGetBinaryTagItemIndexed (wpc, i, item, item_len + 1); value_len = dump_tag_item_to_file (wpc, item, NULL, fname); fprintf (dst, "%s:%s", item, strlen (item) < strlen (spaces) ? spaces + strlen (item) : " "); if (filespec_ext (fname)) fprintf (dst, "%d-byte binary item (%s)\n", value_len, filespec_ext (fname)+1); else fprintf (dst, "%d-byte binary item\n", value_len); #if 0 // debug binary tag reading { char md5_string [] = "00000000000000000000000000000000"; unsigned char md5_result [16]; MD5_CTX md5_context; char *value; int i, j; MD5_Init (&md5_context); value_len = WavpackGetBinaryTagItem (wpc, item, NULL, 0); value = malloc (value_len); value_len = WavpackGetBinaryTagItem (wpc, item, value, value_len); for (i = 0; i < value_len; ++i) if (!value [i]) { MD5_Update (&md5_context, (unsigned char *) value + i + 1, value_len - i - 1); MD5_Final (md5_result, &md5_context); for (j = 0; j < 16; ++j) sprintf (md5_string + (j * 2), "%02x", md5_result [j]); fprintf (dst, " %d byte string >>%s<<\n", i, value); fprintf (dst, " %d bytes binary data >>%s<<\n", value_len - i - 1, md5_string); break; } if (i == value_len) fprintf (dst, " no NULL found in binary value (or value not readable)\n"); free (value); } #endif free (item); } } }
0
[ "CWE-476", "CWE-703" ]
WavPack
25b4a2725d8568212e7cf89ca05ca29d128af7ac
51,852,012,862,238,620,000,000,000,000,000,000,000
257
issue #121: NULL pointer dereference in wvunpack.c * check for NULL pointer before dereferencing in wvunpack.c * sanitize custom extensions to be alphanumeric only
dns_zone_setaltxfrsource6dscp(dns_zone_t *zone, isc_dscp_t dscp) { REQUIRE(DNS_ZONE_VALID(zone)); LOCK_ZONE(zone); zone->altxfrsource6dscp = dscp; UNLOCK_ZONE(zone); return (ISC_R_SUCCESS); }
0
[ "CWE-327" ]
bind9
f09352d20a9d360e50683cd1d2fc52ccedcd77a0
334,118,540,512,654,860,000,000,000,000,000,000,000
9
Update keyfetch_done compute_tag check If in keyfetch_done the compute_tag fails (because for example the algorithm is not supported), don't crash, but instead ignore the key.
const char *get_slot_tokenlabel(pkcs11_handle_t *h) { return h->slots[h->current_slot].label; }
0
[]
pam_pkcs11
cc51b3e2720ea862d500cab2ea517518ff39a497
92,063,436,292,776,950,000,000,000,000,000,000,000
4
verify using a nonce from the system, not the card Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting the problem.
static void nf_tables_set_notify(const struct nft_ctx *ctx, const struct nft_set *set, int event, gfp_t gfp_flags) { struct nftables_pernet *nft_net = nft_pernet(ctx->net); u32 portid = ctx->portid; struct sk_buff *skb; u16 flags = 0; int err; if (!ctx->report && !nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES)) return; skb = nlmsg_new(NLMSG_GOODSIZE, gfp_flags); if (skb == NULL) goto err; if (ctx->flags & (NLM_F_CREATE | NLM_F_EXCL)) flags |= ctx->flags & (NLM_F_CREATE | NLM_F_EXCL); err = nf_tables_fill_set(skb, ctx, set, event, flags); if (err < 0) { kfree_skb(skb); goto err; } nft_notify_enqueue(skb, ctx->report, &nft_net->notify_list); return; err: nfnetlink_set_err(ctx->net, portid, NFNLGRP_NFTABLES, -ENOBUFS); }
0
[]
net
520778042ccca019f3ffa136dd0ca565c486cedd
170,830,293,280,602,250,000,000,000,000,000,000,000
32
netfilter: nf_tables: disallow non-stateful expression in sets earlier Since 3e135cd499bf ("netfilter: nft_dynset: dynamic stateful expression instantiation"), it is possible to attach stateful expressions to set elements. cd5125d8f518 ("netfilter: nf_tables: split set destruction in deactivate and destroy phase") introduces conditional destruction on the object to accomodate transaction semantics. nft_expr_init() calls expr->ops->init() first, then check for NFT_STATEFUL_EXPR, this stills allows to initialize a non-stateful lookup expressions which points to a set, which might lead to UAF since the set is not properly detached from the set->binding for this case. Anyway, this combination is non-sense from nf_tables perspective. This patch fixes this problem by checking for NFT_STATEFUL_EXPR before expr->ops->init() is called. The reporter provides a KASAN splat and a poc reproducer (similar to those autogenerated by syzbot to report use-after-free errors). It is unknown to me if they are using syzbot or if they use similar automated tool to locate the bug that they are reporting. For the record, this is the KASAN splat. [ 85.431824] ================================================================== [ 85.432901] BUG: KASAN: use-after-free in nf_tables_bind_set+0x81b/0xa20 [ 85.433825] Write of size 8 at addr ffff8880286f0e98 by task poc/776 [ 85.434756] [ 85.434999] CPU: 1 PID: 776 Comm: poc Tainted: G W 5.18.0+ #2 [ 85.436023] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 Fixes: 0b2d8a7b638b ("netfilter: nf_tables: add helper functions for expression handling") Reported-and-tested-by: Aaron Adams <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
ast_for_async_funcdef(struct compiling *c, const node *n, asdl_seq *decorator_seq) { /* async_funcdef: ASYNC funcdef */ REQ(n, async_funcdef); REQ(CHILD(n, 0), ASYNC); REQ(CHILD(n, 1), funcdef); return ast_for_funcdef_impl(c, n, decorator_seq, true /* is_async */); }
0
[ "CWE-125" ]
cpython
a4d78362397fc3bced6ea80fbc7b5f4827aec55e
243,200,966,982,781,500,000,000,000,000,000,000,000
10
bpo-36495: Fix two out-of-bounds array reads (GH-12641) Research and fix by @bradlarsen.
int tls_parse_all_extensions(SSL *s, int context, RAW_EXTENSION *exts, X509 *x, size_t chainidx, int fin) { size_t i, numexts = OSSL_NELEM(ext_defs); const EXTENSION_DEFINITION *thisexd; /* Calculate the number of extensions in the extensions list */ numexts += s->cert->custext.meths_count; /* Parse each extension in turn */ for (i = 0; i < numexts; i++) { if (!tls_parse_extension(s, i, context, exts, x, chainidx)) { /* SSLfatal() already called */ return 0; } } if (fin) { /* * Finalise all known extensions relevant to this context, * whether we have found them or not */ for (i = 0, thisexd = ext_defs; i < OSSL_NELEM(ext_defs); i++, thisexd++) { if (thisexd->final != NULL && (thisexd->context & context) != 0 && !thisexd->final(s, context, exts[i].present)) { /* SSLfatal() already called */ return 0; } } } return 1; }
0
[ "CWE-476" ]
openssl
fb9fa6b51defd48157eeb207f52181f735d96148
268,334,502,183,987,800,000,000,000,000,000,000,000
34
ssl sigalg extension: fix NULL pointer dereference As the variable peer_sigalgslen is not cleared on ssl rehandshake, it's possible to crash an openssl tls secured server remotely by sending a manipulated hello message in a rehandshake. On such a manipulated rehandshake, tls1_set_shared_sigalgs() calls tls12_shared_sigalgs() with the peer_sigalgslen of the previous handshake, while the peer_sigalgs has been freed. As a result tls12_shared_sigalgs() walks over the available peer_sigalgs and tries to access data of a NULL pointer. This issue was introduced by c589c34e61 (Add support for the TLS 1.3 signature_algorithms_cert extension, 2018-01-11). Signed-off-by: Peter Kästle <[email protected]> Signed-off-by: Samuel Sapalski <[email protected]> CVE-2021-3449 CLA: trivial Reviewed-by: Tomas Mraz <[email protected]> Reviewed-by: Paul Dale <[email protected]> Reviewed-by: Matt Caswell <[email protected]>
isodate7(const unsigned char *v) { struct tm tm; int offset; time_t t; memset(&tm, 0, sizeof(tm)); tm.tm_year = v[0]; tm.tm_mon = v[1] - 1; tm.tm_mday = v[2]; tm.tm_hour = v[3]; tm.tm_min = v[4]; tm.tm_sec = v[5]; /* v[6] is the signed timezone offset, in 1/4-hour increments. */ offset = ((const signed char *)v)[6]; if (offset > -48 && offset < 52) { tm.tm_hour -= offset / 4; tm.tm_min -= (offset % 4) * 15; } t = time_from_tm(&tm); if (t == (time_t)-1) return ((time_t)0); return (t); }
0
[ "CWE-125" ]
libarchive
f9569c086ff29259c73790db9cbf39fe8fb9d862
52,737,155,189,138,690,000,000,000,000,000,000,000
24
iso9660: validate directory record length
static int snd_pcm_action_group(const struct action_ops *ops, struct snd_pcm_substream *substream, snd_pcm_state_t state, bool do_lock) { struct snd_pcm_substream *s = NULL; struct snd_pcm_substream *s1; int res = 0, depth = 1; snd_pcm_group_for_each_entry(s, substream) { if (do_lock && s != substream) { if (s->pcm->nonatomic) mutex_lock_nested(&s->self_group.mutex, depth); else spin_lock_nested(&s->self_group.lock, depth); depth++; } res = ops->pre_action(s, state); if (res < 0) goto _unlock; } snd_pcm_group_for_each_entry(s, substream) { res = ops->do_action(s, state); if (res < 0) { if (ops->undo_action) { snd_pcm_group_for_each_entry(s1, substream) { if (s1 == s) /* failed stream */ break; ops->undo_action(s1, state); } } s = NULL; /* unlock all */ goto _unlock; } } snd_pcm_group_for_each_entry(s, substream) { ops->post_action(s, state); } _unlock: if (do_lock) { /* unlock streams */ snd_pcm_group_for_each_entry(s1, substream) { if (s1 != substream) { if (s1->pcm->nonatomic) mutex_unlock(&s1->self_group.mutex); else spin_unlock(&s1->self_group.lock); } if (s1 == s) /* end */ break; } } return res; }
0
[ "CWE-125" ]
linux
92ee3c60ec9fe64404dc035e7c41277d74aa26cb
257,905,684,544,547,800,000,000,000,000,000,000,000
54
ALSA: pcm: Fix races among concurrent hw_params and hw_free calls Currently we have neither proper check nor protection against the concurrent calls of PCM hw_params and hw_free ioctls, which may result in a UAF. Since the existing PCM stream lock can't be used for protecting the whole ioctl operations, we need a new mutex to protect those racy calls. This patch introduced a new mutex, runtime->buffer_mutex, and applies it to both hw_params and hw_free ioctl code paths. Along with it, the both functions are slightly modified (the mmap_count check is moved into the state-check block) for code simplicity. Reported-by: Hu Jiahui <[email protected]> Cc: <[email protected]> Reviewed-by: Jaroslav Kysela <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
SetHostIP(tcps_sess_t *pThis, prop_t *ip) { DEFiRet; ISOBJ_TYPE_assert(pThis, tcps_sess); if(pThis->fromHostIP != NULL) { prop.Destruct(&pThis->fromHostIP); } pThis->fromHostIP = ip; RETiRet; }
0
[ "CWE-787" ]
rsyslog
89955b0bcb1ff105e1374aad7e0e993faa6a038f
190,912,179,000,014,220,000,000,000,000,000,000,000
11
net bugfix: potential buffer overrun
DEFUN (neighbor_attr_unchanged, neighbor_attr_unchanged_cmd, NEIGHBOR_CMD2 "attribute-unchanged", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "BGP attribute is propagated unchanged to this neighbor\n") { return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), (PEER_FLAG_AS_PATH_UNCHANGED | PEER_FLAG_NEXTHOP_UNCHANGED | PEER_FLAG_MED_UNCHANGED)); }
0
[ "CWE-125" ]
frr
6d58272b4cf96f0daa846210dd2104877900f921
196,154,784,991,685,530,000,000,000,000,000,000,000
13
[bgpd] cleanup, compact and consolidate capability parsing code 2007-07-26 Paul Jakma <[email protected]> * (general) Clean up and compact capability parsing slightly. Consolidate validation of length and logging of generic TLV, and memcpy of capability data, thus removing such from cap specifc code (not always present or correct). * bgp_open.h: Add structures for the generic capability TLV header and for the data formats of the various specific capabilities we support. Hence remove the badly named, or else misdefined, struct capability. * bgp_open.c: (bgp_capability_vty_out) Use struct capability_mp_data. Do the length checks *before* memcpy()'ing based on that length (stored capability - should have been validated anyway on input, but..). (bgp_afi_safi_valid_indices) new function to validate (afi,safi) which is about to be used as index into arrays, consolidates several instances of same, at least one of which appeared to be incomplete.. (bgp_capability_mp) Much condensed. (bgp_capability_orf_entry) New, process one ORF entry (bgp_capability_orf) Condensed. Fixed to process all ORF entries. (bgp_capability_restart) Condensed, and fixed to use a cap-specific type, rather than abusing capability_mp. (struct message capcode_str) added to aid generic logging. (size_t cap_minsizes[]) added to aid generic validation of capability length field. (bgp_capability_parse) Generic logging and validation of TLV consolidated here. Code compacted as much as possible. * bgp_packet.c: (bgp_open_receive) Capability parsers now use streams, so no more need here to manually fudge the input stream getp. (bgp_capability_msg_parse) use struct capability_mp_data. Validate lengths /before/ memcpy. Use bgp_afi_safi_valid_indices. (bgp_capability_receive) Exported for use by test harness. * bgp_vty.c: (bgp_show_summary) fix conversion warning (bgp_show_peer) ditto * bgp_debug.h: Fix storage 'extern' after type 'const'. * lib/log.c: (mes_lookup) warning about code not being in same-number array slot should be debug, not warning. E.g. BGP has several discontigious number spaces, allocating from different parts of a space is not uncommon (e.g. IANA assigned versus vendor-assigned code points in some number space).
static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd, void __user *user_arg) { struct hid_device *hid = hiddev->hid; struct hiddev_report_info rinfo; struct hiddev_usage_ref_multi *uref_multi = NULL; struct hiddev_usage_ref *uref; struct hid_report *report; struct hid_field *field; int i; uref_multi = kmalloc(sizeof(struct hiddev_usage_ref_multi), GFP_KERNEL); if (!uref_multi) return -ENOMEM; uref = &uref_multi->uref; if (cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) { if (copy_from_user(uref_multi, user_arg, sizeof(*uref_multi))) goto fault; } else { if (copy_from_user(uref, user_arg, sizeof(*uref))) goto fault; } switch (cmd) { case HIDIOCGUCODE: rinfo.report_type = uref->report_type; rinfo.report_id = uref->report_id; if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) goto inval; if (uref->field_index >= report->maxfield) goto inval; field = report->field[uref->field_index]; if (uref->usage_index >= field->maxusage) goto inval; uref->usage_code = field->usage[uref->usage_index].hid; if (copy_to_user(user_arg, uref, sizeof(*uref))) goto fault; goto goodreturn; default: if (cmd != HIDIOCGUSAGE && cmd != HIDIOCGUSAGES && uref->report_type == HID_REPORT_TYPE_INPUT) goto inval; if (uref->report_id == HID_REPORT_ID_UNKNOWN) { field = hiddev_lookup_usage(hid, uref); if (field == NULL) goto inval; } else { rinfo.report_type = uref->report_type; rinfo.report_id = uref->report_id; if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) goto inval; if (uref->field_index >= report->maxfield) goto inval; field = report->field[uref->field_index]; if (cmd == HIDIOCGCOLLECTIONINDEX) { if (uref->usage_index >= field->maxusage) goto inval; } else if (uref->usage_index >= field->report_count) goto inval; } if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) && (uref_multi->num_values > HID_MAX_MULTI_USAGES || uref->usage_index + uref_multi->num_values > field->report_count)) goto inval; switch (cmd) { case HIDIOCGUSAGE: uref->value = field->value[uref->usage_index]; if (copy_to_user(user_arg, uref, sizeof(*uref))) goto fault; goto goodreturn; case HIDIOCSUSAGE: field->value[uref->usage_index] = uref->value; goto goodreturn; case HIDIOCGCOLLECTIONINDEX: i = field->usage[uref->usage_index].collection_index; kfree(uref_multi); return i; case HIDIOCGUSAGES: for (i = 0; i < uref_multi->num_values; i++) uref_multi->values[i] = field->value[uref->usage_index + i]; if (copy_to_user(user_arg, uref_multi, sizeof(*uref_multi))) goto fault; goto goodreturn; case HIDIOCSUSAGES: for (i = 0; i < uref_multi->num_values; i++) field->value[uref->usage_index + i] = uref_multi->values[i]; goto goodreturn; } goodreturn: kfree(uref_multi); return 0; fault: kfree(uref_multi); return -EFAULT; inval: kfree(uref_multi); return -EINVAL; } }
0
[ "CWE-119", "CWE-787" ]
linux
93a2001bdfd5376c3dc2158653034c20392d15c5
63,651,797,369,670,480,000,000,000,000,000,000,000
118
HID: hiddev: validate num_values for HIDIOCGUSAGES, HIDIOCSUSAGES commands This patch validates the num_values parameter from userland during the HIDIOCGUSAGES and HIDIOCSUSAGES commands. Previously, if the report id was set to HID_REPORT_ID_UNKNOWN, we would fail to validate the num_values parameter leading to a heap overflow. Cc: [email protected] Signed-off-by: Scott Bauer <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
void gf_prompt_set_echo_off(Bool echo_off) { return; }
0
[ "CWE-787" ]
gpac
f3698bb1bce62402805c3fda96551a23101a32f9
48,939,106,452,969,245,000,000,000,000,000,000,000
3
fix buffer overrun in gf_bin128_parse closes #1204 closes #1205
set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx) { int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0; int indir = (int)options[opt_idx].indir; sctx_T new_script_ctx = script_ctx; // Modeline already has the line number set. if (!(opt_flags & OPT_MODELINE)) new_script_ctx.sc_lnum += SOURCING_LNUM; // Remember where the option was set. For local options need to do that // in the buffer or window structure. if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0) options[opt_idx].script_ctx = new_script_ctx; if (both || (opt_flags & OPT_LOCAL)) { if (indir & PV_BUF) curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx; else if (indir & PV_WIN) { curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx; if (both) // also setting the "all buffers" value curwin->w_allbuf_opt.wo_script_ctx[indir & PV_MASK] = new_script_ctx; } } }
0
[ "CWE-122", "CWE-787" ]
vim
652dee448618589de5528a9e9a36995803f5557a
226,687,660,247,157,480,000,000,000,000,000,000,000
28
patch 8.2.4245: ":retab 0" may cause illegal memory access Problem: ":retab 0" may cause illegal memory access. Solution: Limit the value of 'tabstop' to 10000.
bgp_af_caps_cmp(const void *X, const void *Y) { const struct bgp_af_caps *x = X, *y = Y; return (x->afi < y->afi) ? -1 : (x->afi > y->afi) ? 1 : 0; }
0
[ "CWE-787" ]
bird
8388f5a7e14108a1458fea35bfbb5a453e2c563c
240,985,969,765,081,250,000,000,000,000,000,000,000
5
BGP: Fix bugs in handling of shutdown messages There is an improper check for valid message size, which may lead to stack overflow and buffer leaks to log when a large message is received. Thanks to Daniel McCarney for bugreport and analysis.
bool InstanceKlass::is_shareable() const { #if INCLUDE_CDS ClassLoaderData* loader_data = class_loader_data(); if (!SystemDictionaryShared::is_sharing_possible(loader_data)) { return false; } if (is_hidden()) { return false; } if (module()->is_patched()) { return false; } return true; #else return false; #endif }
0
[]
jdk17u
f8eb9abe034f7c6bea4da05a9ea42017b3f80730
133,524,477,604,584,970,000,000,000,000,000,000,000
20
8270386: Better verification of scan methods Reviewed-by: coleenp Backport-of: ac329cef45979bd0159ecd1347e36f7129bb2ce4
static void k_shift(struct vc_data *vc, unsigned char value, char up_flag) { int old_state = shift_state; if (rep) return; /* * Mimic typewriter: * a CapsShift key acts like Shift but undoes CapsLock */ if (value == KVAL(K_CAPSSHIFT)) { value = KVAL(K_SHIFT); if (!up_flag) clr_vc_kbd_led(kbd, VC_CAPSLOCK); } if (up_flag) { /* * handle the case that two shift or control * keys are depressed simultaneously */ if (shift_down[value]) shift_down[value]--; } else shift_down[value]++; if (shift_down[value]) shift_state |= (1 << value); else shift_state &= ~(1 << value); /* kludge */ if (up_flag && shift_state != old_state && npadch_active) { if (kbd->kbdmode == VC_UNICODE) to_utf8(vc, npadch_value); else put_queue(vc, npadch_value & 0xff); npadch_active = false; } }
0
[ "CWE-416" ]
linux
6ca03f90527e499dd5e32d6522909e2ad390896b
201,935,807,462,165,700,000,000,000,000,000,000,000
40
vt: keyboard, simplify vt_kdgkbsent Use 'strlen' of the string, add one for NUL terminator and simply do 'copy_to_user' instead of the explicit 'for' loop. This makes the KDGKBSENT case more compact. The only thing we need to take care about is NULL 'func_table[i]'. Use an empty string in that case. The original check for overflow could never trigger as the func_buf strings are always shorter or equal to 'struct kbsentry's. Cc: <[email protected]> Signed-off-by: Jiri Slaby <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
inf_gtk_certificate_manager_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) { InfGtkCertificateManager* manager; InfGtkCertificateManagerPrivate* priv; manager = INF_GTK_CERTIFICATE_MANAGER(object); priv = INF_GTK_CERTIFICATE_MANAGER_PRIVATE(manager); switch(prop_id) { case PROP_PARENT_WINDOW: g_value_set_object(value, G_OBJECT(priv->parent_window)); break; case PROP_XMPP_MANAGER: g_value_set_object(value, G_OBJECT(priv->xmpp_manager)); break; case PROP_KNOWN_HOSTS_FILE: g_value_set_string(value, priv->known_hosts_file); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } }
0
[ "CWE-295" ]
libinfinity
c97f870f5ae13112988d9f8ad464b4f679903706
122,859,806,732,077,510,000,000,000,000,000,000,000
27
Fix expired certificate validation (gobby #61)
static int brcmf_msgbuf_stats_read(struct seq_file *seq, void *data) { struct brcmf_bus *bus_if = dev_get_drvdata(seq->private); struct brcmf_pub *drvr = bus_if->drvr; struct brcmf_msgbuf *msgbuf = (struct brcmf_msgbuf *)drvr->proto->pd; struct brcmf_commonring *commonring; u16 i; struct brcmf_flowring_ring *ring; struct brcmf_flowring_hash *hash; commonring = msgbuf->commonrings[BRCMF_H2D_MSGRING_CONTROL_SUBMIT]; seq_printf(seq, "h2d_ctl_submit: rp %4u, wp %4u, depth %4u\n", commonring->r_ptr, commonring->w_ptr, commonring->depth); commonring = msgbuf->commonrings[BRCMF_H2D_MSGRING_RXPOST_SUBMIT]; seq_printf(seq, "h2d_rx_submit: rp %4u, wp %4u, depth %4u\n", commonring->r_ptr, commonring->w_ptr, commonring->depth); commonring = msgbuf->commonrings[BRCMF_D2H_MSGRING_CONTROL_COMPLETE]; seq_printf(seq, "d2h_ctl_cmplt: rp %4u, wp %4u, depth %4u\n", commonring->r_ptr, commonring->w_ptr, commonring->depth); commonring = msgbuf->commonrings[BRCMF_D2H_MSGRING_TX_COMPLETE]; seq_printf(seq, "d2h_tx_cmplt: rp %4u, wp %4u, depth %4u\n", commonring->r_ptr, commonring->w_ptr, commonring->depth); commonring = msgbuf->commonrings[BRCMF_D2H_MSGRING_RX_COMPLETE]; seq_printf(seq, "d2h_rx_cmplt: rp %4u, wp %4u, depth %4u\n", commonring->r_ptr, commonring->w_ptr, commonring->depth); seq_printf(seq, "\nh2d_flowrings: depth %u\n", BRCMF_H2D_TXFLOWRING_MAX_ITEM); seq_puts(seq, "Active flowrings:\n"); hash = msgbuf->flow->hash; for (i = 0; i < msgbuf->flow->nrofrings; i++) { if (!msgbuf->flow->rings[i]) continue; ring = msgbuf->flow->rings[i]; if (ring->status != RING_OPEN) continue; commonring = msgbuf->flowrings[i]; hash = &msgbuf->flow->hash[ring->hash_id]; seq_printf(seq, "id %3u: rp %4u, wp %4u, qlen %4u, blocked %u\n" " ifidx %u, fifo %u, da %pM\n", i, commonring->r_ptr, commonring->w_ptr, skb_queue_len(&ring->skblist), ring->blocked, hash->ifidx, hash->fifo, hash->mac); } return 0; }
0
[ "CWE-20" ]
linux
a4176ec356c73a46c07c181c6d04039fafa34a9f
135,758,406,844,348,100,000,000,000,000,000,000,000
47
brcmfmac: add subtype check for event handling in data path For USB there is no separate channel being used to pass events from firmware to the host driver and as such are passed over the data path. In order to detect mock event messages an additional check is needed on event subtype. This check is added conditionally using unlikely() keyword. Reviewed-by: Hante Meuleman <[email protected]> Reviewed-by: Pieter-Paul Giesberts <[email protected]> Reviewed-by: Franky Lin <[email protected]> Signed-off-by: Arend van Spriel <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
GF_ISOMVVCType gf_isom_get_vvc_type(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex) { u32 type; GF_TrackBox *trak; GF_MPEGVisualSampleEntryBox *entry; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !trak->Media || !DescriptionIndex) return GF_ISOM_VVCTYPE_NONE; if (!gf_isom_is_video_handler_type(trak->Media->handler->handlerType)) return GF_ISOM_VVCTYPE_NONE; entry = (GF_MPEGVisualSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, DescriptionIndex-1); if (!entry) return GF_ISOM_VVCTYPE_NONE; if (entry->internal_type != GF_ISOM_SAMPLE_ENTRY_VIDEO) return GF_ISOM_VVCTYPE_NONE; type = entry->type; if (type == GF_ISOM_BOX_TYPE_ENCV) { GF_ProtectionSchemeInfoBox *sinf = (GF_ProtectionSchemeInfoBox *) gf_isom_box_find_child(entry->child_boxes, GF_ISOM_BOX_TYPE_SINF); if (sinf && sinf->original_format) type = sinf->original_format->data_format; } else if (type == GF_ISOM_BOX_TYPE_RESV) { if (entry->rinf && entry->rinf->original_format) type = entry->rinf->original_format->data_format; } switch (type) { case GF_ISOM_BOX_TYPE_VVC1: case GF_ISOM_BOX_TYPE_VVI1: return GF_ISOM_VVCTYPE_ONLY; case GF_ISOM_SUBTYPE_VVS1: return GF_ISOM_VVCTYPE_SUBPIC; case GF_ISOM_SUBTYPE_VVCN: return GF_ISOM_VVCTYPE_NVCL; default: return GF_ISOM_VVCTYPE_NONE; } return GF_ISOM_VVCTYPE_NONE; }
0
[ "CWE-617", "CWE-703" ]
gpac
9ea93a2ec8f555ceed1ee27294cf94822f14f10f
31,267,079,412,536,456,000,000,000,000,000,000,000
35
fixed #2165
filter_push(fz_context *ctx, pdf_filter_processor *p) { filter_gstate *gstate = p->gstate; filter_gstate *new_gstate = fz_malloc_struct(ctx, filter_gstate); *new_gstate = *gstate; new_gstate->pushed = 0; new_gstate->next = gstate; p->gstate = new_gstate; pdf_keep_font(ctx, new_gstate->pending.text.font); pdf_keep_font(ctx, new_gstate->sent.text.font); }
0
[ "CWE-125" ]
mupdf
97096297d409ec6f206298444ba00719607e8ba8
212,652,825,254,749,500,000,000,000,000,000,000,000
12
Bug 701292: Fix test for missing/empty string.
static int vc_con_write_normal(struct vc_data *vc, int tc, int c, struct vc_draw_region *draw) { int next_c; unsigned char vc_attr = vc->vc_attr; u16 himask = vc->vc_hi_font_mask, charmask = himask ? 0x1ff : 0xff; u8 width = 1; bool inverse = false; if (vc->vc_utf && !vc->vc_disp_ctrl) { if (is_double_width(c)) width = 2; } /* Now try to find out how to display it */ tc = conv_uni_to_pc(vc, tc); if (tc & ~charmask) { if (tc == -1 || tc == -2) return -1; /* nothing to display */ /* Glyph not found */ if ((!vc->vc_utf || vc->vc_disp_ctrl || c < 128) && !(c & ~charmask)) { /* * In legacy mode use the glyph we get by a 1:1 * mapping. * This would make absolutely no sense with Unicode in * mind, but do this for ASCII characters since a font * may lack Unicode mapping info and we don't want to * end up with having question marks only. */ tc = c; } else { /* * Display U+FFFD. If it's not found, display an inverse * question mark. */ tc = conv_uni_to_pc(vc, 0xfffd); if (tc < 0) { inverse = true; tc = conv_uni_to_pc(vc, '?'); if (tc < 0) tc = '?'; vc_attr = vc_invert_attr(vc); con_flush(vc, draw); } } } next_c = c; while (1) { if (vc->vc_need_wrap || vc->vc_decim) con_flush(vc, draw); if (vc->vc_need_wrap) { cr(vc); lf(vc); } if (vc->vc_decim) insert_char(vc, 1); vc_uniscr_putc(vc, next_c); if (himask) tc = ((tc & 0x100) ? himask : 0) | (tc & 0xff); tc |= (vc_attr << 8) & ~himask; scr_writew(tc, (u16 *)vc->vc_pos); if (con_should_update(vc) && draw->x < 0) { draw->x = vc->state.x; draw->from = vc->vc_pos; } if (vc->state.x == vc->vc_cols - 1) { vc->vc_need_wrap = vc->vc_decawm; draw->to = vc->vc_pos + 2; } else { vc->state.x++; draw->to = (vc->vc_pos += 2); } if (!--width) break; /* A space is printed in the second column */ tc = conv_uni_to_pc(vc, ' '); if (tc < 0) tc = ' '; next_c = ' '; } notify_write(vc, c); if (inverse) con_flush(vc, draw); return 0; }
0
[ "CWE-125" ]
linux
3c4e0dff2095c579b142d5a0693257f1c58b4804
72,291,433,864,689,730,000,000,000,000,000,000,000
97
vt: Disable KD_FONT_OP_COPY It's buggy: On Fri, Nov 06, 2020 at 10:30:08PM +0800, Minh Yuan wrote: > We recently discovered a slab-out-of-bounds read in fbcon in the latest > kernel ( v5.10-rc2 for now ). The root cause of this vulnerability is that > "fbcon_do_set_font" did not handle "vc->vc_font.data" and > "vc->vc_font.height" correctly, and the patch > <https://lkml.org/lkml/2020/9/27/223> for VT_RESIZEX can't handle this > issue. > > Specifically, we use KD_FONT_OP_SET to set a small font.data for tty6, and > use KD_FONT_OP_SET again to set a large font.height for tty1. After that, > we use KD_FONT_OP_COPY to assign tty6's vc_font.data to tty1's vc_font.data > in "fbcon_do_set_font", while tty1 retains the original larger > height. Obviously, this will cause an out-of-bounds read, because we can > access a smaller vc_font.data with a larger vc_font.height. Further there was only one user ever. - Android's loadfont, busybox and console-tools only ever use OP_GET and OP_SET - fbset documentation only mentions the kernel cmdline font: option, not anything else. - systemd used OP_COPY before release 232 published in Nov 2016 Now unfortunately the crucial report seems to have gone down with gmane, and the commit message doesn't say much. But the pull request hints at OP_COPY being broken https://github.com/systemd/systemd/pull/3651 So in other words, this never worked, and the only project which foolishly every tried to use it, realized that rather quickly too. Instead of trying to fix security issues here on dead code by adding missing checks, fix the entire thing by removing the functionality. Note that systemd code using the OP_COPY function ignored the return value, so it doesn't matter what we're doing here really - just in case a lone server somewhere happens to be extremely unlucky and running an affected old version of systemd. The relevant code from font_copy_to_all_vcs() in systemd was: /* copy font from active VT, where the font was uploaded to */ cfo.op = KD_FONT_OP_COPY; cfo.height = vcs.v_active-1; /* tty1 == index 0 */ (void) ioctl(vcfd, KDFONTOP, &cfo); Note this just disables the ioctl, garbage collecting the now unused callbacks is left for -next. v2: Tetsuo found the old mail, which allowed me to find it on another archive. Add the link too. Acked-by: Peilin Ye <[email protected]> Reported-by: Minh Yuan <[email protected]> References: https://lists.freedesktop.org/archives/systemd-devel/2016-June/036935.html References: https://github.com/systemd/systemd/pull/3651 Cc: Greg KH <[email protected]> Cc: Peilin Ye <[email protected]> Cc: Tetsuo Handa <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
cssp_read_tsrequest(STREAM token, STREAM pubkey) { STREAM s; int length; int tagval; struct stream packet; s = tcp_recv(NULL, 4); if (s == NULL) return False; // verify ASN.1 header if (s->p[0] != (BER_TAG_SEQUENCE | BER_TAG_CONSTRUCTED)) { error("Expected BER_TAG_SEQUENCE|BER_TAG_CONSTRUCTED, got %x", s->p[0]); return False; } // peek at first 4 bytes to get full message length if (s->p[1] < 0x80) length = s->p[1] - 2; else if (s->p[1] == 0x81) length = s->p[2] - 1; else if (s->p[1] == 0x82) length = (s->p[2] << 8) | s->p[3]; else return False; // receive the remainings of message s = tcp_recv(s, length); packet = *s; #if WITH_DEBUG_CREDSSP streamsave(s, "tsrequest_in.raw"); printf("In TSRequest token %ld bytes\n", s_length(s)); hexdump(s->data, s_length(s)); #endif // parse the response and into nego token if (!ber_in_header(s, &tagval, &length) || tagval != (BER_TAG_SEQUENCE | BER_TAG_CONSTRUCTED)) return False; // version [0] if (!ber_in_header(s, &tagval, &length) || tagval != (BER_TAG_CTXT_SPECIFIC | BER_TAG_CONSTRUCTED | 0)) return False; if (!s_check_rem(s, length)) { rdp_protocol_error("cssp_read_tsrequest(), consume of version from stream would overrun", &packet); } in_uint8s(s, length); // negoToken [1] if (token) { if (!ber_in_header(s, &tagval, &length) || tagval != (BER_TAG_CTXT_SPECIFIC | BER_TAG_CONSTRUCTED | 1)) return False; if (!ber_in_header(s, &tagval, &length) || tagval != (BER_TAG_SEQUENCE | BER_TAG_CONSTRUCTED)) return False; if (!ber_in_header(s, &tagval, &length) || tagval != (BER_TAG_SEQUENCE | BER_TAG_CONSTRUCTED)) return False; if (!ber_in_header(s, &tagval, &length) || tagval != (BER_TAG_CTXT_SPECIFIC | BER_TAG_CONSTRUCTED | 0)) return False; if (!ber_in_header(s, &tagval, &length) || tagval != BER_TAG_OCTET_STRING) return False; if (!s_check_rem(s, length)) { rdp_protocol_error("cssp_read_tsrequest(), consume of token from stream would overrun", &packet); } s_realloc(token, length); s_reset(token); out_uint8p(token, s->p, length); s_mark_end(token); } // pubKey [3] if (pubkey) { if (!ber_in_header(s, &tagval, &length) || tagval != (BER_TAG_CTXT_SPECIFIC | BER_TAG_CONSTRUCTED | 3)) return False; if (!ber_in_header(s, &tagval, &length) || tagval != BER_TAG_OCTET_STRING) return False; pubkey->data = pubkey->p = s->p; pubkey->end = pubkey->data + length; pubkey->size = length; } return True; }
0
[ "CWE-787" ]
rdesktop
766ebcf6f23ccfe8323ac10242ae6e127d4505d2
142,788,657,982,244,910,000,000,000,000,000,000,000
105
Malicious RDP server security fixes This commit includes fixes for a set of 21 vulnerabilities in rdesktop when a malicious RDP server is used. All vulnerabilities was identified and reported by Eyal Itkin. * Add rdp_protocol_error function that is used in several fixes * Refactor of process_bitmap_updates * Fix possible integer overflow in s_check_rem() on 32bit arch * Fix memory corruption in process_bitmap_data - CVE-2018-8794 * Fix remote code execution in process_bitmap_data - CVE-2018-8795 * Fix remote code execution in process_plane - CVE-2018-8797 * Fix Denial of Service in mcs_recv_connect_response - CVE-2018-20175 * Fix Denial of Service in mcs_parse_domain_params - CVE-2018-20175 * Fix Denial of Service in sec_parse_crypt_info - CVE-2018-20176 * Fix Denial of Service in sec_recv - CVE-2018-20176 * Fix minor information leak in rdpdr_process - CVE-2018-8791 * Fix Denial of Service in cssp_read_tsrequest - CVE-2018-8792 * Fix remote code execution in cssp_read_tsrequest - CVE-2018-8793 * Fix Denial of Service in process_bitmap_data - CVE-2018-8796 * Fix minor information leak in rdpsnd_process_ping - CVE-2018-8798 * Fix Denial of Service in process_secondary_order - CVE-2018-8799 * Fix remote code execution in in ui_clip_handle_data - CVE-2018-8800 * Fix major information leak in ui_clip_handle_data - CVE-2018-20174 * Fix memory corruption in rdp_in_unistr - CVE-2018-20177 * Fix Denial of Service in process_demand_active - CVE-2018-20178 * Fix remote code execution in lspci_process - CVE-2018-20179 * Fix remote code execution in rdpsnddbg_process - CVE-2018-20180 * Fix remote code execution in seamless_process - CVE-2018-20181 * Fix remote code execution in seamless_process_line - CVE-2018-20182
static int prepend(char **buffer, int *buflen, const char *str, int namelen) { *buflen -= namelen; if (*buflen < 0) return -ENAMETOOLONG; *buffer -= namelen; memcpy(*buffer, str, namelen); return 0; }
0
[ "CWE-362", "CWE-399" ]
linux
49d31c2f389acfe83417083e1208422b4091cd9e
325,674,698,219,276,800,000,000,000,000,000,000,000
9
dentry name snapshots take_dentry_name_snapshot() takes a safe snapshot of dentry name; if the name is a short one, it gets copied into caller-supplied structure, otherwise an extra reference to external name is grabbed (those are never modified). In either case the pointer to stable string is stored into the same structure. dentry must be held by the caller of take_dentry_name_snapshot(), but may be freely dropped afterwards - the snapshot will stay until destroyed by release_dentry_name_snapshot(). Intended use: struct name_snapshot s; take_dentry_name_snapshot(&s, dentry); ... access s.name ... release_dentry_name_snapshot(&s); Replaces fsnotify_oldname_...(), gets used in fsnotify to obtain the name to pass down with event. Signed-off-by: Al Viro <[email protected]>
static int compat_getdrvprm(int drive, struct compat_floppy_drive_params __user *arg) { struct compat_floppy_drive_params v; memset(&v, 0, sizeof(struct compat_floppy_drive_params)); mutex_lock(&floppy_mutex); v.cmos = UDP->cmos; v.max_dtr = UDP->max_dtr; v.hlt = UDP->hlt; v.hut = UDP->hut; v.srt = UDP->srt; v.spinup = UDP->spinup; v.spindown = UDP->spindown; v.spindown_offset = UDP->spindown_offset; v.select_delay = UDP->select_delay; v.rps = UDP->rps; v.tracks = UDP->tracks; v.timeout = UDP->timeout; v.interleave_sect = UDP->interleave_sect; v.max_errors = UDP->max_errors; v.flags = UDP->flags; v.read_track = UDP->read_track; memcpy(v.autodetect, UDP->autodetect, sizeof(v.autodetect)); v.checkfreq = UDP->checkfreq; v.native_format = UDP->native_format; mutex_unlock(&floppy_mutex); if (copy_to_user(arg, &v, sizeof(struct compat_floppy_drive_params))) return -EFAULT; return 0; }
0
[ "CWE-125" ]
linux
2e90ca68b0d2f5548804f22f0dd61145516171e3
252,527,219,732,336,050,000,000,000,000,000,000,000
32
floppy: check FDC index for errors before assigning it Jordy Zomer reported a KASAN out-of-bounds read in the floppy driver in wait_til_ready(). Which on the face of it can't happen, since as Willy Tarreau points out, the function does no particular memory access. Except through the FDCS macro, which just indexes a static allocation through teh current fdc, which is always checked against N_FDC. Except the checking happens after we've already assigned the value. The floppy driver is a disgrace (a lot of it going back to my original horrd "design"), and has no real maintainer. Nobody has the hardware, and nobody really cares. But it still gets used in virtual environment because it's one of those things that everybody supports. The whole thing should be re-written, or at least parts of it should be seriously cleaned up. The 'current fdc' index, which is used by the FDCS macro, and which is often shadowed by a local 'fdc' variable, is a prime example of how not to write code. But because nobody has the hardware or the motivation, let's just fix up the immediate problem with a nasty band-aid: test the fdc index before actually assigning it to the static 'fdc' variable. Reported-by: Jordy Zomer <[email protected]> Cc: Willy Tarreau <[email protected]> Cc: Dan Carpenter <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
void incNumConnections() override { ++num_listener_connections_; }
1
[ "CWE-400" ]
envoy
dfddb529e914d794ac552e906b13d71233609bf7
138,043,373,633,916,600,000,000,000,000,000,000,000
1
listener: Add configurable accepted connection limits (#153) Add support for per-listener limits on accepted connections. Signed-off-by: Tony Allen <[email protected]>
funcdepth_decrement(void) { --funcdepth; }
0
[ "CWE-416" ]
vim
9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04
93,352,055,876,780,220,000,000,000,000,000,000,000
4
patch 8.2.3902: Vim9: double free with nested :def function Problem: Vim9: double free with nested :def function. Solution: Pass "line_to_free" from compile_def_function() and make sure cmdlinep is valid.
CAMLexport value caml_alloc (mlsize_t wosize, tag_t tag) { value result; mlsize_t i; Assert (tag < 256); Assert (tag != Infix_tag); if (wosize == 0){ result = Atom (tag); }else if (wosize <= Max_young_wosize){ Alloc_small (result, wosize, tag); if (tag < No_scan_tag){ for (i = 0; i < wosize; i++) Field (result, i) = Val_unit; } }else{ result = caml_alloc_shr (wosize, tag); if (tag < No_scan_tag){ for (i = 0; i < wosize; i++) Field (result, i) = Val_unit; } result = caml_check_urgent_gc (result); } return result; }
0
[ "CWE-200" ]
ocaml
659615c7b100a89eafe6253e7a5b9d84d0e8df74
290,979,981,197,824,150,000,000,000,000,000,000,000
23
fix PR#7003 and a few other bugs caused by misuse of Int_val git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16525 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
static void gf_dump_vrml_sffield(GF_SceneDumper *sdump, u32 type, void *ptr, Bool is_mf, GF_Node *node) { switch (type) { case GF_SG_VRML_SFBOOL: gf_fprintf(sdump->trace, "%s", * ((SFBool *)ptr) ? "true" : "false"); break; case GF_SG_VRML_SFINT32: gf_fprintf(sdump->trace, "%d", * ((SFInt32 *)ptr) ); break; case GF_SG_VRML_SFFLOAT: gf_fprintf(sdump->trace, "%g", FIX2FLT( * ((SFFloat *)ptr) ) ); break; case GF_SG_VRML_SFDOUBLE: gf_fprintf(sdump->trace, "%g", * ((SFDouble *)ptr) ); break; case GF_SG_VRML_SFTIME: gf_fprintf(sdump->trace, "%g", * ((SFTime *)ptr) ); break; case GF_SG_VRML_SFCOLOR: gf_fprintf(sdump->trace, "%g %g %g", FIX2FLT( ((SFColor *)ptr)->red ), FIX2FLT( ((SFColor *)ptr)->green ), FIX2FLT( ((SFColor *)ptr)->blue )); break; case GF_SG_VRML_SFCOLORRGBA: gf_fprintf(sdump->trace, "%g %g %g %g", FIX2FLT( ((SFColorRGBA *)ptr)->red ), FIX2FLT( ((SFColorRGBA *)ptr)->green ), FIX2FLT( ((SFColorRGBA *)ptr)->blue ), FIX2FLT( ((SFColorRGBA *)ptr)->alpha )); break; case GF_SG_VRML_SFVEC2F: gf_fprintf(sdump->trace, "%g %g", FIX2FLT( ((SFVec2f *)ptr)->x ), FIX2FLT( ((SFVec2f *)ptr)->y )); break; case GF_SG_VRML_SFVEC2D: gf_fprintf(sdump->trace, "%g %g", ((SFVec2d *)ptr)->x, ((SFVec2d *)ptr)->y); break; case GF_SG_VRML_SFVEC3F: gf_fprintf(sdump->trace, "%g %g %g", FIX2FLT( ((SFVec3f *)ptr)->x ), FIX2FLT( ((SFVec3f *)ptr)->y ), FIX2FLT( ((SFVec3f *)ptr)->z )); break; case GF_SG_VRML_SFVEC3D: gf_fprintf(sdump->trace, "%g %g %g", ((SFVec3d *)ptr)->x, ((SFVec3d *)ptr)->y, ((SFVec3d *)ptr)->z); break; case GF_SG_VRML_SFROTATION: gf_fprintf(sdump->trace, "%g %g %g %g", FIX2FLT( ((SFRotation *)ptr)->x ), FIX2FLT( ((SFRotation *)ptr)->y ), FIX2FLT( ((SFRotation *)ptr)->z ), FIX2FLT( ((SFRotation *)ptr)->q ) ); break; case GF_SG_VRML_SFATTRREF: { SFAttrRef *ar = (SFAttrRef *)ptr; if (ar->node) { GF_FieldInfo pinfo; gf_node_get_field(ar->node, ar->fieldIndex, &pinfo); scene_dump_vrml_id(sdump, ar->node); gf_fprintf(sdump->trace, ".%s", pinfo.name); } } break; case GF_SG_VRML_SFSCRIPT: { u32 len, i; char *str; str = (char*)((SFScript *)ptr)->script_text; if (!str) { if (!sdump->XMLDump) { gf_fprintf(sdump->trace, "\"\""); } break; } len = (u32)strlen(str); if (!sdump->XMLDump) { gf_fprintf(sdump->trace, "\"%s\"", str); } else { u16 *uniLine; uniLine = (u16*)gf_malloc(sizeof(short) * (len + 1)); len = gf_utf8_mbstowcs(uniLine, len, (const char **)&str); if (len != GF_UTF8_FAIL) { for (i = 0; i<len; i++) { switch (uniLine[i]) { case '&': gf_fprintf(sdump->trace, "&amp;"); break; case '<': gf_fprintf(sdump->trace, "&lt;"); break; case '>': gf_fprintf(sdump->trace, "&gt;"); break; case '\'': case '"': gf_fprintf(sdump->trace, "&apos;"); break; case 0: break; /*FIXME: how the heck can we preserve newlines and spaces of JavaScript in an XML attribute in any viewer ? */ default: if (uniLine[i]<128) { gf_fprintf(sdump->trace, "%c", (u8)uniLine[i]); } else { gf_fprintf(sdump->trace, "&#%d;", uniLine[i]); } break; } } } gf_free(uniLine); } DUMP_IND(sdump); } break; case GF_SG_VRML_SFSTRING: { char *str; if (sdump->XMLDump) { if (is_mf) gf_fprintf(sdump->trace, sdump->X3DDump ? "\"" : "&quot;"); } else { gf_fprintf(sdump->trace, "\""); } /*dump in unicode*/ str = ((SFString *)ptr)->buffer; if (node && (gf_node_get_tag(node)==TAG_MPEG4_BitWrapper)) { u32 bufsize = 37 + ((M_BitWrapper*)node)->buffer_len * 2 + 3; str = gf_malloc(sizeof(char) * bufsize); if (str) { s32 res; strcpy(str, "data:application/octet-string;base64,"); res = gf_base64_encode(((M_BitWrapper*)node)->buffer.buffer, ((M_BitWrapper*)node)->buffer_len, str+37, bufsize-37); if (res<0) { gf_free(str); str = NULL; } else { str[res+37] = 0; } } } if (str && str[0]) { if (sdump->XMLDump) { scene_dump_utf_string(sdump, 1, str); } else if (!strchr(str, '\"')) { gf_fprintf(sdump->trace, "%s", str); } else { u32 i, len = (u32)strlen(str); for (i=0; i<len; i++) { if (str[i]=='\"') gf_fputc('\\', sdump->trace); gf_fputc(str[i], sdump->trace); } } } if (node && (gf_node_get_tag(node)==TAG_MPEG4_BitWrapper)) { if (str) gf_free(str); } if (sdump->XMLDump) { if (is_mf) gf_fprintf(sdump->trace, sdump->X3DDump ? "\"" : "&quot;"); } else { gf_fprintf(sdump->trace, "\""); } } break; case GF_SG_VRML_SFURL: if (((SFURL *)ptr)->url) { #if 0 u32 len; char *str; short uniLine[5000]; str = ((SFURL *)ptr)->url; len = gf_utf8_mbstowcs(uniLine, 5000, (const char **) &str); if (len != GF_UTF8_FAIL) { gf_fprintf(sdump->trace, sdump->XMLDump ? (sdump->X3DDump ? "'" : "&quot;") : "\""); fwprintf(sdump->trace, (unsigned short *) uniLine); gf_fprintf(sdump->trace, sdump->XMLDump ? (sdump->X3DDump ? "'" : "&quot;") : "\""); } #else gf_fprintf(sdump->trace, sdump->XMLDump ? (sdump->X3DDump ? "'" : "&quot;") : "\""); gf_fprintf(sdump->trace, "%s", ((SFURL *)ptr)->url); gf_fprintf(sdump->trace, sdump->XMLDump ? (sdump->X3DDump ? "'" : "&quot;") : "\""); #endif } else { if (sdump->XMLDump) { gf_fprintf(sdump->trace, "&quot;od://od%d&quot;", ((SFURL *)ptr)->OD_ID); } else { gf_fprintf(sdump->trace, "od:%d", ((SFURL *)ptr)->OD_ID); } } break; case GF_SG_VRML_SFIMAGE: { u32 i, count; SFImage *img = (SFImage *)ptr; gf_fprintf(sdump->trace, "%d %d %d", img->width, img->height, img->numComponents); count = img->width * img->height * img->numComponents; for (i=0; i<count; ) { switch (img->numComponents) { case 1: gf_fprintf(sdump->trace, " 0x%02X", img->pixels[i]); i++; break; case 2: gf_fprintf(sdump->trace, " 0x%02X%02X", img->pixels[i], img->pixels[i+1]); i+=2; break; case 3: gf_fprintf(sdump->trace, " 0x%02X%02X%02X", img->pixels[i], img->pixels[i+1], img->pixels[i+2]); i+=3; break; case 4: gf_fprintf(sdump->trace, " 0x%02X%02X%02X%02X", img->pixels[i], img->pixels[i+1], img->pixels[i+2], img->pixels[i+3]); i+=4; break; } } } break; } }
0
[ "CWE-476" ]
gpac
0102c5d4db7fdbf08b5b591b2a6264de33867a07
114,250,990,107,172,660,000,000,000,000,000,000,000
218
fixed #2232
number_format(int value) { const char *result = "%d"; if ((outform != F_TERMCAP) && (value > 255)) { unsigned long lv = (unsigned long) value; unsigned long mm; int bits = sizeof(unsigned long) * 8; int nn; for (nn = 8; nn < bits; ++nn) { mm = 1UL << nn; if ((mm - 16) <= lv && (mm + 16) > lv) { result = "%#x"; break; } } } return result; }
0
[ "CWE-125" ]
ncurses
b025434573f466efe27862656a6a9d41dd2bd609
85,666,894,564,340,300,000,000,000,000,000,000,000
18
ncurses 6.1 - patch 20191012 + amend recent changes to ncurses*-config and pc-files to filter out Debian linker-flags (report by Sven Joachim, cf: 20150516). + clarify relationship between tic, infocmp and captoinfo in manpage. + check for invalid hashcode in _nc_find_type_entry and _nc_find_name_entry. > fix several errata in tic (reports/testcases by "zjuchenyuan"): + check for invalid hashcode in _nc_find_entry. + check for missing character after backslash in fmt_entry + check for acsc with odd length in dump_entry in check for one-one mapping (cf: 20060415); + check length when converting from old AIX box_chars_1 capability, overlooked in changes to eliminate strcpy (cf: 20001007). + amend the ncurses*-config and pc-files to take into account the rpath
static void free_all_urbs(pegasus_t *pegasus) { usb_free_urb(pegasus->intr_urb); usb_free_urb(pegasus->tx_urb); usb_free_urb(pegasus->rx_urb); }
0
[ "CWE-119", "CWE-284" ]
linux
5593523f968bc86d42a035c6df47d5e0979b5ace
100,068,339,774,553,920,000,000,000,000,000,000,000
6
pegasus: Use heap buffers for all register access Allocating USB buffers on the stack is not portable, and no longer works on x86_64 (with VMAP_STACK enabled as per default). Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") References: https://bugs.debian.org/852556 Reported-by: Lisandro Damián Nicanor Pérez Meyer <[email protected]> Tested-by: Lisandro Damián Nicanor Pérez Meyer <[email protected]> Signed-off-by: Ben Hutchings <[email protected]> Signed-off-by: David S. Miller <[email protected]>
TEST_F(ConnectionManagerUtilityTest, ExternalAddressExternalRequestDontUseRemote) { connection_.stream_info_.downstream_address_provider_->setRemoteAddress( std::make_shared<Network::Address::Ipv4Instance>("60.0.0.2")); ON_CALL(config_, useRemoteAddress()).WillByDefault(Return(false)); TestRequestHeaderMapImpl headers{{"x-envoy-external-address", "60.0.0.1"}, {"x-forwarded-for", "60.0.0.1"}}; EXPECT_EQ((MutateRequestRet{"60.0.0.1:0", false, Tracing::Reason::NotTraceable}), callMutateRequestHeaders(headers, Protocol::Http2)); EXPECT_EQ("60.0.0.1", headers.get_("x-envoy-external-address")); EXPECT_EQ("60.0.0.1", headers.get_("x-forwarded-for")); }
0
[ "CWE-22" ]
envoy
5333b928d8bcffa26ab19bf018369a835f697585
252,465,646,548,115,980,000,000,000,000,000,000,000
12
Implement handling of escaped slash characters in URL path Fixes: CVE-2021-29492 Signed-off-by: Yan Avlasov <[email protected]>
static int avic_update_access_page(struct kvm *kvm, bool activate) { int ret = 0; mutex_lock(&kvm->slots_lock); /* * During kvm_destroy_vm(), kvm_pit_set_reinject() could trigger * APICv mode change, which update APIC_ACCESS_PAGE_PRIVATE_MEMSLOT * memory region. So, we need to ensure that kvm->mm == current->mm. */ if ((kvm->arch.apic_access_page_done == activate) || (kvm->mm != current->mm)) goto out; ret = __x86_set_memory_region(kvm, APIC_ACCESS_PAGE_PRIVATE_MEMSLOT, APIC_DEFAULT_PHYS_BASE, activate ? PAGE_SIZE : 0); if (ret) goto out; kvm->arch.apic_access_page_done = activate; out: mutex_unlock(&kvm->slots_lock); return ret; }
0
[ "CWE-401" ]
linux
d80b64ff297e40c2b6f7d7abc1b3eba70d22a068
157,794,681,911,344,800,000,000,000,000,000,000,000
26
KVM: SVM: Fix potential memory leak in svm_cpu_init() When kmalloc memory for sd->sev_vmcbs failed, we forget to free the page held by sd->save_area. Also get rid of the var r as '-ENOMEM' is actually the only possible outcome here. Reviewed-by: Liran Alon <[email protected]> Reviewed-by: Vitaly Kuznetsov <[email protected]> Signed-off-by: Miaohe Lin <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
S3BootScriptSaveInformationAsciiString ( IN CONST CHAR8 *String ) { return S3BootScriptSaveInformation ( (UINT32) AsciiStrLen (String) + 1, (VOID*) String ); }
0
[ "CWE-787" ]
edk2
322ac05f8bbc1bce066af1dabd1b70ccdbe28891
252,187,189,627,006,840,000,000,000,000,000,000,000
9
MdeModulePkg/PiDxeS3BootScriptLib: Fix potential numeric truncation (CVE-2019-14563) REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2001 For S3BootScriptLib APIs: S3BootScriptSaveIoWrite S3BootScriptSaveMemWrite S3BootScriptSavePciCfgWrite S3BootScriptSavePciCfg2Write S3BootScriptSaveSmbusExecute S3BootScriptSaveInformation S3BootScriptSaveInformationAsciiString S3BootScriptLabel (happen in S3BootScriptLabelInternal()) possible numeric truncations will happen that may lead to S3 boot script entry with improper size being returned to store the boot script data. This commit will add checks to prevent this kind of issue. Please note that the remaining S3BootScriptLib APIs: S3BootScriptSaveIoReadWrite S3BootScriptSaveMemReadWrite S3BootScriptSavePciCfgReadWrite S3BootScriptSavePciCfg2ReadWrite S3BootScriptSaveStall S3BootScriptSaveDispatch2 S3BootScriptSaveDispatch S3BootScriptSaveMemPoll S3BootScriptSaveIoPoll S3BootScriptSavePciPoll S3BootScriptSavePci2Poll S3BootScriptCloseTable S3BootScriptExecute S3BootScriptMoveLastOpcode S3BootScriptCompare are not affected by such numeric truncation. Signed-off-by: Hao A Wu <[email protected]> Reviewed-by: Laszlo Ersek <[email protected]> Reviewed-by: Eric Dong <[email protected]> Acked-by: Jian J Wang <[email protected]>
authority_cert_dup(authority_cert_t *cert) { authority_cert_t *out = tor_malloc(sizeof(authority_cert_t)); tor_assert(cert); memcpy(out, cert, sizeof(authority_cert_t)); /* Now copy pointed-to things. */ out->cache_info.signed_descriptor_body = tor_strndup(cert->cache_info.signed_descriptor_body, cert->cache_info.signed_descriptor_len); out->cache_info.saved_location = SAVED_NOWHERE; out->identity_key = crypto_pk_dup_key(cert->identity_key); out->signing_key = crypto_pk_dup_key(cert->signing_key); return out; }
0
[]
tor
973c18bf0e84d14d8006a9ae97fde7f7fb97e404
120,210,053,465,161,470,000,000,000,000,000,000,000
16
Fix assertion failure in tor_timegm. Fixes bug 6811.
PrepareRowForJpeg24(rfbClientPtr cl, uint8_t *dst, int x, int y, int count) { uint32_t *fbptr; uint32_t pix; fbptr = (uint32_t *) &cl->scaledScreen->frameBuffer[y * cl->scaledScreen->paddedWidthInBytes + x * 4]; while (count--) { pix = *fbptr++; *dst++ = (uint8_t)(pix >> cl->screen->serverFormat.redShift); *dst++ = (uint8_t)(pix >> cl->screen->serverFormat.greenShift); *dst++ = (uint8_t)(pix >> cl->screen->serverFormat.blueShift); } }
0
[]
libvncserver
804335f9d296440bb708ca844f5d89b58b50b0c6
243,152,270,095,818,230,000,000,000,000,000,000,000
19
Thread safety for zrle, zlib, tight. Proposed tight security type fix for debian bug 517422.
static void *genlocaldata(void *_gt,int32 *len) { GTextField *gt = _gt; unichar_t *temp =u_copyn(gt->text+gt->sel_start,gt->sel_end-gt->sel_start); char *ret = u2def_copy(temp); free(temp); *len = strlen(ret); return( ret ); }
0
[ "CWE-119", "CWE-787" ]
fontforge
626f751752875a0ddd74b9e217b6f4828713573c
38,723,697,737,586,907,000,000,000,000,000,000,000
8
Warn users before discarding their unsaved scripts (#3852) * Warn users before discarding their unsaved scripts This closes #3846.
static int compare_vavail(const void *v1, const void *v2) { struct vavailability *a = (struct vavailability *) v1; struct vavailability *b = (struct vavailability *) v2; int r = a->priority - b->priority; if (r == 0) { r = icaltime_compare(a->per.start, b->per.start); if (r == 0) r = icaltime_compare(a->per.end, b->per.end); } return r; }
0
[ "CWE-787" ]
cyrus-imapd
a5779db8163b99463e25e7c476f9cbba438b65f3
5,702,954,791,148,625,000,000,000,000,000,000,000
15
HTTP: don't overrun buffer when parsing strings with sscanf()
void cil_destroy_bounds(struct cil_bounds *bounds) { if (bounds == NULL) { return; } free(bounds); }
0
[ "CWE-125" ]
selinux
340f0eb7f3673e8aacaf0a96cbfcd4d12a405521
268,863,753,618,851,320,000,000,000,000,000,000,000
8
libsepol/cil: Check for statements not allowed in optional blocks While there are some checks for invalid statements in an optional block when resolving the AST, there are no checks when building the AST. OSS-Fuzz found the following policy which caused a null dereference in cil_tree_get_next_path(). (blockinherit b3) (sid SID) (sidorder(SID)) (optional o (ibpkeycon :(1 0)s) (block b3 (filecon""block()) (filecon""block()))) The problem is that the blockinherit copies block b3 before the optional block is disabled. When the optional is disabled, block b3 is deleted along with everything else in the optional. Later, when filecon statements with the same path are found an error message is produced and in trying to find out where the block was copied from, the reference to the deleted block is used. The error handling code assumes (rightly) that if something was copied from a block then that block should still exist. It is clear that in-statements, blocks, and macros cannot be in an optional, because that allows nodes to be copied from the optional block to somewhere outside even though the optional could be disabled later. When optionals are disabled the AST is reset and the resolution is restarted at the point of resolving macro calls, so anything resolved before macro calls will never be re-resolved. This includes tunableifs, in-statements, blockinherits, blockabstracts, and macro definitions. Tunable declarations also cannot be in an optional block because they are needed to resolve tunableifs. It should be fine to allow blockinherit statements in an optional, because that is copying nodes from outside the optional to the optional and if the optional is later disabled, everything will be deleted anyway. Check and quit with an error if a tunable declaration, in-statement, block, blockabstract, or macro definition is found within an optional when either building or resolving the AST. Signed-off-by: James Carter <[email protected]>