func
stringlengths
0
484k
target
int64
0
1
cwe
sequencelengths
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
bytes_endswith(PyBytesObject *self, PyObject *args) { Py_ssize_t start = 0; Py_ssize_t end = PY_SSIZE_T_MAX; PyObject *subobj; int result; if (!stringlib_parse_args_finds("endswith", args, &subobj, &start, &end)) return NULL; if (PyTuple_Check(subobj)) { Py_ssize_t i; for (i = 0; i < PyTuple_GET_SIZE(subobj); i++) { result = _bytes_tailmatch(self, PyTuple_GET_ITEM(subobj, i), start, end, +1); if (result == -1) return NULL; else if (result) { Py_RETURN_TRUE; } } Py_RETURN_FALSE; } result = _bytes_tailmatch(self, subobj, start, end, +1); if (result == -1) { if (PyErr_ExceptionMatches(PyExc_TypeError)) PyErr_Format(PyExc_TypeError, "endswith first arg must be bytes or " "a tuple of bytes, not %s", Py_TYPE(subobj)->tp_name); return NULL; } else return PyBool_FromLong(result); }
0
[ "CWE-190" ]
cpython
6c004b40f9d51872d848981ef1a18bb08c2dfc42
208,420,141,286,427,560,000,000,000,000,000,000,000
33
bpo-30657: Fix CVE-2017-1000158 (#4758) Fixes possible integer overflow in PyBytes_DecodeEscape. Co-Authored-By: Jay Bosamiya <[email protected]>
onigenc_property_list_init(int (*f)(void)) { int r; THREAD_ATOMIC_START; r = f(); THREAD_ATOMIC_END; return r; }
0
[ "CWE-125" ]
oniguruma
65a9b1aa03c9bc2dc01b074295b9603232cb3b78
75,743,235,336,749,840,000,000,000,000,000,000,000
11
onig-5.9.2
struct dentry *lookup_one_len(const char *name, struct dentry *base, int len) { int err; struct qstr this; WARN_ON_ONCE(!mutex_is_locked(&base->d_inode->i_mutex)); err = __lookup_one_len(name, &this, base, len); if (err) return ERR_PTR(err); err = exec_permission(base->d_inode); if (err) return ERR_PTR(err); return __lookup_hash(&this, base, NULL); }
0
[ "CWE-20", "CWE-362", "CWE-416" ]
linux
86acdca1b63e6890540fa19495cfc708beff3d8b
295,679,184,804,565,600,000,000,000,000,000,000,000
16
fix autofs/afs/etc. magic mountpoint breakage We end up trying to kfree() nd.last.name on open("/mnt/tmp", O_CREAT) if /mnt/tmp is an autofs direct mount. The reason is that nd.last_type is bogus here; we want LAST_BIND for everything of that kind and we get LAST_NORM left over from finding parent directory. So make sure that it *is* set properly; set to LAST_BIND before doing ->follow_link() - for normal symlinks it will be changed by __vfs_follow_link() and everything else needs it set that way. Signed-off-by: Al Viro <[email protected]>
encode_saved_post_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp) { /* Attributes to follow */ *p++ = xdr_one; return encode_fattr3(rqstp, p, fhp, &fhp->fh_post_attr); }
0
[ "CWE-119", "CWE-703" ]
linux
13bf9fbff0e5e099e2b6f003a0ab8ae145436309
231,241,847,946,335,870,000,000,000,000,000,000,000
6
nfsd: stricter decoding of write-like NFSv2/v3 ops The NFSv2/v3 code does not systematically check whether we decode past the end of the buffer. This generally appears to be harmless, but there are a few places where we do arithmetic on the pointers involved and don't account for the possibility that a length could be negative. Add checks to catch these. Reported-by: Tuomas Haanpää <[email protected]> Reported-by: Ari Kauppi <[email protected]> Reviewed-by: NeilBrown <[email protected]> Cc: [email protected] Signed-off-by: J. Bruce Fields <[email protected]>
static int _CheckProbablePrime(mp_int* p, mp_int* q, mp_int* e, int nlen, int* isPrime, WC_RNG* rng) { int ret; mp_int tmp1, tmp2; mp_int* prime; if (p == NULL || e == NULL || isPrime == NULL) return BAD_FUNC_ARG; if (!RsaSizeCheck(nlen)) return BAD_FUNC_ARG; *isPrime = MP_NO; if (q != NULL) { /* 5.4 - check that |p-q| <= (2^(1/2))(2^((nlen/2)-1)) */ ret = wc_CompareDiffPQ(p, q, nlen); if (ret != MP_OKAY) goto notOkay; prime = q; } else prime = p; ret = mp_init_multi(&tmp1, &tmp2, NULL, NULL, NULL, NULL); if (ret != MP_OKAY) goto notOkay; /* 4.4,5.5 - Check that prime >= (2^(1/2))(2^((nlen/2)-1)) * This is a comparison against lowerBound */ ret = mp_read_unsigned_bin(&tmp1, lower_bound, nlen/16); if (ret != MP_OKAY) goto notOkay; ret = mp_cmp(prime, &tmp1); if (ret == MP_LT) goto exit; /* 4.5,5.6 - Check that GCD(p-1, e) == 1 */ ret = mp_sub_d(prime, 1, &tmp1); /* tmp1 = prime-1 */ if (ret != MP_OKAY) goto notOkay; ret = mp_gcd(&tmp1, e, &tmp2); /* tmp2 = gcd(prime-1, e) */ if (ret != MP_OKAY) goto notOkay; ret = mp_cmp_d(&tmp2, 1); if (ret != MP_EQ) goto exit; /* e divides p-1 */ /* 4.5.1,5.6.1 - Check primality of p with 8 rounds of M-R. * mp_prime_is_prime_ex() performs test divisions against the first 256 * prime numbers. After that it performs 8 rounds of M-R using random * bases between 2 and n-2. * mp_prime_is_prime() performs the same test divisions and then does * M-R with the first 8 primes. Both functions set isPrime as a * side-effect. */ if (rng != NULL) ret = mp_prime_is_prime_ex(prime, 8, isPrime, rng); else ret = mp_prime_is_prime(prime, 8, isPrime); if (ret != MP_OKAY) goto notOkay; exit: ret = MP_OKAY; notOkay: mp_clear(&tmp1); mp_clear(&tmp2); return ret; }
0
[ "CWE-310", "CWE-787" ]
wolfssl
fb2288c46dd4c864b78f00a47a364b96a09a5c0f
108,067,576,018,157,480,000,000,000,000,000,000,000
62
RSA-PSS: Handle edge case with encoding message to hash When the key is small relative to the digest (1024-bit key, 64-byte hash, 61-byte salt length), the internal message to hash is larger than the output size. Allocate a buffer for the message when this happens.
static inline char *airo_translate_scan(struct net_device *dev, struct iw_request_info *info, char *current_ev, char *end_buf, BSSListRid *bss) { struct airo_info *ai = dev->ml_priv; struct iw_event iwe; /* Temporary buffer */ __le16 capabilities; char * current_val; /* For rates */ int i; char * buf; u16 dBm; /* First entry *MUST* be the AP MAC address */ iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN); current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN); /* Other entries will be displayed in the order we give them */ /* Add the ESSID */ iwe.u.data.length = bss->ssidLen; if(iwe.u.data.length > 32) iwe.u.data.length = 32; iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, bss->ssid); /* Add mode */ iwe.cmd = SIOCGIWMODE; capabilities = bss->cap; if(capabilities & (CAP_ESS | CAP_IBSS)) { if(capabilities & CAP_ESS) iwe.u.mode = IW_MODE_MASTER; else iwe.u.mode = IW_MODE_ADHOC; current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN); } /* Add frequency */ iwe.cmd = SIOCGIWFREQ; iwe.u.freq.m = le16_to_cpu(bss->dsChannel); iwe.u.freq.m = ieee80211_dsss_chan_to_freq(iwe.u.freq.m) * 100000; iwe.u.freq.e = 1; current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); dBm = le16_to_cpu(bss->dBm); /* Add quality statistics */ iwe.cmd = IWEVQUAL; if (ai->rssi) { iwe.u.qual.level = 0x100 - dBm; iwe.u.qual.qual = airo_dbm_to_pct(ai->rssi, dBm); iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_DBM; } else { iwe.u.qual.level = (dBm + 321) / 2; iwe.u.qual.qual = 0; iwe.u.qual.updated = IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_UPDATED | IW_QUAL_DBM; } iwe.u.qual.noise = ai->wstats.qual.noise; current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); /* Add encryption capability */ iwe.cmd = SIOCGIWENCODE; if(capabilities & CAP_PRIVACY) iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; else iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.length = 0; current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, bss->ssid); /* Rate : stuffing multiple values in a single event require a bit * more of magic - Jean II */ current_val = current_ev + iwe_stream_lcp_len(info); iwe.cmd = SIOCGIWRATE; /* Those two flags are ignored... */ iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; /* Max 8 values */ for(i = 0 ; i < 8 ; i++) { /* NULL terminated */ if(bss->rates[i] == 0) break; /* Bit rate given in 500 kb/s units (+ 0x80) */ iwe.u.bitrate.value = ((bss->rates[i] & 0x7f) * 500000); /* Add new value to event */ current_val = iwe_stream_add_value(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); } /* Check if we added any event */ if ((current_val - current_ev) > iwe_stream_lcp_len(info)) current_ev = current_val; /* Beacon interval */ buf = kmalloc(30, GFP_KERNEL); if (buf) { iwe.cmd = IWEVCUSTOM; sprintf(buf, "bcn_int=%d", bss->beaconInterval); iwe.u.data.length = strlen(buf); current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, buf); kfree(buf); } /* Put WPA/RSN Information Elements into the event stream */ if (test_bit(FLAG_WPA_CAPABLE, &ai->flags)) { unsigned int num_null_ies = 0; u16 length = sizeof (bss->extra.iep); u8 *ie = (void *)&bss->extra.iep; while ((length >= 2) && (num_null_ies < 2)) { if (2 + ie[1] > length) { /* Invalid element, don't continue parsing IE */ break; } switch (ie[0]) { case WLAN_EID_SSID: /* Two zero-length SSID elements * mean we're done parsing elements */ if (!ie[1]) num_null_ies++; break; case WLAN_EID_GENERIC: if (ie[1] >= 4 && ie[2] == 0x00 && ie[3] == 0x50 && ie[4] == 0xf2 && ie[5] == 0x01) { iwe.cmd = IWEVGENIE; /* 64 is an arbitrary cut-off */ iwe.u.data.length = min(ie[1] + 2, 64); current_ev = iwe_stream_add_point( info, current_ev, end_buf, &iwe, ie); } break; case WLAN_EID_RSN: iwe.cmd = IWEVGENIE; /* 64 is an arbitrary cut-off */ iwe.u.data.length = min(ie[1] + 2, 64); current_ev = iwe_stream_add_point( info, current_ev, end_buf, &iwe, ie); break; default: break; } length -= 2 + ie[1]; ie += 2 + ie[1]; } } return current_ev; }
0
[ "CWE-703", "CWE-264" ]
linux
550fd08c2cebad61c548def135f67aba284c6162
38,763,920,059,871,040,000,000,000,000,000,000,000
172
net: Audit drivers to identify those needing IFF_TX_SKB_SHARING cleared After the last patch, We are left in a state in which only drivers calling ether_setup have IFF_TX_SKB_SHARING set (we assume that drivers touching real hardware call ether_setup for their net_devices and don't hold any state in their skbs. There are a handful of drivers that violate this assumption of course, and need to be fixed up. This patch identifies those drivers, and marks them as not being able to support the safe transmission of skbs by clearning the IFF_TX_SKB_SHARING flag in priv_flags Signed-off-by: Neil Horman <[email protected]> CC: Karsten Keil <[email protected]> CC: "David S. Miller" <[email protected]> CC: Jay Vosburgh <[email protected]> CC: Andy Gospodarek <[email protected]> CC: Patrick McHardy <[email protected]> CC: Krzysztof Halasa <[email protected]> CC: "John W. Linville" <[email protected]> CC: Greg Kroah-Hartman <[email protected]> CC: Marcel Holtmann <[email protected]> CC: Johannes Berg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
void G_NORETURN do_raise_exception(CPULoongArchState *env, uint32_t exception, uintptr_t pc) { CPUState *cs = env_cpu(env); qemu_log_mask(CPU_LOG_INT, "%s: %d (%s)\n", __func__, exception, loongarch_exception_name(exception)); cs->exception_index = exception; cpu_loop_exit_restore(cs, pc); }
0
[]
qemu
3517fb726741c109cae7995f9ea46f0cab6187d6
285,871,588,490,941,750,000,000,000,000,000,000,000
14
target/loongarch: Clean up tlb when cpu reset We should make sure that tlb is clean when cpu reset. Signed-off-by: Song Gao <[email protected]> Message-Id: <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Richard Henderson <[email protected]>
BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style) { gdPoint pts[3]; int i; int lx = 0, ly = 0; int fx = 0, fy = 0; while (e < s) { e += 360; } for (i = s; (i <= e); i++) { int x, y; x = ((long) gdCosT[i % 360] * (long) w / (2 * 1024)) + cx; y = ((long) gdSinT[i % 360] * (long) h / (2 * 1024)) + cy; if (i != s) { if (!(style & gdChord)) { if (style & gdNoFill) { gdImageLine (im, lx, ly, x, y, color); } else { /* This is expensive! */ pts[0].x = lx; pts[0].y = ly; pts[1].x = x; pts[1].y = y; pts[2].x = cx; pts[2].y = cy; gdImageFilledPolygon (im, pts, 3, color); } } } else { fx = x; fy = y; } lx = x; ly = y; } if (style & gdChord) { if (style & gdNoFill) { if (style & gdEdged) { gdImageLine (im, cx, cy, lx, ly, color); gdImageLine (im, cx, cy, fx, fy, color); } gdImageLine (im, fx, fy, lx, ly, color); } else { pts[0].x = fx; pts[0].y = fy; pts[1].x = lx; pts[1].y = ly; pts[2].x = cx; pts[2].y = cy; gdImageFilledPolygon (im, pts, 3, color); } } else { if (style & gdNoFill) { if (style & gdEdged) { gdImageLine (im, cx, cy, lx, ly, color); gdImageLine (im, cx, cy, fx, fy, color); } } } }
0
[ "CWE-190" ]
libgd
cfee163a5e848fc3e3fb1d05a30d7557cdd36457
96,534,295,436,773,140,000,000,000,000,000,000,000
79
- #18, Removed invalid gdFree call when overflow2 fails - #17, Free im->pixels as well on error
wait_queue_func_t wake_func) __acquires(&ctx->completion_lock) { struct io_ring_ctx *ctx = req->ctx; bool cancel = false; INIT_HLIST_NODE(&req->hash_node); io_init_poll_iocb(poll, mask, wake_func); poll->file = req->file; poll->wait.private = req; ipt->pt._key = mask; ipt->req = req; ipt->error = -EINVAL; mask = vfs_poll(req->file, &ipt->pt) & poll->events; spin_lock_irq(&ctx->completion_lock); if (likely(poll->head)) { spin_lock(&poll->head->lock); if (unlikely(list_empty(&poll->wait.entry))) { if (ipt->error) cancel = true; ipt->error = 0; mask = 0; } if (mask || ipt->error) list_del_init(&poll->wait.entry); else if (cancel) WRITE_ONCE(poll->canceled, true); else if (!poll->done) /* actually waiting for an event */ io_poll_req_insert(req); spin_unlock(&poll->head->lock); } return mask;
0
[ "CWE-667" ]
linux
3ebba796fa251d042be42b929a2d916ee5c34a49
294,033,056,259,307,220,000,000,000,000,000,000,000
36
io_uring: ensure that SQPOLL thread is started for exit If we create it in a disabled state because IORING_SETUP_R_DISABLED is set on ring creation, we need to ensure that we've kicked the thread if we're exiting before it's been explicitly disabled. Otherwise we can run into a deadlock where exit is waiting go park the SQPOLL thread, but the SQPOLL thread itself is waiting to get a signal to start. That results in the below trace of both tasks hung, waiting on each other: INFO: task syz-executor458:8401 blocked for more than 143 seconds. Not tainted 5.11.0-next-20210226-syzkaller #0 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. task:syz-executor458 state:D stack:27536 pid: 8401 ppid: 8400 flags:0x00004004 Call Trace: context_switch kernel/sched/core.c:4324 [inline] __schedule+0x90c/0x21a0 kernel/sched/core.c:5075 schedule+0xcf/0x270 kernel/sched/core.c:5154 schedule_timeout+0x1db/0x250 kernel/time/timer.c:1868 do_wait_for_common kernel/sched/completion.c:85 [inline] __wait_for_common kernel/sched/completion.c:106 [inline] wait_for_common kernel/sched/completion.c:117 [inline] wait_for_completion+0x168/0x270 kernel/sched/completion.c:138 io_sq_thread_park fs/io_uring.c:7115 [inline] io_sq_thread_park+0xd5/0x130 fs/io_uring.c:7103 io_uring_cancel_task_requests+0x24c/0xd90 fs/io_uring.c:8745 __io_uring_files_cancel+0x110/0x230 fs/io_uring.c:8840 io_uring_files_cancel include/linux/io_uring.h:47 [inline] do_exit+0x299/0x2a60 kernel/exit.c:780 do_group_exit+0x125/0x310 kernel/exit.c:922 __do_sys_exit_group kernel/exit.c:933 [inline] __se_sys_exit_group kernel/exit.c:931 [inline] __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:931 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x43e899 RSP: 002b:00007ffe89376d48 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 RAX: ffffffffffffffda RBX: 00000000004af2f0 RCX: 000000000043e899 RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000 RBP: 0000000000000000 R08: ffffffffffffffc0 R09: 0000000010000000 R10: 0000000000008011 R11: 0000000000000246 R12: 00000000004af2f0 R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001 INFO: task iou-sqp-8401:8402 can't die for more than 143 seconds. task:iou-sqp-8401 state:D stack:30272 pid: 8402 ppid: 8400 flags:0x00004004 Call Trace: context_switch kernel/sched/core.c:4324 [inline] __schedule+0x90c/0x21a0 kernel/sched/core.c:5075 schedule+0xcf/0x270 kernel/sched/core.c:5154 schedule_timeout+0x1db/0x250 kernel/time/timer.c:1868 do_wait_for_common kernel/sched/completion.c:85 [inline] __wait_for_common kernel/sched/completion.c:106 [inline] wait_for_common kernel/sched/completion.c:117 [inline] wait_for_completion+0x168/0x270 kernel/sched/completion.c:138 io_sq_thread+0x27d/0x1ae0 fs/io_uring.c:6717 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 INFO: task iou-sqp-8401:8402 blocked for more than 143 seconds. Reported-by: [email protected] Signed-off-by: Jens Axboe <[email protected]>
static inline void inode_inc_dirty_pages(struct inode *inode) { atomic_inc(&F2FS_I(inode)->dirty_pages); inc_page_count(F2FS_I_SB(inode), S_ISDIR(inode->i_mode) ? F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA); if (IS_NOQUOTA(inode)) inc_page_count(F2FS_I_SB(inode), F2FS_DIRTY_QDATA); }
0
[ "CWE-476" ]
linux
4969c06a0d83c9c3dc50b8efcdc8eeedfce896f6
18,403,420,714,968,396,000,000,000,000,000,000,000
8
f2fs: support swap file w/ DIO Signed-off-by: Jaegeuk Kim <[email protected]>
static void xen_irq_lateeoi_worker(struct work_struct *work) { struct lateeoi_work *eoi; struct irq_info *info; u64 now = get_jiffies_64(); unsigned long flags; eoi = container_of(to_delayed_work(work), struct lateeoi_work, delayed); read_lock_irqsave(&evtchn_rwlock, flags); while (true) { spin_lock(&eoi->eoi_list_lock); info = list_first_entry_or_null(&eoi->eoi_list, struct irq_info, eoi_list); if (info == NULL || now < info->eoi_time) { spin_unlock(&eoi->eoi_list_lock); break; } list_del_init(&info->eoi_list); spin_unlock(&eoi->eoi_list_lock); info->eoi_time = 0; xen_irq_lateeoi_locked(info); } if (info) mod_delayed_work_on(info->eoi_cpu, system_wq, &eoi->delayed, info->eoi_time - now); read_unlock_irqrestore(&evtchn_rwlock, flags); }
0
[ "CWE-400", "CWE-703" ]
linux
e99502f76271d6bc4e374fe368c50c67a1fd3070
153,065,748,111,080,280,000,000,000,000,000,000,000
37
xen/events: defer eoi in case of excessive number of events In case rogue guests are sending events at high frequency it might happen that xen_evtchn_do_upcall() won't stop processing events in dom0. As this is done in irq handling a crash might be the result. In order to avoid that, delay further inter-domain events after some time in xen_evtchn_do_upcall() by forcing eoi processing into a worker on the same cpu, thus inhibiting new events coming in. The time after which eoi processing is to be delayed is configurable via a new module parameter "event_loop_timeout" which specifies the maximum event loop time in jiffies (default: 2, the value was chosen after some tests showing that a value of 2 was the lowest with an only slight drop of dom0 network throughput while multiple guests performed an event storm). How long eoi processing will be delayed can be specified via another parameter "event_eoi_delay" (again in jiffies, default 10, again the value was chosen after testing with different delay values). This is part of XSA-332. Cc: [email protected] Reported-by: Julien Grall <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Stefano Stabellini <[email protected]> Reviewed-by: Wei Liu <[email protected]>
ServerConnectionImpl::ServerConnectionImpl( Network::Connection& connection, CodecStats& stats, ServerConnectionCallbacks& callbacks, const Http1Settings& settings, uint32_t max_request_headers_kb, const uint32_t max_request_headers_count, envoy::config::core::v3::HttpProtocolOptions::HeadersWithUnderscoresAction headers_with_underscores_action) : ConnectionImpl(connection, stats, settings, MessageType::Request, max_request_headers_kb, max_request_headers_count), callbacks_(callbacks), response_buffer_releasor_([this](const Buffer::OwnedBufferFragmentImpl* fragment) { releaseOutboundResponse(fragment); }), headers_with_underscores_action_(headers_with_underscores_action), runtime_lazy_read_disable_( Runtime::runtimeFeatureEnabled("envoy.reloadable_features.http1_lazy_read_disable")) {}
0
[ "CWE-416" ]
envoy
fe7c69c248f4fe5a9080c7ccb35275b5218bb5ab
140,570,120,716,679,240,000,000,000,000,000,000,000
15
internal redirect: fix a lifetime bug (#785) Signed-off-by: Alyssa Wilk <[email protected]> Signed-off-by: Matt Klein <[email protected]> Signed-off-by: Pradeep Rao <[email protected]>
const HeaderEntryImpl* const* constInlineHeaders() const override { return inline_headers_; }
0
[]
envoy
2c60632d41555ec8b3d9ef5246242be637a2db0f
46,873,336,958,220,160,000,000,000,000,000,000,000
1
http: header map security fixes for duplicate headers (#197) Previously header matching did not match on all headers for non-inline headers. This patch changes the default behavior to always logically match on all headers. Multiple individual headers will be logically concatenated with ',' similar to what is done with inline headers. This makes the behavior effectively consistent. This behavior can be temporary reverted by setting the runtime value "envoy.reloadable_features.header_match_on_all_headers" to "false". Targeted fixes have been additionally performed on the following extensions which make them consider all duplicate headers by default as a comma concatenated list: 1) Any extension using CEL matching on headers. 2) The header to metadata filter. 3) The JWT filter. 4) The Lua filter. Like primary header matching used in routing, RBAC, etc. this behavior can be disabled by setting the runtime value "envoy.reloadable_features.header_match_on_all_headers" to false. Finally, the setCopy() header map API previously only set the first header in the case of duplicate non-inline headers. setCopy() now behaves similiarly to the other set*() APIs and replaces all found headers with a single value. This may have had security implications in the extauth filter which uses this API. This behavior can be disabled by setting the runtime value "envoy.reloadable_features.http_set_copy_replace_all_headers" to false. Fixes https://github.com/envoyproxy/envoy-setec/issues/188 Signed-off-by: Matt Klein <[email protected]>
test_commercial(int from, int to, double sg) { int j; fprintf(stderr, "test_commercial: %d...%d (%d) - %.0f\n", from, to, to - from, sg); for (j = from; j <= to; j++) { int y, w, d, rj, ns; c_jd_to_commercial(j, sg, &y, &w, &d); c_commercial_to_jd(y, w, d, sg, &rj, &ns); if (j != rj) { fprintf(stderr, "%d != %d\n", j, rj); return 0; } } return 1; }
0
[]
date
3959accef8da5c128f8a8e2fd54e932a4fb253b0
108,973,136,644,299,640,000,000,000,000,000,000,000
18
Add length limit option for methods that parses date strings `Date.parse` now raises an ArgumentError when a given date string is longer than 128. You can configure the limit by giving `limit` keyword arguments like `Date.parse(str, limit: 1000)`. If you pass `limit: nil`, the limit is disabled. Not only `Date.parse` but also the following methods are changed. * Date._parse * Date.parse * DateTime.parse * Date._iso8601 * Date.iso8601 * DateTime.iso8601 * Date._rfc3339 * Date.rfc3339 * DateTime.rfc3339 * Date._xmlschema * Date.xmlschema * DateTime.xmlschema * Date._rfc2822 * Date.rfc2822 * DateTime.rfc2822 * Date._rfc822 * Date.rfc822 * DateTime.rfc822 * Date._jisx0301 * Date.jisx0301 * DateTime.jisx0301
NTSTATUS change_dir_owner_to_parent(connection_struct *conn, const char *inherit_from_dir, const char *fname, SMB_STRUCT_STAT *psbuf) { struct smb_filename *smb_fname_parent; struct smb_filename *smb_fname_cwd = NULL; char *saved_dir = NULL; TALLOC_CTX *ctx = talloc_tos(); NTSTATUS status = NT_STATUS_OK; int ret; smb_fname_parent = synthetic_smb_fname(ctx, inherit_from_dir, NULL, NULL); if (smb_fname_parent == NULL) { return NT_STATUS_NO_MEMORY; } ret = SMB_VFS_STAT(conn, smb_fname_parent); if (ret == -1) { status = map_nt_error_from_unix(errno); DEBUG(0,("change_dir_owner_to_parent: failed to stat parent " "directory %s. Error was %s\n", smb_fname_str_dbg(smb_fname_parent), strerror(errno))); goto out; } /* We've already done an lstat into psbuf, and we know it's a directory. If we can cd into the directory and the dev/ino are the same then we can safely chown without races as we're locking the directory in place by being in it. This should work on any UNIX (thanks tridge :-). JRA. */ saved_dir = vfs_GetWd(ctx,conn); if (!saved_dir) { status = map_nt_error_from_unix(errno); DEBUG(0,("change_dir_owner_to_parent: failed to get " "current working directory. Error was %s\n", strerror(errno))); goto out; } /* Chdir into the new path. */ if (vfs_ChDir(conn, fname) == -1) { status = map_nt_error_from_unix(errno); DEBUG(0,("change_dir_owner_to_parent: failed to change " "current working directory to %s. Error " "was %s\n", fname, strerror(errno) )); goto chdir; } smb_fname_cwd = synthetic_smb_fname(ctx, ".", NULL, NULL); if (smb_fname_cwd == NULL) { status = NT_STATUS_NO_MEMORY; goto chdir; } ret = SMB_VFS_STAT(conn, smb_fname_cwd); if (ret == -1) { status = map_nt_error_from_unix(errno); DEBUG(0,("change_dir_owner_to_parent: failed to stat " "directory '.' (%s) Error was %s\n", fname, strerror(errno))); goto chdir; } /* Ensure we're pointing at the same place. */ if (smb_fname_cwd->st.st_ex_dev != psbuf->st_ex_dev || smb_fname_cwd->st.st_ex_ino != psbuf->st_ex_ino) { DEBUG(0,("change_dir_owner_to_parent: " "device/inode on directory %s changed. " "Refusing to chown !\n", fname )); status = NT_STATUS_ACCESS_DENIED; goto chdir; } if (smb_fname_parent->st.st_ex_uid == smb_fname_cwd->st.st_ex_uid) { /* Already this uid - no need to change. */ DEBUG(10,("change_dir_owner_to_parent: directory %s " "is already owned by uid %d\n", fname, (int)smb_fname_cwd->st.st_ex_uid )); status = NT_STATUS_OK; goto chdir; } become_root(); ret = SMB_VFS_LCHOWN(conn, ".", smb_fname_parent->st.st_ex_uid, (gid_t)-1); unbecome_root(); if (ret == -1) { status = map_nt_error_from_unix(errno); DEBUG(10,("change_dir_owner_to_parent: failed to chown " "directory %s to parent directory uid %u. " "Error was %s\n", fname, (unsigned int)smb_fname_parent->st.st_ex_uid, strerror(errno) )); } else { DEBUG(10,("change_dir_owner_to_parent: changed ownership of new " "directory %s to parent directory uid %u.\n", fname, (unsigned int)smb_fname_parent->st.st_ex_uid )); /* Ensure the uid entry is updated. */ psbuf->st_ex_uid = smb_fname_parent->st.st_ex_uid; } chdir: vfs_ChDir(conn,saved_dir); out: TALLOC_FREE(smb_fname_parent); TALLOC_FREE(smb_fname_cwd); return status; }
0
[]
samba
60f922bf1bd8816eacbb32c24793ad1f97a1d9f2
272,803,414,130,482,330,000,000,000,000,000,000,000
114
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]>
s_realloc(STREAM s, unsigned int size) { unsigned char *data; if (s->size >= size) return; data = s->data; s->size = size; s->data = xrealloc(data, size); s->p = s->data + (s->p - data); s->end = s->data + (s->end - data); s->iso_hdr = s->data + (s->iso_hdr - data); s->mcs_hdr = s->data + (s->mcs_hdr - data); s->sec_hdr = s->data + (s->sec_hdr - data); s->rdp_hdr = s->data + (s->rdp_hdr - data); s->channel_hdr = s->data + (s->channel_hdr - data); }
0
[ "CWE-787" ]
rdesktop
766ebcf6f23ccfe8323ac10242ae6e127d4505d2
41,690,056,435,900,485,000,000,000,000,000,000,000
18
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
mail_config_ews_autodiscover_finish (EMailConfigEwsAutodiscover *autodiscover, GAsyncResult *result, GError **error) { g_return_val_if_fail (E_IS_MAIL_CONFIG_EWS_AUTODISCOVER (autodiscover), FALSE); g_return_val_if_fail (g_task_is_valid (result, autodiscover), FALSE); g_return_val_if_fail ( g_async_result_is_tagged ( result, mail_config_ews_autodiscover_finish), FALSE); return g_task_propagate_boolean (G_TASK (result), error); }
0
[ "CWE-295" ]
evolution-ews
915226eca9454b8b3e5adb6f2fff9698451778de
294,497,030,143,028,800,000,000,000,000,000,000,000
13
I#27 - SSL Certificates are not validated This depends on https://gitlab.gnome.org/GNOME/evolution-data-server/commit/6672b8236139bd6ef41ecb915f4c72e2a052dba5 too. Closes https://gitlab.gnome.org/GNOME/evolution-ews/issues/27
GnashImage::update(const GnashImage& from) { assert(size() <= from.size()); assert(width() == from.width()); assert(_type == from._type); assert(_location == from._location); std::copy(from.begin(), from.begin() + size(), begin()); }
0
[ "CWE-189" ]
gnash
bb4dc77eecb6ed1b967e3ecbce3dac6c5e6f1527
112,068,796,737,103,110,000,000,000,000,000,000,000
8
Fix crash in GnashImage.cpp
void _cgsem_post(cgsem_t *cgsem, const char *file, const char *func, const int line) { if (unlikely(sem_post(cgsem))) quitfrom(1, file, func, line, "Failed to sem_post errno=%d cgsem=0x%p", errno, cgsem); }
0
[ "CWE-20", "CWE-703" ]
sgminer
910c36089940e81fb85c65b8e63dcd2fac71470c
150,911,101,616,240,290,000,000,000,000,000,000,000
5
stratum: parse_notify(): Don't die on malformed bbversion/prev_hash/nbit/ntime. Might have introduced a memory leak, don't have time to check. :( Should the other hex2bin()'s be checked? Thanks to Mick Ayzenberg <mick.dejavusecurity.com> for finding this.
static int __init algif_skcipher_init(void) { return af_alg_register_type(&algif_type_skcipher); }
0
[]
linux-stable
36c84b22ac8aa041cbdfbe48a55ebb32e3521704
181,383,551,447,311,860,000,000,000,000,000,000,000
4
crypto: algif_skcipher - Load TX SG list after waiting commit 4f0414e54e4d1893c6f08260693f8ef84c929293 upstream. We need to load the TX SG list in sendmsg(2) after waiting for incoming data, not before. [[email protected]: backport to 3.18, where the relevant logic is located in skcipher_recvmsg() rather than skcipher_recvmsg_sync()] Reported-by: Dmitry Vyukov <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Tested-by: Dmitry Vyukov <[email protected]> Signed-off-by: Connor O'Brien <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
static void ar6000_dump_skb(struct sk_buff *skb) { u_char *ch; for (ch = A_NETBUF_DATA(skb); (unsigned long)ch < ((unsigned long)A_NETBUF_DATA(skb) + A_NETBUF_LEN(skb)); ch++) { AR_DEBUG_PRINTF(ATH_DEBUG_WARN,("%2.2x ", *ch)); } AR_DEBUG_PRINTF(ATH_DEBUG_WARN,("\n")); }
0
[ "CWE-703", "CWE-264" ]
linux
550fd08c2cebad61c548def135f67aba284c6162
8,053,777,602,464,703,000,000,000,000,000,000,000
11
net: Audit drivers to identify those needing IFF_TX_SKB_SHARING cleared After the last patch, We are left in a state in which only drivers calling ether_setup have IFF_TX_SKB_SHARING set (we assume that drivers touching real hardware call ether_setup for their net_devices and don't hold any state in their skbs. There are a handful of drivers that violate this assumption of course, and need to be fixed up. This patch identifies those drivers, and marks them as not being able to support the safe transmission of skbs by clearning the IFF_TX_SKB_SHARING flag in priv_flags Signed-off-by: Neil Horman <[email protected]> CC: Karsten Keil <[email protected]> CC: "David S. Miller" <[email protected]> CC: Jay Vosburgh <[email protected]> CC: Andy Gospodarek <[email protected]> CC: Patrick McHardy <[email protected]> CC: Krzysztof Halasa <[email protected]> CC: "John W. Linville" <[email protected]> CC: Greg Kroah-Hartman <[email protected]> CC: Marcel Holtmann <[email protected]> CC: Johannes Berg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
vrrp_garp_lower_prio_delay_handler(vector_t *strvec) { unsigned delay; if (!read_unsigned_strvec(strvec, 1, &delay, 0, UINT_MAX / TIMER_HZ, true)) { report_config_error(CONFIG_GENERAL_ERROR, "vrrp_garp_lower_prio_delay '%s' invalid - ignoring", FMT_STR_VSLOT(strvec, 1)); return; } global_data->vrrp_garp_lower_prio_delay = delay * TIMER_HZ; }
0
[ "CWE-200" ]
keepalived
c6247a9ef2c7b33244ab1d3aa5d629ec49f0a067
325,105,297,574,892,180,000,000,000,000,000,000,000
11
Add command line and configuration option to set umask Issue #1048 identified that files created by keepalived are created with mode 0666. This commit changes the default to 0644, and also allows the umask to be specified in the configuration or as a command line option. Signed-off-by: Quentin Armitage <[email protected]>
gtl::InlinedVector<int64_t, 4> Tensor::ComputeFlatInnerDims( gtl::ArraySlice<int64_t> orig, int64_t num_out_dims) { gtl::InlinedVector<int64_t, 4> out_dims(num_out_dims, 0); int64_t offset = orig.size() - num_out_dims; for (int64_t out_dim = num_out_dims - 1; out_dim >= 0; --out_dim) { const int64_t in_dim = out_dim + offset; out_dims[out_dim] = in_dim < 0 ? 1 : orig[in_dim]; } for (int64_t in_dim = 0; in_dim < offset; ++in_dim) { out_dims[0] *= orig[in_dim]; } return out_dims; }
0
[ "CWE-345" ]
tensorflow
abcced051cb1bd8fb05046ac3b6023a7ebcc4578
316,821,629,390,329,260,000,000,000,000,000,000,000
13
Prevent crashes when loading tensor slices with unsupported types. Also fix the `Tensor(const TensorShape&)` constructor swapping the LOG(FATAL) messages for the unset and unsupported types. PiperOrigin-RevId: 392695027 Change-Id: I4beda7db950db951d273e3259a7c8534ece49354
server_begin_update(struct xrdp_mod* mod) { struct xrdp_wm* wm; struct xrdp_painter* p; wm = (struct xrdp_wm*)(mod->wm); p = xrdp_painter_create(wm, wm->session); xrdp_painter_begin_update(p); mod->painter = (long)p; return 0; }
0
[]
xrdp
d8f9e8310dac362bb9578763d1024178f94f4ecc
213,587,300,879,848,420,000,000,000,000,000,000,000
11
move temp files from /tmp to /tmp/.xrdp
onigenc_always_true_is_allowed_reverse_match(const UChar* s ARG_UNUSED, const UChar* end ARG_UNUSED, OnigEncoding enc ARG_UNUSED) { return TRUE; }
0
[ "CWE-125" ]
Onigmo
d4cf99d30bd5f6a8a4ababd0b9d7b06f3a479a24
92,224,516,615,198,360,000,000,000,000,000,000,000
6
Fix out-of-bounds read in parse_char_class() (Close #139) /[\x{111111}]/ causes out-of-bounds read when encoding is a single byte encoding. \x{111111} is an invalid codepoint for a single byte encoding. Check if it is a valid codepoint.
_TIFFrealloc(tdata_t p, tsize_t s) { return (realloc(p, (size_t) s)); }
0
[ "CWE-369" ]
libtiff
3c5eb8b1be544e41d2c336191bc4936300ad7543
36,989,333,131,225,386,000,000,000,000,000,000,000
4
* libtiff/tif_{unix,vms,win32}.c (_TIFFmalloc): ANSI C does not require malloc() to return NULL pointer if requested allocation size is zero. Assure that _TIFFmalloc does.
cbq_reclassify(struct sk_buff *skb, struct cbq_class *this) { struct cbq_class *cl, *new; for (cl = this->tparent; cl; cl = cl->tparent) if ((new = cl->defaults[TC_PRIO_BESTEFFORT]) != NULL && new != this) return new; return NULL; }
0
[ "CWE-200" ]
linux-2.6
8a47077a0b5aa2649751c46e7a27884e6686ccbf
175,723,691,329,629,100,000,000,000,000,000,000,000
10
[NETLINK]: Missing padding fields in dumped structures Plug holes with padding fields and initialized them to zero. Signed-off-by: Patrick McHardy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
gnutls_x509_crl_check_issuer (gnutls_x509_crl_t cert, gnutls_x509_crt_t issuer) { return is_crl_issuer (cert, issuer); }
0
[ "CWE-264" ]
gnutls
c8dcbedd1fdc312f5b1a70fcfbc1afe235d800cd
149,708,628,585,380,230,000,000,000,000,000,000,000
5
Corrected bit disable (was flipping instead). Initialy reported by Daniel Kahn Gillmor on 9/1/2008. Many thanks to [email protected] for bringing this into my attention.
int cipso_v4_doi_remove(u32 doi, struct netlbl_audit *audit_info) { int ret_val; struct cipso_v4_doi *doi_def; struct audit_buffer *audit_buf; spin_lock(&cipso_v4_doi_list_lock); doi_def = cipso_v4_doi_search(doi); if (!doi_def) { spin_unlock(&cipso_v4_doi_list_lock); ret_val = -ENOENT; goto doi_remove_return; } list_del_rcu(&doi_def->list); spin_unlock(&cipso_v4_doi_list_lock); cipso_v4_doi_putdef(doi_def); ret_val = 0; doi_remove_return: audit_buf = netlbl_audit_start(AUDIT_MAC_CIPSOV4_DEL, audit_info); if (audit_buf) { audit_log_format(audit_buf, " cipso_doi=%u res=%u", doi, ret_val == 0 ? 1 : 0); audit_log_end(audit_buf); } return ret_val; }
0
[ "CWE-416" ]
linux
ad5d07f4a9cd671233ae20983848874731102c08
199,657,537,084,405,800,000,000,000,000,000,000,000
30
cipso,calipso: resolve a number of problems with the DOI refcounts The current CIPSO and CALIPSO refcounting scheme for the DOI definitions is a bit flawed in that we: 1. Don't correctly match gets/puts in netlbl_cipsov4_list(). 2. Decrement the refcount on each attempt to remove the DOI from the DOI list, only removing it from the list once the refcount drops to zero. This patch fixes these problems by adding the missing "puts" to netlbl_cipsov4_list() and introduces a more conventional, i.e. not-buggy, refcounting mechanism to the DOI definitions. Upon the addition of a DOI to the DOI list, it is initialized with a refcount of one, removing a DOI from the list removes it from the list and drops the refcount by one; "gets" and "puts" behave as expected with respect to refcounts, increasing and decreasing the DOI's refcount by one. Fixes: b1edeb102397 ("netlabel: Replace protocol/NetLabel linking with refrerence counts") Fixes: d7cce01504a0 ("netlabel: Add support for removing a CALIPSO DOI.") Reported-by: [email protected] Signed-off-by: Paul Moore <[email protected]> Signed-off-by: David S. Miller <[email protected]>
PssEncode( TPM2B *out, // OUT: the encoded buffer TPM_ALG_ID hashAlg, // IN: hash algorithm for the encoding TPM2B *digest, // IN: the digest RAND_STATE *rand // IN: random number source ) { UINT32 hLen = CryptHashGetDigestSize(hashAlg); BYTE salt[MAX_RSA_KEY_BYTES - 1]; UINT16 saltSize; BYTE *ps = salt; BYTE *pOut; UINT16 mLen; HASH_STATE hashState; // These are fatal errors indicating bad TPM firmware pAssert(out != NULL && hLen > 0 && digest != NULL); // Get the size of the mask mLen = (UINT16)(out->size - hLen - 1); // Maximum possible salt size is mask length - 1 saltSize = mLen - 1; // Use the maximum salt size allowed by FIPS 186-4 if(saltSize > hLen) saltSize = (UINT16)hLen; //using eOut for scratch space // Set the first 8 bytes to zero pOut = out->buffer; memset(pOut, 0, 8); // Get set the salt DRBG_Generate(rand, salt, saltSize); // Create the hash of the pad || input hash || salt CryptHashStart(&hashState, hashAlg); CryptDigestUpdate(&hashState, 8, pOut); CryptDigestUpdate2B(&hashState, digest); CryptDigestUpdate(&hashState, saltSize, salt); CryptHashEnd(&hashState, hLen, &pOut[out->size - hLen - 1]); // Create a mask if(CryptMGF1(mLen, pOut, hashAlg, hLen, &pOut[mLen]) != mLen) FAIL(FATAL_ERROR_INTERNAL); // Since this implementation uses key sizes that are all even multiples of // 8, just need to make sure that the most significant bit is CLEAR *pOut &= 0x7f; // Before we mess up the pOut value, set the last byte to 0xbc pOut[out->size - 1] = 0xbc; // XOR a byte of 0x01 at the position just before where the salt will be XOR'ed pOut = &pOut[mLen - saltSize - 1]; *pOut++ ^= 0x01; // XOR the salt data into the buffer for(; saltSize > 0; saltSize--) *pOut++ ^= *ps++; // and we are done return TPM_RC_SUCCESS; }
0
[ "CWE-787" ]
libtpms
505ef841c00b4c096b1977c667cb957bec3a1d8b
139,051,390,016,035,180,000,000,000,000,000,000,000
52
tpm2: Fix output buffer parameter and size for RSA decyrption For the RSA decryption we have to use an output buffer of the size of the (largest possible) RSA key for the decryption to always work. This fixes a stack corruption bug that caused a SIGBUS and termination of 'swtpm'. Signed-off-by: Stefan Berger <[email protected]>
static int rpmsg_recv_single(struct virtproc_info *vrp, struct device *dev, struct rpmsg_hdr *msg, unsigned int len) { struct rpmsg_endpoint *ept; struct scatterlist sg; bool little_endian = virtio_is_little_endian(vrp->vdev); unsigned int msg_len = __rpmsg16_to_cpu(little_endian, msg->len); int err; dev_dbg(dev, "From: 0x%x, To: 0x%x, Len: %d, Flags: %d, Reserved: %d\n", __rpmsg32_to_cpu(little_endian, msg->src), __rpmsg32_to_cpu(little_endian, msg->dst), msg_len, __rpmsg16_to_cpu(little_endian, msg->flags), __rpmsg32_to_cpu(little_endian, msg->reserved)); #if defined(CONFIG_DYNAMIC_DEBUG) dynamic_hex_dump("rpmsg_virtio RX: ", DUMP_PREFIX_NONE, 16, 1, msg, sizeof(*msg) + msg_len, true); #endif /* * We currently use fixed-sized buffers, so trivially sanitize * the reported payload length. */ if (len > vrp->buf_size || msg_len > (len - sizeof(struct rpmsg_hdr))) { dev_warn(dev, "inbound msg too big: (%d, %d)\n", len, msg_len); return -EINVAL; } /* use the dst addr to fetch the callback of the appropriate user */ mutex_lock(&vrp->endpoints_lock); ept = idr_find(&vrp->endpoints, __rpmsg32_to_cpu(little_endian, msg->dst)); /* let's make sure no one deallocates ept while we use it */ if (ept) kref_get(&ept->refcount); mutex_unlock(&vrp->endpoints_lock); if (ept) { /* make sure ept->cb doesn't go away while we use it */ mutex_lock(&ept->cb_lock); if (ept->cb) ept->cb(ept->rpdev, msg->data, msg_len, ept->priv, __rpmsg32_to_cpu(little_endian, msg->src)); mutex_unlock(&ept->cb_lock); /* farewell, ept, we don't need you anymore */ kref_put(&ept->refcount, __ept_release); } else dev_warn_ratelimited(dev, "msg received with no recipient\n"); /* publish the real size of the buffer */ rpmsg_sg_init(&sg, msg, vrp->buf_size); /* add the buffer back to the remote processor's virtqueue */ err = virtqueue_add_inbuf(vrp->rvq, &sg, 1, msg, GFP_KERNEL); if (err < 0) { dev_err(dev, "failed to add a virtqueue buffer: %d\n", err); return err; } return 0; }
0
[ "CWE-415" ]
linux
1680939e9ecf7764fba8689cfb3429c2fe2bb23c
176,328,137,934,751,950,000,000,000,000,000,000,000
67
rpmsg: virtio: Fix possible double free in rpmsg_virtio_add_ctrl_dev() vch will be free in virtio_rpmsg_release_device() when rpmsg_ctrldev_register_device() fails. There is no need to call kfree() again. Fixes: c486682ae1e2 ("rpmsg: virtio: Register the rpmsg_char device") Signed-off-by: Hangyu Hua <[email protected]> Tested-by: Arnaud Pouliquen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]>
static bool multi_ischanged(struct Curl_multi *multi, bool clear) { bool retval = multi->recheckstate; if(clear) multi->recheckstate = FALSE; return retval; }
0
[ "CWE-416" ]
curl
75dc096e01ef1e21b6c57690d99371dedb2c0b80
75,052,737,216,752,620,000,000,000,000,000,000,000
7
curl_multi_cleanup: clear connection pointer for easy handles CVE-2016-5421 Bug: https://curl.haxx.se/docs/adv_20160803C.html Reported-by: Marcelo Echeverria and Fernando Muñoz
static UINT printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp) { UINT32 Length; UINT64 Offset; rdpPrintJob* printjob = NULL; UINT error = CHANNEL_RC_OK; void* ptr; if (Stream_GetRemainingLength(irp->input) < 32) return ERROR_INVALID_DATA; Stream_Read_UINT32(irp->input, Length); Stream_Read_UINT64(irp->input, Offset); Stream_Seek(irp->input, 20); /* Padding */ ptr = Stream_Pointer(irp->input); if (!Stream_SafeSeek(irp->input, Length)) return ERROR_INVALID_DATA; if (printer_dev->printer) printjob = printer_dev->printer->FindPrintJob(printer_dev->printer, irp->FileId); if (!printjob) { irp->IoStatus = STATUS_UNSUCCESSFUL; Length = 0; } else { error = printjob->Write(printjob, ptr, Length); } if (error) { WLog_ERR(TAG, "printjob->Write failed with error %" PRIu32 "!", error); return error; } Stream_Write_UINT32(irp->output, Length); Stream_Write_UINT8(irp->output, 0); /* Padding */ return irp->Complete(irp); }
0
[ "CWE-125" ]
FreeRDP
6b485b146a1b9d6ce72dfd7b5f36456c166e7a16
247,348,489,745,188,500,000,000,000,000,000,000,000
39
Fixed oob read in irp_write and similar
PHPAPI int php_getimagetype(php_stream * stream, char *filetype TSRMLS_DC) { char tmp[12]; int twelve_bytes_read; if ( !filetype) filetype = tmp; if((php_stream_read(stream, filetype, 3)) != 3) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Read error!"); return IMAGE_FILETYPE_UNKNOWN; } /* BYTES READ: 3 */ if (!memcmp(filetype, php_sig_gif, 3)) { return IMAGE_FILETYPE_GIF; } else if (!memcmp(filetype, php_sig_jpg, 3)) { return IMAGE_FILETYPE_JPEG; } else if (!memcmp(filetype, php_sig_png, 3)) { if (php_stream_read(stream, filetype+3, 5) != 5) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Read error!"); return IMAGE_FILETYPE_UNKNOWN; } if (!memcmp(filetype, php_sig_png, 8)) { return IMAGE_FILETYPE_PNG; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "PNG file corrupted by ASCII conversion"); return IMAGE_FILETYPE_UNKNOWN; } } else if (!memcmp(filetype, php_sig_swf, 3)) { return IMAGE_FILETYPE_SWF; } else if (!memcmp(filetype, php_sig_swc, 3)) { return IMAGE_FILETYPE_SWC; } else if (!memcmp(filetype, php_sig_psd, 3)) { return IMAGE_FILETYPE_PSD; } else if (!memcmp(filetype, php_sig_bmp, 2)) { return IMAGE_FILETYPE_BMP; } else if (!memcmp(filetype, php_sig_jpc, 3)) { return IMAGE_FILETYPE_JPC; } if (php_stream_read(stream, filetype+3, 1) != 1) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Read error!"); return IMAGE_FILETYPE_UNKNOWN; } /* BYTES READ: 4 */ if (!memcmp(filetype, php_sig_tif_ii, 4)) { return IMAGE_FILETYPE_TIFF_II; } else if (!memcmp(filetype, php_sig_tif_mm, 4)) { return IMAGE_FILETYPE_TIFF_MM; } else if (!memcmp(filetype, php_sig_iff, 4)) { return IMAGE_FILETYPE_IFF; } else if (!memcmp(filetype, php_sig_ico, 4)) { return IMAGE_FILETYPE_ICO; } /* WBMP may be smaller than 12 bytes, so delay error */ twelve_bytes_read = (php_stream_read(stream, filetype+4, 8) == 8); /* BYTES READ: 12 */ if (twelve_bytes_read && !memcmp(filetype, php_sig_jp2, 12)) { return IMAGE_FILETYPE_JP2; } /* AFTER ALL ABOVE FAILED */ if (php_get_wbmp(stream, NULL, 1 TSRMLS_CC)) { return IMAGE_FILETYPE_WBMP; } if (!twelve_bytes_read) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Read error!"); return IMAGE_FILETYPE_UNKNOWN; } if (php_get_xbm(stream, NULL TSRMLS_CC)) { return IMAGE_FILETYPE_XBM; } return IMAGE_FILETYPE_UNKNOWN; }
0
[]
php-src
87829c09a1d9e39bee994460d7ccf19dd20eda14
201,781,293,944,505,950,000,000,000,000,000,000,000
75
Fix #70052: getimagesize() fails for very large and very small WBMP Very large WBMP (width or height greater than 2**31-1) cause an overflow and circumvent the size limitation of 2048x2048 px. Very small WBMP (less than 12 bytes) cause a read error and are not recognized. This patch fixes both bugs.
shell_gtk_embed_on_window_destroy (GtkWidget *object, ShellGtkEmbed *embed) { shell_gtk_embed_set_window (embed, NULL); }
0
[]
gnome-shell
90c55e1977fde252b79bcfd9d0ef41144fb21fe2
275,276,315,536,020,500,000,000,000,000,000,000,000
5
gtk-embed: ensure we only listen for window-created events once If a tray icon gets a mapped and unmapped and the mapped again in quick succession, we can end up with multiple handlers listening for window creation events. This commit tries to guard against that by only listening for window-created events when we don't know the actor associated with the icon. https://bugzilla.gnome.org/show_bug.cgi?id=787361
keyblock_equal(const krb5_keyblock *k1, const krb5_keyblock *k2) { if (k1->enctype != k2->enctype) return FALSE; if (k1->length != k2->length) return FALSE; return memcmp(k1->contents, k2->contents, k1->length) == 0; }
0
[ "CWE-617" ]
krb5
94e5eda5bb94d1d44733a49c3d9b6d1e42c74def
163,538,416,352,058,950,000,000,000,000,000,000,000
8
Remove incorrect KDC assertion The assertion in return_enc_padata() is reachable because kdc_make_s4u2self_rep() may have previously added encrypted padata. It is no longer necessary because the code uses add_pa_data_element() instead of allocating a new list. CVE-2018-20217: In MIT krb5 1.8 or later, an authenticated user who can obtain a TGT using an older encryption type (DES, DES3, or RC4) can cause an assertion failure in the KDC by sending an S4U2Self request. [[email protected]: rewrote commit message with CVE description] ticket: 8767 (new) tags: pullup target_version: 1.17 target_version: 1.16-next target_version: 1.15-next
pfm_fasync(int fd, struct file *filp, int on) { pfm_context_t *ctx; int ret; if (PFM_IS_FILE(filp) == 0) { printk(KERN_ERR "perfmon: pfm_fasync bad magic [%d]\n", current->pid); return -EBADF; } ctx = (pfm_context_t *)filp->private_data; if (ctx == NULL) { printk(KERN_ERR "perfmon: pfm_fasync NULL ctx [%d]\n", current->pid); return -EBADF; } /* * we cannot mask interrupts during this call because this may * may go to sleep if memory is not readily avalaible. * * We are protected from the conetxt disappearing by the get_fd()/put_fd() * done in caller. Serialization of this function is ensured by caller. */ ret = pfm_do_fasync(fd, filp, ctx, on); DPRINT(("pfm_fasync called on ctx_fd=%d on=%d async_queue=%p ret=%d\n", fd, on, ctx->ctx_async_queue, ret)); return ret; }
0
[]
linux-2.6
41d5e5d73ecef4ef56b7b4cde962929a712689b4
299,277,485,883,408,300,000,000,000,000,000,000,000
32
[IA64] permon use-after-free fix Perfmon associates vmalloc()ed memory with a file descriptor, and installs a vma mapping that memory. Unfortunately, the vm_file field is not filled in, so processes with mappings to that memory do not prevent the file from being closed and the memory freed. This results in use-after-free bugs and multiple freeing of pages, etc. I saw this bug on an Altix on SLES9. Haven't reproduced upstream but it looks like the same issue is there. Signed-off-by: Nick Piggin <[email protected]> Cc: Stephane Eranian <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Tony Luck <[email protected]>
obj_to_asn1bool(VALUE obj) { if (NIL_P(obj)) ossl_raise(rb_eTypeError, "Can't convert nil into Boolean"); return RTEST(obj) ? 0xff : 0x0; }
0
[ "CWE-119" ]
openssl
1648afef33c1d97fb203c82291b8a61269e85d3b
5,277,670,544,190,516,700,000,000,000,000,000,000
7
asn1: fix out-of-bounds read in decoding constructed objects OpenSSL::ASN1.{decode,decode_all,traverse} have a bug of out-of-bounds read. int_ossl_asn1_decode0_cons() does not give the correct available length to ossl_asn1_decode() when decoding the inner components of a constructed object. This can cause out-of-bounds read if a crafted input given. Reference: https://hackerone.com/reports/170316
void trex_del(GF_Box *s) { GF_TrackExtendsBox *ptr = (GF_TrackExtendsBox *)s; if (ptr == NULL) return; gf_free(ptr);
0
[ "CWE-400", "CWE-401" ]
gpac
d2371b4b204f0a3c0af51ad4e9b491144dd1225c
288,667,917,552,931,930,000,000,000,000,000,000,000
6
prevent dref memleak on invalid input (#1183)
CloudInitSetup(const char *tmpDirPath) { int deployStatus = DEPLOY_ERROR; const char *cloudInitTmpDirPath = "/var/run/vmware-imc"; int forkExecResult; char command[1024]; Bool cloudInitTmpDirCreated = FALSE; snprintf(command, sizeof(command), "/bin/mkdir -p %s", cloudInitTmpDirPath); command[sizeof(command) - 1] = '\0'; forkExecResult = ForkExecAndWaitCommand(command); if (forkExecResult != 0) { SetDeployError("Error creating %s dir: %s", cloudInitTmpDirPath, strerror(errno)); goto done; } cloudInitTmpDirCreated = TRUE; snprintf(command, sizeof(command), "/bin/rm -f %s/cust.cfg %s/nics.txt", cloudInitTmpDirPath, cloudInitTmpDirPath); command[sizeof(command) - 1] = '\0'; forkExecResult = ForkExecAndWaitCommand(command); snprintf(command, sizeof(command), "/bin/cp %s/cust.cfg %s/cust.cfg", tmpDirPath, cloudInitTmpDirPath); command[sizeof(command) - 1] = '\0'; forkExecResult = ForkExecAndWaitCommand(command); if (forkExecResult != 0) { SetDeployError("Error copying cust.cfg file: %s", strerror(errno)); goto done; } snprintf(command, sizeof(command), "/usr/bin/test -f %s/nics.txt", tmpDirPath); command[sizeof(command) - 1] = '\0'; forkExecResult = ForkExecAndWaitCommand(command); /* * /usr/bin/test -f returns 0 if the file exists * non zero is returned if the file does not exist. * We need to copy the nics.txt only if it exists. */ if (forkExecResult == 0) { snprintf(command, sizeof(command), "/bin/cp %s/nics.txt %s/nics.txt", tmpDirPath, cloudInitTmpDirPath); command[sizeof(command) - 1] = '\0'; forkExecResult = ForkExecAndWaitCommand(command); if (forkExecResult != 0) { SetDeployError("Error copying nics.txt file: %s", strerror(errno)); goto done; } } deployStatus = DEPLOY_SUCCESS; done: if (DEPLOY_SUCCESS == deployStatus) { TransitionState(INPROGRESS, DONE); } else { if (cloudInitTmpDirCreated) { snprintf(command, sizeof(command), "/bin/rm -rf %s", cloudInitTmpDirPath); command[sizeof(command) - 1] = '\0'; ForkExecAndWaitCommand(command); } sLog(log_error, "Setting generic error status in vmx. \n"); SetCustomizationStatusInVmx(TOOLSDEPLOYPKG_RUNNING, GUESTCUST_EVENT_CUSTOMIZE_FAILED, NULL); TransitionState(INPROGRESS, ERRORED); } return deployStatus; }
1
[ "CWE-362" ]
open-vm-tools
22e58289f71232310d30cf162b83b5151a937bac
249,089,174,268,305,300,000,000,000,000,000,000,000
89
randomly generate tmp directory name
struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, int flag) { struct mount *res, *p, *q, *r, *parent; if (!(flag & CL_COPY_UNBINDABLE) && IS_MNT_UNBINDABLE(mnt)) return ERR_PTR(-EINVAL); if (!(flag & CL_COPY_MNT_NS_FILE) && is_mnt_ns_file(dentry)) return ERR_PTR(-EINVAL); res = q = clone_mnt(mnt, dentry, flag); if (IS_ERR(q)) return q; q->mnt_mountpoint = mnt->mnt_mountpoint; p = mnt; list_for_each_entry(r, &mnt->mnt_mounts, mnt_child) { struct mount *s; if (!is_subdir(r->mnt_mountpoint, dentry)) continue; for (s = r; s; s = next_mnt(s, r)) { if (!(flag & CL_COPY_UNBINDABLE) && IS_MNT_UNBINDABLE(s)) { if (s->mnt.mnt_flags & MNT_LOCKED) { /* Both unbindable and locked. */ q = ERR_PTR(-EPERM); goto out; } else { s = skip_mnt_tree(s); continue; } } if (!(flag & CL_COPY_MNT_NS_FILE) && is_mnt_ns_file(s->mnt.mnt_root)) { s = skip_mnt_tree(s); continue; } while (p != s->mnt_parent) { p = p->mnt_parent; q = q->mnt_parent; } p = s; parent = q; q = clone_mnt(p, p->mnt.mnt_root, flag); if (IS_ERR(q)) goto out; lock_mount_hash(); list_add_tail(&q->mnt_list, &res->mnt_list); attach_mnt(q, parent, p->mnt_mp); unlock_mount_hash(); } } return res; out: if (res) { lock_mount_hash(); umount_tree(res, UMOUNT_SYNC); unlock_mount_hash(); } return q; }
0
[ "CWE-200" ]
linux
427215d85e8d1476da1a86b8d67aceb485eb3631
299,700,048,793,841,700,000,000,000,000,000,000,000
64
ovl: prevent private clone if bind mount is not allowed Add the following checks from __do_loopback() to clone_private_mount() as well: - verify that the mount is in the current namespace - verify that there are no locked children Reported-by: Alois Wohlschlager <[email protected]> Fixes: c771d683a62e ("vfs: introduce clone_private_mount()") Cc: <[email protected]> # v3.18 Signed-off-by: Miklos Szeredi <[email protected]>
static void uv__chld(uv_signal_t* handle, int signum) { uv_process_t* process; uv_loop_t* loop; int exit_status; int term_signal; unsigned int i; int status; pid_t pid; QUEUE pending; QUEUE* h; QUEUE* q; assert(signum == SIGCHLD); QUEUE_INIT(&pending); loop = handle->loop; for (i = 0; i < ARRAY_SIZE(loop->process_handles); i++) { h = loop->process_handles + i; q = QUEUE_HEAD(h); while (q != h) { process = QUEUE_DATA(q, uv_process_t, queue); q = QUEUE_NEXT(q); do pid = waitpid(process->pid, &status, WNOHANG); while (pid == -1 && errno == EINTR); if (pid == 0) continue; if (pid == -1) { if (errno != ECHILD) abort(); continue; } process->status = status; QUEUE_REMOVE(&process->queue); QUEUE_INSERT_TAIL(&pending, &process->queue); } while (!QUEUE_EMPTY(&pending)) { q = QUEUE_HEAD(&pending); QUEUE_REMOVE(q); QUEUE_INIT(q); process = QUEUE_DATA(q, uv_process_t, queue); uv__handle_stop(process); if (process->exit_cb == NULL) continue; exit_status = 0; if (WIFEXITED(process->status)) exit_status = WEXITSTATUS(process->status); term_signal = 0; if (WIFSIGNALED(process->status)) term_signal = WTERMSIG(process->status); process->exit_cb(process, exit_status, term_signal); } } }
0
[ "CWE-273", "CWE-284", "CWE-264" ]
libuv
66ab38918c911bcff025562cf06237d7fedaba0c
100,743,524,918,250,310,000,000,000,000,000,000,000
66
unix: call setgoups before calling setuid/setgid Partial fix for #1093
static int complete_fast_pio_out(struct kvm_vcpu *vcpu) { vcpu->arch.pio.count = 0; if (unlikely(!kvm_is_linear_rip(vcpu, vcpu->arch.pio.linear_rip))) return 1; return kvm_skip_emulated_instruction(vcpu); }
0
[ "CWE-476" ]
linux
55749769fe608fa3f4a075e42e89d237c8e37637
226,063,351,332,488,480,000,000,000,000,000,000,000
9
KVM: x86: Fix wall clock writes in Xen shared_info not to mark page dirty When dirty ring logging is enabled, any dirty logging without an active vCPU context will cause a kernel oops. But we've already declared that the shared_info page doesn't get dirty tracking anyway, since it would be kind of insane to mark it dirty every time we deliver an event channel interrupt. Userspace is supposed to just assume it's always dirty any time a vCPU can run or event channels are routed. So stop using the generic kvm_write_wall_clock() and just write directly through the gfn_to_pfn_cache that we already have set up. We can make kvm_write_wall_clock() static in x86.c again now, but let's not remove the 'sec_hi_ofs' argument even though it's not used yet. At some point we *will* want to use that for KVM guests too. Fixes: 629b5348841a ("KVM: x86/xen: update wallclock region") Reported-by: butt3rflyh4ck <[email protected]> Signed-off-by: David Woodhouse <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
static void analPathFollow(RCoreAnalPaths *p, ut64 addr, PJ *pj) { if (addr == UT64_MAX) { return; } if (!dict_get (&p->visited, addr)) { p->cur = r_anal_bb_from_offset (p->core->anal, addr); analPaths (p, pj); } }
0
[ "CWE-416" ]
radare2
10517e3ff0e609697eb8cde60ec8dc999ee5ea24
37,062,080,465,891,375,000,000,000,000,000,000,000
9
aaef on arm/thumb switches causes uaf ##crash * Reported by peacock-doris via huntr.dev * Reproducer: poc_uaf_r_reg_get
uint32_t LEtoUint32(const uint8_t*buffer) { uint32_t retval = buffer[3]; retval <<=8; retval |= buffer[2]; retval <<= 8; retval |= buffer[1]; retval <<= 8; retval |= buffer[0]; return retval; }
0
[ "CWE-399", "CWE-190" ]
lepton
6a5ceefac1162783fffd9506a3de39c85c725761
86,469,256,638,559,890,000,000,000,000,000,000,000
10
fix #111
static js_Ast *parameters(js_State *J) { js_Ast *head, *tail; if (J->lookahead == ')') return NULL; head = tail = LIST(identifier(J)); while (jsP_accept(J, ',')) { tail = tail->b = LIST(identifier(J)); } return jsP_list(head); }
0
[ "CWE-674" ]
mujs
4d45a96e57fbabf00a7378b337d0ddcace6f38c1
79,330,972,439,661,950,000,000,000,000,000,000,000
11
Guard binary expressions from too much recursion.
static void hclge_tm_pg_info_init(struct hclge_dev *hdev) { #define BW_PERCENT 100 u8 i; for (i = 0; i < hdev->tm_info.num_pg; i++) { int k; hdev->tm_info.pg_dwrr[i] = i ? 0 : BW_PERCENT; hdev->tm_info.pg_info[i].pg_id = i; hdev->tm_info.pg_info[i].pg_sch_mode = HCLGE_SCH_MODE_DWRR; hdev->tm_info.pg_info[i].bw_limit = HCLGE_ETHER_MAX_RATE; if (i != 0) continue; hdev->tm_info.pg_info[i].tc_bit_map = hdev->hw_tc_map; for (k = 0; k < hdev->tm_info.num_tc; k++) hdev->tm_info.pg_info[i].tc_dwrr[k] = BW_PERCENT; } }
0
[ "CWE-125" ]
linux
04f25edb48c441fc278ecc154c270f16966cbb90
61,601,100,390,222,150,000,000,000,000,000,000,000
24
net: hns3: add some error checking in hclge_tm module When hdev->tx_sch_mode is HCLGE_FLAG_VNET_BASE_SCH_MODE, the hclge_tm_schd_mode_vnet_base_cfg calls hclge_tm_pri_schd_mode_cfg with vport->vport_id as pri_id, which is used as index for hdev->tm_info.tc_info, it will cause out of bound access issue if vport_id is equal to or larger than HNAE3_MAX_TC. Also hardware only support maximum speed of HCLGE_ETHER_MAX_RATE. So this patch adds two checks for above cases. Fixes: 848440544b41 ("net: hns3: Add support of TX Scheduler & Shaper to HNS3 driver") Signed-off-by: Yunsheng Lin <[email protected]> Signed-off-by: Peng Li <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
void propagate(struct redisCommand *cmd, int dbid, robj **argv, int argc, int flags) { if (server.aof_state != AOF_OFF && flags & PROPAGATE_AOF) feedAppendOnlyFile(cmd,dbid,argv,argc); if (flags & PROPAGATE_REPL) replicationFeedSlaves(server.slaves,dbid,argv,argc); }
0
[ "CWE-770" ]
redis
5674b0057ff2903d43eaff802017eddf37c360f8
200,813,840,515,400,000,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 void cmd_agraph_edge(RCore *core, const char *input) { switch (*input) { case ' ': // "age" case '-': { // "age-" RANode *u, *v; char **args; int n_args; args = r_str_argv (input + 1, &n_args); if (n_args != 2) { r_cons_printf ("Wrong arguments\n"); r_str_argv_free (args); break; } u = r_agraph_get_node (core->graph, args[0]); v = r_agraph_get_node (core->graph, args[1]); if (!u || !v) { if (!u) { r_cons_printf ("Node %s not found!\n", args[0]); } else { r_cons_printf ("Node %s not found!\n", args[1]); } r_str_argv_free (args); break; } if (*input == ' ') { r_agraph_add_edge (core->graph, u, v); } else { r_agraph_del_edge (core->graph, u, v); } r_str_argv_free (args); break; } case '?': default: r_core_cmd_help (core, help_msg_age); break; } }
0
[ "CWE-125", "CWE-787" ]
radare2
a1bc65c3db593530775823d6d7506a457ed95267
33,352,379,821,137,850,000,000,000,000,000,000,000
40
Fix #12375 - Crash in bd+ao (#12382)
SProcXkbGetNames(ClientPtr client) { REQUEST(xkbGetNamesReq); swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbGetNamesReq); swaps(&stuff->deviceSpec); swapl(&stuff->which); return ProcXkbGetNames(client); }
0
[ "CWE-191" ]
xserver
144849ea27230962227e62a943b399e2ab304787
287,384,786,179,690,400,000,000,000,000,000,000,000
10
Fix XkbSelectEvents() integer underflow CVE-2020-14361 ZDI-CAN 11573 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative Signed-off-by: Matthieu Herrb <[email protected]>
ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be searched */ { ecma_value_t num = ecma_make_number_value (number_arg); if (ecma_is_value_integer_number (num)) { return num; } JERRY_ASSERT (ecma_is_value_float_number (num)); jmem_cpointer_t number_list_cp = JERRY_CONTEXT (number_list_first_cp); jmem_cpointer_t *empty_cpointer_p = NULL; while (number_list_cp != JMEM_CP_NULL) { ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, number_list_cp); for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++) { if (number_list_p->values[i] == JMEM_CP_NULL) { if (empty_cpointer_p == NULL) { empty_cpointer_p = number_list_p->values + i; } } else { ecma_number_t *number_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, number_list_p->values[i]); if (*number_p == number_arg) { ecma_free_value (num); return ecma_make_float_value (number_p); } } } number_list_cp = number_list_p->next_cp; } jmem_cpointer_t result; JMEM_CP_SET_NON_NULL_POINTER (result, ecma_get_pointer_from_float_value (num)); if (empty_cpointer_p != NULL) { *empty_cpointer_p = result; return num; } ecma_lit_storage_item_t *new_item_p; new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc (sizeof (ecma_lit_storage_item_t)); new_item_p->values[0] = result; for (int i = 1; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++) { new_item_p->values[i] = JMEM_CP_NULL; } new_item_p->next_cp = JERRY_CONTEXT (number_list_first_cp); JMEM_CP_SET_NON_NULL_POINTER (JERRY_CONTEXT (number_list_first_cp), new_item_p); return num; } /* ecma_find_or_create_literal_number */
0
[ "CWE-416" ]
jerryscript
3bcd48f72d4af01d1304b754ef19fe1a02c96049
337,511,275,870,107,430,000,000,000,000,000,000,000
67
Improve parse_identifier (#4691) Ascii string length is no longer computed during string allocation. JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz [email protected]
static int spawn_https_helper_openssl(const char *host, unsigned port) { char *allocated = NULL; char *servername; int sp[2]; int pid; IF_FEATURE_WGET_HTTPS(volatile int child_failed = 0;) if (socketpair(AF_UNIX, SOCK_STREAM, 0, sp) != 0) /* Kernel can have AF_UNIX support disabled */ bb_perror_msg_and_die("socketpair"); if (!strchr(host, ':')) host = allocated = xasprintf("%s:%u", host, port); servername = xstrdup(host); strrchr(servername, ':')[0] = '\0'; fflush_all(); pid = xvfork(); if (pid == 0) { /* Child */ char *argv[8]; close(sp[0]); xmove_fd(sp[1], 0); xdup2(0, 1); /* * openssl s_client -quiet -connect www.kernel.org:443 2>/dev/null * It prints some debug stuff on stderr, don't know how to suppress it. * Work around by dev-nulling stderr. We lose all error messages :( */ xmove_fd(2, 3); xopen("/dev/null", O_RDWR); memset(&argv, 0, sizeof(argv)); argv[0] = (char*)"openssl"; argv[1] = (char*)"s_client"; argv[2] = (char*)"-quiet"; argv[3] = (char*)"-connect"; argv[4] = (char*)host; /* * Per RFC 6066 Section 3, the only permitted values in the * TLS server_name (SNI) field are FQDNs (DNS hostnames). * IPv4 and IPv6 addresses, port numbers are not allowed. */ if (!is_ip_address(servername)) { argv[5] = (char*)"-servername"; argv[6] = (char*)servername; } BB_EXECVP(argv[0], argv); xmove_fd(3, 2); # if ENABLE_FEATURE_WGET_HTTPS child_failed = 1; xfunc_die(); # else bb_perror_msg_and_die("can't execute '%s'", argv[0]); # endif /* notreached */ } /* Parent */ free(servername); free(allocated); close(sp[1]); # if ENABLE_FEATURE_WGET_HTTPS if (child_failed) { close(sp[0]); return -1; } # endif return sp[0]; }
0
[ "CWE-120" ]
busybox
8e2174e9bd836e53c8b9c6e00d1bc6e2a718686e
290,502,329,656,520,970,000,000,000,000,000,000,000
72
wget: check chunk length for overflowing off_t function old new delta retrieve_file_data 428 465 +37 wget_main 2386 2389 +3 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 40/0) Total: 40 bytes Signed-off-by: Denys Vlasenko <[email protected]>
bool FileBody::Move(const fs::path& new_path) { if (path_ == new_path) { return false; } if (ifstream_.is_open()) { ifstream_.close(); } fs::error_code ec; fs::rename(path_, new_path, ec); if (ec) { LOG_ERRO("Failed to rename file (%s).", ec.message().c_str()); return false; } // Reset original file path. path_.clear(); return true; }
0
[ "CWE-22" ]
webcc
55a45fd5039061d5cc62e9f1b9d1f7e97a15143f
153,405,497,403,215,850,000,000,000,000,000,000,000
22
fix static file serving security issue; fix url path encoding issue
static int __init init_ext4_fs(void) { int err; ext4_proc_root = proc_mkdir("fs/ext4", NULL); err = init_ext4_mballoc(); if (err) return err; err = init_ext4_xattr(); if (err) goto out2; err = init_inodecache(); if (err) goto out1; err = register_filesystem(&ext4_fs_type); if (err) goto out; #ifdef CONFIG_EXT4DEV_COMPAT err = register_filesystem(&ext4dev_fs_type); if (err) { unregister_filesystem(&ext4_fs_type); goto out; } #endif return 0; out: destroy_inodecache(); out1: exit_ext4_xattr(); out2: exit_ext4_mballoc(); return err; }
0
[ "CWE-20" ]
linux-2.6
4ec110281379826c5cf6ed14735e47027c3c5765
296,504,652,177,134,960,000,000,000,000,000,000,000
34
ext4: Add sanity checks for the superblock before mounting the filesystem This avoids insane superblock configurations that could lead to kernel oops due to null pointer derefences. http://bugzilla.kernel.org/show_bug.cgi?id=12371 Thanks to David Maciejak at Fortinet's FortiGuard Global Security Research Team who discovered this bug independently (but at approximately the same time) as Thiemo Nagel, who submitted the patch. Signed-off-by: Thiemo Nagel <[email protected]> Signed-off-by: "Theodore Ts'o" <[email protected]> Cc: [email protected]
lha_read_file_header_3(struct archive_read *a, struct lha *lha) { const unsigned char *p; size_t extdsize; int err; uint16_t header_crc; if ((p = __archive_read_ahead(a, H3_FIXED_SIZE, NULL)) == NULL) return (truncated_error(a)); if (archive_le16dec(p + H3_FIELD_LEN_OFFSET) != 4) goto invalid; lha->header_size =archive_le32dec(p + H3_HEADER_SIZE_OFFSET); lha->compsize = archive_le32dec(p + H3_COMP_SIZE_OFFSET); lha->origsize = archive_le32dec(p + H3_ORIG_SIZE_OFFSET); lha->mtime = archive_le32dec(p + H3_TIME_OFFSET); lha->crc = archive_le16dec(p + H3_CRC_OFFSET); lha->setflag |= CRC_IS_SET; if (lha->header_size < H3_FIXED_SIZE + 4) goto invalid; header_crc = lha_crc16(0, p, H3_FIXED_SIZE); __archive_read_consume(a, H3_FIXED_SIZE); /* Read extended headers */ err = lha_read_file_extended_header(a, lha, &header_crc, 4, lha->header_size - H3_FIXED_SIZE, &extdsize); if (err < ARCHIVE_WARN) return (err); if (header_crc != lha->header_crc) { archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "LHa header CRC error"); return (ARCHIVE_FATAL); } return (err); invalid: archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "Invalid LHa header"); return (ARCHIVE_FATAL); }
0
[ "CWE-125" ]
libarchive
98dcbbf0bf4854bf987557e55e55fff7abbf3ea9
288,687,748,270,560,700,000,000,000,000,000,000,000
41
Fail with negative lha->compsize in lha_read_file_header_1() Fixes a heap buffer overflow reported in Secunia SA74169
void gf_filterpacket_del(void *p) { GF_FilterPacket *pck=(GF_FilterPacket *)p; if (pck->data) gf_free(pck->data); gf_free(p); }
0
[ "CWE-787" ]
gpac
da37ec8582266983d0ec4b7550ec907401ec441e
252,652,012,381,131,100,000,000,000,000,000,000,000
6
fixed crashes for very long path - cf #1908
void set_position(JOIN *join,uint idx,JOIN_TAB *table,KEYUSE *key) { join->positions[idx].table= table; join->positions[idx].key=key; join->positions[idx].records_read=1.0; /* This is a const table */ join->positions[idx].cond_selectivity= 1.0; join->positions[idx].ref_depend_map= 0; // join->positions[idx].loosescan_key= MAX_KEY; /* Not a LooseScan */ join->positions[idx].sj_strategy= SJ_OPT_NONE; join->positions[idx].use_join_buffer= FALSE; /* Move the const table as down as possible in best_ref */ JOIN_TAB **pos=join->best_ref+idx+1; JOIN_TAB *next=join->best_ref[idx]; for (;next != table ; pos++) { JOIN_TAB *tmp=pos[0]; pos[0]=next; next=tmp; } join->best_ref[idx]=table; }
0
[ "CWE-89" ]
server
5ba77222e9fe7af8ff403816b5338b18b342053c
282,421,400,678,332,360,000,000,000,000,000,000,000
23
MDEV-21028 Server crashes in Query_arena::set_query_arena upon SELECT from view if the view has algorithm=temptable it is not updatable, so DEFAULT() for its fields is meaningless, and thus it's NULL or 0/'' for NOT NULL columns.
int32_t PersianCalendar::defaultCenturyStartYear() const { // lazy-evaluate systemDefaultCenturyStartYear umtx_initOnce(gSystemDefaultCenturyInit, &initializeSystemDefaultCentury); return gSystemDefaultCenturyStartYear; }
0
[ "CWE-190" ]
icu
71dd84d4ffd6600a70e5bca56a22b957e6642bd4
160,449,426,700,570,830,000,000,000,000,000,000,000
5
ICU-12504 in ICU4C Persian cal, use int64_t math for one operation to avoid overflow; add tests in C and J X-SVN-Rev: 40654
GF_Box *mdia_box_new() { ISOM_DECL_BOX_ALLOC(GF_MediaBox, GF_ISOM_BOX_TYPE_MDIA); return (GF_Box *)tmp; }
0
[ "CWE-787" ]
gpac
388ecce75d05e11fc8496aa4857b91245007d26e
186,722,971,332,346,600,000,000,000,000,000,000,000
5
fixed #1587
noCompbrlAhead(const TranslationTableHeader *table, int pos, int mode, const InString *input, int transOpcode, int transCharslen, int cursorPosition) { int start = pos + transCharslen; int end; int p; if (start >= input->length) return 1; while (start < input->length && checkAttr(input->chars[start], CTC_Space, 0, table)) start++; if (start == input->length || (transOpcode == CTO_JoinableWord && (!checkAttr(input->chars[start], CTC_Letter | CTC_Digit, 0, table) || !checkAttr(input->chars[start - 1], CTC_Space, 0, table)))) return 1; end = start; while (end < input->length && !checkAttr(input->chars[end], CTC_Space, 0, table)) end++; if ((mode & (compbrlAtCursor | compbrlLeftCursor)) && cursorPosition >= start && cursorPosition < end) return 0; /* Look ahead for rules with CTO_CompBrl */ for (p = start; p < end; p++) { int length = input->length - p; int tryThis; const TranslationTableCharacter *character1; const TranslationTableCharacter *character2; int k; character1 = findCharOrDots(input->chars[p], 0, table); for (tryThis = 0; tryThis < 2; tryThis++) { TranslationTableOffset ruleOffset = 0; TranslationTableRule *testRule; unsigned long int makeHash = 0; switch (tryThis) { case 0: if (!(length >= 2)) break; /* Hash function optimized for forward translation */ makeHash = (unsigned long int)character1->lowercase << 8; character2 = findCharOrDots(input->chars[p + 1], 0, table); makeHash += (unsigned long int)character2->lowercase; makeHash %= HASHNUM; ruleOffset = table->forRules[makeHash]; break; case 1: if (!(length >= 1)) break; length = 1; ruleOffset = character1->otherRules; break; } while (ruleOffset) { testRule = (TranslationTableRule *)&table->ruleArea[ruleOffset]; for (k = 0; k < testRule->charslen; k++) { character1 = findCharOrDots(testRule->charsdots[k], 0, table); character2 = findCharOrDots(input->chars[p + k], 0, table); if (character1->lowercase != character2->lowercase) break; } if (tryThis == 1 || k == testRule->charslen) { if (testRule->opcode == CTO_CompBrl || testRule->opcode == CTO_Literal) return 0; } ruleOffset = testRule->charsnext; } } } return 1; }
0
[ "CWE-125" ]
liblouis
5e4089659bb49b3095fa541fa6387b4c40d7396e
164,636,700,340,952,210,000,000,000,000,000,000,000
65
Fix a buffer overflow Fixes #635 Thanks to HongxuChen for reporting it
static void pass_destroy(jpc_enc_pass_t *pass) { /* XXX - need to free resources here */ }
0
[ "CWE-189" ]
jasper
3c55b399c36ef46befcb21e4ebc4799367f89684
325,223,179,965,415,670,000,000,000,000,000,000,000
4
At many places in the code, jas_malloc or jas_recalloc was being invoked with the size argument being computed in a manner that would not allow integer overflow to be detected. Now, these places in the code have been modified to use special-purpose memory allocation functions (e.g., jas_alloc2, jas_alloc3, jas_realloc2) that check for overflow. This should fix many security problems.
bool get_time(MYSQL_TIME *ltime) { DBUG_ASSERT(fixed); return (*ref)->get_time(ltime); }
0
[]
mysql-server
f7316aa0c9a3909fc7498e7b95d5d3af044a7e21
238,069,136,746,649,200,000,000,000,000,000,000,000
5
Bug#26361149 MYSQL SERVER CRASHES AT: COL IN(IFNULL(CONST, COL), NAME_CONST('NAME', NULL)) Backport of Bug#19143243 fix. NAME_CONST item can return NULL_ITEM type in case of incorrect arguments. NULL_ITEM has special processing in Item_func_in function. In Item_func_in::fix_length_and_dec an array of possible comparators is created. Since NAME_CONST function has NULL_ITEM type, corresponding array element is empty. Then NAME_CONST is wrapped to ITEM_CACHE. ITEM_CACHE can not return proper type(NULL_ITEM) in Item_func_in::val_int(), so the NULL_ITEM is attempted compared with an empty comparator. The fix is to disable the caching of Item_name_const item.
get_correct_host_mode( int token ) { switch (token) { case T_Server: case T_Pool: case T_Manycastclient: return MODE_CLIENT; case T_Peer: return MODE_ACTIVE; case T_Broadcast: return MODE_BROADCAST; default: return 0; } }
0
[ "CWE-19" ]
ntp
fe46889f7baa75fc8e6c0fcde87706d396ce1461
157,731,515,231,232,340,000,000,000,000,000,000
21
[Sec 2942]: Off-path DoS attack on auth broadcast mode. HStenn.
virDomainEmulatorSchedParse(xmlNodePtr node, virDomainDefPtr def) { g_autofree virDomainThreadSchedParamPtr sched = NULL; if (VIR_ALLOC(sched) < 0) return -1; if (virDomainSchedulerParseCommonAttrs(node, &sched->policy, &sched->priority) < 0) return -1; def->cputune.emulatorsched = g_steal_pointer(&sched); return 0; }
0
[ "CWE-212" ]
libvirt
a5b064bf4b17a9884d7d361733737fb614ad8979
111,615,762,681,996,730,000,000,000,000,000,000,000
16
conf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410 (v6.1.0-122-g3b076391be) we support http cookies. Since they may contain somewhat sensitive information we should not format them into the XML unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted. Reported-by: Han Han <[email protected]> Signed-off-by: Peter Krempa <[email protected]> Reviewed-by: Erik Skultety <[email protected]>
static void __init vfio_pci_fill_ids(void) { char *p, *id; int rc; /* no ids passed actually */ if (ids[0] == '\0') return; /* add ids specified in the module parameter */ p = ids; while ((id = strsep(&p, ","))) { unsigned int vendor, device, subvendor = PCI_ANY_ID, subdevice = PCI_ANY_ID, class = 0, class_mask = 0; int fields; if (!strlen(id)) continue; fields = sscanf(id, "%x:%x:%x:%x:%x:%x", &vendor, &device, &subvendor, &subdevice, &class, &class_mask); if (fields < 2) { pr_warn("invalid id string \"%s\"\n", id); continue; } rc = pci_add_dynid(&vfio_pci_driver, vendor, device, subvendor, subdevice, class, class_mask, 0); if (rc) pr_warn("failed to add dynamic id [%04hx:%04hx[%04hx:%04hx]] class %#08x/%08x (%d)\n", vendor, device, subvendor, subdevice, class, class_mask, rc); else pr_info("add [%04hx:%04hx[%04hx:%04hx]] class %#08x/%08x\n", vendor, device, subvendor, subdevice, class, class_mask); } }
0
[ "CWE-399", "CWE-190" ]
linux
05692d7005a364add85c6e25a6c4447ce08f913a
122,887,901,022,971,520,000,000,000,000,000,000,000
40
vfio/pci: Fix integer overflows, bitmask check The VFIO_DEVICE_SET_IRQS ioctl did not sufficiently sanitize user-supplied integers, potentially allowing memory corruption. This patch adds appropriate integer overflow checks, checks the range bounds for VFIO_IRQ_SET_DATA_NONE, and also verifies that only single element in the VFIO_IRQ_SET_DATA_TYPE_MASK bitmask is set. VFIO_IRQ_SET_ACTION_TYPE_MASK is already correctly checked later in vfio_pci_set_irqs_ioctl(). Furthermore, a kzalloc is changed to a kcalloc because the use of a kzalloc with an integer multiplication allowed an integer overflow condition to be reached without this patch. kcalloc checks for overflow and should prevent a similar occurrence. Signed-off-by: Vlad Tsyrklevich <[email protected]> Signed-off-by: Alex Williamson <[email protected]>
static int brcmf_cfg80211_set_pmk(struct wiphy *wiphy, struct net_device *dev, const struct cfg80211_pmk_conf *conf) { struct brcmf_if *ifp; brcmf_dbg(TRACE, "enter\n"); /* expect using firmware supplicant for 1X */ ifp = netdev_priv(dev); if (WARN_ON(ifp->vif->profile.use_fwsup != BRCMF_PROFILE_FWSUP_1X)) return -EINVAL; if (conf->pmk_len > BRCMF_WSEC_MAX_PSK_LEN) return -ERANGE; return brcmf_set_pmk(ifp, conf->pmk, conf->pmk_len); }
0
[ "CWE-787" ]
linux
1b5e2423164b3670e8bc9174e4762d297990deff
188,193,653,584,164,800,000,000,000,000,000,000,000
17
brcmfmac: assure SSID length from firmware is limited The SSID length as received from firmware should not exceed IEEE80211_MAX_SSID_LEN as that would result in heap overflow. 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]>
static void nfs4_layoutcommit_prepare(struct rpc_task *task, void *calldata) { struct nfs4_layoutcommit_data *data = calldata; struct nfs_server *server = NFS_SERVER(data->args.inode); nfs4_setup_sequence(server->nfs_client, &data->args.seq_args, &data->res.seq_res, task); }
0
[ "CWE-787" ]
linux
b4487b93545214a9db8cbf32e86411677b0cca21
124,556,053,101,058,490,000,000,000,000,000,000,000
10
nfs: Fix getxattr kernel panic and memory overflow Move the buffer size check to decode_attr_security_label() before memcpy() Only call memcpy() if the buffer is large enough Fixes: aa9c2669626c ("NFS: Client implementation of Labeled-NFS") Signed-off-by: Jeffrey Mitchell <[email protected]> [Trond: clean up duplicate test of label->len != 0] Signed-off-by: Trond Myklebust <[email protected]>
static void frob_rodata(const struct module_layout *layout, int (*set_memory)(unsigned long start, int num_pages)) { BUG_ON((unsigned long)layout->base & (PAGE_SIZE-1)); BUG_ON((unsigned long)layout->text_size & (PAGE_SIZE-1)); BUG_ON((unsigned long)layout->ro_size & (PAGE_SIZE-1)); set_memory((unsigned long)layout->base + layout->text_size, (layout->ro_size - layout->text_size) >> PAGE_SHIFT); }
0
[ "CWE-362", "CWE-347" ]
linux
0c18f29aae7ce3dadd26d8ee3505d07cc982df75
334,238,057,230,340,000,000,000,000,000,000,000,000
9
module: limit enabling module.sig_enforce Irrespective as to whether CONFIG_MODULE_SIG is configured, specifying "module.sig_enforce=1" on the boot command line sets "sig_enforce". Only allow "sig_enforce" to be set when CONFIG_MODULE_SIG is configured. This patch makes the presence of /sys/module/module/parameters/sig_enforce dependent on CONFIG_MODULE_SIG=y. Fixes: fda784e50aac ("module: export module signature enforcement status") Reported-by: Nayna Jain <[email protected]> Tested-by: Mimi Zohar <[email protected]> Tested-by: Jessica Yu <[email protected]> Signed-off-by: Mimi Zohar <[email protected]> Signed-off-by: Jessica Yu <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
f_lispindent(typval_T *argvars UNUSED, typval_T *rettv) { #ifdef FEAT_LISP pos_T pos; linenr_T lnum; if (in_vim9script() && check_for_lnum_arg(argvars, 0) == FAIL) return; pos = curwin->w_cursor; lnum = tv_get_lnum(argvars); if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count) { curwin->w_cursor.lnum = lnum; rettv->vval.v_number = get_lisp_indent(); curwin->w_cursor = pos; } else if (in_vim9script()) semsg(_(e_invalid_line_number_nr), lnum); else #endif rettv->vval.v_number = -1; }
0
[ "CWE-122", "CWE-787" ]
vim
652dee448618589de5528a9e9a36995803f5557a
78,605,128,669,354,070,000,000,000,000,000,000,000
23
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.
static void openssl_print_object_sn(const char *s) { }
0
[ "CWE-119", "CWE-787" ]
OpenSC
412a6142c27a5973c61ba540e33cdc22d5608e68
178,607,814,542,123,400,000,000,000,000,000,000,000
3
fixed out of bounds access of ASN.1 Bitstring Credit to OSS-Fuzz
static int test_remove(struct libmnt_test *ts, int argc, char *argv[]) { const char *name; char *optstr; int rc; if (argc < 3) return -EINVAL; optstr = xstrdup(argv[1]); name = argv[2]; rc = mnt_optstr_remove_option(&optstr, name); if (!rc) printf("result: >%s<\n", optstr); free(optstr); return rc; }
0
[ "CWE-552", "CWE-703" ]
util-linux
57202f5713afa2af20ffbb6ab5331481d0396f8d
190,944,558,537,508,670,000,000,000,000,000,000,000
17
libmount: fix UID check for FUSE umount [CVE-2021-3995] Improper UID check allows an unprivileged user to unmount FUSE filesystems of users with similar UID. Signed-off-by: Karel Zak <[email protected]>
static CURLcode imap_state_auth_resp(struct connectdata *conn, int imapcode, imapstate instate) { CURLcode result = CURLE_OK; struct Curl_easy *data = conn->data; struct imap_conn *imapc = &conn->proto.imapc; saslprogress progress; (void)instate; /* no use for this yet */ result = Curl_sasl_continue(&imapc->sasl, conn, imapcode, &progress); if(!result) switch(progress) { case SASL_DONE: state(conn, IMAP_STOP); /* Authenticated */ break; case SASL_IDLE: /* No mechanism left after cancellation */ if((!imapc->login_disabled) && (imapc->preftype & IMAP_TYPE_CLEARTEXT)) /* Perform clear text authentication */ result = imap_perform_login(conn); else { failf(data, "Authentication cancelled"); result = CURLE_LOGIN_DENIED; } break; default: break; } return result; }
0
[ "CWE-119" ]
curl
13c9a9ded3ae744a1e11cbc14e9146d9fa427040
11,994,514,130,222,459,000,000,000,000,000,000,000
32
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
Database::~Database() { QSqlQuery query; query.exec(QLatin1String("PRAGMA journal_mode = DELETE")); query.exec(QLatin1String("VACUUM")); }
0
[ "CWE-310" ]
mumble
5632c35d6759f5e13a7dfe78e4ee6403ff6a8e3e
102,258,204,269,252,380,000,000,000,000,000,000,000
5
Explicitly remove file permissions for settings and DB
__do_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address) { struct vm_area_struct *vma; struct task_struct *tsk; struct mm_struct *mm; int fault, major = 0; unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; tsk = current; mm = tsk->mm; /* * Detect and handle instructions that would cause a page fault for * both a tracked kernel page and a userspace page. */ if (kmemcheck_active(regs)) kmemcheck_hide(regs); prefetchw(&mm->mmap_sem); if (unlikely(kmmio_fault(regs, address))) return; /* * We fault-in kernel-space virtual memory on-demand. The * 'reference' page table is init_mm.pgd. * * NOTE! We MUST NOT take any locks for this case. We may * be in an interrupt or a critical region, and should * only copy the information from the master page table, * nothing more. * * This verifies that the fault happens in kernel space * (error_code & 4) == 0, and that the fault was not a * protection error (error_code & 9) == 0. */ if (unlikely(fault_in_kernel_space(address))) { if (!(error_code & (PF_RSVD | PF_USER | PF_PROT))) { if (vmalloc_fault(address) >= 0) return; if (kmemcheck_fault(regs, address, error_code)) return; } /* Can handle a stale RO->RW TLB: */ if (spurious_fault(error_code, address)) return; /* kprobes don't want to hook the spurious faults: */ if (kprobes_fault(regs)) return; /* * Don't take the mm semaphore here. If we fixup a prefetch * fault we could otherwise deadlock: */ bad_area_nosemaphore(regs, error_code, address); return; } /* kprobes don't want to hook the spurious faults: */ if (unlikely(kprobes_fault(regs))) return; if (unlikely(error_code & PF_RSVD)) pgtable_bad(regs, error_code, address); if (unlikely(smap_violation(error_code, regs))) { bad_area_nosemaphore(regs, error_code, address); return; } /* * If we're in an interrupt, have no user context or are running * in a region with pagefaults disabled then we must not take the fault */ if (unlikely(faulthandler_disabled() || !mm)) { bad_area_nosemaphore(regs, error_code, address); return; } /* * It's safe to allow irq's after cr2 has been saved and the * vmalloc fault has been handled. * * User-mode registers count as a user access even for any * potential system fault or CPU buglet: */ if (user_mode(regs)) { local_irq_enable(); error_code |= PF_USER; flags |= FAULT_FLAG_USER; } else { if (regs->flags & X86_EFLAGS_IF) local_irq_enable(); } perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); if (error_code & PF_WRITE) flags |= FAULT_FLAG_WRITE; /* * When running in the kernel we expect faults to occur only to * addresses in user space. All other faults represent errors in * the kernel and should generate an OOPS. Unfortunately, in the * case of an erroneous fault occurring in a code path which already * holds mmap_sem we will deadlock attempting to validate the fault * against the address space. Luckily the kernel only validly * references user space from well defined areas of code, which are * listed in the exceptions table. * * As the vast majority of faults will be valid we will only perform * the source reference check when there is a possibility of a * deadlock. Attempt to lock the address space, if we cannot we then * validate the source. If this is invalid we can skip the address * space check, thus avoiding the deadlock: */ if (unlikely(!down_read_trylock(&mm->mmap_sem))) { if ((error_code & PF_USER) == 0 && !search_exception_tables(regs->ip)) { bad_area_nosemaphore(regs, error_code, address); return; } retry: down_read(&mm->mmap_sem); } else { /* * The above down_read_trylock() might have succeeded in * which case we'll have missed the might_sleep() from * down_read(): */ might_sleep(); } vma = find_vma(mm, address); if (unlikely(!vma)) { bad_area(regs, error_code, address); return; } if (likely(vma->vm_start <= address)) goto good_area; if (unlikely(!(vma->vm_flags & VM_GROWSDOWN))) { bad_area(regs, error_code, address); return; } if (error_code & PF_USER) { /* * Accessing the stack below %sp is always a bug. * The large cushion allows instructions like enter * and pusha to work. ("enter $65535, $31" pushes * 32 pointers and then decrements %sp by 65535.) */ if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) { bad_area(regs, error_code, address); return; } } if (unlikely(expand_stack(vma, address))) { bad_area(regs, error_code, address); return; } /* * Ok, we have a good vm_area for this memory access, so * we can handle it.. */ good_area: if (unlikely(access_error(error_code, vma))) { bad_area_access_error(regs, error_code, address); return; } /* * If for any reason at all we couldn't handle the fault, * make sure we exit gracefully rather than endlessly redo * the fault. Since we never set FAULT_FLAG_RETRY_NOWAIT, if * we get VM_FAULT_RETRY back, the mmap_sem has been unlocked. */ fault = handle_mm_fault(mm, vma, address, flags); major |= fault & VM_FAULT_MAJOR; /* * If we need to retry the mmap_sem has already been released, * and if there is a fatal signal pending there is no guarantee * that we made any progress. Handle this case first. */ if (unlikely(fault & VM_FAULT_RETRY)) { /* Retry at most once */ if (flags & FAULT_FLAG_ALLOW_RETRY) { flags &= ~FAULT_FLAG_ALLOW_RETRY; flags |= FAULT_FLAG_TRIED; if (!fatal_signal_pending(tsk)) goto retry; } /* User mode? Just return to handle the fatal exception */ if (flags & FAULT_FLAG_USER) return; /* Not returning to user mode? Handle exceptions or die: */ no_context(regs, error_code, address, SIGBUS, BUS_ADRERR); return; } up_read(&mm->mmap_sem); if (unlikely(fault & VM_FAULT_ERROR)) { mm_fault_error(regs, error_code, address, fault); return; } /* * Major/minor page fault accounting. If any of the events * returned VM_FAULT_MAJOR, we account it as a major fault. */ if (major) { tsk->maj_flt++; perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, regs, address); } else { tsk->min_flt++; perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address); } check_v8086_mode(regs, address, tsk); }
0
[ "CWE-264" ]
linux
548acf19234dbda5a52d5a8e7e205af46e9da840
288,113,204,490,346,560,000,000,000,000,000,000,000
226
x86/mm: Expand the exception table logic to allow new handling options Huge amounts of help from Andy Lutomirski and Borislav Petkov to produce this. Andy provided the inspiration to add classes to the exception table with a clever bit-squeezing trick, Boris pointed out how much cleaner it would all be if we just had a new field. Linus Torvalds blessed the expansion with: ' I'd rather not be clever in order to save just a tiny amount of space in the exception table, which isn't really criticial for anybody. ' The third field is another relative function pointer, this one to a handler that executes the actions. We start out with three handlers: 1: Legacy - just jumps the to fixup IP 2: Fault - provide the trap number in %ax to the fixup code 3: Cleaned up legacy for the uaccess error hack Signed-off-by: Tony Luck <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/f6af78fcbd348cf4939875cfda9c19689b5e50b8.1455732970.git.tony.luck@intel.com Signed-off-by: Ingo Molnar <[email protected]>
void handle_reset(Connection *con) { Mutex::Locker l(lock); available_connections.erase(con); dispatcher.clear_pending(con); }
0
[ "CWE-287", "CWE-284" ]
ceph
5ead97120e07054d80623dada90a5cc764c28468
125,363,988,044,768,480,000,000,000,000,000,000,000
5
auth/cephx: add authorizer challenge Allow the accepting side of a connection to reject an initial authorizer with a random challenge. The connecting side then has to respond with an updated authorizer proving they are able to decrypt the service's challenge and that the new authorizer was produced for this specific connection instance. The accepting side requires this challenge and response unconditionally if the client side advertises they have the feature bit. Servers wishing to require this improved level of authentication simply have to require the appropriate feature. Signed-off-by: Sage Weil <[email protected]> (cherry picked from commit f80b848d3f830eb6dba50123e04385173fa4540b) # Conflicts: # src/auth/Auth.h # src/auth/cephx/CephxProtocol.cc # src/auth/cephx/CephxProtocol.h # src/auth/none/AuthNoneProtocol.h # src/msg/Dispatcher.h # src/msg/async/AsyncConnection.cc - const_iterator - ::decode vs decode - AsyncConnection ctor arg noise - get_random_bytes(), not cct->random()
blob_cmp_sn (KEYBOXBLOB blob, const unsigned char *sn, int snlen) { const unsigned char *buffer; size_t length; size_t pos, off; size_t nkeys, keyinfolen; size_t nserial; buffer = _keybox_get_blob_image (blob, &length); if (length < 40) return 0; /* blob too short */ /*keys*/ nkeys = get16 (buffer + 16); keyinfolen = get16 (buffer + 18 ); if (keyinfolen < 28) return 0; /* invalid blob */ pos = 20 + keyinfolen*nkeys; if (pos+2 > length) return 0; /* out of bounds */ /*serial*/ nserial = get16 (buffer+pos); off = pos + 2; if (off+nserial > length) return 0; /* out of bounds */ return nserial == snlen && !memcmp (buffer+off, sn, snlen); }
0
[ "CWE-20" ]
gnupg
2183683bd633818dd031b090b5530951de76f392
183,340,030,413,504,400,000,000,000,000,000,000,000
29
Use inline functions to convert buffer data to scalars. * common/host2net.h (buf16_to_ulong, buf16_to_uint): New. (buf16_to_ushort, buf16_to_u16): New. (buf32_to_size_t, buf32_to_ulong, buf32_to_uint, buf32_to_u32): New. -- Commit 91b826a38880fd8a989318585eb502582636ddd8 was not enough to avoid all sign extension on shift problems. Hanno Böck found a case with an invalid read due to this problem. To fix that once and for all almost all uses of "<< 24" and "<< 8" are changed by this patch to use an inline function from host2net.h. Signed-off-by: Werner Koch <[email protected]>
static void lo_rmdir(fuse_req_t req, fuse_ino_t parent, const char *name) { int res; struct lo_inode *inode; struct lo_data *lo = lo_data(req); if (is_empty(name)) { fuse_reply_err(req, ENOENT); return; } if (!is_safe_path_component(name)) { fuse_reply_err(req, EINVAL); return; } inode = lookup_name(req, parent, name); if (!inode) { fuse_reply_err(req, EIO); return; } res = unlinkat(lo_fd(req, parent), name, AT_REMOVEDIR); fuse_reply_err(req, res == -1 ? errno : 0); unref_inode_lolocked(lo, inode, 1); lo_inode_put(lo, &inode); }
0
[ "CWE-273" ]
qemu
449e8171f96a6a944d1f3b7d3627ae059eae21ca
315,337,974,485,191,900,000,000,000,000,000,000,000
28
virtiofsd: Drop membership of all supplementary groups (CVE-2022-0358) At the start, drop membership of all supplementary groups. This is not required. If we have membership of "root" supplementary group and when we switch uid/gid using setresuid/setsgid, we still retain membership of existing supplemntary groups. And that can allow some operations which are not normally allowed. For example, if root in guest creates a dir as follows. $ mkdir -m 03777 test_dir This sets SGID on dir as well as allows unprivileged users to write into this dir. And now as unprivileged user open file as follows. $ su test $ fd = open("test_dir/priviledge_id", O_RDWR|O_CREAT|O_EXCL, 02755); This will create SGID set executable in test_dir/. And that's a problem because now an unpriviliged user can execute it, get egid=0 and get access to resources owned by "root" group. This is privilege escalation. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2044863 Fixes: CVE-2022-0358 Reported-by: JIETAO XIAO <[email protected]> Suggested-by: Miklos Szeredi <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]> Reviewed-by: Dr. David Alan Gilbert <[email protected]> Signed-off-by: Vivek Goyal <[email protected]> Message-Id: <[email protected]> Signed-off-by: Dr. David Alan Gilbert <[email protected]> dgilbert: Fixed missing {}'s style nit
static UINT rdpei_send_cs_ready_pdu(RDPEI_CHANNEL_CALLBACK* callback) { UINT status; wStream* s; UINT32 flags; UINT32 pduLength; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*)callback->plugin; flags = 0; flags |= READY_FLAGS_SHOW_TOUCH_VISUALS; // flags |= READY_FLAGS_DISABLE_TIMESTAMP_INJECTION; pduLength = RDPINPUT_HEADER_LENGTH + 10; s = Stream_New(NULL, pduLength); if (!s) { WLog_ERR(TAG, "Stream_New failed!"); return CHANNEL_RC_NO_MEMORY; } Stream_Seek(s, RDPINPUT_HEADER_LENGTH); Stream_Write_UINT32(s, flags); /* flags (4 bytes) */ Stream_Write_UINT32(s, RDPINPUT_PROTOCOL_V10); /* protocolVersion (4 bytes) */ Stream_Write_UINT16(s, rdpei->maxTouchContacts); /* maxTouchContacts (2 bytes) */ Stream_SealLength(s); status = rdpei_send_pdu(callback, s, EVENTID_CS_READY, pduLength); Stream_Free(s, TRUE); return status; }
0
[ "CWE-125" ]
FreeRDP
6b485b146a1b9d6ce72dfd7b5f36456c166e7a16
140,099,231,237,714,070,000,000,000,000,000,000,000
28
Fixed oob read in irp_write and similar
Return a list of subscribed mailboxes */ PHP_FUNCTION(imap_lsub) { zval *streamind; zend_string *ref, *pat; pils *imap_le_struct; STRINGLIST *cur=NIL; if (zend_parse_parameters(ZEND_NUM_ARGS(), "rSS", &streamind, &ref, &pat) == FAILURE) { return; } if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) { RETURN_FALSE; } /* set flag for normal, old mailbox list */ IMAPG(folderlist_style) = FLIST_ARRAY; IMAPG(imap_sfolders) = NIL; mail_lsub(imap_le_struct->imap_stream, ZSTR_VAL(ref), ZSTR_VAL(pat)); if (IMAPG(imap_sfolders) == NIL) { RETURN_FALSE; } array_init(return_value); cur=IMAPG(imap_sfolders); while (cur != NIL) { add_next_index_string(return_value, (char*)cur->LTEXT); cur=cur->next; } mail_free_stringlist (&IMAPG(imap_sfolders)); IMAPG(imap_sfolders) = IMAPG(imap_sfolders_tail) = NIL;
0
[ "CWE-88" ]
php-src
336d2086a9189006909ae06c7e95902d7d5ff77e
320,650,559,105,290,800,000,000,000,000,000,000,000
33
Disable rsh/ssh functionality in imap by default (bug #77153)
getPhysicalQueueSize(qqueue_t *pThis) { return pThis->iQueueSize; }
0
[ "CWE-772" ]
rsyslog
dfa88369d4ca4290db56b843f9eabdae1bfe0fd5
312,692,232,215,479,460,000,000,000,000,000,000,000
4
bugfix: memory leak when $RepeatedMsgReduction on was used bug tracker: http://bugzilla.adiscon.com/show_bug.cgi?id=225
hb_ot_layout_language_get_feature_index (hb_ot_layout_t *layout, hb_ot_layout_table_type_t table_type, unsigned int script_index, unsigned int language_index, unsigned int num_feature) { const GSUBGPOS &g = get_gsubgpos_table (layout, table_type); const LangSys &l = g.get_script (script_index).get_lang_sys (language_index); return l.get_feature_index (num_feature); }
0
[]
pango
336bb3201096bdd0494d29926dd44e8cca8bed26
297,540,501,302,237,900,000,000,000,000,000,000,000
11
[HB] Remove all references to the old code!
EC_Group_Data_Map& EC_Group::ec_group_data() { /* * This exists purely to ensure the allocator is constructed before g_ec_data, * which ensures that its destructor runs after ~g_ec_data is complete. */ static Allocator_Initializer g_init_allocator; static EC_Group_Data_Map g_ec_data; return g_ec_data; }
0
[ "CWE-200" ]
botan
48fc8df51d99f9d8ba251219367b3d629cc848e3
243,375,948,503,624,070,000,000,000,000,000,000,000
11
Address DSA/ECDSA side channel
BSONObj spec() { return BSON("$gte" << BSON_ARRAY(2 << "$b")); }
0
[ "CWE-835" ]
mongo
0a076417d1d7fba3632b73349a1fd29a83e68816
82,260,524,965,546,120,000,000,000,000,000,000,000
3
SERVER-38070 fix infinite loop in agg expression
bool lock_sock_fast(struct sock *sk) { might_sleep(); spin_lock_bh(&sk->sk_lock.slock); if (!sk->sk_lock.owned) /* * Note : We must disable BH */ return false; __lock_sock(sk); sk->sk_lock.owned = 1; spin_unlock(&sk->sk_lock.slock); /* * The sk_lock has mutex_lock() semantics here: */ mutex_acquire(&sk->sk_lock.dep_map, 0, 0, _RET_IP_); local_bh_enable(); return true; }
0
[ "CWE-119", "CWE-787" ]
linux
b98b0bc8c431e3ceb4b26b0dfc8db509518fb290
102,572,310,521,602,170,000,000,000,000,000,000,000
21
net: avoid signed overflows for SO_{SND|RCV}BUFFORCE CAP_NET_ADMIN users should not be allowed to set negative sk_sndbuf or sk_rcvbuf values, as it can lead to various memory corruptions, crashes, OOM... Note that before commit 82981930125a ("net: cleanups in sock_setsockopt()"), the bug was even more serious, since SO_SNDBUF and SO_RCVBUF were vulnerable. This needs to be backported to all known linux kernels. Again, many thanks to syzkaller team for discovering this gem. Signed-off-by: Eric Dumazet <[email protected]> Reported-by: Andrey Konovalov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int nx, const struct flowi *fl, struct dst_entry *dst) { struct net *net = xp_net(policy); unsigned long now = jiffies; struct net_device *dev; struct xfrm_mode *inner_mode; struct dst_entry *dst_prev = NULL; struct dst_entry *dst0 = NULL; int i = 0; int err; int header_len = 0; int nfheader_len = 0; int trailer_len = 0; int tos; int family = policy->selector.family; xfrm_address_t saddr, daddr; xfrm_flowi_addr_get(fl, &saddr, &daddr, family); tos = xfrm_get_tos(fl, family); dst_hold(dst); for (; i < nx; i++) { struct xfrm_dst *xdst = xfrm_alloc_dst(net, family); struct dst_entry *dst1 = &xdst->u.dst; err = PTR_ERR(xdst); if (IS_ERR(xdst)) { dst_release(dst); goto put_states; } if (xfrm[i]->sel.family == AF_UNSPEC) { inner_mode = xfrm_ip2inner_mode(xfrm[i], xfrm_af2proto(family)); if (!inner_mode) { err = -EAFNOSUPPORT; dst_release(dst); goto put_states; } } else inner_mode = xfrm[i]->inner_mode; if (!dst_prev) dst0 = dst1; else /* Ref count is taken during xfrm_alloc_dst() * No need to do dst_clone() on dst1 */ dst_prev->child = dst1; xdst->route = dst; dst_copy_metrics(dst1, dst); if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) { family = xfrm[i]->props.family; dst = xfrm_dst_lookup(xfrm[i], tos, fl->flowi_oif, &saddr, &daddr, family); err = PTR_ERR(dst); if (IS_ERR(dst)) goto put_states; } else dst_hold(dst); dst1->xfrm = xfrm[i]; xdst->xfrm_genid = xfrm[i]->genid; dst1->obsolete = DST_OBSOLETE_FORCE_CHK; dst1->flags |= DST_HOST; dst1->lastuse = now; dst1->input = dst_discard; dst1->output = inner_mode->afinfo->output; dst1->next = dst_prev; dst_prev = dst1; header_len += xfrm[i]->props.header_len; if (xfrm[i]->type->flags & XFRM_TYPE_NON_FRAGMENT) nfheader_len += xfrm[i]->props.header_len; trailer_len += xfrm[i]->props.trailer_len; } dst_prev->child = dst; dst0->path = dst; err = -ENODEV; dev = dst->dev; if (!dev) goto free_dst; xfrm_init_path((struct xfrm_dst *)dst0, dst, nfheader_len); xfrm_init_pmtu(dst_prev); for (dst_prev = dst0; dst_prev != dst; dst_prev = dst_prev->child) { struct xfrm_dst *xdst = (struct xfrm_dst *)dst_prev; err = xfrm_fill_dst(xdst, dev, fl); if (err) goto free_dst; dst_prev->header_len = header_len; dst_prev->trailer_len = trailer_len; header_len -= xdst->u.dst.xfrm->props.header_len; trailer_len -= xdst->u.dst.xfrm->props.trailer_len; } out: return dst0; put_states: for (; i < nx; i++) xfrm_state_put(xfrm[i]); free_dst: if (dst0) dst_release_immediate(dst0); dst0 = ERR_PTR(err); goto out; }
0
[ "CWE-125" ]
ipsec
7bab09631c2a303f87a7eb7e3d69e888673b9b7e
160,831,195,333,555,150,000,000,000,000,000,000,000
123
xfrm: policy: check policy direction value The 'dir' parameter in xfrm_migrate() is a user-controlled byte which is used as an array index. This can lead to an out-of-bound access, kernel lockup and DoS. Add a check for the 'dir' value. This fixes CVE-2017-11600. References: https://bugzilla.redhat.com/show_bug.cgi?id=1474928 Fixes: 80c9abaabf42 ("[XFRM]: Extension for dynamic update of endpoint address(es)") Cc: <[email protected]> # v2.6.21-rc1 Reported-by: "bo Zhang" <[email protected]> Signed-off-by: Vladis Dronov <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
void JOIN_TAB::cleanup() { DBUG_ENTER("JOIN_TAB::cleanup"); DBUG_PRINT("enter", ("tab: %p table %s.%s", this, (table ? table->s->db.str : "?"), (table ? table->s->table_name.str : "?"))); delete select; select= 0; delete quick; quick= 0; if (cache) { cache->free(); cache= 0; } limit= 0; // Free select that was created for filesort outside of create_sort_index if (filesort && filesort->select && !filesort->own_select) delete filesort->select; delete filesort; filesort= NULL; /* Skip non-existing derived tables/views result tables */ if (table && (table->s->tmp_table != INTERNAL_TMP_TABLE || table->is_created())) { table->file->ha_end_keyread(); table->file->ha_index_or_rnd_end(); } if (table) { table->file->ha_end_keyread(); if (type == JT_FT) table->file->ha_ft_end(); else table->file->ha_index_or_rnd_end(); preread_init_done= FALSE; if (table->pos_in_table_list && table->pos_in_table_list->jtbm_subselect) { if (table->pos_in_table_list->jtbm_subselect->is_jtbm_const_tab) { /* Set this to NULL so that cleanup_empty_jtbm_semi_joins() doesn't attempt to make another free_tmp_table call. */ table->pos_in_table_list->table= NULL; free_tmp_table(join->thd, table); table= NULL; } else { TABLE_LIST *tmp= table->pos_in_table_list; end_read_record(&read_record); tmp->jtbm_subselect->cleanup(); /* The above call freed the materializedd temptable. Set it to NULL so that we don't attempt to touch it if JOIN_TAB::cleanup() is invoked multiple times (it may be) */ tmp->table= NULL; table= NULL; } DBUG_VOID_RETURN; } /* We need to reset this for next select (Tested in part_of_refkey) */ table->reginfo.join_tab= 0; } end_read_record(&read_record); explain_plan= NULL; DBUG_VOID_RETURN; }
0
[]
server
ff77a09bda884fe6bf3917eb29b9d3a2f53f919b
305,366,145,323,587,100,000,000,000,000,000,000,000
76
MDEV-22464 Server crash on UPDATE with nested subquery Uninitialized ref_pointer_array[] because setup_fields() got empty fields list. mysql_multi_update() for some reason does that by substituting the fields list with empty total_list for the mysql_select() call (looks like wrong merge since total_list is not used anywhere else and is always empty). The fix would be to return back the original fields list. But this fails update_use_source.test case: --error ER_BAD_FIELD_ERROR update v1 set t1c1=2 order by 1; Actually not failing the above seems to be ok. The other fix would be to keep resolve_in_select_list false (and that keeps outer context from being resolved in Item_ref::fix_fields()). This fix is more consistent with how SELECT behaves: --error ER_SUBQUERY_NO_1_ROW select a from t1 where a= (select 2 from t1 having (a = 3)); So this patch implements this fix.
static inline void set_idle_cores(int cpu, int val) { struct sched_domain_shared *sds; sds = rcu_dereference(per_cpu(sd_llc_shared, cpu)); if (sds) WRITE_ONCE(sds->has_idle_cores, val); }
0
[ "CWE-400", "CWE-703", "CWE-835" ]
linux
c40f7d74c741a907cfaeb73a7697081881c497d0
195,699,566,691,630,940,000,000,000,000,000,000,000
8
sched/fair: Fix infinite loop in update_blocked_averages() by reverting a9e7f6544b9c Zhipeng Xie, Xie XiuQi and Sargun Dhillon reported lockups in the scheduler under high loads, starting at around the v4.18 time frame, and Zhipeng Xie tracked it down to bugs in the rq->leaf_cfs_rq_list manipulation. Do a (manual) revert of: a9e7f6544b9c ("sched/fair: Fix O(nr_cgroups) in load balance path") It turns out that the list_del_leaf_cfs_rq() introduced by this commit is a surprising property that was not considered in followup commits such as: 9c2791f936ef ("sched/fair: Fix hierarchical order in rq->leaf_cfs_rq_list") As Vincent Guittot explains: "I think that there is a bigger problem with commit a9e7f6544b9c and cfs_rq throttling: Let take the example of the following topology TG2 --> TG1 --> root: 1) The 1st time a task is enqueued, we will add TG2 cfs_rq then TG1 cfs_rq to leaf_cfs_rq_list and we are sure to do the whole branch in one path because it has never been used and can't be throttled so tmp_alone_branch will point to leaf_cfs_rq_list at the end. 2) Then TG1 is throttled 3) and we add TG3 as a new child of TG1. 4) The 1st enqueue of a task on TG3 will add TG3 cfs_rq just before TG1 cfs_rq and tmp_alone_branch will stay on rq->leaf_cfs_rq_list. With commit a9e7f6544b9c, we can del a cfs_rq from rq->leaf_cfs_rq_list. So if the load of TG1 cfs_rq becomes NULL before step 2) above, TG1 cfs_rq is removed from the list. Then at step 4), TG3 cfs_rq is added at the beginning of rq->leaf_cfs_rq_list but tmp_alone_branch still points to TG3 cfs_rq because its throttled parent can't be enqueued when the lock is released. tmp_alone_branch doesn't point to rq->leaf_cfs_rq_list whereas it should. So if TG3 cfs_rq is removed or destroyed before tmp_alone_branch points on another TG cfs_rq, the next TG cfs_rq that will be added, will be linked outside rq->leaf_cfs_rq_list - which is bad. In addition, we can break the ordering of the cfs_rq in rq->leaf_cfs_rq_list but this ordering is used to update and propagate the update from leaf down to root." Instead of trying to work through all these cases and trying to reproduce the very high loads that produced the lockup to begin with, simplify the code temporarily by reverting a9e7f6544b9c - which change was clearly not thought through completely. This (hopefully) gives us a kernel that doesn't lock up so people can continue to enjoy their holidays without worrying about regressions. ;-) [ mingo: Wrote changelog, fixed weird spelling in code comment while at it. ] Analyzed-by: Xie XiuQi <[email protected]> Analyzed-by: Vincent Guittot <[email protected]> Reported-by: Zhipeng Xie <[email protected]> Reported-by: Sargun Dhillon <[email protected]> Reported-by: Xie XiuQi <[email protected]> Tested-by: Zhipeng Xie <[email protected]> Tested-by: Sargun Dhillon <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Acked-by: Vincent Guittot <[email protected]> Cc: <[email protected]> # v4.13+ Cc: Bin Li <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Thomas Gleixner <[email protected]> Fixes: a9e7f6544b9c ("sched/fair: Fix O(nr_cgroups) in load balance path") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
int main(int argc, char **argv) { int n; /* general index */ int noop; /* true to suppress option decoding */ unsigned long done; /* number of named files processed */ char *opts, *p; /* environment default options, marker */ /* initialize globals */ g.outf = NULL; g.first = 1; g.hname = NULL; /* save pointer to program name for error messages */ p = strrchr(argv[0], '/'); p = p == NULL ? argv[0] : p + 1; g.prog = *p ? p : "pigz"; /* prepare for interrupts and logging */ signal(SIGINT, cut_short); #ifndef NOTHREAD yarn_prefix = g.prog; /* prefix for yarn error messages */ yarn_abort = cut_short; /* call on thread error */ #endif #ifdef DEBUG gettimeofday(&start, NULL); /* starting time for log entries */ log_init(); /* initialize logging */ #endif /* set all options to defaults */ defaults(); /* process user environment variable defaults in GZIP */ opts = getenv("GZIP"); if (opts != NULL) { while (*opts) { while (*opts == ' ' || *opts == '\t') opts++; p = opts; while (*p && *p != ' ' && *p != '\t') p++; n = *p; *p = 0; if (option(opts)) bail("cannot provide files in GZIP environment variable", ""); opts = p + (n ? 1 : 0); } option(NULL); } /* process user environment variable defaults in PIGZ as well */ opts = getenv("PIGZ"); if (opts != NULL) { while (*opts) { while (*opts == ' ' || *opts == '\t') opts++; p = opts; while (*p && *p != ' ' && *p != '\t') p++; n = *p; *p = 0; if (option(opts)) bail("cannot provide files in PIGZ environment variable", ""); opts = p + (n ? 1 : 0); } option(NULL); } /* decompress if named "unpigz" or "gunzip", to stdout if "*cat" */ if (strcmp(g.prog, "unpigz") == 0 || strcmp(g.prog, "gunzip") == 0) { if (!g.decode) g.headis >>= 2; g.decode = 1; } if ((n = strlen(g.prog)) > 2 && strcmp(g.prog + n - 3, "cat") == 0) { if (!g.decode) g.headis >>= 2; g.decode = 1; g.pipeout = 1; } /* if no arguments and compressed data to or from a terminal, show help */ if (argc < 2 && isatty(g.decode ? 0 : 1)) help(); /* process command-line arguments, no options after "--" */ done = noop = 0; for (n = 1; n < argc; n++) if (noop == 0 && strcmp(argv[n], "--") == 0) { noop = 1; option(NULL); } else if (noop || option(argv[n])) { /* true if file name, process it */ if (done == 1 && g.pipeout && !g.decode && !g.list && g.form > 1) complain("warning: output will be concatenated zip files -- " "will not be able to extract"); process(strcmp(argv[n], "-") ? argv[n] : NULL); done++; } option(NULL); /* list stdin or compress stdin to stdout if no file names provided */ if (done == 0) process(NULL); /* done -- release resources, show log */ new_opts(); log_dump(); return 0; }
0
[ "CWE-703", "CWE-22" ]
pigz
fdad1406b3ec809f4954ff7cdf9e99eb18c2458f
94,166,835,948,571,100,000,000,000,000,000,000,000
109
When decompressing with -N or -NT, strip any path from header name. This uses the path of the compressed file combined with the name from the header as the name of the decompressed output file. Any path information in the header name is stripped. This avoids a possible vulnerability where absolute or descending paths are put in the gzip header.
xmlExpSubsume(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) { xmlExpNodePtr tmp; if ((exp == NULL) || (ctxt == NULL) || (sub == NULL)) return(-1); /* * TODO: speedup by checking the language of sub is a subset of the * language of exp */ /* * O(1) speedups */ if (IS_NILLABLE(sub) && (!IS_NILLABLE(exp))) { #ifdef DEBUG_DERIV printf("Sub nillable and not exp : can't subsume\n"); #endif return(0); } if (xmlExpCheckCard(exp, sub) == 0) { #ifdef DEBUG_DERIV printf("sub generate longuer sequances than exp : can't subsume\n"); #endif return(0); } tmp = xmlExpExpDeriveInt(ctxt, exp, sub); #ifdef DEBUG_DERIV printf("Result derivation :\n"); PRINT_EXP(tmp); #endif if (tmp == NULL) return(-1); if (tmp == forbiddenExp) return(0); if (tmp == emptyExp) return(1); if ((tmp != NULL) && (IS_NILLABLE(tmp))) { xmlExpFree(ctxt, tmp); return(1); } xmlExpFree(ctxt, tmp); return(0); }
0
[ "CWE-119" ]
libxml2
cbb271655cadeb8dbb258a64701d9a3a0c4835b4
180,776,170,355,678,240,000,000,000,000,000,000,000
43
Bug 757711: heap-buffer-overflow in xmlFAParsePosCharGroup <https://bugzilla.gnome.org/show_bug.cgi?id=757711> * xmlregexp.c: (xmlFAParseCharRange): Only advance to the next character if there is no error. Advancing to the next character in case of an error while parsing regexp leads to an out of bounds access.
hrtick_start_fair(struct rq *rq, struct task_struct *p) { }
0
[]
linux-2.6
6a6029b8cefe0ca7e82f27f3904dbedba3de4e06
303,064,253,235,374,150,000,000,000,000,000,000,000
3
sched: simplify sched_slice() Use the existing calc_delta_mine() calculation for sched_slice(). This saves a divide and simplifies the code because we share it with the other /cfs_rq->load users. It also improves code size: text data bss dec hex filename 42659 2740 144 45543 b1e7 sched.o.before 42093 2740 144 44977 afb1 sched.o.after Signed-off-by: Ingo Molnar <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]>
static int slcan_change_mtu(struct net_device *dev, int new_mtu) { return -EINVAL; }
0
[ "CWE-200", "CWE-909", "CWE-908" ]
linux
b9258a2cece4ec1f020715fe3554bc2e360f6264
1,606,410,614,164,221,800,000,000,000,000,000,000
4
slcan: Don't transmit uninitialized stack data in padding struct can_frame contains some padding which is not explicitly zeroed in slc_bump. This uninitialized data will then be transmitted if the stack initialization hardening feature is not enabled (CONFIG_INIT_STACK_ALL). This commit just zeroes the whole struct including the padding. Signed-off-by: Richard Palethorpe <[email protected]> Fixes: a1044e36e457 ("can: add slcan driver for serial/USB-serial CAN adapters") Reviewed-by: Kees Cook <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Acked-by: Marc Kleine-Budde <[email protected]> Signed-off-by: David S. Miller <[email protected]>
bool Item_default_value::get_date_result(MYSQL_TIME *ltime,ulonglong fuzzydate) { calculate(); return Item_field::get_date_result(ltime, fuzzydate); }
0
[ "CWE-416" ]
server
c02ebf3510850ba78a106be9974c94c3b97d8585
66,208,980,427,666,270,000,000,000,000,000,000,000
5
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 int am_cache_entry_store_string(am_cache_entry_t *entry, am_cache_storage_t *slot, const char *string) { char *datastr = NULL; apr_size_t datalen = 0; apr_size_t str_len = 0; if (string == NULL) return 0; if (slot->ptr != 0) { datastr = &entry->pool[slot->ptr]; datalen = strlen(datastr) + 1; } str_len = strlen(string) + 1; if (str_len - datalen <= 0) { memcpy(datastr, string, str_len); return 0; } /* recover space if slot happens to point to the last allocated space */ if (slot->ptr + datalen == entry->pool_used) { entry->pool_used -= datalen; slot->ptr = 0; } if (am_cache_entry_pool_left(entry) < str_len) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, "apr_cache_entry_store_string() asked %zd available: %zd. " "It may be a good idea to increase MellonCacheEntrySize.", str_len, am_cache_entry_pool_left(entry)); return HTTP_INTERNAL_SERVER_ERROR; } slot->ptr = entry->pool_used; datastr = &entry->pool[slot->ptr]; memcpy(datastr, string, str_len); entry->pool_used += str_len; return 0; }
0
[ "CWE-79" ]
mod_auth_mellon
7af21c53da7bb1de024274ee6da30bc22316a079
64,910,331,433,375,620,000,000,000,000,000,000,000
40
Fix Cross-Site Session Transfer vulnerability mod_auth_mellon did not verify that the site the session was created for was the same site as the site the user accessed. This allows an attacker with access to one web site on a server to use the same session to get access to a different site running on the same server. This patch fixes this vulnerability by storing the cookie parameters used when creating the session in the session, and verifying those parameters when the session is loaded. Thanks to François Kooman for reporting this vulnerability. This vulnerability has been assigned CVE-2017-6807.
static inline void sctp_set_owner_w(struct sctp_chunk *chunk) { struct sctp_association *asoc = chunk->asoc; struct sock *sk = asoc->base.sk; /* The sndbuf space is tracked per association. */ sctp_association_hold(asoc); skb_set_owner_w(chunk->skb, sk); chunk->skb->destructor = sctp_wfree; /* Save the chunk pointer in skb for sctp_wfree to use later. */ *((struct sctp_chunk **)(chunk->skb->cb)) = chunk; asoc->sndbuf_used += SCTP_DATA_SNDSIZE(chunk) + sizeof(struct sk_buff) + sizeof(struct sctp_chunk); atomic_add(sizeof(struct sctp_chunk), &sk->sk_wmem_alloc); }
0
[ "CWE-476" ]
linux
ea2bc483ff5caada7c4aa0d5fbf87d3a6590273d
324,285,318,960,119,000,000,000,000,000,000,000,000
20
[SCTP]: Fix assertion (!atomic_read(&sk->sk_rmem_alloc)) failed message In current implementation, LKSCTP does receive buffer accounting for data in sctp_receive_queue and pd_lobby. However, LKSCTP don't do accounting for data in frag_list when data is fragmented. In addition, LKSCTP doesn't do accounting for data in reasm and lobby queue in structure sctp_ulpq. When there are date in these queue, assertion failed message is printed in inet_sock_destruct because sk_rmem_alloc of oldsk does not become 0 when socket is destroyed. Signed-off-by: Tsutomu Fujii <[email protected]> Signed-off-by: Vlad Yasevich <[email protected]> Signed-off-by: David S. Miller <[email protected]>
compress_write(ds_file_t *file, const uchar *buf, size_t len) { ds_compress_file_t *comp_file; ds_compress_ctxt_t *comp_ctxt; comp_thread_ctxt_t *threads; comp_thread_ctxt_t *thd; uint nthreads; uint i; const char *ptr; ds_file_t *dest_file; comp_file = (ds_compress_file_t *) file->ptr; comp_ctxt = comp_file->comp_ctxt; dest_file = comp_file->dest_file; threads = comp_ctxt->threads; nthreads = comp_ctxt->nthreads; ptr = (const char *) buf; while (len > 0) { uint max_thread; /* Send data to worker threads for compression */ for (i = 0; i < nthreads; i++) { size_t chunk_len; thd = threads + i; pthread_mutex_lock(&thd->ctrl_mutex); chunk_len = (len > COMPRESS_CHUNK_SIZE) ? COMPRESS_CHUNK_SIZE : len; thd->from = ptr; thd->from_len = chunk_len; pthread_mutex_lock(&thd->data_mutex); thd->data_avail = TRUE; pthread_cond_signal(&thd->data_cond); pthread_mutex_unlock(&thd->data_mutex); len -= chunk_len; if (len == 0) { break; } ptr += chunk_len; } max_thread = (i < nthreads) ? i : nthreads - 1; /* Reap and stream the compressed data */ for (i = 0; i <= max_thread; i++) { thd = threads + i; pthread_mutex_lock(&thd->data_mutex); while (thd->data_avail == TRUE) { pthread_cond_wait(&thd->data_cond, &thd->data_mutex); } xb_a(threads[i].to_len > 0); if (ds_write(dest_file, "NEWBNEWB", 8) || write_uint64_le(dest_file, comp_file->bytes_processed)) { msg("compress: write to the destination stream " "failed."); return 1; } comp_file->bytes_processed += threads[i].from_len; if (write_uint32_le(dest_file, threads[i].adler) || ds_write(dest_file, threads[i].to, threads[i].to_len)) { msg("compress: write to the destination stream " "failed."); return 1; } pthread_mutex_unlock(&threads[i].data_mutex); pthread_mutex_unlock(&threads[i].ctrl_mutex); } } return 0; }
0
[ "CWE-404", "CWE-703" ]
server
e1eb39a446c30b8459c39fd7f2ee1c55a36e97d2
280,696,671,306,821,760,000,000,000,000,000,000,000
86
MDEV-26561 Fix a bug due to unreleased lock Fix a bug of unreleased lock ctrl_mutex in the method create_worker_threads
TEST_P(SdsDynamicUpstreamIntegrationTest, BasicSuccess) { on_server_init_function_ = [this]() { createSdsStream(*(fake_upstreams_[1])); sendSdsResponse(getClientSecret()); }; initialize(); fake_upstreams_[0]->set_allow_unexpected_disconnects(true); // There is a race condition here; there are two static clusters: // backend cluster_0 with sds and sds_cluster. cluster_0 is created first, its init_manager // is called so it issues a sds call, but fail since sds_cluster is not added yet. // so cluster_0 is initialized with an empty secret. initialize() will not wait and will return. // the testing request will be called, even though in the pre_worker_function, a good sds is // send, the cluster will be updated with good secret, the testing request may fail if it is // before context is updated. Hence, need to wait for context_update counter. test_server_->waitForCounterGe( "cluster.cluster_0.client_ssl_socket_factory.ssl_context_update_by_sds", 1); testRouterHeaderOnlyRequestAndResponse(); }
0
[ "CWE-400" ]
envoy
0e49a495826ea9e29134c1bd54fdeb31a034f40c
57,662,273,488,443,470,000,000,000,000,000,000,000
21
http/2: add stats and stream flush timeout (#139) This commit adds a new stream flush timeout to guard against a remote server that does not open window once an entire stream has been buffered for flushing. Additional stats have also been added to better understand the codecs view of active streams as well as amount of data buffered. Signed-off-by: Matt Klein <[email protected]>
void print_modules(void) { struct module *mod; char buf[MODULE_FLAGS_BUF_SIZE]; printk(KERN_DEFAULT "Modules linked in:"); /* Most callers should already have preempt disabled, but make sure */ preempt_disable(); list_for_each_entry_rcu(mod, &modules, list) { if (mod->state == MODULE_STATE_UNFORMED) continue; pr_cont(" %s%s", mod->name, module_flags(mod, buf)); } preempt_enable(); if (last_unloaded_module[0]) pr_cont(" [last unloaded: %s]", last_unloaded_module); pr_cont("\n"); }
0
[ "CWE-362", "CWE-347" ]
linux
0c18f29aae7ce3dadd26d8ee3505d07cc982df75
94,366,123,663,598,450,000,000,000,000,000,000,000
18
module: limit enabling module.sig_enforce Irrespective as to whether CONFIG_MODULE_SIG is configured, specifying "module.sig_enforce=1" on the boot command line sets "sig_enforce". Only allow "sig_enforce" to be set when CONFIG_MODULE_SIG is configured. This patch makes the presence of /sys/module/module/parameters/sig_enforce dependent on CONFIG_MODULE_SIG=y. Fixes: fda784e50aac ("module: export module signature enforcement status") Reported-by: Nayna Jain <[email protected]> Tested-by: Mimi Zohar <[email protected]> Tested-by: Jessica Yu <[email protected]> Signed-off-by: Mimi Zohar <[email protected]> Signed-off-by: Jessica Yu <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
static void forward_syslog_iovec(Server *s, const struct iovec *iovec, unsigned n_iovec, const struct ucred *ucred, const struct timeval *tv) { static const union sockaddr_union sa = { .un.sun_family = AF_UNIX, .un.sun_path = "/run/systemd/journal/syslog", }; struct msghdr msghdr = { .msg_iov = (struct iovec *) iovec, .msg_iovlen = n_iovec, .msg_name = (struct sockaddr*) &sa.sa, .msg_namelen = SOCKADDR_UN_LEN(sa.un), }; struct cmsghdr *cmsg; union { struct cmsghdr cmsghdr; uint8_t buf[CMSG_SPACE(sizeof(struct ucred))]; } control; assert(s); assert(iovec); assert(n_iovec > 0); if (ucred) { zero(control); msghdr.msg_control = &control; msghdr.msg_controllen = sizeof(control); cmsg = CMSG_FIRSTHDR(&msghdr); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_CREDENTIALS; cmsg->cmsg_len = CMSG_LEN(sizeof(struct ucred)); memcpy(CMSG_DATA(cmsg), ucred, sizeof(struct ucred)); msghdr.msg_controllen = cmsg->cmsg_len; } /* Forward the syslog message we received via /dev/log to * /run/systemd/syslog. Unfortunately we currently can't set * the SO_TIMESTAMP auxiliary data, and hence we don't. */ if (sendmsg(s->syslog_fd, &msghdr, MSG_NOSIGNAL) >= 0) return; /* The socket is full? I guess the syslog implementation is * too slow, and we shouldn't wait for that... */ if (errno == EAGAIN) { s->n_forward_syslog_missed++; return; } if (ucred && IN_SET(errno, ESRCH, EPERM)) { struct ucred u; /* Hmm, presumably the sender process vanished * by now, or we don't have CAP_SYS_AMDIN, so * let's fix it as good as we can, and retry */ u = *ucred; u.pid = getpid_cached(); memcpy(CMSG_DATA(cmsg), &u, sizeof(struct ucred)); if (sendmsg(s->syslog_fd, &msghdr, MSG_NOSIGNAL) >= 0) return; if (errno == EAGAIN) { s->n_forward_syslog_missed++; return; } } if (errno != ENOENT) log_debug_errno(errno, "Failed to forward syslog message: %m"); }
0
[ "CWE-125" ]
systemd
a6aadf4ae0bae185dc4c414d492a4a781c80ffe5
223,982,951,081,230,900,000,000,000,000,000,000,000
72
journal: fix syslog_parse_identifier() Fixes #9829.
filter2bv_undef_x( Operation *op, Filter *f, int noundef, struct berval *fstr ) { int i; Filter *p; struct berval tmp, value; static struct berval ber_bvfalse = BER_BVC( "(?=false)" ), ber_bvtrue = BER_BVC( "(?=true)" ), ber_bvundefined = BER_BVC( "(?=undefined)" ), ber_bverror = BER_BVC( "(?=error)" ), ber_bvunknown = BER_BVC( "(?=unknown)" ), ber_bvnone = BER_BVC( "(?=none)" ), ber_bvF = BER_BVC( "(|)" ), ber_bvT = BER_BVC( "(&)" ); ber_len_t len; ber_tag_t choice; int undef, undef2; char *sign; if ( f == NULL ) { ber_dupbv_x( fstr, &ber_bvnone, op->o_tmpmemctx ); return; } undef = f->f_choice & SLAPD_FILTER_UNDEFINED; undef2 = (undef && !noundef); choice = f->f_choice & SLAPD_FILTER_MASK; switch ( choice ) { case LDAP_FILTER_EQUALITY: fstr->bv_len = STRLENOF("(=)"); sign = "="; goto simple; case LDAP_FILTER_GE: fstr->bv_len = STRLENOF("(>=)"); sign = ">="; goto simple; case LDAP_FILTER_LE: fstr->bv_len = STRLENOF("(<=)"); sign = "<="; goto simple; case LDAP_FILTER_APPROX: fstr->bv_len = STRLENOF("(~=)"); sign = "~="; simple: value = f->f_av_value; if ( f->f_av_desc->ad_type->sat_equality && !undef && ( f->f_av_desc->ad_type->sat_equality->smr_usage & SLAP_MR_MUTATION_NORMALIZER )) { f->f_av_desc->ad_type->sat_equality->smr_normalize( (SLAP_MR_DENORMALIZE|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX), NULL, NULL, &f->f_av_value, &value, op->o_tmpmemctx ); } filter_escape_value_x( &value, &tmp, op->o_tmpmemctx ); /* NOTE: tmp can legitimately be NULL (meaning empty) * since in a Filter values in AVAs are supposed * to have been normalized, meaning that an empty value * is legal for that attribute's syntax */ fstr->bv_len += f->f_av_desc->ad_cname.bv_len + tmp.bv_len; if ( undef2 ) fstr->bv_len++; fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s)", undef2 ? "?" : "", f->f_av_desc->ad_cname.bv_val, sign, tmp.bv_len ? tmp.bv_val : "" ); if ( value.bv_val != f->f_av_value.bv_val ) { ber_memfree_x( value.bv_val, op->o_tmpmemctx ); } ber_memfree_x( tmp.bv_val, op->o_tmpmemctx ); break; case LDAP_FILTER_SUBSTRINGS: fstr->bv_len = f->f_sub_desc->ad_cname.bv_len + STRLENOF("(=*)"); if ( undef2 ) fstr->bv_len++; fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 128, op->o_tmpmemctx ); snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s=*)", undef2 ? "?" : "", f->f_sub_desc->ad_cname.bv_val ); if ( f->f_sub_initial.bv_val != NULL ) { ber_len_t tmplen; len = fstr->bv_len; filter_escape_value_x( &f->f_sub_initial, &tmp, op->o_tmpmemctx ); tmplen = tmp.bv_len; fstr->bv_len += tmplen; fstr->bv_val = op->o_tmprealloc( fstr->bv_val, fstr->bv_len + 1, op->o_tmpmemctx ); snprintf( &fstr->bv_val[len - 2], tmplen + STRLENOF( /*(*/ "*)" ) + 1, /* "(attr=" */ "%s*)", tmp.bv_len ? tmp.bv_val : ""); ber_memfree_x( tmp.bv_val, op->o_tmpmemctx ); } if ( f->f_sub_any != NULL ) { for ( i = 0; f->f_sub_any[i].bv_val != NULL; i++ ) { ber_len_t tmplen; len = fstr->bv_len; filter_escape_value_x( &f->f_sub_any[i], &tmp, op->o_tmpmemctx ); tmplen = tmp.bv_len; fstr->bv_len += tmplen + STRLENOF( /*(*/ ")" ); fstr->bv_val = op->o_tmprealloc( fstr->bv_val, fstr->bv_len + 1, op->o_tmpmemctx ); snprintf( &fstr->bv_val[len - 1], tmplen + STRLENOF( /*(*/ "*)" ) + 1, /* "(attr=[init]*[any*]" */ "%s*)", tmp.bv_len ? tmp.bv_val : ""); ber_memfree_x( tmp.bv_val, op->o_tmpmemctx ); } } if ( f->f_sub_final.bv_val != NULL ) { ber_len_t tmplen; len = fstr->bv_len; filter_escape_value_x( &f->f_sub_final, &tmp, op->o_tmpmemctx ); tmplen = tmp.bv_len; fstr->bv_len += tmplen; fstr->bv_val = op->o_tmprealloc( fstr->bv_val, fstr->bv_len + 1, op->o_tmpmemctx ); snprintf( &fstr->bv_val[len - 1], tmplen + STRLENOF( /*(*/ ")" ) + 1, /* "(attr=[init*][any*]" */ "%s)", tmp.bv_len ? tmp.bv_val : ""); ber_memfree_x( tmp.bv_val, op->o_tmpmemctx ); } break; case LDAP_FILTER_PRESENT: fstr->bv_len = f->f_desc->ad_cname.bv_len + STRLENOF("(=*)"); if ( undef2 ) fstr->bv_len++; fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s=*)", undef2 ? "?" : "", f->f_desc->ad_cname.bv_val ); break; case LDAP_FILTER_AND: case LDAP_FILTER_OR: case LDAP_FILTER_NOT: fstr->bv_len = STRLENOF("(%)"); fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 128, op->o_tmpmemctx ); snprintf( fstr->bv_val, fstr->bv_len + 1, "(%c)", f->f_choice == LDAP_FILTER_AND ? '&' : f->f_choice == LDAP_FILTER_OR ? '|' : '!' ); for ( p = f->f_list; p != NULL; p = p->f_next ) { len = fstr->bv_len; filter2bv_undef_x( op, p, noundef, &tmp ); fstr->bv_len += tmp.bv_len; fstr->bv_val = op->o_tmprealloc( fstr->bv_val, fstr->bv_len + 1, op->o_tmpmemctx ); snprintf( &fstr->bv_val[len-1], tmp.bv_len + STRLENOF( /*(*/ ")" ) + 1, /*"("*/ "%s)", tmp.bv_val ); op->o_tmpfree( tmp.bv_val, op->o_tmpmemctx ); } break; case LDAP_FILTER_EXT: { struct berval ad; filter_escape_value_x( &f->f_mr_value, &tmp, op->o_tmpmemctx ); /* NOTE: tmp can legitimately be NULL (meaning empty) * since in a Filter values in MRAs are supposed * to have been normalized, meaning that an empty value * is legal for that attribute's syntax */ if ( f->f_mr_desc ) { ad = f->f_mr_desc->ad_cname; } else { ad.bv_len = 0; ad.bv_val = ""; } fstr->bv_len = ad.bv_len + ( undef2 ? 1 : 0 ) + ( f->f_mr_dnattrs ? STRLENOF(":dn") : 0 ) + ( f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_len + STRLENOF(":") : 0 ) + tmp.bv_len + STRLENOF("(:=)"); fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s%s:=%s)", undef2 ? "?" : "", ad.bv_val, f->f_mr_dnattrs ? ":dn" : "", f->f_mr_rule_text.bv_len ? ":" : "", f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_val : "", tmp.bv_len ? tmp.bv_val : "" ); ber_memfree_x( tmp.bv_val, op->o_tmpmemctx ); } break; case SLAPD_FILTER_COMPUTED: switch ( f->f_result ) { case LDAP_COMPARE_FALSE: tmp = ( noundef ? ber_bvF : ber_bvfalse ); break; case LDAP_COMPARE_TRUE: tmp = ( noundef ? ber_bvT : ber_bvtrue ); break; case SLAPD_COMPARE_UNDEFINED: tmp = ber_bvundefined; break; default: tmp = ber_bverror; break; } ber_dupbv_x( fstr, &tmp, op->o_tmpmemctx ); break; default: ber_dupbv_x( fstr, &ber_bvunknown, op->o_tmpmemctx ); break; } }
0
[ "CWE-674" ]
openldap
98464c11df8247d6a11b52e294ba5dd4f0380440
118,426,565,250,517,640,000,000,000,000,000,000,000
254
ITS#9202 limit depth of nested filters Using a hardcoded limit for now; no reasonable apps should ever run into it.
TEST(AsyncSSLSocketTest, ConnectWriteReadClose) { // Start listening on a local port WriteCallbackBase writeCallback; ReadCallback readCallback(&writeCallback); HandshakeCallback handshakeCallback(&readCallback); SSLServerAcceptCallback acceptCallback(&handshakeCallback); TestSSLServer server(&acceptCallback); // Set up SSL context. std::shared_ptr<SSLContext> sslContext(new SSLContext()); sslContext->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); // sslContext->loadTrustedCertificates("./trusted-ca-certificate.pem"); // sslContext->authenticate(true, false); // connect auto socket = std::make_shared<BlockingSocket>(server.getAddress(), sslContext); socket->open(std::chrono::milliseconds(10000)); // write() uint8_t buf[128]; memset(buf, 'a', sizeof(buf)); socket->write(buf, sizeof(buf)); // read() uint8_t readbuf[128]; uint32_t bytesRead = socket->readAll(readbuf, sizeof(readbuf)); EXPECT_EQ(bytesRead, 128); EXPECT_EQ(memcmp(buf, readbuf, bytesRead), 0); // close() socket->close(); cerr << "ConnectWriteReadClose test completed" << endl; EXPECT_EQ(socket->getSSLSocket()->getTotalConnectTimeout().count(), 10000); }
0
[ "CWE-125" ]
folly
c321eb588909646c15aefde035fd3133ba32cdee
59,967,814,816,262,160,000,000,000,000,000,000,000
36
Handle close_notify as standard writeErr in AsyncSSLSocket. Summary: Fixes CVE-2019-11934 Reviewed By: mingtaoy Differential Revision: D18020613 fbshipit-source-id: db82bb250e53f0d225f1280bd67bc74abd417836