func
stringlengths
0
484k
target
int64
0
1
cwe
listlengths
0
4
project
stringclasses
799 values
commit_id
stringlengths
40
40
hash
float64
1,215,700,430,453,689,100,000,000B
340,281,914,521,452,260,000,000,000,000B
size
int64
1
24k
message
stringlengths
0
13.3k
void ServerItem::init() { // Without this, columncount is wrong. setData(0, Qt::DisplayRole, QVariant()); setData(1, Qt::DisplayRole, QVariant()); setData(2, Qt::DisplayRole, QVariant()); emitDataChanged(); }
0
[ "CWE-59", "CWE-61" ]
mumble
e59ee87abe249f345908c7d568f6879d16bfd648
316,400,608,269,547,830,000,000,000,000,000,000,000
7
FIX(client): Only allow "http"/"https" for URLs in ConnectDialog Our public server list registration script doesn't have an URL scheme whitelist for the website field. Turns out a malicious server can register itself with a dangerous URL in an attempt to attack a user's machine. User interaction is required, as the URL has to be opened by right-clicking on the server entry and clicking on "Open Webpage". This commit introduces a client-side whitelist, which only allows "http" and "https" schemes. We will also implement it in our public list. In future we should probably add a warning QMessageBox informing the user that there's no guarantee the URL is safe (regardless of the scheme). Thanks a lot to https://positive.security for reporting the RCE vulnerability to us privately.
static int abort_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) { struct iwch_ep *ep = ctx; unsigned long flags; int release = 0; PDBG("%s ep %p\n", __func__, ep); BUG_ON(!ep); /* * We get 2 abort replies from the HW. The first one must * be ignored except for scribbling that we need one more. */ if (!test_and_set_bit(ABORT_REQ_IN_PROGRESS, &ep->com.flags)) { return CPL_RET_BUF_DONE; } spin_lock_irqsave(&ep->com.lock, flags); switch (ep->com.state) { case ABORTING: close_complete_upcall(ep); __state_set(&ep->com, DEAD); release = 1; break; default: printk(KERN_ERR "%s ep %p state %d\n", __func__, ep, ep->com.state); break; } spin_unlock_irqrestore(&ep->com.lock, flags); if (release) release_ep_resources(ep); return CPL_RET_BUF_DONE; }
0
[ "CWE-703" ]
linux
67f1aee6f45059fd6b0f5b0ecb2c97ad0451f6b3
310,007,943,175,624,740,000,000,000,000,000,000,000
35
iw_cxgb3: Fix incorrectly returning error on success The cxgb3_*_send() functions return NET_XMIT_ values, which are positive integers values. So don't treat positive return values as an error. Signed-off-by: Steve Wise <[email protected]> Signed-off-by: Hariprasad Shenai <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
int ConnectionImpl::onBeforeFrameSend(const nghttp2_frame* frame) { ENVOY_CONN_LOG(trace, "about to send frame type={}, flags={}", connection_, static_cast<uint64_t>(frame->hd.type), static_cast<uint64_t>(frame->hd.flags)); ASSERT(!is_outbound_flood_monitored_control_frame_); // Flag flood monitored outbound control frames. is_outbound_flood_monitored_control_frame_ = ((frame->hd.type == NGHTTP2_PING || frame->hd.type == NGHTTP2_SETTINGS) && frame->hd.flags & NGHTTP2_FLAG_ACK) || frame->hd.type == NGHTTP2_RST_STREAM; return 0; }
0
[ "CWE-400", "CWE-703" ]
envoy
afc39bea36fd436e54262f150c009e8d72db5014
315,818,286,063,504,680,000,000,000,000,000,000,000
11
Track byteSize of HeaderMap internally. Introduces a cached byte size updated internally in HeaderMap. The value is stored as an optional, and is cleared whenever a non-const pointer or reference to a HeaderEntry is accessed. The cached value can be set with refreshByteSize() which performs an iteration over the HeaderMap to sum the size of each key and value in the HeaderMap. Signed-off-by: Asra Ali <[email protected]>
ves_icall_Type_IsArrayImpl (MonoReflectionType *t) { MonoType *type; MonoBoolean res; MONO_ARCH_SAVE_REGS; type = t->type; res = !type->byref && (type->type == MONO_TYPE_ARRAY || type->type == MONO_TYPE_SZARRAY); return res; }
0
[ "CWE-264" ]
mono
035c8587c0d8d307e45f1b7171a0d337bb451f1e
16,486,289,234,675,349,000,000,000,000,000,000,000
12
Allow only primitive types/enums in RuntimeHelpers.InitializeArray ().
BGD_DECLARE(gdImagePtr) gdImageCreateFromPngPtr (int size, void *data) { gdImagePtr im; gdIOCtx *in = gdNewDynamicCtxEx (size, data, 0); if(!in) return 0; im = gdImageCreateFromPngCtx (in); in->gd_free (in); return im; }
0
[ "CWE-415" ]
libgd
56ce6ef068b954ad28379e83cca04feefc51320c
213,491,323,188,227,500,000,000,000,000,000,000,000
10
Fix #381: libgd double-free vulnerability The issue is that `gdImagePngCtxEx` (which is called by `gdImagePngPtr` and the other PNG output functions to do the real work) does not return whether it succeeded or failed, so this is not checked in `gdImagePngPtr` and the function wrongly assumes everything is okay, which is not, in this case, because the palette image contains no palette entries. We can't change the signature of `gdImagePngCtxEx` for API compatibility reasons, so we introduce the static helper `_gdImagePngCtxEx` which returns success respective failure, so `gdImagePngPtr` and `gdImagePngPtrEx` can check the return value. We leave it solely to libpng for now to report warnings regarding the failing write. CVE-2017-6362 (cherry picked from commit 2207e3c88a06a5c42230907554ab1e9f2ec021ea)
void gdi_graphics_pipeline_uninit(rdpGdi* gdi, RdpgfxClientContext* gfx) { if (gdi) gdi->gfx = NULL; if (!gfx) return; gfx->custom = NULL; DeleteCriticalSection(&gfx->mux); PROFILER_PRINT_HEADER PROFILER_PRINT(gfx->SurfaceProfiler) PROFILER_PRINT_FOOTER PROFILER_FREE(gfx->SurfaceProfiler) }
0
[ "CWE-190" ]
FreeRDP
e08a23f93136f59a52651f66d064b8d4303872e1
137,982,561,875,870,200,000,000,000,000,000,000,000
15
Fixed missing input sanitation for GFX surfaces. Thanks to Sunglin and HuanGMz of the Knownsec 404 security team and pangzi of pwnzen
std::string ZRtp::getPeerHelloHash() { std::ostringstream stm; if (peerHelloVersion[0] == 0) return std::string(); uint8_t* hp = peerHelloHash; stm << peerHelloVersion; stm << " "; stm.fill('0'); stm << hex; for (int i = 0; i < hashLengthImpl; i++) { stm.width(2); stm << static_cast<uint32_t>(*hp++); } return stm.str(); }
0
[ "CWE-119" ]
ZRTPCPP
c8617100f359b217a974938c5539a1dd8a120b0e
145,132,818,877,567,770,000,000,000,000,000,000,000
18
Fix vulnerabilities found and reported by Mark Dowd - limit length of memcpy - limit number of offered algorithms in Hello packet - length check in PING packet - fix a small coding error
userauth_pubkey(struct ssh *ssh) { Authctxt *authctxt = ssh->authctxt; struct passwd *pw = authctxt->pw; struct sshbuf *b; struct sshkey *key = NULL; char *pkalg, *userstyle = NULL, *key_s = NULL, *ca_s = NULL; u_char *pkblob, *sig, have_sig; size_t blen, slen; int r, pktype; int authenticated = 0; struct sshauthopt *authopts = NULL; if (!authctxt->valid) { debug2("%s: disabled because of invalid user", __func__); return 0; } if ((r = sshpkt_get_u8(ssh, &have_sig)) != 0 || (r = sshpkt_get_cstring(ssh, &pkalg, NULL)) != 0 || (r = sshpkt_get_string(ssh, &pkblob, &blen)) != 0) fatal("%s: parse request failed: %s", __func__, ssh_err(r)); pktype = sshkey_type_from_name(pkalg); if (pktype == KEY_UNSPEC) { /* this is perfectly legal */ verbose("%s: unsupported public key algorithm: %s", __func__, pkalg); goto done; } if ((r = sshkey_from_blob(pkblob, blen, &key)) != 0) { error("%s: could not parse key: %s", __func__, ssh_err(r)); goto done; } if (key == NULL) { error("%s: cannot decode key: %s", __func__, pkalg); goto done; } if (key->type != pktype) { error("%s: type mismatch for decoded key " "(received %d, expected %d)", __func__, key->type, pktype); goto done; } if (sshkey_type_plain(key->type) == KEY_RSA && (ssh->compat & SSH_BUG_RSASIGMD5) != 0) { logit("Refusing RSA key because client uses unsafe " "signature scheme"); goto done; } if (auth2_key_already_used(authctxt, key)) { logit("refusing previously-used %s key", sshkey_type(key)); goto done; } if (match_pattern_list(pkalg, options.pubkey_key_types, 0) != 1) { logit("%s: key type %s not in PubkeyAcceptedKeyTypes", __func__, sshkey_ssh_name(key)); goto done; } key_s = format_key(key); if (sshkey_is_cert(key)) ca_s = format_key(key->cert->signature_key); if (have_sig) { debug3("%s: have %s signature for %s%s%s", __func__, pkalg, key_s, ca_s == NULL ? "" : " CA ", ca_s == NULL ? "" : ca_s); if ((r = sshpkt_get_string(ssh, &sig, &slen)) != 0 || (r = sshpkt_get_end(ssh)) != 0) fatal("%s: %s", __func__, ssh_err(r)); if ((b = sshbuf_new()) == NULL) fatal("%s: sshbuf_new failed", __func__); if (ssh->compat & SSH_OLD_SESSIONID) { if ((r = sshbuf_put(b, session_id2, session_id2_len)) != 0) fatal("%s: sshbuf_put session id: %s", __func__, ssh_err(r)); } else { if ((r = sshbuf_put_string(b, session_id2, session_id2_len)) != 0) fatal("%s: sshbuf_put_string session id: %s", __func__, ssh_err(r)); } /* reconstruct packet */ xasprintf(&userstyle, "%s%s%s", authctxt->user, authctxt->style ? ":" : "", authctxt->style ? authctxt->style : ""); if ((r = sshbuf_put_u8(b, SSH2_MSG_USERAUTH_REQUEST)) != 0 || (r = sshbuf_put_cstring(b, userstyle)) != 0 || (r = sshbuf_put_cstring(b, authctxt->service)) != 0 || (r = sshbuf_put_cstring(b, "publickey")) != 0 || (r = sshbuf_put_u8(b, have_sig)) != 0 || (r = sshbuf_put_cstring(b, pkalg) != 0) || (r = sshbuf_put_string(b, pkblob, blen)) != 0) fatal("%s: build packet failed: %s", __func__, ssh_err(r)); #ifdef DEBUG_PK sshbuf_dump(b, stderr); #endif /* test for correct signature */ authenticated = 0; if (PRIVSEP(user_key_allowed(ssh, pw, key, 1, &authopts)) && PRIVSEP(sshkey_verify(key, sig, slen, sshbuf_ptr(b), sshbuf_len(b), (ssh->compat & SSH_BUG_SIGTYPE) == 0 ? pkalg : NULL, ssh->compat)) == 0) { authenticated = 1; } sshbuf_free(b); free(sig); auth2_record_key(authctxt, authenticated, key); } else { debug("%s: test pkalg %s pkblob %s%s%s", __func__, pkalg, key_s, ca_s == NULL ? "" : " CA ", ca_s == NULL ? "" : ca_s); if ((r = sshpkt_get_end(ssh)) != 0) fatal("%s: %s", __func__, ssh_err(r)); /* XXX fake reply and always send PK_OK ? */ /* * XXX this allows testing whether a user is allowed * to login: if you happen to have a valid pubkey this * message is sent. the message is NEVER sent at all * if a user is not allowed to login. is this an * issue? -markus */ if (PRIVSEP(user_key_allowed(ssh, pw, key, 0, NULL))) { if ((r = sshpkt_start(ssh, SSH2_MSG_USERAUTH_PK_OK)) != 0 || (r = sshpkt_put_cstring(ssh, pkalg)) != 0 || (r = sshpkt_put_string(ssh, pkblob, blen)) != 0 || (r = sshpkt_send(ssh)) != 0 || (r = ssh_packet_write_wait(ssh)) != 0) fatal("%s: %s", __func__, ssh_err(r)); authctxt->postponed = 1; } } done: if (authenticated == 1 && auth_activate_options(ssh, authopts) != 0) { debug("%s: key options inconsistent with existing", __func__); authenticated = 0; } debug2("%s: authenticated %d pkalg %s", __func__, authenticated, pkalg); sshauthopt_free(authopts); sshkey_free(key); free(userstyle); free(pkalg); free(pkblob); free(key_s); free(ca_s); return authenticated; }
1
[ "CWE-200", "CWE-362", "CWE-703" ]
src
779974d35b4859c07bc3cb8a12c74b43b0a7d1e0
76,284,155,674,402,210,000,000,000,000,000,000,000
155
delay bailout for invalid authenticating user until after the packet containing the request has been fully parsed. Reported by Dariusz Tytko and Michał Sajdak; ok deraadt
static int apparmor_cred_alloc_blank(struct cred *cred, gfp_t gfp) { /* freed by apparmor_cred_free */ struct aa_task_cxt *cxt = aa_alloc_task_context(gfp); if (!cxt) return -ENOMEM; cred->security = cxt; return 0; }
0
[ "CWE-20" ]
linux
a5b2c5b2ad5853591a6cac6134cd0f599a720865
132,296,152,196,183,680,000,000,000,000,000,000,000
10
AppArmor: fix oops in apparmor_setprocattr When invalid parameters are passed to apparmor_setprocattr a NULL deref oops occurs when it tries to record an audit message. This is because it is passing NULL for the profile parameter for aa_audit. But aa_audit now requires that the profile passed is not NULL. Fix this by passing the current profile on the task that is trying to setprocattr. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: John Johansen <[email protected]> Cc: [email protected] Signed-off-by: James Morris <[email protected]>
int jas_image_addfmt(int id, char *name, char *ext, char *desc, jas_image_fmtops_t *ops) { jas_image_fmtinfo_t *fmtinfo; assert(id >= 0 && name && ext && ops); if (jas_image_numfmts >= JAS_IMAGE_MAXFMTS) { return -1; } fmtinfo = &jas_image_fmtinfos[jas_image_numfmts]; fmtinfo->id = id; if (!(fmtinfo->name = jas_strdup(name))) { return -1; } if (!(fmtinfo->ext = jas_strdup(ext))) { jas_free(fmtinfo->name); return -1; } if (!(fmtinfo->desc = jas_strdup(desc))) { jas_free(fmtinfo->name); jas_free(fmtinfo->ext); return -1; } fmtinfo->ops = *ops; ++jas_image_numfmts; return 0; }
0
[ "CWE-189" ]
jasper
3c55b399c36ef46befcb21e4ebc4799367f89684
6,016,339,438,507,192,000,000,000,000,000,000,000
26
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.
glob(const char *pattern, int flags, int (*errfunc) (const char *, int), glob_t * pglob) { return glob_(pattern, flags, errfunc, pglob, (unsigned long) -1, 0); }
0
[]
pure-ftpd
0627004e23a24108785dc1506c5767392b90f807
284,985,137,895,641,970,000,000,000,000,000,000,000
5
BSD glob(): check max pattern length after having initialized pglob
static void release_thread_cb(void) { unsigned i = 0; #if OPENSSL_VERSION_NUMBER >= 0x10000000 CRYPTO_THREADID_set_callback(NULL); #else CRYPTO_set_id_callback(NULL); #endif CRYPTO_set_locking_callback(NULL); for (; i < ossl_num_locks; ++i) { if (ossl_locks[i]) { pj_lock_destroy(ossl_locks[i]); ossl_locks[i] = NULL; } } if (lock_pool) { pj_pool_release(lock_pool); lock_pool = NULL; pj_caching_pool_destroy(&cp); } ossl_locks = NULL; ossl_num_locks = 0; }
0
[ "CWE-362", "CWE-703" ]
pjproject
d5f95aa066f878b0aef6a64e60b61e8626e664cd
91,382,344,683,113,370,000,000,000,000,000,000,000
25
Merge pull request from GHSA-cv8x-p47p-99wr * - Avoid SSL socket parent/listener getting destroyed during handshake by increasing parent's reference count. - Add missing SSL socket close when the newly accepted SSL socket is discarded in SIP TLS transport. * - Fix silly mistake: accepted active socket created without group lock in SSL socket. - Replace assertion with normal validation check of SSL socket instance in OpenSSL verification callback (verify_cb()) to avoid crash, e.g: if somehow race condition with SSL socket destroy happens or OpenSSL application data index somehow gets corrupted.
void addViaMove(HeaderString&& key, HeaderString&& value) override { header_map_->addViaMove(std::move(key), std::move(value)); header_map_->verifyByteSizeInternalForTest(); }
0
[]
envoy
2c60632d41555ec8b3d9ef5246242be637a2db0f
227,489,574,912,156,660,000,000,000,000,000,000,000
4
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]>
static int cgroup_subtree_control_show(struct seq_file *seq, void *v) { struct cgroup *cgrp = seq_css(seq)->cgroup; cgroup_print_ss_mask(seq, cgrp->subtree_control); return 0; }
0
[ "CWE-416" ]
linux
a06247c6804f1a7c86a2e5398a4c1f1db1471848
179,161,518,187,284,800,000,000,000,000,000,000,000
7
psi: Fix uaf issue when psi trigger is destroyed while being polled With write operation on psi files replacing old trigger with a new one, the lifetime of its waitqueue is totally arbitrary. Overwriting an existing trigger causes its waitqueue to be freed and pending poll() will stumble on trigger->event_wait which was destroyed. Fix this by disallowing to redefine an existing psi trigger. If a write operation is used on a file descriptor with an already existing psi trigger, the operation will fail with EBUSY error. Also bypass a check for psi_disabled in the psi_trigger_destroy as the flag can be flipped after the trigger is created, leading to a memory leak. Fixes: 0e94682b73bf ("psi: introduce psi monitor") Reported-by: [email protected] Suggested-by: Linus Torvalds <[email protected]> Analyzed-by: Eric Biggers <[email protected]> Signed-off-by: Suren Baghdasaryan <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Eric Biggers <[email protected]> Acked-by: Johannes Weiner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid, int issync) { struct nfs4_delegreturndata *data; struct nfs_server *server = NFS_SERVER(inode); struct rpc_task *task; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DELEGRETURN], .rpc_cred = cred, }; struct rpc_task_setup task_setup_data = { .rpc_client = server->client, .rpc_message = &msg, .callback_ops = &nfs4_delegreturn_ops, .flags = RPC_TASK_ASYNC, }; int status = 0; data = kmalloc(sizeof(*data), GFP_KERNEL); if (data == NULL) return -ENOMEM; data->args.fhandle = &data->fh; data->args.stateid = &data->stateid; data->args.bitmask = server->attr_bitmask; nfs_copy_fh(&data->fh, NFS_FH(inode)); memcpy(&data->stateid, stateid, sizeof(data->stateid)); data->res.fattr = &data->fattr; data->res.server = server; nfs_fattr_init(data->res.fattr); data->timestamp = jiffies; data->rpc_status = 0; task_setup_data.callback_data = data; msg.rpc_argp = &data->args, msg.rpc_resp = &data->res, task = rpc_run_task(&task_setup_data); if (IS_ERR(task)) return PTR_ERR(task); if (!issync) goto out; status = nfs4_wait_for_completion_rpc_task(task); if (status != 0) goto out; status = data->rpc_status; if (status != 0) goto out; nfs_refresh_inode(inode, &data->fattr); out: rpc_put_task(task); return status; }
0
[ "CWE-703" ]
linux
dc0b027dfadfcb8a5504f7d8052754bf8d501ab9
283,719,251,072,932,770,000,000,000,000,000,000,000
50
NFSv4: Convert the open and close ops to use fmode Signed-off-by: Trond Myklebust <[email protected]>
int git_path_diriter_stat(struct stat *out, git_path_diriter *diriter) { assert(out && diriter); return git_path_lstat(diriter->path.ptr, out); }
0
[ "CWE-20", "CWE-706" ]
libgit2
3f7851eadca36a99627ad78cbe56a40d3776ed01
6,888,305,809,675,630,000,000,000,000,000,000,000
6
Disallow NTFS Alternate Data Stream attacks, even on Linux/macOS A little-known feature of NTFS is that it offers to store metadata in so-called "Alternate Data Streams" (inspired by Apple's "resource forks") that are copied together with the file they are associated with. These Alternate Data Streams can be accessed via `<file name>:<stream name>:<stream type>`. Directories, too, have Alternate Data Streams, and they even have a default stream type `$INDEX_ALLOCATION`. Which means that `abc/` and `abc::$INDEX_ALLOCATION/` are actually equivalent. This is of course another attack vector on the Git directory that we definitely want to prevent. On Windows, we already do this incidentally, by disallowing colons in file/directory names. While it looks as if files'/directories' Alternate Data Streams are not accessible in the Windows Subsystem for Linux, and neither via CIFS/SMB-mounted network shares in Linux, it _is_ possible to access them on SMB-mounted network shares on macOS. Therefore, let's go the extra mile and prevent this particular attack _everywhere_. To keep things simple, let's just disallow *any* Alternate Data Stream of `.git`. This is libgit2's variant of CVE-2019-1352. Signed-off-by: Johannes Schindelin <[email protected]>
String_Schema_Obj Parser::parse_value_schema(const char* stop) { // initialize the string schema object to add tokens String_Schema_Obj schema = SASS_MEMORY_NEW(String_Schema, pstate); if (peek<exactly<'}'>>()) { css_error("Invalid CSS", " after ", ": expected expression (e.g. 1px, bold), was "); } const char* e; const char* ee = end; end = stop; size_t num_items = 0; bool need_space = false; while (position < stop) { // parse space between tokens if (lex< spaces >() && num_items) { need_space = true; } if (need_space) { need_space = false; // schema->append(SASS_MEMORY_NEW(String_Constant, pstate, " ")); } if ((e = peek< re_functional >()) && e < stop) { schema->append(parse_function_call()); } // lex an interpolant /#{...}/ else if (lex< exactly < hash_lbrace > >()) { // Try to lex static expression first if (peek< exactly< rbrace > >()) { css_error("Invalid CSS", " after ", ": expected expression (e.g. 1px, bold), was "); } Expression_Obj ex; if (lex< re_static_expression >()) { ex = SASS_MEMORY_NEW(String_Constant, pstate, lexed); } else { ex = parse_list(true); } ex->is_interpolant(true); schema->append(ex); if (!lex < exactly < rbrace > >()) { css_error("Invalid CSS", " after ", ": expected \"}\", was "); } } // lex some string constants or other valid token // Note: [-+] chars are left over from i.e. `#{3}+3` else if (lex< alternatives < exactly<'%'>, exactly < '-' >, exactly < '+' > > >()) { schema->append(SASS_MEMORY_NEW(String_Constant, pstate, lexed)); } // lex a quoted string else if (lex< quoted_string >()) { // need_space = true; // if (schema->length()) schema->append(SASS_MEMORY_NEW(String_Constant, pstate, " ")); // else need_space = true; schema->append(parse_string()); if ((*position == '"' || *position == '\'') || peek < alternatives < alpha > >()) { // need_space = true; } if (peek < exactly < '-' > >()) break; } else if (lex< identifier >()) { schema->append(SASS_MEMORY_NEW(String_Constant, pstate, lexed)); if ((*position == '"' || *position == '\'') || peek < alternatives < alpha > >()) { // need_space = true; } } // lex (normalized) variable else if (lex< variable >()) { std::string name(Util::normalize_underscores(lexed)); schema->append(SASS_MEMORY_NEW(Variable, pstate, name)); } // lex percentage value else if (lex< percentage >()) { schema->append(lexed_percentage(lexed)); } // lex dimension value else if (lex< dimension >()) { schema->append(lexed_dimension(lexed)); } // lex number value else if (lex< number >()) { schema->append(lexed_number(lexed)); } // lex hex color value else if (lex< sequence < hex, negate < exactly < '-' > > > >()) { schema->append(lexed_hex_color(lexed)); } else if (lex< sequence < exactly <'#'>, identifier > >()) { schema->append(SASS_MEMORY_NEW(String_Quoted, pstate, lexed)); } // lex a value in parentheses else if (peek< parenthese_scope >()) { schema->append(parse_factor()); } else { break; } ++num_items; } if (position != stop) { schema->append(SASS_MEMORY_NEW(String_Constant, pstate, std::string(position, stop))); position = stop; } end = ee; return schema; }
0
[ "CWE-125" ]
libsass
eb15533b07773c30dc03c9d742865604f47120ef
272,868,901,473,940,520,000,000,000,000,000,000,000
106
Fix memory leak in `parse_ie_keyword_arg` `kwd_arg` would never get freed when there was a parse error in `parse_ie_keyword_arg`. Closes #2656
int unsafe_symlink(const char *dest, const char *src) { const char *name, *slash; int depth = 0; /* all absolute and null symlinks are unsafe */ if (!dest || !*dest || *dest == '/') return 1; /* find out what our safety margin is */ for (name = src; (slash = strchr(name, '/')) != 0; name = slash+1) { /* ".." segment starts the count over. "." segment is ignored. */ if (*name == '.' && (name[1] == '/' || (name[1] == '.' && name[2] == '/'))) { if (name[1] == '.') depth = 0; } else depth++; while (slash[1] == '/') slash++; /* just in case src isn't clean */ } if (*name == '.' && name[1] == '.' && name[2] == '\0') depth = 0; for (name = dest; (slash = strchr(name, '/')) != 0; name = slash+1) { if (*name == '.' && (name[1] == '/' || (name[1] == '.' && name[2] == '/'))) { if (name[1] == '.') { /* if at any point we go outside the current directory then stop - it is unsafe */ if (--depth < 0) return 1; } } else depth++; while (slash[1] == '/') slash++; } if (*name == '.' && name[1] == '.' && name[2] == '\0') depth--; return depth < 0; }
0
[ "CWE-59" ]
rsync
4cad402ea8a91031f86c53961d78bb7f4f174790
174,856,778,167,105,100,000,000,000,000,000,000,000
39
Receiver now rejects invalid filenames in filelist. If the receiver gets a filename with a leading slash (w/o --relative) and/or a filename with an embedded ".." dir in the path, it dies with an error (rather than continuing). Those invalid paths should never happen in reality, so just reject someone trying to pull a fast one.
eb_add_vma(struct i915_execbuffer *eb, unsigned int i, unsigned batch_idx, struct i915_vma *vma) { struct drm_i915_gem_exec_object2 *entry = &eb->exec[i]; int err; GEM_BUG_ON(i915_vma_is_closed(vma)); if (!(eb->args->flags & __EXEC_VALIDATED)) { err = eb_validate_vma(eb, entry, vma); if (unlikely(err)) return err; } if (eb->lut_size > 0) { vma->exec_handle = entry->handle; hlist_add_head(&vma->exec_node, &eb->buckets[hash_32(entry->handle, eb->lut_size)]); } if (entry->relocation_count) list_add_tail(&vma->reloc_link, &eb->relocs); /* * Stash a pointer from the vma to execobj, so we can query its flags, * size, alignment etc as provided by the user. Also we stash a pointer * to the vma inside the execobj so that we can use a direct lookup * to find the right target VMA when doing relocations. */ eb->vma[i] = vma; eb->flags[i] = entry->flags; vma->exec_flags = &eb->flags[i]; /* * SNA is doing fancy tricks with compressing batch buffers, which leads * to negative relocation deltas. Usually that works out ok since the * relocate address is still positive, except when the batch is placed * very low in the GTT. Ensure this doesn't happen. * * Note that actual hangs have only been observed on gen7, but for * paranoia do it everywhere. */ if (i == batch_idx) { if (entry->relocation_count && !(eb->flags[i] & EXEC_OBJECT_PINNED)) eb->flags[i] |= __EXEC_OBJECT_NEEDS_BIAS; if (eb->reloc_cache.has_fence) eb->flags[i] |= EXEC_OBJECT_NEEDS_FENCE; eb->batch = vma; } err = 0; if (eb_pin_vma(eb, entry, vma)) { if (entry->offset != vma->node.start) { entry->offset = vma->node.start | UPDATE; eb->args->flags |= __EXEC_HAS_RELOC; } } else { eb_unreserve_vma(vma, vma->exec_flags); list_add_tail(&vma->exec_link, &eb->unbound); if (drm_mm_node_allocated(&vma->node)) err = i915_vma_unbind(vma); if (unlikely(err)) vma->exec_flags = NULL; } return err; }
0
[ "CWE-20" ]
linux
594cc251fdd0d231d342d88b2fdff4bc42fb0690
183,574,098,178,254,260,000,000,000,000,000,000,000
71
make 'user_access_begin()' do 'access_ok()' Originally, the rule used to be that you'd have to do access_ok() separately, and then user_access_begin() before actually doing the direct (optimized) user access. But experience has shown that people then decide not to do access_ok() at all, and instead rely on it being implied by other operations or similar. Which makes it very hard to verify that the access has actually been range-checked. If you use the unsafe direct user accesses, hardware features (either SMAP - Supervisor Mode Access Protection - on x86, or PAN - Privileged Access Never - on ARM) do force you to use user_access_begin(). But nothing really forces the range check. By putting the range check into user_access_begin(), we actually force people to do the right thing (tm), and the range check vill be visible near the actual accesses. We have way too long a history of people trying to avoid them. Signed-off-by: Linus Torvalds <[email protected]>
bool skipFilter() const { return filter_match_state_ && filter_match_state_->skipFilter(); }
0
[ "CWE-416" ]
envoy
148de954ed3585d8b4298b424aa24916d0de6136
215,396,593,697,511,400,000,000,000,000,000,000,000
1
CVE-2021-43825 Response filter manager crash Signed-off-by: Yan Avlasov <[email protected]>
static unsigned zlib_decompress(unsigned char** out, size_t* outsize, const unsigned char* in, size_t insize, const LodePNGDecompressSettings* settings) { if(settings->custom_zlib) { return settings->custom_zlib(out, outsize, in, insize, settings); } else { return lodepng_zlib_decompress(out, outsize, in, insize, settings); } }
0
[ "CWE-401" ]
FreeRDP
9fee4ae076b1ec97b97efb79ece08d1dab4df29a
232,659,631,389,971,800,000,000,000,000,000,000,000
12
Fixed #5645: realloc return handling
struct ion_handle *ion_handle_get_by_id(struct ion_client *client, int id) { struct ion_handle *handle; mutex_lock(&client->lock); handle = ion_handle_get_by_id_nolock(client, id); mutex_unlock(&client->lock); return handle; }
0
[ "CWE-416", "CWE-284" ]
linux
9590232bb4f4cc824f3425a6e1349afbe6d6d2b7
172,373,309,050,722,250,000,000,000,000,000,000,000
11
staging/android/ion : fix a race condition in the ion driver There is a use-after-free problem in the ion driver. This is caused by a race condition in the ion_ioctl() function. A handle has ref count of 1 and two tasks on different cpus calls ION_IOC_FREE simultaneously. cpu 0 cpu 1 ------------------------------------------------------- ion_handle_get_by_id() (ref == 2) ion_handle_get_by_id() (ref == 3) ion_free() (ref == 2) ion_handle_put() (ref == 1) ion_free() (ref == 0 so ion_handle_destroy() is called and the handle is freed.) ion_handle_put() is called and it decreases the slub's next free pointer The problem is detected as an unaligned access in the spin lock functions since it uses load exclusive instruction. In some cases it corrupts the slub's free pointer which causes a mis-aligned access to the next free pointer.(kmalloc returns a pointer like ffffc0745b4580aa). And it causes lots of other hard-to-debug problems. This symptom is caused since the first member in the ion_handle structure is the reference count and the ion driver decrements the reference after it has been freed. To fix this problem client->lock mutex is extended to protect all the codes that uses the handle. Signed-off-by: Eun Taik Lee <[email protected]> Reviewed-by: Laura Abbott <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
int uncompress_gzip(void* uncompressed, size_t *uncompressed_len, const void* compressed, size_t compressed_len) { z_stream stream; memset(&stream, 0, sizeof stream); stream.total_in = compressed_len; stream.avail_in = compressed_len; stream.total_out = *uncompressed_len; stream.avail_out = *uncompressed_len; stream.next_in = (Bytef *) compressed; stream.next_out = (Bytef *) uncompressed; /* 15 window bits, and the +32 tells zlib to to detect if using gzip or zlib */ if (Z_OK == inflateInit2(&stream, (15 + 32)) && Z_STREAM_END == inflate(&stream, Z_FINISH)) { *uncompressed_len = stream.total_out; } else { return SC_ERROR_INVALID_DATA; } inflateEnd(&stream); return SC_SUCCESS; }
0
[ "CWE-415", "CWE-119" ]
OpenSC
360e95d45ac4123255a4c796db96337f332160ad
33,103,678,213,541,520,000,000,000,000,000,000,000
23
fixed out of bounds writes Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting the problems.
void setDeferredPushLen(client *c, void *node, long length) { serverAssert(c->resp >= 3); setDeferredAggregateLen(c,node,length,'>'); }
0
[ "CWE-770" ]
redis
5674b0057ff2903d43eaff802017eddf37c360f8
224,856,823,623,898,800,000,000,000,000,000,000,000
4
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)
bool IsNumericSupportedType(const TfLiteType type) { return type == kTfLiteFloat32; }
0
[ "CWE-125", "CWE-787" ]
tensorflow
1970c2158b1ffa416d159d03c3370b9a462aee35
324,508,218,680,402,980,000,000,000,000,000,000,000
3
[tflite]: Insert `nullptr` checks when obtaining tensors. As part of ongoing refactoring, `tflite::GetInput`, `tflite::GetOutput`, `tflite::GetTemporary` and `tflite::GetIntermediates` will return `nullptr` in some cases. Hence, we insert the `nullptr` checks on all usages. We also insert `nullptr` checks on usages of `tflite::GetVariableInput` and `tflite::GetOptionalInputTensor` but only in the cases where there is no obvious check that `nullptr` is acceptable (that is, we only insert the check for the output of these two functions if the tensor is accessed as if it is always not `nullptr`). PiperOrigin-RevId: 332521299 Change-Id: I29af455bcb48d0b92e58132d951a3badbd772d56
static void SVGStartElement(void *context,const xmlChar *name, const xmlChar **attributes) { #define PushGraphicContext(id) \ { \ if (*id == '\0') \ (void) FormatLocaleFile(svg_info->file,"push graphic-context\n"); \ else \ (void) FormatLocaleFile(svg_info->file,"push graphic-context \"%s\"\n", \ id); \ } char *color, background[MagickPathExtent], id[MagickPathExtent], *next_token, token[MagickPathExtent], **tokens, *units; const char *keyword, *p, *value; register ssize_t i, j; size_t number_tokens; SVGInfo *svg_info; /* Called when an opening tag has been processed. */ (void) LogMagickEvent(CoderEvent,GetMagickModule()," SAX.startElement(%s", name); svg_info=(SVGInfo *) context; svg_info->n++; svg_info->scale=(double *) ResizeQuantumMemory(svg_info->scale, svg_info->n+1UL,sizeof(*svg_info->scale)); if (svg_info->scale == (double *) NULL) { (void) ThrowMagickException(svg_info->exception,GetMagickModule(), ResourceLimitError,"MemoryAllocationFailed","`%s'",name); return; } svg_info->scale[svg_info->n]=svg_info->scale[svg_info->n-1]; color=AcquireString("none"); units=AcquireString("userSpaceOnUse"); *id='\0'; *token='\0'; *background='\0'; value=(const char *) NULL; if ((LocaleCompare((char *) name,"image") == 0) || (LocaleCompare((char *) name,"pattern") == 0) || (LocaleCompare((char *) name,"rect") == 0) || (LocaleCompare((char *) name,"text") == 0) || (LocaleCompare((char *) name,"use") == 0)) { svg_info->bounds.x=0.0; svg_info->bounds.y=0.0; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i+=2) { keyword=(const char *) attributes[i]; value=(const char *) attributes[i+1]; switch (*keyword) { case 'C': case 'c': { if (LocaleCompare(keyword,"cx") == 0) { svg_info->element.cx= GetUserSpaceCoordinateValue(svg_info,1,value); break; } if (LocaleCompare(keyword,"cy") == 0) { svg_info->element.cy= GetUserSpaceCoordinateValue(svg_info,-1,value); break; } break; } case 'F': case 'f': { if (LocaleCompare(keyword,"fx") == 0) { svg_info->element.major= GetUserSpaceCoordinateValue(svg_info,1,value); break; } if (LocaleCompare(keyword,"fy") == 0) { svg_info->element.minor= GetUserSpaceCoordinateValue(svg_info,-1,value); break; } break; } case 'H': case 'h': { if (LocaleCompare(keyword,"height") == 0) { svg_info->bounds.height= GetUserSpaceCoordinateValue(svg_info,-1,value); break; } break; } case 'I': case 'i': { if (LocaleCompare(keyword,"id") == 0) { (void) CopyMagickString(id,value,MagickPathExtent); break; } break; } case 'R': case 'r': { if (LocaleCompare(keyword,"r") == 0) { svg_info->element.angle= GetUserSpaceCoordinateValue(svg_info,0,value); break; } break; } case 'W': case 'w': { if (LocaleCompare(keyword,"width") == 0) { svg_info->bounds.width= GetUserSpaceCoordinateValue(svg_info,1,value); break; } break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { if (LocaleCompare((char *) name,"tspan") != 0) svg_info->bounds.x=GetUserSpaceCoordinateValue(svg_info,1, value)-svg_info->center.x; break; } if (LocaleCompare(keyword,"x1") == 0) { svg_info->segment.x1=GetUserSpaceCoordinateValue(svg_info,1, value); break; } if (LocaleCompare(keyword,"x2") == 0) { svg_info->segment.x2=GetUserSpaceCoordinateValue(svg_info,1, value); break; } break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { if (LocaleCompare((char *) name,"tspan") != 0) svg_info->bounds.y=GetUserSpaceCoordinateValue(svg_info,-1, value)-svg_info->center.y; break; } if (LocaleCompare(keyword,"y1") == 0) { svg_info->segment.y1=GetUserSpaceCoordinateValue(svg_info,-1, value); break; } if (LocaleCompare(keyword,"y2") == 0) { svg_info->segment.y2=GetUserSpaceCoordinateValue(svg_info,-1, value); break; } break; } default: break; } } if (strchr((char *) name,':') != (char *) NULL) { /* Skip over namespace. */ for ( ; *name != ':'; name++) ; name++; } switch (*name) { case 'C': case 'c': { if (LocaleCompare((const char *) name,"circle") == 0) { PushGraphicContext(id); break; } if (LocaleCompare((const char *) name,"clipPath") == 0) { (void) FormatLocaleFile(svg_info->file,"push clip-path \"%s\"\n",id); break; } break; } case 'D': case 'd': { if (LocaleCompare((const char *) name,"defs") == 0) { (void) FormatLocaleFile(svg_info->file,"push defs\n"); break; } break; } case 'E': case 'e': { if (LocaleCompare((const char *) name,"ellipse") == 0) { PushGraphicContext(id); break; } break; } case 'F': case 'f': { if (LocaleCompare((const char *) name,"foreignObject") == 0) { PushGraphicContext(id); break; } break; } case 'G': case 'g': { if (LocaleCompare((const char *) name,"g") == 0) { PushGraphicContext(id); break; } break; } case 'I': case 'i': { if (LocaleCompare((const char *) name,"image") == 0) { PushGraphicContext(id); break; } break; } case 'L': case 'l': { if (LocaleCompare((const char *) name,"line") == 0) { PushGraphicContext(id); break; } if (LocaleCompare((const char *) name,"linearGradient") == 0) { (void) FormatLocaleFile(svg_info->file, "push gradient \"%s\" linear %g,%g %g,%g\n",id, svg_info->segment.x1,svg_info->segment.y1,svg_info->segment.x2, svg_info->segment.y2); break; } break; } case 'M': case 'm': { if (LocaleCompare((const char *) name,"mask") == 0) { (void) FormatLocaleFile(svg_info->file,"push mask \"%s\"\n",id); break; } break; } case 'P': case 'p': { if (LocaleCompare((const char *) name,"path") == 0) { PushGraphicContext(id); break; } if (LocaleCompare((const char *) name,"pattern") == 0) { (void) FormatLocaleFile(svg_info->file, "push pattern \"%s\" %g,%g %g,%g\n",id, svg_info->bounds.x,svg_info->bounds.y,svg_info->bounds.width, svg_info->bounds.height); break; } if (LocaleCompare((const char *) name,"polygon") == 0) { PushGraphicContext(id); break; } if (LocaleCompare((const char *) name,"polyline") == 0) { PushGraphicContext(id); break; } break; } case 'R': case 'r': { if (LocaleCompare((const char *) name,"radialGradient") == 0) { (void) FormatLocaleFile(svg_info->file, "push gradient \"%s\" radial %g,%g %g,%g %g\n", id,svg_info->element.cx,svg_info->element.cy, svg_info->element.major,svg_info->element.minor, svg_info->element.angle); break; } if (LocaleCompare((const char *) name,"rect") == 0) { PushGraphicContext(id); break; } break; } case 'S': case 's': { if (LocaleCompare((char *) name,"style") == 0) break; if (LocaleCompare((const char *) name,"svg") == 0) { svg_info->svgDepth++; PushGraphicContext(id); (void) FormatLocaleFile(svg_info->file,"compliance \"SVG\"\n"); (void) FormatLocaleFile(svg_info->file,"fill \"black\"\n"); (void) FormatLocaleFile(svg_info->file,"fill-opacity 1\n"); (void) FormatLocaleFile(svg_info->file,"stroke \"none\"\n"); (void) FormatLocaleFile(svg_info->file,"stroke-width 1\n"); (void) FormatLocaleFile(svg_info->file,"stroke-opacity 1\n"); (void) FormatLocaleFile(svg_info->file,"fill-rule nonzero\n"); break; } if (LocaleCompare((const char *) name,"symbol") == 0) { (void) FormatLocaleFile(svg_info->file,"push symbol\n"); break; } break; } case 'T': case 't': { if (LocaleCompare((const char *) name,"text") == 0) { PushGraphicContext(id); (void) FormatLocaleFile(svg_info->file,"class \"text\"\n"); (void) FormatLocaleFile(svg_info->file,"translate %g,%g\n", svg_info->bounds.x,svg_info->bounds.y); svg_info->center.x=svg_info->bounds.x; svg_info->center.y=svg_info->bounds.y; svg_info->bounds.x=0.0; svg_info->bounds.y=0.0; svg_info->bounds.width=0.0; svg_info->bounds.height=0.0; break; } if (LocaleCompare((const char *) name,"tspan") == 0) { if (*svg_info->text != '\0') { char *text; text=EscapeString(svg_info->text,'\''); (void) FormatLocaleFile(svg_info->file,"text %g,%g \"%s\"\n", svg_info->bounds.x-svg_info->center.x,svg_info->bounds.y- svg_info->center.y,text); text=DestroyString(text); *svg_info->text='\0'; } PushGraphicContext(id); break; } break; } case 'U': case 'u': { if (LocaleCompare((char *) name,"use") == 0) { PushGraphicContext(id); break; } break; } default: break; } if (attributes != (const xmlChar **) NULL) for (i=0; (attributes[i] != (const xmlChar *) NULL); i+=2) { keyword=(const char *) attributes[i]; value=(const char *) attributes[i+1]; (void) LogMagickEvent(CoderEvent,GetMagickModule(), " %s = %s",keyword,value); switch (*keyword) { case 'A': case 'a': { if (LocaleCompare(keyword,"angle") == 0) { (void) FormatLocaleFile(svg_info->file,"angle %g\n", GetUserSpaceCoordinateValue(svg_info,0,value)); break; } break; } case 'C': case 'c': { if (LocaleCompare(keyword,"class") == 0) { const char *p; for (p=value; ; ) { GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); if (*token != '\0') { (void) FormatLocaleFile(svg_info->file,"class \"%s\"\n", value); break; } } break; } if (LocaleCompare(keyword,"clip-path") == 0) { (void) FormatLocaleFile(svg_info->file,"clip-path \"%s\"\n", value); break; } if (LocaleCompare(keyword,"clip-rule") == 0) { (void) FormatLocaleFile(svg_info->file,"clip-rule \"%s\"\n", value); break; } if (LocaleCompare(keyword,"clipPathUnits") == 0) { (void) CloneString(&units,value); (void) FormatLocaleFile(svg_info->file,"clip-units \"%s\"\n", value); break; } if (LocaleCompare(keyword,"color") == 0) { (void) CloneString(&color,value); break; } if (LocaleCompare(keyword,"cx") == 0) { svg_info->element.cx= GetUserSpaceCoordinateValue(svg_info,1,value); break; } if (LocaleCompare(keyword,"cy") == 0) { svg_info->element.cy= GetUserSpaceCoordinateValue(svg_info,-1,value); break; } break; } case 'D': case 'd': { if (LocaleCompare(keyword,"d") == 0) { (void) CloneString(&svg_info->vertices,value); break; } if (LocaleCompare(keyword,"dx") == 0) { double dx; dx=GetUserSpaceCoordinateValue(svg_info,1,value); svg_info->bounds.x+=dx; if (LocaleCompare((char *) name,"text") == 0) (void) FormatLocaleFile(svg_info->file,"translate %g,0.0\n",dx); break; } if (LocaleCompare(keyword,"dy") == 0) { double dy; dy=GetUserSpaceCoordinateValue(svg_info,-1,value); svg_info->bounds.y+=dy; if (LocaleCompare((char *) name,"text") == 0) (void) FormatLocaleFile(svg_info->file,"translate 0.0,%g\n",dy); break; } break; } case 'F': case 'f': { if (LocaleCompare(keyword,"fill") == 0) { if (LocaleCompare(value,"currentColor") == 0) { (void) FormatLocaleFile(svg_info->file,"fill \"%s\"\n",color); break; } (void) FormatLocaleFile(svg_info->file,"fill \"%s\"\n",value); break; } if (LocaleCompare(keyword,"fillcolor") == 0) { (void) FormatLocaleFile(svg_info->file,"fill \"%s\"\n",value); break; } if (LocaleCompare(keyword,"fill-rule") == 0) { (void) FormatLocaleFile(svg_info->file,"fill-rule \"%s\"\n", value); break; } if (LocaleCompare(keyword,"fill-opacity") == 0) { (void) FormatLocaleFile(svg_info->file,"fill-opacity \"%s\"\n", value); break; } if (LocaleCompare(keyword,"font-family") == 0) { (void) FormatLocaleFile(svg_info->file,"font-family \"%s\"\n", value); break; } if (LocaleCompare(keyword,"font-stretch") == 0) { (void) FormatLocaleFile(svg_info->file,"font-stretch \"%s\"\n", value); break; } if (LocaleCompare(keyword,"font-style") == 0) { (void) FormatLocaleFile(svg_info->file,"font-style \"%s\"\n", value); break; } if (LocaleCompare(keyword,"font-size") == 0) { if (LocaleCompare(value,"xx-small") == 0) svg_info->pointsize=6.144; else if (LocaleCompare(value,"x-small") == 0) svg_info->pointsize=7.68; else if (LocaleCompare(value,"small") == 0) svg_info->pointsize=9.6; else if (LocaleCompare(value,"medium") == 0) svg_info->pointsize=12.0; else if (LocaleCompare(value,"large") == 0) svg_info->pointsize=14.4; else if (LocaleCompare(value,"x-large") == 0) svg_info->pointsize=17.28; else if (LocaleCompare(value,"xx-large") == 0) svg_info->pointsize=20.736; else svg_info->pointsize=GetUserSpaceCoordinateValue(svg_info,0, value); (void) FormatLocaleFile(svg_info->file,"font-size %g\n", svg_info->pointsize); break; } if (LocaleCompare(keyword,"font-weight") == 0) { (void) FormatLocaleFile(svg_info->file,"font-weight \"%s\"\n", value); break; } break; } case 'G': case 'g': { if (LocaleCompare(keyword,"gradientTransform") == 0) { AffineMatrix affine, current, transform; GetAffineMatrix(&transform); (void) LogMagickEvent(CoderEvent,GetMagickModule()," "); tokens=SVGKeyValuePairs(context,'(',')',value,&number_tokens); if (tokens == (char **) NULL) break; for (j=0; j < (ssize_t) (number_tokens-1); j+=2) { keyword=(char *) tokens[j]; if (keyword == (char *) NULL) continue; value=(char *) tokens[j+1]; (void) LogMagickEvent(CoderEvent,GetMagickModule(), " %s: %s",keyword,value); current=transform; GetAffineMatrix(&affine); switch (*keyword) { case 'M': case 'm': { if (LocaleCompare(keyword,"matrix") == 0) { p=(const char *) value; GetNextToken(p,&p,MagickPathExtent,token); affine.sx=StringToDouble(value,(char **) NULL); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); affine.rx=StringToDouble(token,&next_token); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); affine.ry=StringToDouble(token,&next_token); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); affine.sy=StringToDouble(token,&next_token); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); affine.tx=StringToDouble(token,&next_token); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); affine.ty=StringToDouble(token,&next_token); break; } break; } case 'R': case 'r': { if (LocaleCompare(keyword,"rotate") == 0) { double angle; angle=GetUserSpaceCoordinateValue(svg_info,0,value); affine.sx=cos(DegreesToRadians(fmod(angle,360.0))); affine.rx=sin(DegreesToRadians(fmod(angle,360.0))); affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0)))); affine.sy=cos(DegreesToRadians(fmod(angle,360.0))); break; } break; } case 'S': case 's': { if (LocaleCompare(keyword,"scale") == 0) { for (p=(const char *) value; *p != '\0'; p++) if ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ',')) break; affine.sx=GetUserSpaceCoordinateValue(svg_info,1,value); affine.sy=affine.sx; if (*p != '\0') affine.sy= GetUserSpaceCoordinateValue(svg_info,-1,p+1); svg_info->scale[svg_info->n]=ExpandAffine(&affine); break; } if (LocaleCompare(keyword,"skewX") == 0) { affine.sx=svg_info->affine.sx; affine.ry=tan(DegreesToRadians(fmod( GetUserSpaceCoordinateValue(svg_info,1,value), 360.0))); affine.sy=svg_info->affine.sy; break; } if (LocaleCompare(keyword,"skewY") == 0) { affine.sx=svg_info->affine.sx; affine.rx=tan(DegreesToRadians(fmod( GetUserSpaceCoordinateValue(svg_info,-1,value), 360.0))); affine.sy=svg_info->affine.sy; break; } break; } case 'T': case 't': { if (LocaleCompare(keyword,"translate") == 0) { for (p=(const char *) value; *p != '\0'; p++) if ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ',')) break; affine.tx=GetUserSpaceCoordinateValue(svg_info,1,value); affine.ty=affine.tx; if (*p != '\0') affine.ty= GetUserSpaceCoordinateValue(svg_info,-1,p+1); break; } break; } default: break; } transform.sx=affine.sx*current.sx+affine.ry*current.rx; transform.rx=affine.rx*current.sx+affine.sy*current.rx; transform.ry=affine.sx*current.ry+affine.ry*current.sy; transform.sy=affine.rx*current.ry+affine.sy*current.sy; transform.tx=affine.tx*current.sx+affine.ty*current.ry+ current.tx; transform.ty=affine.tx*current.rx+affine.ty*current.sy+ current.ty; } (void) FormatLocaleFile(svg_info->file, "affine %g %g %g %g %g %g\n",transform.sx, transform.rx,transform.ry,transform.sy,transform.tx, transform.ty); for (j=0; tokens[j] != (char *) NULL; j++) tokens[j]=DestroyString(tokens[j]); tokens=(char **) RelinquishMagickMemory(tokens); break; } if (LocaleCompare(keyword,"gradientUnits") == 0) { (void) CloneString(&units,value); (void) FormatLocaleFile(svg_info->file,"gradient-units \"%s\"\n", value); break; } break; } case 'H': case 'h': { if (LocaleCompare(keyword,"height") == 0) { svg_info->bounds.height= GetUserSpaceCoordinateValue(svg_info,-1,value); break; } if (LocaleCompare(keyword,"href") == 0) { (void) CloneString(&svg_info->url,value); break; } break; } case 'K': case 'k': { if (LocaleCompare(keyword,"kerning") == 0) { (void) FormatLocaleFile(svg_info->file,"kerning \"%s\"\n", value); break; } break; } case 'L': case 'l': { if (LocaleCompare(keyword,"letter-spacing") == 0) { (void) FormatLocaleFile(svg_info->file,"letter-spacing \"%s\"\n", value); break; } break; } case 'M': case 'm': { if (LocaleCompare(keyword,"major") == 0) { svg_info->element.major= GetUserSpaceCoordinateValue(svg_info,1,value); break; } if (LocaleCompare(keyword,"mask") == 0) { (void) FormatLocaleFile(svg_info->file,"mask \"%s\"\n",value); break; } if (LocaleCompare(keyword,"minor") == 0) { svg_info->element.minor= GetUserSpaceCoordinateValue(svg_info,-1,value); break; } break; } case 'O': case 'o': { if (LocaleCompare(keyword,"offset") == 0) { (void) CloneString(&svg_info->offset,value); break; } if (LocaleCompare(keyword,"opacity") == 0) { (void) FormatLocaleFile(svg_info->file,"opacity \"%s\"\n",value); break; } break; } case 'P': case 'p': { if (LocaleCompare(keyword,"path") == 0) { (void) CloneString(&svg_info->url,value); break; } if (LocaleCompare(keyword,"points") == 0) { (void) CloneString(&svg_info->vertices,value); break; } break; } case 'R': case 'r': { if (LocaleCompare(keyword,"r") == 0) { svg_info->element.major= GetUserSpaceCoordinateValue(svg_info,1,value); svg_info->element.minor= GetUserSpaceCoordinateValue(svg_info,-1,value); break; } if (LocaleCompare(keyword,"rotate") == 0) { double angle; angle=GetUserSpaceCoordinateValue(svg_info,0,value); (void) FormatLocaleFile(svg_info->file,"translate %g,%g\n", svg_info->bounds.x,svg_info->bounds.y); svg_info->bounds.x=0; svg_info->bounds.y=0; (void) FormatLocaleFile(svg_info->file,"rotate %g\n",angle); break; } if (LocaleCompare(keyword,"rx") == 0) { if (LocaleCompare((const char *) name,"ellipse") == 0) svg_info->element.major= GetUserSpaceCoordinateValue(svg_info,1,value); else svg_info->radius.x= GetUserSpaceCoordinateValue(svg_info,1,value); break; } if (LocaleCompare(keyword,"ry") == 0) { if (LocaleCompare((const char *) name,"ellipse") == 0) svg_info->element.minor= GetUserSpaceCoordinateValue(svg_info,-1,value); else svg_info->radius.y= GetUserSpaceCoordinateValue(svg_info,-1,value); break; } break; } case 'S': case 's': { if (LocaleCompare(keyword,"stop-color") == 0) { (void) CloneString(&svg_info->stop_color,value); break; } if (LocaleCompare(keyword,"stroke") == 0) { if (LocaleCompare(value,"currentColor") == 0) { (void) FormatLocaleFile(svg_info->file,"stroke \"%s\"\n", color); break; } (void) FormatLocaleFile(svg_info->file,"stroke \"%s\"\n",value); break; } if (LocaleCompare(keyword,"stroke-antialiasing") == 0) { (void) FormatLocaleFile(svg_info->file,"stroke-antialias %d\n", LocaleCompare(value,"true") == 0); break; } if (LocaleCompare(keyword,"stroke-dasharray") == 0) { (void) FormatLocaleFile(svg_info->file,"stroke-dasharray %s\n", value); break; } if (LocaleCompare(keyword,"stroke-dashoffset") == 0) { (void) FormatLocaleFile(svg_info->file,"stroke-dashoffset %g\n", GetUserSpaceCoordinateValue(svg_info,1,value)); break; } if (LocaleCompare(keyword,"stroke-linecap") == 0) { (void) FormatLocaleFile(svg_info->file,"stroke-linecap \"%s\"\n", value); break; } if (LocaleCompare(keyword,"stroke-linejoin") == 0) { (void) FormatLocaleFile(svg_info->file,"stroke-linejoin \"%s\"\n", value); break; } if (LocaleCompare(keyword,"stroke-miterlimit") == 0) { (void) FormatLocaleFile(svg_info->file, "stroke-miterlimit \"%s\"\n",value); break; } if (LocaleCompare(keyword,"stroke-opacity") == 0) { (void) FormatLocaleFile(svg_info->file,"stroke-opacity \"%s\"\n", value); break; } if (LocaleCompare(keyword,"stroke-width") == 0) { (void) FormatLocaleFile(svg_info->file,"stroke-width %g\n", GetUserSpaceCoordinateValue(svg_info,1,value)); break; } if (LocaleCompare(keyword,"style") == 0) { SVGProcessStyleElement(context,name,value); break; } break; } case 'T': case 't': { if (LocaleCompare(keyword,"text-align") == 0) { (void) FormatLocaleFile(svg_info->file,"text-align \"%s\"\n", value); break; } if (LocaleCompare(keyword,"text-anchor") == 0) { (void) FormatLocaleFile(svg_info->file,"text-anchor \"%s\"\n", value); break; } if (LocaleCompare(keyword,"text-decoration") == 0) { if (LocaleCompare(value,"underline") == 0) (void) FormatLocaleFile(svg_info->file,"decorate underline\n"); if (LocaleCompare(value,"line-through") == 0) (void) FormatLocaleFile(svg_info->file, "decorate line-through\n"); if (LocaleCompare(value,"overline") == 0) (void) FormatLocaleFile(svg_info->file,"decorate overline\n"); break; } if (LocaleCompare(keyword,"text-antialiasing") == 0) { (void) FormatLocaleFile(svg_info->file,"text-antialias %d\n", LocaleCompare(value,"true") == 0); break; } if (LocaleCompare(keyword,"transform") == 0) { AffineMatrix affine, current, transform; GetAffineMatrix(&transform); (void) LogMagickEvent(CoderEvent,GetMagickModule()," "); tokens=SVGKeyValuePairs(context,'(',')',value,&number_tokens); if (tokens == (char **) NULL) break; for (j=0; j < (ssize_t) (number_tokens-1); j+=2) { keyword=(char *) tokens[j]; value=(char *) tokens[j+1]; (void) LogMagickEvent(CoderEvent,GetMagickModule(), " %s: %s",keyword,value); current=transform; GetAffineMatrix(&affine); switch (*keyword) { case 'M': case 'm': { if (LocaleCompare(keyword,"matrix") == 0) { p=(const char *) value; GetNextToken(p,&p,MagickPathExtent,token); affine.sx=StringToDouble(value,(char **) NULL); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); affine.rx=StringToDouble(token,&next_token); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); affine.ry=StringToDouble(token,&next_token); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); affine.sy=StringToDouble(token,&next_token); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); affine.tx=StringToDouble(token,&next_token); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); affine.ty=StringToDouble(token,&next_token); break; } break; } case 'R': case 'r': { if (LocaleCompare(keyword,"rotate") == 0) { double angle, x, y; p=(const char *) value; GetNextToken(p,&p,MagickPathExtent,token); angle=StringToDouble(value,(char **) NULL); affine.sx=cos(DegreesToRadians(fmod(angle,360.0))); affine.rx=sin(DegreesToRadians(fmod(angle,360.0))); affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0)))); affine.sy=cos(DegreesToRadians(fmod(angle,360.0))); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); x=StringToDouble(token,&next_token); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); y=StringToDouble(token,&next_token); affine.tx=svg_info->bounds.x+x* cos(DegreesToRadians(fmod(angle,360.0)))+y* sin(DegreesToRadians(fmod(angle,360.0))); affine.ty=svg_info->bounds.y-x* sin(DegreesToRadians(fmod(angle,360.0)))+y* cos(DegreesToRadians(fmod(angle,360.0))); affine.tx-=x/2.0; affine.ty-=y/2.0; break; } break; } case 'S': case 's': { if (LocaleCompare(keyword,"scale") == 0) { for (p=(const char *) value; *p != '\0'; p++) if ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ',')) break; affine.sx=GetUserSpaceCoordinateValue(svg_info,1,value); affine.sy=affine.sx; if (*p != '\0') affine.sy=GetUserSpaceCoordinateValue(svg_info,-1, p+1); svg_info->scale[svg_info->n]=ExpandAffine(&affine); break; } if (LocaleCompare(keyword,"skewX") == 0) { affine.sx=svg_info->affine.sx; affine.ry=tan(DegreesToRadians(fmod( GetUserSpaceCoordinateValue(svg_info,1,value), 360.0))); affine.sy=svg_info->affine.sy; break; } if (LocaleCompare(keyword,"skewY") == 0) { affine.sx=svg_info->affine.sx; affine.rx=tan(DegreesToRadians(fmod( GetUserSpaceCoordinateValue(svg_info,-1,value), 360.0))); affine.sy=svg_info->affine.sy; break; } break; } case 'T': case 't': { if (LocaleCompare(keyword,"translate") == 0) { for (p=(const char *) value; *p != '\0'; p++) if ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ',')) break; affine.tx=GetUserSpaceCoordinateValue(svg_info,1,value); affine.ty=0; if (*p != '\0') affine.ty=GetUserSpaceCoordinateValue(svg_info,-1, p+1); break; } break; } default: break; } transform.sx=affine.sx*current.sx+affine.ry*current.rx; transform.rx=affine.rx*current.sx+affine.sy*current.rx; transform.ry=affine.sx*current.ry+affine.ry*current.sy; transform.sy=affine.rx*current.ry+affine.sy*current.sy; transform.tx=affine.tx*current.sx+affine.ty*current.ry+ current.tx; transform.ty=affine.tx*current.rx+affine.ty*current.sy+ current.ty; } (void) FormatLocaleFile(svg_info->file, "affine %g %g %g %g %g %g\n",transform.sx,transform.rx, transform.ry,transform.sy,transform.tx,transform.ty); for (j=0; tokens[j] != (char *) NULL; j++) tokens[j]=DestroyString(tokens[j]); tokens=(char **) RelinquishMagickMemory(tokens); break; } break; } case 'V': case 'v': { if (LocaleCompare(keyword,"verts") == 0) { (void) CloneString(&svg_info->vertices,value); break; } if (LocaleCompare(keyword,"viewBox") == 0) { p=(const char *) value; GetNextToken(p,&p,MagickPathExtent,token); svg_info->view_box.x=StringToDouble(token,&next_token); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); svg_info->view_box.y=StringToDouble(token,&next_token); GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); svg_info->view_box.width=StringToDouble(token, (char **) NULL); if (svg_info->bounds.width == 0) svg_info->bounds.width=svg_info->view_box.width; GetNextToken(p,&p,MagickPathExtent,token); if (*token == ',') GetNextToken(p,&p,MagickPathExtent,token); svg_info->view_box.height=StringToDouble(token, (char **) NULL); if (svg_info->bounds.height == 0) svg_info->bounds.height=svg_info->view_box.height; break; } break; } case 'W': case 'w': { if (LocaleCompare(keyword,"width") == 0) { svg_info->bounds.width= GetUserSpaceCoordinateValue(svg_info,1,value); break; } break; } case 'X': case 'x': { if (LocaleCompare(keyword,"x") == 0) { svg_info->bounds.x=GetUserSpaceCoordinateValue(svg_info,1,value); break; } if (LocaleCompare(keyword,"xlink:href") == 0) { (void) CloneString(&svg_info->url,value); break; } if (LocaleCompare(keyword,"x1") == 0) { svg_info->segment.x1= GetUserSpaceCoordinateValue(svg_info,1,value); break; } if (LocaleCompare(keyword,"x2") == 0) { svg_info->segment.x2= GetUserSpaceCoordinateValue(svg_info,1,value); break; } break; } case 'Y': case 'y': { if (LocaleCompare(keyword,"y") == 0) { svg_info->bounds.y=GetUserSpaceCoordinateValue(svg_info,-1,value); break; } if (LocaleCompare(keyword,"y1") == 0) { svg_info->segment.y1= GetUserSpaceCoordinateValue(svg_info,-1,value); break; } if (LocaleCompare(keyword,"y2") == 0) { svg_info->segment.y2= GetUserSpaceCoordinateValue(svg_info,-1,value); break; } break; } default: break; } } if (LocaleCompare((const char *) name,"svg") == 0) { if (svg_info->document->encoding != (const xmlChar *) NULL) (void) FormatLocaleFile(svg_info->file,"encoding \"%s\"\n", (const char *) svg_info->document->encoding); if (attributes != (const xmlChar **) NULL) { double sx, sy, tx, ty; if ((svg_info->view_box.width == 0.0) || (svg_info->view_box.height == 0.0)) svg_info->view_box=svg_info->bounds; svg_info->width=0; if (svg_info->bounds.width > 0.0) svg_info->width=(size_t) floor(svg_info->bounds.width+0.5); svg_info->height=0; if (svg_info->bounds.height > 0.0) svg_info->height=(size_t) floor(svg_info->bounds.height+0.5); (void) FormatLocaleFile(svg_info->file,"viewbox 0 0 %.20g %.20g\n", (double) svg_info->width,(double) svg_info->height); sx=(double) svg_info->width/svg_info->view_box.width; sy=(double) svg_info->height/svg_info->view_box.height; tx=svg_info->view_box.x != 0.0 ? (double) -sx*svg_info->view_box.x : 0.0; ty=svg_info->view_box.y != 0.0 ? (double) -sy*svg_info->view_box.y : 0.0; (void) FormatLocaleFile(svg_info->file,"affine %g 0 0 %g %g %g\n", sx,sy,tx,ty); if ((svg_info->svgDepth == 1) && (*background != '\0')) { PushGraphicContext(id); (void) FormatLocaleFile(svg_info->file,"fill %s\n",background); (void) FormatLocaleFile(svg_info->file, "rectangle 0,0 %g,%g\n",svg_info->view_box.width, svg_info->view_box.height); (void) FormatLocaleFile(svg_info->file,"pop graphic-context\n"); } } } (void) LogMagickEvent(CoderEvent,GetMagickModule()," )"); if (units != (char *) NULL) units=DestroyString(units); if (color != (char *) NULL) color=DestroyString(color); }
0
[ "CWE-125" ]
ImageMagick
5d71e23b853461dd3628cd1218834fcf13938365
148,467,705,740,257,900,000,000,000,000,000,000,000
1,337
https://github.com/ImageMagick/ImageMagick/issues/1336
stf_status ikev2_decrypt_msg(struct msg_digest *md, enum phase1_role init) { struct state *st = md->st; unsigned char *encend; pb_stream *e_pbs; unsigned int np; unsigned char *iv; chunk_t *cipherkey, *authkey; unsigned char *authstart; struct state *pst = st; if (st->st_clonedfrom != 0) pst = state_with_serialno(st->st_clonedfrom); if (init == INITIATOR) { cipherkey = &pst->st_skey_er; authkey = &pst->st_skey_ar; } else { cipherkey = &pst->st_skey_ei; authkey = &pst->st_skey_ai; } e_pbs = &md->chain[ISAKMP_NEXT_v2E]->pbs; np = md->chain[ISAKMP_NEXT_v2E]->payload.generic.isag_np; authstart = md->packet_pbs.start; iv = e_pbs->cur; encend = e_pbs->roof - pst->st_oakley.integ_hasher->hash_integ_len; /* start by checking authenticator */ { unsigned char *b12 = alloca( pst->st_oakley.integ_hasher->hash_digest_len); struct hmac_ctx ctx; hmac_init_chunk(&ctx, pst->st_oakley.integ_hasher, *authkey); hmac_update(&ctx, authstart, encend - authstart); hmac_final(b12, &ctx); DBG(DBG_PARSING, { DBG_dump("data being hmac:", authstart, encend - authstart); DBG_dump("R2 calculated auth:", b12, pst->st_oakley.integ_hasher-> hash_integ_len); DBG_dump("R2 provided auth:", encend, pst->st_oakley.integ_hasher-> hash_integ_len); }); /* compare first 96 bits == 12 bytes */ /* It is not always 96 bytes, it depends upon which integ algo is used*/ if (memcmp(b12, encend, pst->st_oakley.integ_hasher->hash_integ_len) != 0) { libreswan_log("R2 failed to match authenticator"); return STF_FAIL; } } DBG(DBG_PARSING, DBG_log("authenticator matched")); /* decrypt */ { size_t blocksize = pst->st_oakley.encrypter->enc_blocksize; unsigned char *encstart = iv + blocksize; unsigned int enclen = encend - encstart; unsigned int padlen; DBG(DBG_CRYPT, DBG_dump("data before decryption:", encstart, enclen)); /* now, decrypt */ (pst->st_oakley.encrypter->do_crypt)(encstart, enclen, cipherkey->ptr, cipherkey->len, iv, FALSE); padlen = encstart[enclen - 1]; encend = encend - padlen + 1; if (encend < encstart) { libreswan_log("invalid pad length: %u", padlen); return STF_FAIL; } DBG(DBG_CRYPT, { DBG_dump("decrypted payload:", encstart, enclen); DBG_log("striping %u bytes as pad", padlen + 1); }); init_pbs(&md->clr_pbs, encstart, enclen - (padlen + 1), "cleartext"); } { stf_status ret; ret = ikev2_process_payloads(md, &md->clr_pbs, st->st_state, np); if (ret != STF_OK) return ret; } return STF_OK; }
0
[ "CWE-20" ]
libreswan
2899351224fe2940aec37d7656e1e392c0fe07f0
23,858,095,920,543,575,000,000,000,000,000,000,000
107
SECURITY: Properly handle IKEv2 I1 notification packet without KE payload
static apr_status_t gset_encode_next(gset_encoder *encoder, apr_uint64_t pval) { apr_uint64_t delta, flex_bits; apr_status_t status = APR_SUCCESS; int i; delta = pval - encoder->last; encoder->last = pval; flex_bits = (delta >> encoder->fixed_bits); /* Intentional no APLOGNO */ ap_log_perror(APLOG_MARK, GCSLOG_LEVEL, 0, encoder->pool, "h2_push_diary_enc: val=%"APR_UINT64_T_HEX_FMT", delta=%" APR_UINT64_T_HEX_FMT" flex_bits=%"APR_UINT64_T_FMT", " ", fixed_bits=%d, fixed_val=%"APR_UINT64_T_HEX_FMT, pval, delta, flex_bits, encoder->fixed_bits, delta&encoder->fixed_mask); for (; flex_bits != 0; --flex_bits) { status = gset_encode_bit(encoder, 1); if (status != APR_SUCCESS) { return status; } } status = gset_encode_bit(encoder, 0); if (status != APR_SUCCESS) { return status; } for (i = encoder->fixed_bits-1; i >= 0; --i) { status = gset_encode_bit(encoder, (delta >> i) & 1); if (status != APR_SUCCESS) { return status; } } return APR_SUCCESS; }
0
[ "CWE-444" ]
mod_h2
b8a8c5061eada0ce3339b24ba1d587134552bc0c
105,256,136,087,608,800,000,000,000,000,000,000,000
34
* Removing support for abandoned draft of http-wg regarding cache-digests.
static int bnx2x_init_bp(struct bnx2x *bp) { int func; int rc; mutex_init(&bp->port.phy_mutex); mutex_init(&bp->fw_mb_mutex); mutex_init(&bp->drv_info_mutex); sema_init(&bp->stats_lock, 1); bp->drv_info_mng_owner = false; INIT_LIST_HEAD(&bp->vlan_reg); INIT_DELAYED_WORK(&bp->sp_task, bnx2x_sp_task); INIT_DELAYED_WORK(&bp->sp_rtnl_task, bnx2x_sp_rtnl_task); INIT_DELAYED_WORK(&bp->period_task, bnx2x_period_task); INIT_DELAYED_WORK(&bp->iov_task, bnx2x_iov_task); if (IS_PF(bp)) { rc = bnx2x_get_hwinfo(bp); if (rc) return rc; } else { eth_zero_addr(bp->dev->dev_addr); } bnx2x_set_modes_bitmap(bp); rc = bnx2x_alloc_mem_bp(bp); if (rc) return rc; bnx2x_read_fwinfo(bp); func = BP_FUNC(bp); /* need to reset chip if undi was active */ if (IS_PF(bp) && !BP_NOMCP(bp)) { /* init fw_seq */ bp->fw_seq = SHMEM_RD(bp, func_mb[BP_FW_MB_IDX(bp)].drv_mb_header) & DRV_MSG_SEQ_NUMBER_MASK; BNX2X_DEV_INFO("fw_seq 0x%08x\n", bp->fw_seq); rc = bnx2x_prev_unload(bp); if (rc) { bnx2x_free_mem_bp(bp); return rc; } } if (CHIP_REV_IS_FPGA(bp)) dev_err(&bp->pdev->dev, "FPGA detected\n"); if (BP_NOMCP(bp) && (func == 0)) dev_err(&bp->pdev->dev, "MCP disabled, must load devices in order!\n"); bp->disable_tpa = disable_tpa; bp->disable_tpa |= !!IS_MF_STORAGE_ONLY(bp); /* Reduce memory usage in kdump environment by disabling TPA */ bp->disable_tpa |= is_kdump_kernel(); /* Set TPA flags */ if (bp->disable_tpa) { bp->dev->hw_features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); bp->dev->features &= ~(NETIF_F_LRO | NETIF_F_GRO_HW); } if (CHIP_IS_E1(bp)) bp->dropless_fc = 0; else bp->dropless_fc = dropless_fc | bnx2x_get_dropless_info(bp); bp->mrrs = mrrs; bp->tx_ring_size = IS_MF_STORAGE_ONLY(bp) ? 0 : MAX_TX_AVAIL; if (IS_VF(bp)) bp->rx_ring_size = MAX_RX_AVAIL; /* make sure that the numbers are in the right granularity */ bp->tx_ticks = (50 / BNX2X_BTR) * BNX2X_BTR; bp->rx_ticks = (25 / BNX2X_BTR) * BNX2X_BTR; bp->current_interval = CHIP_REV_IS_SLOW(bp) ? 5*HZ : HZ; timer_setup(&bp->timer, bnx2x_timer, 0); bp->timer.expires = jiffies + bp->current_interval; if (SHMEM2_HAS(bp, dcbx_lldp_params_offset) && SHMEM2_HAS(bp, dcbx_lldp_dcbx_stat_offset) && SHMEM2_HAS(bp, dcbx_en) && SHMEM2_RD(bp, dcbx_lldp_params_offset) && SHMEM2_RD(bp, dcbx_lldp_dcbx_stat_offset) && SHMEM2_RD(bp, dcbx_en[BP_PORT(bp)])) { bnx2x_dcbx_set_state(bp, true, BNX2X_DCBX_ENABLED_ON_NEG_ON); bnx2x_dcbx_init_params(bp); } else { bnx2x_dcbx_set_state(bp, false, BNX2X_DCBX_ENABLED_OFF); } if (CHIP_IS_E1x(bp)) bp->cnic_base_cl_id = FP_SB_MAX_E1x; else bp->cnic_base_cl_id = FP_SB_MAX_E2; /* multiple tx priority */ if (IS_VF(bp)) bp->max_cos = 1; else if (CHIP_IS_E1x(bp)) bp->max_cos = BNX2X_MULTI_TX_COS_E1X; else if (CHIP_IS_E2(bp) || CHIP_IS_E3A0(bp)) bp->max_cos = BNX2X_MULTI_TX_COS_E2_E3A0; else if (CHIP_IS_E3B0(bp)) bp->max_cos = BNX2X_MULTI_TX_COS_E3B0; else BNX2X_ERR("unknown chip %x revision %x\n", CHIP_NUM(bp), CHIP_REV(bp)); BNX2X_DEV_INFO("set bp->max_cos to %d\n", bp->max_cos); /* We need at least one default status block for slow-path events, * second status block for the L2 queue, and a third status block for * CNIC if supported. */ if (IS_VF(bp)) bp->min_msix_vec_cnt = 1; else if (CNIC_SUPPORT(bp)) bp->min_msix_vec_cnt = 3; else /* PF w/o cnic */ bp->min_msix_vec_cnt = 2; BNX2X_DEV_INFO("bp->min_msix_vec_cnt %d", bp->min_msix_vec_cnt); bp->dump_preset_idx = 1; if (CHIP_IS_E3B0(bp)) bp->flags |= PTP_SUPPORTED; return rc; }
0
[ "CWE-20" ]
linux
8914a595110a6eca69a5e275b323f5d09e18f4f9
168,485,560,205,122,350,000,000,000,000,000,000,000
136
bnx2x: disable GSO where gso_size is too big for hardware If a bnx2x card is passed a GSO packet with a gso_size larger than ~9700 bytes, it will cause a firmware error that will bring the card down: bnx2x: [bnx2x_attn_int_deasserted3:4323(enP24p1s0f0)]MC assert! bnx2x: [bnx2x_mc_assert:720(enP24p1s0f0)]XSTORM_ASSERT_LIST_INDEX 0x2 bnx2x: [bnx2x_mc_assert:736(enP24p1s0f0)]XSTORM_ASSERT_INDEX 0x0 = 0x00000000 0x25e43e47 0x00463e01 0x00010052 bnx2x: [bnx2x_mc_assert:750(enP24p1s0f0)]Chip Revision: everest3, FW Version: 7_13_1 ... (dump of values continues) ... Detect when the mac length of a GSO packet is greater than the maximum packet size (9700 bytes) and disable GSO. Signed-off-by: Daniel Axtens <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
__be32 inet_current_timestamp(void) { u32 secs; u32 msecs; struct timespec64 ts; ktime_get_real_ts64(&ts); /* Get secs since midnight. */ (void)div_u64_rem(ts.tv_sec, SECONDS_PER_DAY, &secs); /* Convert to msecs. */ msecs = secs * MSEC_PER_SEC; /* Convert nsec to msec. */ msecs += (u32)ts.tv_nsec / NSEC_PER_MSEC; /* Convert to network byte order. */ return htons(msecs); }
0
[ "CWE-400", "CWE-703" ]
linux
fac8e0f579695a3ecbc4d3cac369139d7f819971
84,364,283,375,207,120,000,000,000,000,000,000,000
18
tunnels: Don't apply GRO to multiple layers of encapsulation. When drivers express support for TSO of encapsulated packets, they only mean that they can do it for one layer of encapsulation. Supporting additional levels would mean updating, at a minimum, more IP length fields and they are unaware of this. No encapsulation device expresses support for handling offloaded encapsulated packets, so we won't generate these types of frames in the transmit path. However, GRO doesn't have a check for multiple levels of encapsulation and will attempt to build them. UDP tunnel GRO actually does prevent this situation but it only handles multiple UDP tunnels stacked on top of each other. This generalizes that solution to prevent any kind of tunnel stacking that would cause problems. Fixes: bf5a755f ("net-gre-gro: Add GRE support to the GRO stack") Signed-off-by: Jesse Gross <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static int selinux_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen) { return selinux_inode_setsecurity(inode, XATTR_SELINUX_SUFFIX, ctx, ctxlen, 0); }
0
[ "CWE-264" ]
linux
259e5e6c75a910f3b5e656151dc602f53f9d7548
77,105,147,349,451,900,000,000,000,000,000,000,000
4
Add PR_{GET,SET}_NO_NEW_PRIVS to prevent execve from granting privs With this change, calling prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) disables privilege granting operations at execve-time. For example, a process will not be able to execute a setuid binary to change their uid or gid if this bit is set. The same is true for file capabilities. Additionally, LSM_UNSAFE_NO_NEW_PRIVS is defined to ensure that LSMs respect the requested behavior. To determine if the NO_NEW_PRIVS bit is set, a task may call prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0); It returns 1 if set and 0 if it is not set. If any of the arguments are non-zero, it will return -1 and set errno to -EINVAL. (PR_SET_NO_NEW_PRIVS behaves similarly.) This functionality is desired for the proposed seccomp filter patch series. By using PR_SET_NO_NEW_PRIVS, it allows a task to modify the system call behavior for itself and its child tasks without being able to impact the behavior of a more privileged task. Another potential use is making certain privileged operations unprivileged. For example, chroot may be considered "safe" if it cannot affect privileged tasks. Note, this patch causes execve to fail when PR_SET_NO_NEW_PRIVS is set and AppArmor is in use. It is fixed in a subsequent patch. Signed-off-by: Andy Lutomirski <[email protected]> Signed-off-by: Will Drewry <[email protected]> Acked-by: Eric Paris <[email protected]> Acked-by: Kees Cook <[email protected]> v18: updated change desc v17: using new define values as per 3.4 Signed-off-by: James Morris <[email protected]>
int32_t cli_bcapi_inflate_process(struct cli_bc_ctx *ctx , int32_t id) { int ret; unsigned avail_in_orig, avail_out_orig; struct bc_inflate *b = get_inflate(ctx, id); if (!b || b->from == -1 || b->to == -1) return -1; b->stream.avail_in = avail_in_orig = cli_bcapi_buffer_pipe_read_avail(ctx, b->from); b->stream.next_in = cli_bcapi_buffer_pipe_read_get(ctx, b->from, b->stream.avail_in); b->stream.avail_out = avail_out_orig = cli_bcapi_buffer_pipe_write_avail(ctx, b->to); b->stream.next_out = cli_bcapi_buffer_pipe_write_get(ctx, b->to, b->stream.avail_out); if (!b->stream.avail_in || !b->stream.avail_out || !b->stream.next_in || !b->stream.next_out) return -1; /* try hard to extract data, skipping over corrupted data */ do { if (!b->needSync) { ret = inflate(&b->stream, Z_NO_FLUSH); if (ret == Z_DATA_ERROR) { cli_dbgmsg("bytecode api: inflate at %lu: %s, trying to recover\n", b->stream.total_in, b->stream.msg); b->needSync = 1; } } if (b->needSync) { ret = inflateSync(&b->stream); if (ret == Z_OK) { cli_dbgmsg("bytecode api: successfully recovered inflate stream\n"); b->needSync = 0; continue; } } break; } while (1); cli_bcapi_buffer_pipe_read_stopped(ctx, b->from, avail_in_orig - b->stream.avail_in); cli_bcapi_buffer_pipe_write_stopped(ctx, b->to, avail_out_orig - b->stream.avail_out); if (ret == Z_MEM_ERROR) { cli_dbgmsg("bytecode api: out of memory!\n"); cli_bcapi_inflate_done(ctx, id); return ret; } if (ret == Z_STREAM_END) { cli_bcapi_inflate_done(ctx, id); } if (ret == Z_BUF_ERROR) { cli_dbgmsg("bytecode api: buffer error!\n"); } return ret; }
0
[ "CWE-189" ]
clamav-devel
3d664817f6ef833a17414a4ecea42004c35cc42f
24,808,708,106,878,413,000,000,000,000,000,000,000
59
fix recursion level crash (bb #3706). Thanks to Stephane Chazelas for the analysis.
HttpTransact::handle_response_keep_alive_headers(State* s, HTTPVersion ver, HTTPHdr* heads) { enum KA_Action_t { KA_UNKNOWN, KA_DISABLED, KA_CLOSE, KA_CONNECTION }; KA_Action_t ka_action = KA_UNKNOWN; ink_assert(heads->type_get() == HTTP_TYPE_RESPONSE); // Since connection headers are hop-to-hop, strip the // the ones we received from upstream heads->field_delete(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION); heads->field_delete(MIME_FIELD_PROXY_CONNECTION, MIME_LEN_PROXY_CONNECTION); // Handle the upgrade cases if (s->is_upgrade_request && heads->status_get() == HTTP_STATUS_SWITCHING_PROTOCOL && s->source == SOURCE_HTTP_ORIGIN_SERVER) { s->client_info.keep_alive = HTTP_NO_KEEPALIVE; if (s->is_websocket) { DebugTxn("http_trans", "transaction successfully upgraded to websockets."); //s->transparent_passthrough = true; heads->value_set(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION, MIME_FIELD_UPGRADE, MIME_LEN_UPGRADE); heads->value_set(MIME_FIELD_UPGRADE, MIME_LEN_UPGRADE, "websocket", 9); } // We set this state so that we can jump to our blind forwarding state once // the response is sent to the client. s->did_upgrade_succeed = true; return; } int c_hdr_field_len; const char *c_hdr_field_str; if (s->client_info.proxy_connect_hdr) { c_hdr_field_str = MIME_FIELD_PROXY_CONNECTION; c_hdr_field_len = MIME_LEN_PROXY_CONNECTION; } else { c_hdr_field_str = MIME_FIELD_CONNECTION; c_hdr_field_len = MIME_LEN_CONNECTION; } // Check pre-conditions for keep-alive if (HTTP_MAJOR(ver.m_version) == 0) { /* No K-A for 0.9 apps */ ka_action = KA_DISABLED; } else if (heads->status_get() == HTTP_STATUS_NO_CONTENT && ((s->source == SOURCE_HTTP_ORIGIN_SERVER && s->current.server->transfer_encoding != NO_TRANSFER_ENCODING) || heads->get_content_length() != 0)) { // some systems hang until the connection closes when receiving a 204 regardless of the K-A headers // close if there is any body response from the origin ka_action = KA_CLOSE; } else { // Determine if we are going to send either a server-generated or // proxy-generated chunked response to the client. If we cannot // trust the content-length, we may be able to chunk the response // to the client to keep the connection alive. // Insert a Transfer-Encoding header in the response if necessary. // check that the client is HTTP 1.1 and the conf allows chunking if (s->client_info.http_version == HTTPVersion(1, 1) && s->txn_conf->chunking_enabled == 1 && // if we're not sending a body, don't set a chunked header regardless of server response !is_response_body_precluded(s->hdr_info.client_response.status_get(), s->method) && // we do not need chunked encoding for internal error messages // that are sent to the client if the server response is not valid. (((s->source == SOURCE_HTTP_ORIGIN_SERVER || s->source == SOURCE_TRANSFORM) && s->hdr_info.server_response.valid() && // if we receive a 304, we will serve the client from the // cache and thus do not need chunked encoding. s->hdr_info.server_response.status_get() != HTTP_STATUS_NOT_MODIFIED && (s->current.server->transfer_encoding == HttpTransact::CHUNKED_ENCODING || // we can use chunked encoding if we cannot trust the content // length (e.g. no Content-Length and Connection:close in HTTP/1.1 responses) s->hdr_info.trust_response_cl == false)) || // handle serve from cache (read-while-write) case (s->source == SOURCE_CACHE && s->hdr_info.trust_response_cl == false) || //any transform will potentially alter the content length. try chunking if possible (s->source == SOURCE_TRANSFORM && s->hdr_info.trust_response_cl == false ))) { s->client_info.receive_chunked_response = true; heads->value_append(MIME_FIELD_TRANSFER_ENCODING, MIME_LEN_TRANSFER_ENCODING, HTTP_VALUE_CHUNKED, HTTP_LEN_CHUNKED, true); } else { s->client_info.receive_chunked_response = false; } //make sure no content length header is send when transfer encoding is chunked if ( s->client_info.receive_chunked_response ) { s->hdr_info.trust_response_cl = false; // And delete the header if it's already been added... heads->field_delete(MIME_FIELD_CONTENT_LENGTH, MIME_LEN_CONTENT_LENGTH); } // Close the connection if client_info is not keep-alive. // Otherwise, if we cannot trust the content length, we will close the connection // unless we are going to use chunked encoding or the client issued // a PUSH request if (s->client_info.keep_alive != HTTP_KEEPALIVE) { ka_action = KA_DISABLED; } else if (s->hdr_info.trust_response_cl == false && !(s->client_info.receive_chunked_response == true || (s->method == HTTP_WKSIDX_PUSH && s->client_info.keep_alive == HTTP_KEEPALIVE))) { ka_action = KA_CLOSE; } else { ka_action = KA_CONNECTION; } } // Insert K-A headers as necessary switch (ka_action) { case KA_CONNECTION: ink_assert(s->client_info.keep_alive != HTTP_NO_KEEPALIVE); // This is a hack, we send the keep-alive header for both 1.0 // and 1.1, to be "compatible" with Akamai. // if (ver == HTTPVersion (1, 0)) { heads->value_set(c_hdr_field_str, c_hdr_field_len, "keep-alive", 10); // NOTE: if the version is 1.1 we don't need to do // anything since keep-alive is assumed break; case KA_CLOSE: case KA_DISABLED: if (s->client_info.keep_alive != HTTP_NO_KEEPALIVE || (ver == HTTPVersion(1, 1))) { heads->value_set(c_hdr_field_str, c_hdr_field_len, "close", 5); s->client_info.keep_alive = HTTP_NO_KEEPALIVE; } // Note: if we are 1.1, we always need to send the close // header since persistant connnections are the default break; case KA_UNKNOWN: default: ink_assert(0); break; } } /* End HttpTransact::handle_response_keep_alive_headers */
0
[ "CWE-119" ]
trafficserver
8b5f0345dade6b2822d9b52c8ad12e63011a5c12
243,962,823,109,581,000,000,000,000,000,000,000,000
132
Fix the internal buffer sizing. Thanks to Sudheer for helping isolating this bug
void lodepng_state_cleanup(LodePNGState* state) { lodepng_color_mode_cleanup(&state->info_raw); lodepng_info_cleanup(&state->info_png); }
0
[ "CWE-401" ]
FreeRDP
9fee4ae076b1ec97b97efb79ece08d1dab4df29a
252,579,765,009,992,200,000,000,000,000,000,000,000
5
Fixed #5645: realloc return handling
bool CIRCSock::OnNoticeMessage(CNoticeMessage& Message) { CString sTarget = Message.GetTarget(); bool bResult = false; if (sTarget.Equals(GetNick())) { IRCSOCKMODULECALL(OnPrivNoticeMessage(Message), &bResult); if (bResult) return true; if (!m_pNetwork->IsUserOnline()) { // If the user is detached, add to the buffer CNoticeMessage Format; Format.Clone(Message); Format.SetNick(CNick(_NAMEDFMT(Message.GetNick().GetNickMask()))); Format.SetTarget("{target}"); Format.SetText("{text}"); m_pNetwork->AddNoticeBuffer(Format, Message.GetText()); } return false; } else { CChan* pChan = m_pNetwork->FindChan(sTarget); if (pChan) { Message.SetChan(pChan); FixupChanNick(Message.GetNick(), pChan); IRCSOCKMODULECALL(OnChanNoticeMessage(Message), &bResult); if (bResult) return true; if (!pChan->AutoClearChanBuffer() || !m_pNetwork->IsUserOnline() || pChan->IsDetached()) { CNoticeMessage Format; Format.Clone(Message); Format.SetNick(_NAMEDFMT(Message.GetNick().GetNickMask())); Format.SetTarget(_NAMEDFMT(Message.GetTarget())); Format.SetText("{text}"); pChan->AddBuffer(Format, Message.GetText()); } } return (pChan && pChan->IsDetached()); } }
0
[ "CWE-20", "CWE-284" ]
znc
d22fef8620cdd87490754f607e7153979731c69d
46,680,979,684,753,630,000,000,000,000,000,000,000
41
Better cleanup lines coming from network. Thanks for Jeriko One <[email protected]> for finding and reporting this.
static int search_chunk(struct mschmd_header *chm, const unsigned char *chunk, const char *filename, const unsigned char **result, const unsigned char **result_end) { const unsigned char *start, *end, *p; unsigned int qr_size, num_entries, qr_entries, qr_density, name_len; unsigned int L, R, M, fname_len, entries_off, is_pmgl; int cmp; fname_len = strlen(filename); /* PMGL chunk or PMGI chunk? (note: read_chunk() has already * checked the rest of the characters in the chunk signature) */ if (chunk[3] == 0x4C) { is_pmgl = 1; entries_off = pmgl_Entries; } else { is_pmgl = 0; entries_off = pmgi_Entries; } /* Step 1: binary search first filename of each QR entry * - target filename == entry * found file * - target filename < all entries * file not found * - target filename > all entries * proceed to step 2 using final entry * - target filename between two searched entries * proceed to step 2 */ qr_size = EndGetI32(&chunk[pmgl_QuickRefSize]); start = &chunk[chm->chunk_size - 2]; end = &chunk[chm->chunk_size - qr_size]; num_entries = EndGetI16(start); qr_density = 1 + (1 << chm->density); qr_entries = (num_entries + qr_density-1) / qr_density; if (num_entries == 0) { D(("chunk has no entries")) return -1; } if (qr_size > chm->chunk_size) { D(("quickref size > chunk size")) return -1; } *result_end = end; if (((int)qr_entries * 2) > (start - end)) { D(("WARNING; more quickrefs than quickref space")) qr_entries = 0; /* but we can live with it */ } if (qr_entries > 0) { L = 0; R = qr_entries - 1; do { /* pick new midpoint */ M = (L + R) >> 1; /* compare filename with entry QR points to */ p = &chunk[entries_off + (M ? EndGetI16(start - (M << 1)) : 0)]; READ_ENCINT(name_len); if (name_len > (unsigned int) (end - p)) goto chunk_end; cmp = compare(filename, (char *)p, fname_len, name_len); if (cmp == 0) break; else if (cmp < 0) { if (M) R = M - 1; else return 0; } else if (cmp > 0) L = M + 1; } while (L <= R); M = (L + R) >> 1; if (cmp == 0) { /* exact match! */ p += name_len; *result = p; return 1; } /* otherwise, read the group of entries for QR entry M */ p = &chunk[entries_off + (M ? EndGetI16(start - (M << 1)) : 0)]; num_entries -= (M * qr_density); if (num_entries > qr_density) num_entries = qr_density; } else { p = &chunk[entries_off]; } /* Step 2: linear search through the set of entries reached in step 1. * - filename == any entry * found entry * - filename < all entries (PMGI) or any entry (PMGL) * entry not found, stop now * - filename > all entries * entry not found (PMGL) / maybe found (PMGI) * - */ *result = NULL; while (num_entries-- > 0) { READ_ENCINT(name_len); if (name_len > (unsigned int) (end - p)) goto chunk_end; cmp = compare(filename, (char *)p, fname_len, name_len); p += name_len; if (cmp == 0) { /* entry found */ *result = p; return 1; } if (cmp < 0) { /* entry not found (PMGL) / maybe found (PMGI) */ break; } /* read and ignore the rest of this entry */ if (is_pmgl) { READ_ENCINT(R); /* skip section */ READ_ENCINT(R); /* skip offset */ READ_ENCINT(R); /* skip length */ } else { *result = p; /* store potential final result */ READ_ENCINT(R); /* skip chunk number */ } } /* PMGL? not found. PMGI? maybe found */ return (is_pmgl) ? 0 : (*result ? 1 : 0); chunk_end: D(("reached end of chunk data while searching")) return -1; }
0
[ "CWE-119", "CWE-787" ]
libmspack
2f084136cfe0d05e5bf5703f3e83c6d955234b4d
170,832,940,715,364,250,000,000,000,000,000,000,000
139
length checks when looking for control files
static void spotcheck_subframe_estimate_( FLAC__StreamEncoder *encoder, unsigned blocksize, unsigned subframe_bps, const FLAC__Subframe *subframe, unsigned estimate ) { FLAC__bool ret; FLAC__BitWriter *frame = FLAC__bitwriter_new(); if(frame == 0) { fprintf(stderr, "EST: can't allocate frame\n"); return; } if(!FLAC__bitwriter_init(frame)) { fprintf(stderr, "EST: can't init frame\n"); return; } ret = add_subframe_(encoder, blocksize, subframe_bps, subframe, frame); FLAC__ASSERT(ret); { const unsigned actual = FLAC__bitwriter_get_input_bits_unconsumed(frame); if(estimate != actual) fprintf(stderr, "EST: bad, frame#%u sub#%%d type=%8s est=%u, actual=%u, delta=%d\n", encoder->private_->current_frame_number, FLAC__SubframeTypeString[subframe->type], estimate, actual, (int)actual-(int)estimate); } FLAC__bitwriter_delete(frame); }
0
[]
flac
c06a44969c1145242a22f75fc8fb2e8b54c55303
206,511,783,073,245,600,000,000,000,000,000,000,000
27
flac : Fix for https://sourceforge.net/p/flac/bugs/425/ * flac/encode.c : Validate num_tracks field of cuesheet. * libFLAC/stream_encoder.c : Add check for a NULL pointer. * flac/encode.c : Improve bounds checking. Closes: https://sourceforge.net/p/flac/bugs/425/
static int dmg_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVDMGState *s = bs->opaque; uint64_t info_begin, info_end, last_in_offset, last_out_offset; uint32_t count, tmp; uint32_t max_compressed_size = 1, max_sectors_per_chunk = 1, i; int64_t offset; int ret; bs->read_only = 1; s->n_chunks = 0; s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL; /* read offset of info blocks */ offset = bdrv_getlength(bs->file); if (offset < 0) { ret = offset; goto fail; } offset -= 0x1d8; ret = read_uint64(bs, offset, &info_begin); if (ret < 0) { goto fail; } else if (info_begin == 0) { ret = -EINVAL; goto fail; } ret = read_uint32(bs, info_begin, &tmp); if (ret < 0) { goto fail; } else if (tmp != 0x100) { ret = -EINVAL; goto fail; } ret = read_uint32(bs, info_begin + 4, &count); if (ret < 0) { goto fail; } else if (count == 0) { ret = -EINVAL; goto fail; } info_end = info_begin + count; offset = info_begin + 0x100; /* read offsets */ last_in_offset = last_out_offset = 0; while (offset < info_end) { uint32_t type; ret = read_uint32(bs, offset, &count); if (ret < 0) { goto fail; } else if (count == 0) { ret = -EINVAL; goto fail; } offset += 4; ret = read_uint32(bs, offset, &type); if (ret < 0) { goto fail; } if (type == 0x6d697368 && count >= 244) { size_t new_size; uint32_t chunk_count; offset += 4; offset += 200; chunk_count = (count - 204) / 40; new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count); s->types = g_realloc(s->types, new_size / 2); s->offsets = g_realloc(s->offsets, new_size); s->lengths = g_realloc(s->lengths, new_size); s->sectors = g_realloc(s->sectors, new_size); s->sectorcounts = g_realloc(s->sectorcounts, new_size); for (i = s->n_chunks; i < s->n_chunks + chunk_count; i++) { ret = read_uint32(bs, offset, &s->types[i]); if (ret < 0) { goto fail; } offset += 4; if (s->types[i] != 0x80000005 && s->types[i] != 1 && s->types[i] != 2) { if (s->types[i] == 0xffffffff && i > 0) { last_in_offset = s->offsets[i - 1] + s->lengths[i - 1]; last_out_offset = s->sectors[i - 1] + s->sectorcounts[i - 1]; } chunk_count--; i--; offset += 36; continue; } offset += 4; ret = read_uint64(bs, offset, &s->sectors[i]); if (ret < 0) { goto fail; } s->sectors[i] += last_out_offset; offset += 8; ret = read_uint64(bs, offset, &s->sectorcounts[i]); if (ret < 0) { goto fail; } offset += 8; ret = read_uint64(bs, offset, &s->offsets[i]); if (ret < 0) { goto fail; } s->offsets[i] += last_in_offset; offset += 8; ret = read_uint64(bs, offset, &s->lengths[i]); if (ret < 0) { goto fail; } offset += 8; if (s->lengths[i] > max_compressed_size) { max_compressed_size = s->lengths[i]; } if (s->sectorcounts[i] > max_sectors_per_chunk) { max_sectors_per_chunk = s->sectorcounts[i]; } } s->n_chunks += chunk_count; } } /* initialize zlib engine */ s->compressed_chunk = g_malloc(max_compressed_size + 1); s->uncompressed_chunk = g_malloc(512 * max_sectors_per_chunk); if (inflateInit(&s->zstream) != Z_OK) { ret = -EINVAL; goto fail; } s->current_chunk = s->n_chunks; qemu_co_mutex_init(&s->lock); return 0; fail: g_free(s->types); g_free(s->offsets); g_free(s->lengths); g_free(s->sectors); g_free(s->sectorcounts); g_free(s->compressed_chunk); g_free(s->uncompressed_chunk); return ret; }
1
[ "CWE-119" ]
qemu
c165f7758009a4f793c1fc19ebb69cf55313450b
30,678,368,268,608,270,000,000,000,000,000,000,000
163
dmg: sanitize chunk length and sectorcount (CVE-2014-0145) Chunk length and sectorcount are used for decompression buffers as well as the bdrv_pread() count argument. Ensure that they have reasonable values so neither memory allocation nor conversion from uint64_t to int will cause problems. Signed-off-by: Stefan Hajnoczi <[email protected]> Signed-off-by: Kevin Wolf <[email protected]> Reviewed-by: Max Reitz <[email protected]> Signed-off-by: Stefan Hajnoczi <[email protected]>
mkstr(size_t n) { struct string *str; str = xmalloc(sizeof(*str) + n + 1); str->n = n; return str; }
0
[ "CWE-476", "CWE-284" ]
samurai
e84b6d99c85043fa1ba54851ee500540ec206918
121,151,750,993,528,460,000,000,000,000,000,000,000
9
util: Check for NULL string in writefile This check was there previously, but was removed in f549b757 with the addition of a check during parse that every rule has rspfile if and only if it has rspfile_content. However, this fails to consider the possibility of those variables coming from the edge or global environment. So, re-add the check. Fixes #67.
static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) { struct usb_yurex *dev; int len = 0; char in_buffer[20]; unsigned long flags; dev = file->private_data; mutex_lock(&dev->io_mutex); if (!dev->interface) { /* already disconnected */ mutex_unlock(&dev->io_mutex); return -ENODEV; } spin_lock_irqsave(&dev->lock, flags); len = snprintf(in_buffer, 20, "%lld\n", dev->bbu); spin_unlock_irqrestore(&dev->lock, flags); mutex_unlock(&dev->io_mutex); return simple_read_from_buffer(buffer, count, ppos, in_buffer, len); }
0
[ "CWE-20", "CWE-200" ]
linux
f1e255d60ae66a9f672ff9a207ee6cd8e33d2679
325,654,010,953,730,850,000,000,000,000,000,000,000
23
USB: yurex: fix out-of-bounds uaccess in read handler In general, accessing userspace memory beyond the length of the supplied buffer in VFS read/write handlers can lead to both kernel memory corruption (via kernel_read()/kernel_write(), which can e.g. be triggered via sys_splice()) and privilege escalation inside userspace. Fix it by using simple_read_from_buffer() instead of custom logic. Fixes: 6bc235a2e24a ("USB: add driver for Meywa-Denki & Kayac YUREX") Signed-off-by: Jann Horn <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
static const char *skip(const char *s, const char *e, const char *d, struct mg_str *v) { v->ptr = s; while (s < e && *s != '\n' && strchr(d, *s) == NULL) s++; v->len = (size_t) (s - v->ptr); while (s < e && strchr(d, *s) != NULL) s++; return s; }
0
[ "CWE-552" ]
mongoose
c65c8fdaaa257e0487ab0aaae9e8f6b439335945
71,819,565,769,319,630,000,000,000,000,000,000,000
8
Protect against the directory traversal in mg_upload()
static CURLcode main_init(void) { #ifdef DJGPP /* stop stat() wasting time */ _djstat_flags |= _STAT_INODE | _STAT_EXEC_MAGIC | _STAT_DIRSIZE; #endif return curl_global_init(CURL_GLOBAL_DEFAULT); }
0
[ "CWE-125" ]
curl
70b1900dd13d16f2e83f571407a614541d5ac9ba
158,782,472,037,998,640,000,000,000,000,000,000,000
8
'mytx' in bug report #1723194 (http://curl.haxx.se/bug/view.cgi?id=1723194) pointed out that the warnf() function in the curl tool didn't properly deal with the cases when excessively long words were used in the string to chop up.
static int selinux_bpf_prog(struct bpf_prog *prog) { u32 sid = current_sid(); struct bpf_security_struct *bpfsec; bpfsec = prog->aux->security; return avc_has_perm(&selinux_state, sid, bpfsec->sid, SECCLASS_BPF, BPF__PROG_RUN, NULL); }
0
[ "CWE-349" ]
linux
fb73974172ffaaf57a7c42f35424d9aece1a5af6
253,111,816,584,845,300,000,000,000,000,000,000,000
10
selinux: properly handle multiple messages in selinux_netlink_send() Fix the SELinux netlink_send hook to properly handle multiple netlink messages in a single sk_buff; each message is parsed and subject to SELinux access control. Prior to this patch, SELinux only inspected the first message in the sk_buff. Cc: [email protected] Reported-by: Dmitry Vyukov <[email protected]> Reviewed-by: Stephen Smalley <[email protected]> Signed-off-by: Paul Moore <[email protected]>
void __init udp_table_init(struct udp_table *table, const char *name) { unsigned int i; if (!CONFIG_BASE_SMALL) table->hash = alloc_large_system_hash(name, 2 * sizeof(struct udp_hslot), uhash_entries, 21, /* one slot per 2 MB */ 0, &table->log, &table->mask, 64 * 1024); /* * Make sure hash table has the minimum size */ if (CONFIG_BASE_SMALL || table->mask < UDP_HTABLE_SIZE_MIN - 1) { table->hash = kmalloc(UDP_HTABLE_SIZE_MIN * 2 * sizeof(struct udp_hslot), GFP_KERNEL); if (!table->hash) panic(name); table->log = ilog2(UDP_HTABLE_SIZE_MIN); table->mask = UDP_HTABLE_SIZE_MIN - 1; } table->hash2 = table->hash + (table->mask + 1); for (i = 0; i <= table->mask; i++) { INIT_HLIST_NULLS_HEAD(&table->hash[i].head, i); table->hash[i].count = 0; spin_lock_init(&table->hash[i].lock); } for (i = 0; i <= table->mask; i++) { INIT_HLIST_NULLS_HEAD(&table->hash2[i].head, i); table->hash2[i].count = 0; spin_lock_init(&table->hash2[i].lock); } }
0
[ "CWE-400" ]
linux-2.6
c377411f2494a931ff7facdbb3a6839b1266bcf6
169,487,138,073,097,340,000,000,000,000,000,000,000
36
net: sk_add_backlog() take rmem_alloc into account Current socket backlog limit is not enough to really stop DDOS attacks, because user thread spend many time to process a full backlog each round, and user might crazy spin on socket lock. We should add backlog size and receive_queue size (aka rmem_alloc) to pace writers, and let user run without being slow down too much. Introduce a sk_rcvqueues_full() helper, to avoid taking socket lock in stress situations. Under huge stress from a multiqueue/RPS enabled NIC, a single flow udp receiver can now process ~200.000 pps (instead of ~100 pps before the patch) on a 8 core machine. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static int entersafe_write_small_rsa_key(sc_card_t *card,u8 key_id,struct sc_pkcs15_prkey_rsa *rsa) { sc_apdu_t apdu; u8 sbuff[SC_MAX_APDU_BUFFER_SIZE]; int r; u8 *p=sbuff; SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); {/* write prkey */ *p++=0x00; /* EC */ *p++=0x00; /* ver */ entersafe_encode_bignum('E',rsa->exponent,&p); entersafe_encode_bignum('D',rsa->d,&p); sc_format_apdu(card,&apdu,SC_APDU_CASE_3_SHORT,0xF4,0x22,key_id); apdu.cla=0x84; apdu.data=sbuff; apdu.lc=apdu.datalen=p-sbuff; r=entersafe_transmit_apdu(card,&apdu,key_maintain,sizeof(key_maintain),1,1); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, sc_check_sw(card, apdu.sw1, apdu.sw2),"Write prkey failed"); } p=sbuff; {/* write pukey */ *p++=0x00; /* EC */ *p++=0x00; /* ver */ entersafe_encode_bignum('E',rsa->exponent,&p); entersafe_encode_bignum('N',rsa->modulus,&p); sc_format_apdu(card,&apdu,SC_APDU_CASE_3_SHORT,0xF4,0x2A,key_id); apdu.cla=0x84; apdu.data=sbuff; apdu.lc=apdu.datalen=p-sbuff; r=entersafe_transmit_apdu(card,&apdu,key_maintain,sizeof(key_maintain),1,1); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, sc_check_sw(card, apdu.sw1, apdu.sw2),"Write pukey failed"); } SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_SUCCESS); }
0
[ "CWE-125" ]
OpenSC
8fe377e93b4b56060e5bbfb6f3142ceaeca744fa
298,540,601,140,249,600,000,000,000,000,000,000,000
44
fixed out of bounds reads Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting and suggesting security fixes.
static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) { mm_segment_t old_fs = get_fs(); struct mtget get; struct mtget32 __user *umget32; struct mtpos pos; struct mtpos32 __user *upos32; unsigned long kcmd; void *karg; int err = 0; switch(cmd) { case MTIOCPOS32: kcmd = MTIOCPOS; karg = &pos; break; case MTIOCGET32: kcmd = MTIOCGET; karg = &get; break; default: do { static int count; if (++count <= 20) printk("mt_ioctl: Unknown cmd fd(%d) " "cmd(%08x) arg(%08x)\n", (int)fd, (unsigned int)cmd, (unsigned int)arg); } while(0); return -EINVAL; } set_fs (KERNEL_DS); err = sys_ioctl (fd, kcmd, (unsigned long)karg); set_fs (old_fs); if (err) return err; switch (cmd) { case MTIOCPOS32: upos32 = compat_ptr(arg); err = __put_user(pos.mt_blkno, &upos32->mt_blkno); break; case MTIOCGET32: umget32 = compat_ptr(arg); err = __put_user(get.mt_type, &umget32->mt_type); err |= __put_user(get.mt_resid, &umget32->mt_resid); err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg); err |= __put_user(get.mt_gstat, &umget32->mt_gstat); err |= __put_user(get.mt_erreg, &umget32->mt_erreg); err |= __put_user(get.mt_fileno, &umget32->mt_fileno); err |= __put_user(get.mt_blkno, &umget32->mt_blkno); break; } return err ? -EFAULT: 0; }
0
[]
linux-2.6
188f83dfe0eeecd1427d0d255cc97dbf7ef6b4b7
58,698,381,982,449,190,000,000,000,000,000,000,000
53
[PATCH] BLOCK: Move the msdos device ioctl compat stuff to the msdos driver [try #6] Move the msdos device ioctl compat stuff from fs/compat_ioctl.c to the msdos driver so that the msdos header file doesn't need to be included. Signed-Off-By: David Howells <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
static ut64 boffset(RBinFile *bf) { return Elf_(r_bin_elf_get_boffset) (bf->o->bin_obj); }
0
[ "CWE-125" ]
radare2
1f37c04f2a762500222dda2459e6a04646feeedf
163,209,058,141,664,820,000,000,000,000,000,000,000
3
Fix #9904 - crash in r2_hoobr_r_read_le32 (over 9000 entrypoints) and read_le oobread (#9923)
static int buffer_needs_copy(PadContext *s, AVFrame *frame, AVBufferRef *buf) { int planes[4] = { -1, -1, -1, -1}, *p = planes; int i, j; /* get all planes in this buffer */ for (i = 0; i < FF_ARRAY_ELEMS(planes) && frame->data[i]; i++) { if (av_frame_get_plane_buffer(frame, i) == buf) *p++ = i; } /* for each plane in this buffer, check that it can be padded without * going over buffer bounds or other planes */ for (i = 0; i < FF_ARRAY_ELEMS(planes) && planes[i] >= 0; i++) { int hsub = s->draw.hsub[planes[i]]; int vsub = s->draw.vsub[planes[i]]; uint8_t *start = frame->data[planes[i]]; uint8_t *end = start + (frame->height >> vsub) * frame->linesize[planes[i]]; /* amount of free space needed before the start and after the end * of the plane */ ptrdiff_t req_start = (s->x >> hsub) * s->draw.pixelstep[planes[i]] + (s->y >> vsub) * frame->linesize[planes[i]]; ptrdiff_t req_end = ((s->w - s->x - frame->width) >> hsub) * s->draw.pixelstep[planes[i]] + (s->y >> vsub) * frame->linesize[planes[i]]; if (frame->linesize[planes[i]] < (s->w >> hsub) * s->draw.pixelstep[planes[i]]) return 1; if (start - buf->data < req_start || (buf->data + buf->size) - end < req_end) return 1; for (j = 0; j < FF_ARRAY_ELEMS(planes) && planes[j] >= 0; j++) { int vsub1 = s->draw.vsub[planes[j]]; uint8_t *start1 = frame->data[planes[j]]; uint8_t *end1 = start1 + (frame->height >> vsub1) * frame->linesize[planes[j]]; if (i == j) continue; if (FFSIGN(start - end1) != FFSIGN(start - end1 - req_start) || FFSIGN(end - start1) != FFSIGN(end - start1 + req_end)) return 1; } } return 0; }
0
[ "CWE-119", "CWE-787" ]
FFmpeg
e43a0a232dbf6d3c161823c2e07c52e76227a1bc
26,601,825,567,284,740,000,000,000,000,000,000,000
51
avfilter: fix plane validity checks Fixes out of array accesses Signed-off-by: Michael Niedermayer <[email protected]>
dns_zone_getexpiretime(dns_zone_t *zone, isc_time_t *expiretime) { REQUIRE(DNS_ZONE_VALID(zone)); REQUIRE(expiretime != NULL); LOCK_ZONE(zone); *expiretime = zone->expiretime; UNLOCK_ZONE(zone); return (ISC_R_SUCCESS); }
0
[ "CWE-327" ]
bind9
f09352d20a9d360e50683cd1d2fc52ccedcd77a0
60,601,287,234,527,950,000,000,000,000,000,000,000
9
Update keyfetch_done compute_tag check If in keyfetch_done the compute_tag fails (because for example the algorithm is not supported), don't crash, but instead ignore the key.
bool run(OperationContext* opCtx, const string& dbname, const BSONObj& cmdObj, BSONObjBuilder& result) { Status status = auth::parseAndValidateDropAllUsersFromDatabaseCommand(cmdObj, dbname); if (!status.isOK()) { return appendCommandStatus(result, status); } ServiceContext* serviceContext = opCtx->getClient()->getServiceContext(); stdx::lock_guard<stdx::mutex> lk(getAuthzDataMutex(serviceContext)); AuthorizationManager* authzManager = AuthorizationManager::get(serviceContext); status = requireAuthSchemaVersion26Final(opCtx, authzManager); if (!status.isOK()) { return appendCommandStatus(result, status); } audit::logDropAllUsersFromDatabase(Client::getCurrent(), dbname); long long numRemoved; status = removePrivilegeDocuments( opCtx, BSON(AuthorizationManager::USER_DB_FIELD_NAME << dbname), &numRemoved); // Must invalidate even on bad status - what if the write succeeded but the GLE failed? authzManager->invalidateUsersFromDB(dbname); if (!status.isOK()) { return appendCommandStatus(result, status); } result.append("n", numRemoved); return true; }
0
[ "CWE-613" ]
mongo
db19e7ce84cfd702a4ba9983ee2ea5019f470f82
141,247,293,386,607,870,000,000,000,000,000,000,000
31
SERVER-38984 Validate unique User ID on UserCache hit (cherry picked from commit e55d6e2292e5dbe2f97153251d8193d1cc89f5d7)
void LogSoftmaxFree(TfLiteContext* context, void* buffer) { delete reinterpret_cast<LogSoftmaxOpData*>(buffer); }
0
[ "CWE-125", "CWE-787" ]
tensorflow
1970c2158b1ffa416d159d03c3370b9a462aee35
63,359,988,790,885,270,000,000,000,000,000,000,000
3
[tflite]: Insert `nullptr` checks when obtaining tensors. As part of ongoing refactoring, `tflite::GetInput`, `tflite::GetOutput`, `tflite::GetTemporary` and `tflite::GetIntermediates` will return `nullptr` in some cases. Hence, we insert the `nullptr` checks on all usages. We also insert `nullptr` checks on usages of `tflite::GetVariableInput` and `tflite::GetOptionalInputTensor` but only in the cases where there is no obvious check that `nullptr` is acceptable (that is, we only insert the check for the output of these two functions if the tensor is accessed as if it is always not `nullptr`). PiperOrigin-RevId: 332521299 Change-Id: I29af455bcb48d0b92e58132d951a3badbd772d56
int socket_connect_unix(const char *filename) { struct sockaddr_un name; int sfd = -1; size_t size; struct stat fst; // check if socket file exists... if (stat(filename, &fst) != 0) { if (verbose >= 2) fprintf(stderr, "%s: stat '%s': %s\n", __func__, filename, strerror(errno)); return -1; } // ... and if it is a unix domain socket if (!S_ISSOCK(fst.st_mode)) { if (verbose >= 2) fprintf(stderr, "%s: File '%s' is not a socket!\n", __func__, filename); return -1; } // make a new socket if ((sfd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) { if (verbose >= 2) fprintf(stderr, "%s: socket: %s\n", __func__, strerror(errno)); return -1; } // and connect to 'filename' name.sun_family = AF_LOCAL; strncpy(name.sun_path, filename, sizeof(name.sun_path)); name.sun_path[sizeof(name.sun_path) - 1] = 0; size = (offsetof(struct sockaddr_un, sun_path) + strlen(name.sun_path) + 1); if (connect(sfd, (struct sockaddr *) &name, size) < 0) { socket_close(sfd); if (verbose >= 2) fprintf(stderr, "%s: connect: %s\n", __func__, strerror(errno)); return -1; } return sfd; }
0
[ "CWE-284" ]
libimobiledevice
df1f5c4d70d0c19ad40072f5246ca457e7f9849e
254,640,271,645,697,740,000,000,000,000,000,000,000
45
common: [security fix] Make sure sockets only listen locally
static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu, struct kvm_vcpu_events *events) { events->exception.injected = vcpu->arch.exception.pending && !kvm_exception_is_soft(vcpu->arch.exception.nr); events->exception.nr = vcpu->arch.exception.nr; events->exception.has_error_code = vcpu->arch.exception.has_error_code; events->exception.error_code = vcpu->arch.exception.error_code; events->interrupt.injected = vcpu->arch.interrupt.pending && !vcpu->arch.interrupt.soft; events->interrupt.nr = vcpu->arch.interrupt.nr; events->interrupt.soft = 0; events->interrupt.shadow = kvm_x86_ops->get_interrupt_shadow(vcpu, KVM_X86_SHADOW_INT_MOV_SS | KVM_X86_SHADOW_INT_STI); events->nmi.injected = vcpu->arch.nmi_injected; events->nmi.pending = vcpu->arch.nmi_pending; events->nmi.masked = kvm_x86_ops->get_nmi_mask(vcpu); events->sipi_vector = vcpu->arch.sipi_vector; events->flags = (KVM_VCPUEVENT_VALID_NMI_PENDING | KVM_VCPUEVENT_VALID_SIPI_VECTOR | KVM_VCPUEVENT_VALID_SHADOW); }
1
[ "CWE-200" ]
kvm
831d9d02f9522e739825a51a11e3bc5aa531a905
171,594,829,116,740,970,000,000,000,000,000,000,000
28
KVM: x86: fix information leak to userland Structures kvm_vcpu_events, kvm_debugregs, kvm_pit_state2 and kvm_clock_data are copied to userland with some padding and reserved fields unitialized. It leads to leaking of contents of kernel stack memory. We have to initialize them to zero. In patch v1 Jan Kiszka suggested to fill reserved fields with zeros instead of memset'ting the whole struct. It makes sense as these fields are explicitly marked as padding. No more fields need zeroing. KVM-Stable-Tag. Signed-off-by: Vasiliy Kulikov <[email protected]> Signed-off-by: Marcelo Tosatti <[email protected]>
**/ CImg<T>& resize(const CImgDisplay& disp, const int interpolation_type=1, const unsigned int boundary_conditions=0, const float centering_x = 0, const float centering_y = 0, const float centering_z = 0, const float centering_c = 0) { return resize(disp.width(),disp.height(),_depth,_spectrum,interpolation_type,boundary_conditions, centering_x,centering_y,centering_z,centering_c);
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
221,350,330,980,706,350,000,000,000,000,000,000,000
7
Fix other issues in 'CImg<T>::load_bmp()'.
JVM_RawRealloc(void * ptr, size_t size, const char * callsite) { return j9portLibrary.omrPortLibrary.mem_reallocate_memory(&j9portLibrary.omrPortLibrary, ptr, (UDATA) size, callsite, J9MEM_CATEGORY_SUN_JCL); }
0
[ "CWE-119" ]
openj9
0971f22d88f42cf7332364ad7430e9bd8681c970
324,855,173,609,260,950,000,000,000,000,000,000,000
4
Clean up jio_snprintf and jio_vfprintf Fixes https://bugs.eclipse.org/bugs/show_bug.cgi?id=543659 Signed-off-by: Peter Bain <[email protected]>
static void FVSelectByScript(FontView *fv,int merge) { int j, gid; SplineChar *sc; EncMap *map = fv->b.map; SplineFont *sf = fv->b.sf; extern GTextInfo scripts[]; GRect pos; GWindow gw; GWindowAttrs wattrs; GGadgetCreateData gcd[10], *hvarray[21][2], *barray[8], boxes[3]; GTextInfo label[10]; int i,k; int done = 0, doit; char tagbuf[4]; uint32 tag; const unichar_t *ret; int lc_k, uc_k, select_k; int only_uc=0, only_lc=0; LookupUIInit(); memset(&wattrs,0,sizeof(wattrs)); memset(&gcd,0,sizeof(gcd)); memset(&label,0,sizeof(label)); memset(&boxes,0,sizeof(boxes)); wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict; wattrs.event_masks = ~(1<<et_charup); wattrs.restrict_input_to_me = false; wattrs.is_dlg = 1; wattrs.undercursor = 1; wattrs.cursor = ct_pointer; wattrs.utf8_window_title = _("Select by Script"); wattrs.is_dlg = true; pos.x = pos.y = 0; pos.width = 100; pos.height = 100; gw = GDrawCreateTopWindow(NULL,&pos,ss_e_h,&done,&wattrs); k = i = 0; gcd[k].gd.flags = gg_visible|gg_enabled ; gcd[k].gd.u.list = scripts; gcd[k].gd.handle_controlevent = SS_ScriptChanged; gcd[k++].creator = GListFieldCreate; hvarray[i][0] = &gcd[k-1]; hvarray[i++][1] = NULL; label[k].text = (unichar_t *) _("All glyphs"); label[k].text_is_1byte = true; gcd[k].gd.label = &label[k]; gcd[k].gd.flags = gg_enabled|gg_visible|gg_utf8_popup|gg_cb_on; gcd[k].gd.popup_msg = (unichar_t *) _("Set the selection of the font view to all glyphs in the script."); gcd[k++].creator = GRadioCreate; hvarray[i][0] = &gcd[k-1]; hvarray[i++][1] = NULL; hvarray[i][0] = GCD_HPad10; hvarray[i++][1] = NULL; uc_k = k; label[k].text = (unichar_t *) _("Only upper case"); label[k].text_is_1byte = true; gcd[k].gd.label = &label[k]; gcd[k].gd.flags = gg_enabled|gg_visible|gg_utf8_popup; gcd[k].gd.popup_msg = (unichar_t *) _("Set the selection of the font view to any upper case glyphs in the script."); gcd[k++].creator = GRadioCreate; hvarray[i][0] = &gcd[k-1]; hvarray[i++][1] = NULL; lc_k = k; label[k].text = (unichar_t *) _("Only lower case"); label[k].text_is_1byte = true; gcd[k].gd.label = &label[k]; gcd[k].gd.flags = gg_enabled|gg_visible|gg_utf8_popup; gcd[k].gd.popup_msg = (unichar_t *) _("Set the selection of the font view to any lower case glyphs in the script."); gcd[k++].creator = GRadioCreate; hvarray[i][0] = &gcd[k-1]; hvarray[i++][1] = NULL; hvarray[i][0] = GCD_HPad10; hvarray[i++][1] = NULL; select_k = k; label[k].text = (unichar_t *) _("Select Results"); label[k].text_is_1byte = true; gcd[k].gd.label = &label[k]; gcd[k].gd.flags = gg_enabled|gg_visible|gg_utf8_popup|gg_rad_startnew; gcd[k].gd.popup_msg = (unichar_t *) _("Set the selection of the font view to the glyphs\nwhich match"); gcd[k++].creator = GRadioCreate; hvarray[i][0] = &gcd[k-1]; hvarray[i++][1] = NULL; label[k].text = (unichar_t *) _("Merge Results"); label[k].text_is_1byte = true; gcd[k].gd.label = &label[k]; gcd[k].gd.flags = gg_enabled|gg_visible|gg_utf8_popup; gcd[k].gd.popup_msg = (unichar_t *) _("Expand the selection of the font view to include\nall the glyphs which match"); gcd[k++].creator = GRadioCreate; hvarray[i][0] = &gcd[k-1]; hvarray[i++][1] = NULL; label[k].text = (unichar_t *) _("Restrict Selection"); label[k].text_is_1byte = true; gcd[k].gd.label = &label[k]; gcd[k].gd.flags = gg_enabled|gg_visible|gg_utf8_popup; gcd[k].gd.popup_msg = (unichar_t *) _("Remove matching glyphs from the selection." ); gcd[k++].creator = GRadioCreate; hvarray[i][0] = &gcd[k-1]; hvarray[i++][1] = NULL; label[k].text = (unichar_t *) _("Logical And with Selection"); label[k].text_is_1byte = true; gcd[k].gd.label = &label[k]; gcd[k].gd.flags = gg_enabled|gg_visible|gg_utf8_popup; gcd[k].gd.popup_msg = (unichar_t *) _("Remove glyphs which do not match from the selection." ); gcd[k++].creator = GRadioCreate; hvarray[i][0] = &gcd[k-1]; hvarray[i++][1] = NULL; gcd[k-4 + merge/4].gd.flags |= gg_cb_on; hvarray[i][0] = GCD_Glue; hvarray[i++][1] = NULL; label[k].text = (unichar_t *) _("_OK"); label[k].text_is_1byte = true; label[k].text_in_resource = true; gcd[k].gd.label = &label[k]; gcd[k].gd.flags = gg_visible|gg_enabled | gg_but_default; gcd[k].gd.handle_controlevent = SS_OK; gcd[k++].creator = GButtonCreate; label[k].text = (unichar_t *) _("_Cancel"); label[k].text_is_1byte = true; label[k].text_in_resource = true; gcd[k].gd.label = &label[k]; gcd[k].gd.flags = gg_visible|gg_enabled | gg_but_cancel; gcd[k].gd.handle_controlevent = SS_Cancel; gcd[k++].creator = GButtonCreate; barray[0] = barray[2] = barray[3] = barray[4] = barray[6] = GCD_Glue; barray[7] = NULL; barray[1] = &gcd[k-2]; barray[5] = &gcd[k-1]; hvarray[i][0] = &boxes[2]; hvarray[i++][1] = NULL; hvarray[i][0] = NULL; memset(boxes,0,sizeof(boxes)); boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2; boxes[0].gd.flags = gg_enabled|gg_visible; boxes[0].gd.u.boxelements = hvarray[0]; boxes[0].creator = GHVGroupCreate; boxes[2].gd.flags = gg_enabled|gg_visible; boxes[2].gd.u.boxelements = barray; boxes[2].creator = GHBoxCreate; GGadgetsCreate(gw,boxes); GHVBoxSetExpandableCol(boxes[2].ret,gb_expandgluesame); GHVBoxSetExpandableRow(boxes[0].ret,gb_expandglue); GHVBoxFitWindow(boxes[0].ret); GDrawSetVisible(gw,true); ret = NULL; while ( !done ) { GDrawProcessOneEvent(NULL); if ( done==2 ) { ret = _GGadgetGetTitle(gcd[0].ret); if ( *ret=='\0' ) { ff_post_error(_("No Script"),_("Please specify a script")); done = 0; } else if ( u_strlen(ret)>4 ) { ff_post_error(_("Bad Script"),_("Scripts are 4 letter tags")); done = 0; } } } memset(tagbuf,' ',4); if ( done==2 && ret!=NULL ) { tagbuf[0] = *ret; if ( ret[1]!='\0' ) { tagbuf[1] = ret[1]; if ( ret[2]!='\0' ) { tagbuf[2] = ret[2]; if ( ret[3]!='\0' ) tagbuf[3] = ret[3]; } } } merge = GGadgetIsChecked(gcd[select_k+0].ret) ? mt_set : GGadgetIsChecked(gcd[select_k+1].ret) ? mt_merge : GGadgetIsChecked(gcd[select_k+2].ret) ? mt_restrict : mt_and; only_uc = GGadgetIsChecked(gcd[uc_k+0].ret); only_lc = GGadgetIsChecked(gcd[lc_k+0].ret); GDrawDestroyWindow(gw); if ( done==1 ) return; tag = (tagbuf[0]<<24) | (tagbuf[1]<<16) | (tagbuf[2]<<8) | tagbuf[3]; for ( j=0; j<map->enccount; ++j ) if ( (gid=map->map[j])!=-1 && (sc=sf->glyphs[gid])!=NULL ) { doit = ( SCScriptFromUnicode(sc)==tag ); if ( doit ) { if ( only_uc && (sc->unicodeenc==-1 || sc->unicodeenc>0xffff || !isupper(sc->unicodeenc)) ) doit = false; else if ( only_lc && (sc->unicodeenc==-1 || sc->unicodeenc>0xffff || !islower(sc->unicodeenc)) ) doit = false; } fv->b.selected[j] = mergefunc[ merge + (fv->b.selected[j]?2:0) + doit ]; } else if ( merge==mt_set ) fv->b.selected[j] = false; GDrawRequestExpose(fv->v,NULL,false); }
0
[ "CWE-119", "CWE-787" ]
fontforge
626f751752875a0ddd74b9e217b6f4828713573c
94,576,331,730,573,860,000,000,000,000,000,000,000
204
Warn users before discarding their unsaved scripts (#3852) * Warn users before discarding their unsaved scripts This closes #3846.
xmlNodePtr xml_add_prop(long status, xmlNsPtr davns, struct propstat *propstat, const xmlChar *name, xmlNsPtr ns, xmlChar *content, unsigned precond) { xmlNodePtr newprop = NULL; if (!propstat->root) { propstat->root = xmlNewNode(davns, BAD_CAST "propstat"); xmlNewChild(propstat->root, NULL, BAD_CAST "prop", NULL); } if (name) newprop = xmlNewTextChild(propstat->root->children, ns, name, content); propstat->status = status; propstat->precond = precond; return newprop; }
0
[]
cyrus-imapd
6703ff881b6056e0c045a7b795ce8ba1bbb87027
329,122,363,886,372,820,000,000,000,000,000,000,000
20
http_dav.c: add 'private' Cache-Control directive for cacheable responses that require authentication
struct qtm_stream *qtm_init(int fd, int ofd, int window_bits, int input_buffer_size, struct cab_file *file, int (*read_cb)(struct cab_file *, unsigned char *, int)) { unsigned int window_size = 1 << window_bits; struct qtm_stream *qtm; unsigned offset; int i; /* Quantum supports window sizes of 2^10 (1Kb) through 2^21 (2Mb) */ /* tk: temporary fix: only process 32KB+ window sizes */ if (window_bits < 15 || window_bits > 21) return NULL; input_buffer_size = (input_buffer_size + 1) & -2; if (input_buffer_size < 2) return NULL; /* allocate decompression state */ if (!(qtm = cli_calloc(1, sizeof(struct qtm_stream)))) { return NULL; } for (i = 0, offset = 0; i < 42; i++) { qtm->position_base[i] = offset; qtm->extra_bits[i] = ((i < 2) ? 0 : (i - 2)) >> 1; offset += 1 << qtm->extra_bits[i]; } for (i = 0, offset = 0; i < 26; i++) { qtm->length_base[i] = offset; qtm->length_extra[i] = (i < 2 ? 0 : i - 2) >> 2; offset += 1 << qtm->length_extra[i]; } qtm->length_base[26] = 254; qtm->length_extra[26] = 0; /* allocate decompression window and input buffer */ qtm->window = cli_malloc((size_t) window_size); if (!qtm->window) { free(qtm); return NULL; } qtm->inbuf = cli_malloc((size_t) input_buffer_size); if (!qtm->inbuf) { free(qtm->window); free(qtm); return NULL; } /* initialise decompression state */ qtm->fd = fd; qtm->ofd = ofd; qtm->wflag = 1; qtm->inbuf_size = input_buffer_size; qtm->window_size = window_size; qtm->window_posn = 0; qtm->frame_start = 0; qtm->header_read = 0; qtm->error = CL_SUCCESS; qtm->i_ptr = qtm->i_end = &qtm->inbuf[0]; qtm->o_ptr = qtm->o_end = &qtm->window[0]; qtm->bits_left = 0; qtm->bit_buffer = 0; /* initialise arithmetic coding models * - model 4 depends on window size, ranges from 20 to 24 * - model 5 depends on window size, ranges from 20 to 36 * - model 6pos depends on window size, ranges from 20 to 42 */ i = window_bits * 2; qtm_init_model(&qtm->model0, &qtm->m0sym[0], 0, 64); qtm_init_model(&qtm->model1, &qtm->m1sym[0], 64, 64); qtm_init_model(&qtm->model2, &qtm->m2sym[0], 128, 64); qtm_init_model(&qtm->model3, &qtm->m3sym[0], 192, 64); qtm_init_model(&qtm->model4, &qtm->m4sym[0], 0, (i > 24) ? 24 : i); qtm_init_model(&qtm->model5, &qtm->m5sym[0], 0, (i > 36) ? 36 : i); qtm_init_model(&qtm->model6, &qtm->m6sym[0], 0, i); qtm_init_model(&qtm->model6len, &qtm->m6lsym[0], 0, 27); qtm_init_model(&qtm->model7, &qtm->m7sym[0], 0, 7); qtm->file = file; qtm->read_cb = read_cb; /* all ok */ return qtm; }
0
[]
clamav-devel
158c35e81a25ea5fda55a2a7f62ea9fec2e883d9
177,142,625,835,787,170,000,000,000,000,000,000,000
88
libclamav/mspack.c: improve unpacking of malformed cabinets (bb#1826)
invoke_NPN_Status(PluginInstance *plugin, const char *message) { npw_return_if_fail(rpc_method_invoke_possible(g_rpc_connection)); int error = rpc_method_invoke(g_rpc_connection, RPC_METHOD_NPN_STATUS, RPC_TYPE_NPW_PLUGIN_INSTANCE, plugin, RPC_TYPE_STRING, message, RPC_TYPE_INVALID); if (error != RPC_ERROR_NO_ERROR) { npw_perror("NPN_Status() invoke", error); return; } error = rpc_method_wait_for_reply(g_rpc_connection, RPC_TYPE_INVALID); if (error != RPC_ERROR_NO_ERROR) { npw_perror("NPN_Status() wait for reply", error); return; } }
0
[ "CWE-264" ]
nspluginwrapper
7e4ab8e1189846041f955e6c83f72bc1624e7a98
60,874,970,451,568,490,000,000,000,000,000,000,000
22
Support all the new variables added
void stsg_del(GF_Box *s) { GF_SubTrackSampleGroupBox *ptr = (GF_SubTrackSampleGroupBox *)s; if (ptr == NULL) return; if (ptr->group_description_index) gf_free(ptr->group_description_index); gf_free(ptr); }
0
[ "CWE-125" ]
gpac
bceb03fd2be95097a7b409ea59914f332fb6bc86
124,661,083,191,474,850,000,000,000,000,000,000,000
7
fixed 2 possible heap overflows (inc. #1088)
int git_tree_entry_icmp(const git_tree_entry *e1, const git_tree_entry *e2) { return git_path_cmp( e1->filename, e1->filename_len, git_tree_entry__is_tree(e1), e2->filename, e2->filename_len, git_tree_entry__is_tree(e2), git__strncasecmp); }
0
[ "CWE-20" ]
libgit2
928429c5c96a701bcbcafacb2421a82602b36915
77,882,142,441,730,670,000,000,000,000,000,000,000
7
tree: Check for `.git` with case insensitivy
display_get_params(gx_device * dev, gs_param_list * plist) { gx_device_display *ddev = (gx_device_display *) dev; int code; gs_param_string dhandle; int idx; int val; int i = 0; size_t dptr; char buf[64]; idx = ((int)sizeof(size_t)) * 8 - 4; buf[i++] = '1'; buf[i++] = '6'; buf[i++] = '#'; dptr = (size_t)(ddev->pHandle); while (idx >= 0) { val = (int)(dptr >> idx) & 0xf; if (val <= 9) buf[i++] = '0' + val; else buf[i++] = 'a' - 10 + val; idx -= 4; } buf[i] = '\0'; param_string_from_transient_string(dhandle, buf); code = gx_default_get_params(dev, plist); (void)(code < 0 || (code = param_write_string(plist, "DisplayHandle", &dhandle)) < 0 || (code = param_write_int(plist, "DisplayFormat", &ddev->nFormat)) < 0 || (code = param_write_float(plist, "DisplayResolution", &ddev->HWResolution[1])) < 0); if (code >= 0 && (ddev->nFormat & DISPLAY_COLORS_MASK) == DISPLAY_COLORS_SEPARATION) code = devn_get_params(dev, plist, &ddev->devn_params, &ddev->equiv_cmyk_colors); return code; }
0
[]
ghostpdl
1ef5f08f2c2e27efa978f0010669ff22355c385f
200,975,884,697,738,900,000,000,000,000,000,000,000
42
Fix display device DisplayFormat=16#a0800 (Separation mode) broken by f2cf6829 The ICC profile checking needs to be told that the device supports_devn, so add a spec_op proc to return true when in separation mode, and add a proc for fill_rectangle_hl_color so that fillpage will work in Separation mode. This was fixed for other devices in commit 250b5e83, but the display device was not fixed then.
ssize_t enc_untrusted_recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen) { int klinux_flags = TokLinuxRecvSendFlag(flags); if (klinux_flags == 0 && flags != 0) { errno = EINVAL; return -1; } MessageWriter input; input.Push<int>(sockfd); input.Push<uint64_t>(len); input.Push<int>(klinux_flags); MessageReader output; const auto status = NonSystemCallDispatcher( ::asylo::host_call::kRecvFromHandler, &input, &output); CheckStatusAndParamCount(status, output, "enc_untrusted_recvfrom", 4); int result = output.next<int>(); int klinux_errno = output.next<int>(); // recvfrom() returns -1 on failure, with errno set to indicate the cause // of the error. if (result == -1) { errno = FromkLinuxErrorNumber(klinux_errno); return result; } if (result > len) { ::asylo::primitives::TrustedPrimitives::BestEffortAbort( "enc_untrusted_recvfrom: result exceeds requested"); } auto buffer_received = output.next(); memcpy(buf, buffer_received.data(), std::min(len, buffer_received.size())); // If |src_addr| is not NULL, and the underlying protocol provides the source // address, this source address is filled in. When |src_addr| is NULL, nothing // is filled in; in this case, |addrlen| is not used, and should also be NULL. if (src_addr != nullptr && addrlen != nullptr) { auto klinux_sockaddr_buf = output.next(); const struct klinux_sockaddr *klinux_addr = klinux_sockaddr_buf.As<struct klinux_sockaddr>(); FromkLinuxSockAddr(klinux_addr, klinux_sockaddr_buf.size(), src_addr, addrlen, TrustedPrimitives::BestEffortAbort); } return result; }
0
[ "CWE-125" ]
asylo
b1d120a2c7d7446d2cc58d517e20a1b184b82200
14,397,589,406,695,664,000,000,000,000,000,000,000
47
Check for return size in enc_untrusted_read Check return size does not exceed requested. The returned result and content still cannot be trusted, but it's expected behavior when not using a secure file system. PiperOrigin-RevId: 333827386 Change-Id: I0bdec0aec9356ea333dc8c647eba5d2772875f29
check_SET_MPLS_TC(const struct ofpact_mpls_tc *a OVS_UNUSED, struct ofpact_check_params *cp) { return check_set_mpls(cp); }
0
[ "CWE-416" ]
ovs
77cccc74deede443e8b9102299efc869a52b65b2
101,872,759,823,663,170,000,000,000,000,000,000,000
5
ofp-actions: Fix use-after-free while decoding RAW_ENCAP. While decoding RAW_ENCAP action, decode_ed_prop() might re-allocate ofpbuf if there is no enough space left. However, function 'decode_NXAST_RAW_ENCAP' continues to use old pointer to 'encap' structure leading to write-after-free and incorrect decoding. ==3549105==ERROR: AddressSanitizer: heap-use-after-free on address 0x60600000011a at pc 0x0000005f6cc6 bp 0x7ffc3a2d4410 sp 0x7ffc3a2d4408 WRITE of size 2 at 0x60600000011a thread T0 #0 0x5f6cc5 in decode_NXAST_RAW_ENCAP lib/ofp-actions.c:4461:20 #1 0x5f0551 in ofpact_decode ./lib/ofp-actions.inc2:4777:16 #2 0x5ed17c in ofpacts_decode lib/ofp-actions.c:7752:21 #3 0x5eba9a in ofpacts_pull_openflow_actions__ lib/ofp-actions.c:7791:13 #4 0x5eb9fc in ofpacts_pull_openflow_actions lib/ofp-actions.c:7835:12 #5 0x64bb8b in ofputil_decode_packet_out lib/ofp-packet.c:1113:17 #6 0x65b6f4 in ofp_print_packet_out lib/ofp-print.c:148:13 #7 0x659e3f in ofp_to_string__ lib/ofp-print.c:1029:16 #8 0x659b24 in ofp_to_string lib/ofp-print.c:1244:21 #9 0x65a28c in ofp_print lib/ofp-print.c:1288:28 #10 0x540d11 in ofctl_ofp_parse utilities/ovs-ofctl.c:2814:9 #11 0x564228 in ovs_cmdl_run_command__ lib/command-line.c:247:17 #12 0x56408a in ovs_cmdl_run_command lib/command-line.c:278:5 #13 0x5391ae in main utilities/ovs-ofctl.c:179:9 #14 0x7f6911ce9081 in __libc_start_main (/lib64/libc.so.6+0x27081) #15 0x461fed in _start (utilities/ovs-ofctl+0x461fed) Fix that by getting a new pointer before using. Credit to OSS-Fuzz. Fuzzer regression test will fail only with AddressSanitizer enabled. Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=27851 Fixes: f839892a206a ("OF support and translation of generic encap and decap") Acked-by: William Tu <[email protected]> Signed-off-by: Ilya Maximets <[email protected]>
void Magick::Image::distort(const DistortMethod method_, const size_t numberArguments_,const double *arguments_,const bool bestfit_) { MagickCore::Image *newImage; GetPPException; newImage=DistortImage(constImage(), method_,numberArguments_,arguments_, bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo); replaceImage(newImage); ThrowImageException; }
0
[ "CWE-416" ]
ImageMagick
8c35502217c1879cb8257c617007282eee3fe1cc
56,059,222,027,298,630,000,000,000,000,000,000,000
12
Added missing return to avoid use after free.
HeaderLookupTable_t::lookup (const char *buf, const std::size_t len) const { const HeaderTableRecord *r = HttpHeaderHashTable::lookup(buf, len); if (!r || r->id == Http::HdrType::OTHER) return BadHdr; return *r; }
0
[ "CWE-116", "CWE-79" ]
squid
051824924c709bd6162a378f746fb859454c674e
43,860,048,861,657,270,000,000,000,000,000,000,000
6
Merge pull request from GHSA-jjq6-mh2h-g39h
PHP_FUNCTION(openssl_pkcs12_export) { X509 * cert = NULL; BIO * bio_out; PKCS12 * p12 = NULL; zval * zcert = NULL, *zout = NULL, *zpkey, *args = NULL; EVP_PKEY *priv_key = NULL; long certresource, keyresource; char * pass; int pass_len; char * friendly_name = NULL; zval ** item; STACK_OF(X509) *ca = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzzs|a", &zcert, &zout, &zpkey, &pass, &pass_len, &args) == FAILURE) return; RETVAL_FALSE; cert = php_openssl_x509_from_zval(&zcert, 0, &certresource TSRMLS_CC); if (cert == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get cert from parameter 1"); return; } priv_key = php_openssl_evp_from_zval(&zpkey, 0, "", 1, &keyresource TSRMLS_CC); if (priv_key == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get private key from parameter 3"); goto cleanup; } if (cert && !X509_check_private_key(cert, priv_key)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "private key does not correspond to cert"); goto cleanup; } /* parse extra config from args array, promote this to an extra function */ if (args && zend_hash_find(Z_ARRVAL_P(args), "friendly_name", sizeof("friendly_name"), (void**)&item) == SUCCESS && Z_TYPE_PP(item) == IS_STRING) friendly_name = Z_STRVAL_PP(item); if (args && zend_hash_find(Z_ARRVAL_P(args), "extracerts", sizeof("extracerts"), (void**)&item) == SUCCESS) ca = php_array_to_X509_sk(item TSRMLS_CC); /* end parse extra config */ p12 = PKCS12_create(pass, friendly_name, priv_key, cert, ca, 0, 0, 0, 0, 0); bio_out = BIO_new(BIO_s_mem()); if (i2d_PKCS12_bio(bio_out, p12)) { BUF_MEM *bio_buf; zval_dtor(zout); BIO_get_mem_ptr(bio_out, &bio_buf); ZVAL_STRINGL(zout, bio_buf->data, bio_buf->length, 1); RETVAL_TRUE; } BIO_free(bio_out); PKCS12_free(p12); php_sk_X509_free(ca); cleanup: if (keyresource == -1 && priv_key) { EVP_PKEY_free(priv_key); } if (certresource == -1 && cert) { X509_free(cert); } }
0
[ "CWE-310" ]
php-src
16023f3e3b9c06cf677c3c980e8d574e4c162827
275,465,755,199,493,300,000,000,000,000,000,000,000
68
Fix bug #70014 - use RAND_bytes instead of deprecated RAND_pseudo_bytes
SetComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena) { expr_ty p; if (!elt) { PyErr_SetString(PyExc_ValueError, "field elt is required for SetComp"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) return NULL; p->kind = SetComp_kind; p->v.SetComp.elt = elt; p->v.SetComp.generators = generators; p->lineno = lineno; p->col_offset = col_offset; p->end_lineno = end_lineno; p->end_col_offset = end_col_offset; return p; }
0
[ "CWE-125" ]
cpython
dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c
49,288,474,551,447,695,000,000,000,000,000,000,000
21
bpo-35766: Merge typed_ast back into CPython (GH-11645)
static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq, struct sg_io_hdr *hdr, fmode_t mode) { if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len)) return -EFAULT; if (blk_verify_command(&q->cmd_filter, rq->cmd, mode & FMODE_WRITE)) return -EPERM; /* * fill in request structure */ rq->cmd_len = hdr->cmd_len; rq->cmd_type = REQ_TYPE_BLOCK_PC; rq->timeout = msecs_to_jiffies(hdr->timeout); if (!rq->timeout) rq->timeout = q->sg_timeout; if (!rq->timeout) rq->timeout = BLK_DEFAULT_SG_TIMEOUT; return 0; }
1
[ "CWE-399" ]
linux-2.6
f2f1fa78a155524b849edf359e42a3001ea652c0
259,037,141,837,650,080,000,000,000,000,000,000,000
22
Enforce a minimum SG_IO timeout There's no point in having too short SG_IO timeouts, since if the command does end up timing out, we'll end up through the reset sequence that is several seconds long in order to abort the command that timed out. As a result, shorter timeouts than a few seconds simply do not make sense, as the recovery would be longer than the timeout itself. Add a BLK_MIN_SG_TIMEOUT to match the existign BLK_DEFAULT_SG_TIMEOUT. Suggested-by: Alan Cox <[email protected]> Acked-by: Tejun Heo <[email protected]> Acked-by: Jens Axboe <[email protected]> Cc: Jeff Garzik <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
bool may_expand_vm(struct mm_struct *mm, vm_flags_t flags, unsigned long npages) { if (mm->total_vm + npages > rlimit(RLIMIT_AS) >> PAGE_SHIFT) return false; if (is_data_mapping(flags) && mm->data_vm + npages > rlimit(RLIMIT_DATA) >> PAGE_SHIFT) { /* Workaround for Valgrind */ if (rlimit(RLIMIT_DATA) == 0 && mm->data_vm + npages <= rlimit_max(RLIMIT_DATA) >> PAGE_SHIFT) return true; if (!ignore_rlimit_data) { pr_warn_once("%s (%d): VmData %lu exceed data ulimit %lu. Update limits or use boot option ignore_rlimit_data.\n", current->comm, current->pid, (mm->data_vm + npages) << PAGE_SHIFT, rlimit(RLIMIT_DATA)); return false; } } return true; }
0
[ "CWE-119" ]
linux
1be7107fbe18eed3e319a6c3e83c78254b693acb
3,212,220,927,181,865,000,000,000,000,000,000,000
22
mm: larger stack guard gap, between vmas Stack guard page is a useful feature to reduce a risk of stack smashing into a different mapping. We have been using a single page gap which is sufficient to prevent having stack adjacent to a different mapping. But this seems to be insufficient in the light of the stack usage in userspace. E.g. glibc uses as large as 64kB alloca() in many commonly used functions. Others use constructs liks gid_t buffer[NGROUPS_MAX] which is 256kB or stack strings with MAX_ARG_STRLEN. This will become especially dangerous for suid binaries and the default no limit for the stack size limit because those applications can be tricked to consume a large portion of the stack and a single glibc call could jump over the guard page. These attacks are not theoretical, unfortunatelly. Make those attacks less probable by increasing the stack guard gap to 1MB (on systems with 4k pages; but make it depend on the page size because systems with larger base pages might cap stack allocations in the PAGE_SIZE units) which should cover larger alloca() and VLA stack allocations. It is obviously not a full fix because the problem is somehow inherent, but it should reduce attack space a lot. One could argue that the gap size should be configurable from userspace, but that can be done later when somebody finds that the new 1MB is wrong for some special case applications. For now, add a kernel command line option (stack_guard_gap) to specify the stack gap size (in page units). Implementation wise, first delete all the old code for stack guard page: because although we could get away with accounting one extra page in a stack vma, accounting a larger gap can break userspace - case in point, a program run with "ulimit -S -v 20000" failed when the 1MB gap was counted for RLIMIT_AS; similar problems could come with RLIMIT_MLOCK and strict non-overcommit mode. Instead of keeping gap inside the stack vma, maintain the stack guard gap as a gap between vmas: using vm_start_gap() in place of vm_start (or vm_end_gap() in place of vm_end if VM_GROWSUP) in just those few places which need to respect the gap - mainly arch_get_unmapped_area(), and and the vma tree's subtree_gap support for that. Original-patch-by: Oleg Nesterov <[email protected]> Original-patch-by: Michal Hocko <[email protected]> Signed-off-by: Hugh Dickins <[email protected]> Acked-by: Michal Hocko <[email protected]> Tested-by: Helge Deller <[email protected]> # parisc Signed-off-by: Linus Torvalds <[email protected]>
ModuleExport void UnregisterICONImage(void) { (void) UnregisterMagickInfo("CUR"); (void) UnregisterMagickInfo("ICO"); (void) UnregisterMagickInfo("ICON"); }
0
[ "CWE-190", "CWE-189", "CWE-703" ]
ImageMagick
0f6fc2d5bf8f500820c3dbcf0d23ee14f2d9f734
102,060,207,765,316,060,000,000,000,000,000,000,000
6
static int linked_attr_modify(struct ldb_module *module, const struct ldb_message *message, struct ldb_request *parent) { struct ldb_request *mod_req; int ret; struct ldb_context *ldb = ldb_module_get_ctx(module); TALLOC_CTX *tmp_ctx = talloc_new(module); struct ldb_result *res; res = talloc_zero(tmp_ctx, struct ldb_result); if (!res) { talloc_free(tmp_ctx); return ldb_oom(ldb_module_get_ctx(module)); } ret = ldb_build_mod_req(&mod_req, ldb, tmp_ctx, message, NULL, res, ldb_modify_default_callback, parent); LDB_REQ_SET_LOCATION(mod_req); if (ret != LDB_SUCCESS) { talloc_free(tmp_ctx); return ret; } ret = ldb_request_add_control(mod_req, DSDB_CONTROL_REPLICATED_UPDATE_OID, false, NULL); if (ret != LDB_SUCCESS) { return ret; } /* Run the new request */ ret = ldb_next_request(module, mod_req); if (ret == LDB_SUCCESS) { ret = ldb_wait(mod_req->handle, LDB_WAIT_ALL); } talloc_free(tmp_ctx); return ret; }
0
[ "CWE-200" ]
samba
0a3aa5f908e351201dc9c4d4807b09ed9eedff77
173,944,382,863,517,920,000,000,000,000,000,000,000
44
CVE-2022-32746 ldb: Make use of functions for appending to an ldb_message This aims to minimise usage of the error-prone pattern of searching for a just-added message element in order to make modifications to it (and potentially finding the wrong element). BUG: https://bugzilla.samba.org/show_bug.cgi?id=15009 Signed-off-by: Joseph Sutton <[email protected]>
psg_json_value_set_ngx_str_ne(PsgJsonValue *doc, const char *name, ngx_str_t *value) { return psg_json_value_set_str_ne(doc, name, (const char *) value->data, value->len); }
0
[ "CWE-362" ]
passenger
207870f5b7f5cc240587ab0977d6046782ae1d86
315,331,086,897,937,040,000,000,000,000,000,000,000
6
Fix privilege escalation in the Nginx module The vulnerability is exploitable with a non-standard passenger_instance_registry_dir, via a race condition where after a file was created, it was chowned via the path not the file descriptor. The chown entered the code in 2010, so Passenger 4 + 5 all affected.
RGWPutObj_CB(RGWPutObj *_op) : op(_op) {}
0
[ "CWE-770" ]
ceph
ab29bed2fc9f961fe895de1086a8208e21ddaddc
87,138,711,606,058,430,000,000,000,000,000,000,000
1
rgw: fix issues with 'enforce bounds' patch The patch to enforce bounds on max-keys/max-uploads/max-parts had a few issues that would prevent us from compiling it. Instead of changing the code provided by the submitter, we're addressing them in a separate commit to maintain the DCO. Signed-off-by: Joao Eduardo Luis <[email protected]> Signed-off-by: Abhishek Lekshmanan <[email protected]> (cherry picked from commit 29bc434a6a81a2e5c5b8cfc4c8d5c82ca5bf538a) mimic specific fixes: As the largeish change from master g_conf() isn't in mimic yet, use the g_conf global structure, also make rgw_op use the value from req_info ceph context as we do for all the requests
do_ascii(exarg_T *eap UNUSED) { int c; int cval; char buf1[20]; char buf2[20]; char_u buf3[7]; #ifdef FEAT_DIGRAPHS char_u *dig; #endif int cc[MAX_MCO]; int ci = 0; int len; if (enc_utf8) c = utfc_ptr2char(ml_get_cursor(), cc); else c = gchar_cursor(); if (c == NUL) { msg("NUL"); return; } IObuff[0] = NUL; if (!has_mbyte || (enc_dbcs != 0 && c < 0x100) || c < 0x80) { if (c == NL) // NUL is stored as NL c = NUL; if (c == CAR && get_fileformat(curbuf) == EOL_MAC) cval = NL; // NL is stored as CR else cval = c; if (vim_isprintc_strict(c) && (c < ' ' || c > '~')) { transchar_nonprint(curbuf, buf3, c); vim_snprintf(buf1, sizeof(buf1), " <%s>", (char *)buf3); } else buf1[0] = NUL; if (c >= 0x80) vim_snprintf(buf2, sizeof(buf2), " <M-%s>", (char *)transchar(c & 0x7f)); else buf2[0] = NUL; #ifdef FEAT_DIGRAPHS dig = get_digraph_for_char(cval); if (dig != NULL) vim_snprintf((char *)IObuff, IOSIZE, _("<%s>%s%s %d, Hex %02x, Oct %03o, Digr %s"), transchar(c), buf1, buf2, cval, cval, cval, dig); else #endif vim_snprintf((char *)IObuff, IOSIZE, _("<%s>%s%s %d, Hex %02x, Octal %03o"), transchar(c), buf1, buf2, cval, cval, cval); if (enc_utf8) c = cc[ci++]; else c = 0; } // Repeat for combining characters. while (has_mbyte && (c >= 0x100 || (enc_utf8 && c >= 0x80))) { len = (int)STRLEN(IObuff); // This assumes every multi-byte char is printable... if (len > 0) IObuff[len++] = ' '; IObuff[len++] = '<'; if (enc_utf8 && utf_iscomposing(c) #ifdef USE_GUI && !gui.in_use #endif ) IObuff[len++] = ' '; // draw composing char on top of a space len += (*mb_char2bytes)(c, IObuff + len); #ifdef FEAT_DIGRAPHS dig = get_digraph_for_char(c); if (dig != NULL) vim_snprintf((char *)IObuff + len, IOSIZE - len, c < 0x10000 ? _("> %d, Hex %04x, Oct %o, Digr %s") : _("> %d, Hex %08x, Oct %o, Digr %s"), c, c, c, dig); else #endif vim_snprintf((char *)IObuff + len, IOSIZE - len, c < 0x10000 ? _("> %d, Hex %04x, Octal %o") : _("> %d, Hex %08x, Octal %o"), c, c, c); if (ci == MAX_MCO) break; if (enc_utf8) c = cc[ci++]; else c = 0; } msg((char *)IObuff); }
0
[ "CWE-787" ]
vim
e2bd8600b873d2cd1f9d667c28cba8b1dba18839
64,124,856,812,511,265,000,000,000,000,000,000,000
100
patch 8.2.4977: memory access error when substitute expression changes window Problem: Memory access error when substitute expression changes window. Solution: Disallow changing window in substitute expression.
template<typename tp, typename tf, typename tc, typename to, typename tz> CImg<T>& draw_object3d(const float x0, const float y0, const float z0, const CImg<tp>& vertices, const CImgList<tf>& primitives, const CImgList<tc>& colors, const CImg<to>& opacities, const unsigned int render_type, const bool is_double_sided, const float focale, const float lightx, const float lighty, const float lightz, const float specular_lightness, const float specular_shininess, CImg<tz>& zbuffer) { return _draw_object3d(0,zbuffer,x0,y0,z0,vertices,primitives,colors,opacities, render_type,is_double_sided,focale,lightx,lighty,lightz, specular_lightness,specular_shininess,1);
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
111,725,881,193,244,390,000,000,000,000,000,000,000
12
Fix other issues in 'CImg<T>::load_bmp()'.
static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h, int x16, int y16, int rounder) { const int A=(16-x16)*(16-y16); const int B=( x16)*(16-y16); const int C=(16-x16)*( y16); const int D=( x16)*( y16); int i; for(i=0; i<h; i++) { dst[0]= (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + rounder)>>8; dst[1]= (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + rounder)>>8; dst[2]= (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + rounder)>>8; dst[3]= (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + rounder)>>8; dst[4]= (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + rounder)>>8; dst[5]= (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + rounder)>>8; dst[6]= (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + rounder)>>8; dst[7]= (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + rounder)>>8; dst+= stride; src+= stride; } }
0
[ "CWE-703", "CWE-189" ]
FFmpeg
454a11a1c9c686c78aa97954306fb63453299760
127,544,586,752,269,630,000,000,000,000,000,000,000
22
avcodec/dsputil: fix signedness in sizeof() comparissions Signed-off-by: Michael Niedermayer <[email protected]>
static int do_ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen) { struct inet_sock *inet = inet_sk(sk); int val; int len; if (level != SOL_IP) return -EOPNOTSUPP; if (ip_mroute_opt(optname)) return ip_mroute_getsockopt(sk, optname, optval, optlen); if (get_user(len, optlen)) return -EFAULT; if (len < 0) return -EINVAL; lock_sock(sk); switch (optname) { case IP_OPTIONS: { unsigned char optbuf[sizeof(struct ip_options)+40]; struct ip_options * opt = (struct ip_options *)optbuf; opt->optlen = 0; if (inet->opt) memcpy(optbuf, inet->opt, sizeof(struct ip_options)+ inet->opt->optlen); release_sock(sk); if (opt->optlen == 0) return put_user(0, optlen); ip_options_undo(opt); len = min_t(unsigned int, len, opt->optlen); if (put_user(len, optlen)) return -EFAULT; if (copy_to_user(optval, opt->__data, len)) return -EFAULT; return 0; } case IP_PKTINFO: val = (inet->cmsg_flags & IP_CMSG_PKTINFO) != 0; break; case IP_RECVTTL: val = (inet->cmsg_flags & IP_CMSG_TTL) != 0; break; case IP_RECVTOS: val = (inet->cmsg_flags & IP_CMSG_TOS) != 0; break; case IP_RECVOPTS: val = (inet->cmsg_flags & IP_CMSG_RECVOPTS) != 0; break; case IP_RETOPTS: val = (inet->cmsg_flags & IP_CMSG_RETOPTS) != 0; break; case IP_PASSSEC: val = (inet->cmsg_flags & IP_CMSG_PASSSEC) != 0; break; case IP_RECVORIGDSTADDR: val = (inet->cmsg_flags & IP_CMSG_ORIGDSTADDR) != 0; break; case IP_TOS: val = inet->tos; break; case IP_TTL: val = (inet->uc_ttl == -1 ? sysctl_ip_default_ttl : inet->uc_ttl); break; case IP_HDRINCL: val = inet->hdrincl; break; case IP_NODEFRAG: val = inet->nodefrag; break; case IP_MTU_DISCOVER: val = inet->pmtudisc; break; case IP_MTU: { struct dst_entry *dst; val = 0; dst = sk_dst_get(sk); if (dst) { val = dst_mtu(dst); dst_release(dst); } if (!val) { release_sock(sk); return -ENOTCONN; } break; } case IP_RECVERR: val = inet->recverr; break; case IP_MULTICAST_TTL: val = inet->mc_ttl; break; case IP_MULTICAST_LOOP: val = inet->mc_loop; break; case IP_MULTICAST_IF: { struct in_addr addr; len = min_t(unsigned int, len, sizeof(struct in_addr)); addr.s_addr = inet->mc_addr; release_sock(sk); if (put_user(len, optlen)) return -EFAULT; if (copy_to_user(optval, &addr, len)) return -EFAULT; return 0; } case IP_MSFILTER: { struct ip_msfilter msf; int err; if (len < IP_MSFILTER_SIZE(0)) { release_sock(sk); return -EINVAL; } if (copy_from_user(&msf, optval, IP_MSFILTER_SIZE(0))) { release_sock(sk); return -EFAULT; } err = ip_mc_msfget(sk, &msf, (struct ip_msfilter __user *)optval, optlen); release_sock(sk); return err; } case MCAST_MSFILTER: { struct group_filter gsf; int err; if (len < GROUP_FILTER_SIZE(0)) { release_sock(sk); return -EINVAL; } if (copy_from_user(&gsf, optval, GROUP_FILTER_SIZE(0))) { release_sock(sk); return -EFAULT; } err = ip_mc_gsfget(sk, &gsf, (struct group_filter __user *)optval, optlen); release_sock(sk); return err; } case IP_MULTICAST_ALL: val = inet->mc_all; break; case IP_PKTOPTIONS: { struct msghdr msg; release_sock(sk); if (sk->sk_type != SOCK_STREAM) return -ENOPROTOOPT; msg.msg_control = optval; msg.msg_controllen = len; msg.msg_flags = 0; if (inet->cmsg_flags & IP_CMSG_PKTINFO) { struct in_pktinfo info; info.ipi_addr.s_addr = inet->inet_rcv_saddr; info.ipi_spec_dst.s_addr = inet->inet_rcv_saddr; info.ipi_ifindex = inet->mc_index; put_cmsg(&msg, SOL_IP, IP_PKTINFO, sizeof(info), &info); } if (inet->cmsg_flags & IP_CMSG_TTL) { int hlim = inet->mc_ttl; put_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim); } len -= msg.msg_controllen; return put_user(len, optlen); } case IP_FREEBIND: val = inet->freebind; break; case IP_TRANSPARENT: val = inet->transparent; break; case IP_MINTTL: val = inet->min_ttl; break; default: release_sock(sk); return -ENOPROTOOPT; } release_sock(sk); if (len < sizeof(int) && len > 0 && val >= 0 && val <= 255) { unsigned char ucval = (unsigned char)val; len = 1; if (put_user(len, optlen)) return -EFAULT; if (copy_to_user(optval, &ucval, 1)) return -EFAULT; } else { len = min_t(unsigned int, sizeof(int), len); if (put_user(len, optlen)) return -EFAULT; if (copy_to_user(optval, &val, len)) return -EFAULT; } return 0; }
1
[ "CWE-362" ]
linux-2.6
f6d8bd051c391c1c0458a30b2a7abcd939329259
330,087,616,203,362,950,000,000,000,000,000,000,000
218
inet: add RCU protection to inet->opt We lack proper synchronization to manipulate inet->opt ip_options Problem is ip_make_skb() calls ip_setup_cork() and ip_setup_cork() possibly makes a copy of ipc->opt (struct ip_options), without any protection against another thread manipulating inet->opt. Another thread can change inet->opt pointer and free old one under us. Use RCU to protect inet->opt (changed to inet->inet_opt). Instead of handling atomic refcounts, just copy ip_options when necessary, to avoid cache line dirtying. We cant insert an rcu_head in struct ip_options since its included in skb->cb[], so this patch is large because I had to introduce a new ip_options_rcu structure. Signed-off-by: Eric Dumazet <[email protected]> Cc: Herbert Xu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
explicit MaxPoolingGradOp(OpKernelConstruction* context) : OpKernel(context) { string data_format; OP_REQUIRES_OK(context, context->GetAttr("data_format", &data_format)); OP_REQUIRES(context, FormatFromString(data_format, &data_format_), errors::InvalidArgument("Invalid data format")); if (context->num_inputs() == 3) { OP_REQUIRES_OK(context, context->GetAttr("ksize", &ksize_)); OP_REQUIRES(context, ksize_.size() == 4, errors::InvalidArgument("Sliding window ksize field must " "specify 4 dimensions")); OP_REQUIRES_OK(context, context->GetAttr("strides", &stride_)); OP_REQUIRES(context, stride_.size() == 4, errors::InvalidArgument("Sliding window strides field must " "specify 4 dimensions")); const int32 ksize_n = GetTensorDim(ksize_, data_format_, 'N'); const int32 stride_n = GetTensorDim(stride_, data_format_, 'N'); OP_REQUIRES(context, ksize_n == 1 && stride_n == 1, errors::Unimplemented( "Pooling is not yet supported on the batch dimension.")); } OP_REQUIRES_OK(context, context->GetAttr("padding", &padding_)); if (padding_ == Padding::EXPLICIT) { OP_REQUIRES_OK( context, context->GetAttr("explicit_paddings", &explicit_paddings_)); OP_REQUIRES_OK(context, CheckValidPadding(padding_, explicit_paddings_, /*num_dims=*/4, data_format_)); } TF_CHECK_OK(ReadBoolFromEnvVar("TF_ENABLE_MAXPOOL_NANPROP", false, &propagate_nans_)); }
0
[ "CWE-125" ]
tensorflow
dcd7867de0fea4b72a2b34bd41eb74548dc23886
314,441,776,110,409,520,000,000,000,000,000,000,000
30
Fix heap buffer overflow PiperOrigin-RevId: 372132844 Change-Id: Idef9895efaf145f2b1c23d31983601ec980cd5e4
static int exif_file_sections_realloc(image_info_type *ImageInfo, int section_index, size_t size) { void *tmp; /* This is not a malloc/realloc check. It is a plausibility check for the * function parameters (requirements engineering). */ if (section_index >= ImageInfo->file.count) { EXIF_ERRLOG_FSREALLOC(ImageInfo) return -1; } tmp = safe_erealloc(ImageInfo->file.list[section_index].data, 1, size, 0); ImageInfo->file.list[section_index].data = tmp; ImageInfo->file.list[section_index].size = size; return 0; }
0
[ "CWE-416" ]
php-src
3fdde65617e9f954e2c964768aac8831005497e5
194,737,685,091,792,100,000,000,000,000,000,000,000
16
Fix #76409: heap use after free in _php_stream_free We must not close the stream in exif_read_from_impl(), since it is the responsibility of the (caller's) caller to do so, if it actually opened the stream. We simplify the reproduce script, which is actually about supplying a path to a directory (opposed to a regular file), and use `.` instead of `/` to also make it work on Windows.
NSC_MESSAGE* nsc_encode_messages(NSC_CONTEXT* context, const BYTE* data, UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT32 scanline, UINT32* numMessages, UINT32 maxDataSize) { UINT32 i, j, k; UINT32 dataOffset; UINT32 rows, cols; UINT32 BytesPerPixel; UINT32 MaxRegionWidth; UINT32 MaxRegionHeight; UINT32 ByteCount[4]; UINT32 MaxPlaneSize; UINT32 MaxMessageSize; NSC_MESSAGE* messages; UINT32 PaddedMaxPlaneSize; k = 0; MaxRegionWidth = 64 * 4; MaxRegionHeight = 64 * 2; BytesPerPixel = GetBytesPerPixel(context->format); rows = (width + (MaxRegionWidth - (width % MaxRegionWidth))) / MaxRegionWidth; cols = (height + (MaxRegionHeight - (height % MaxRegionHeight))) / MaxRegionHeight; *numMessages = rows * cols; MaxPlaneSize = nsc_compute_byte_count(context, (UINT32*) ByteCount, width, height); MaxMessageSize = ByteCount[0] + ByteCount[1] + ByteCount[2] + ByteCount[3] + 20; maxDataSize -= 1024; /* reserve enough space for headers */ messages = (NSC_MESSAGE*) calloc(*numMessages, sizeof(NSC_MESSAGE)); if (!messages) return NULL; for (i = 0; i < rows; i++) { for (j = 0; j < cols; j++) { messages[k].x = x + (i * MaxRegionWidth); messages[k].y = y + (j * MaxRegionHeight); messages[k].width = (i < (rows - 1)) ? MaxRegionWidth : width - (i * MaxRegionWidth); messages[k].height = (j < (cols - 1)) ? MaxRegionHeight : height - (j * MaxRegionHeight); messages[k].data = data; messages[k].scanline = scanline; messages[k].MaxPlaneSize = nsc_compute_byte_count(context, (UINT32*) messages[k].OrgByteCount, messages[k].width, messages[k].height); k++; } } *numMessages = k; for (i = 0; i < *numMessages; i++) { PaddedMaxPlaneSize = messages[i].MaxPlaneSize + 32; messages[i].PlaneBuffer = (BYTE*) BufferPool_Take(context->priv->PlanePool, PaddedMaxPlaneSize * 5); if (!messages[i].PlaneBuffer) goto fail; messages[i].PlaneBuffers[0] = (BYTE*) & (messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 0) + 16]); messages[i].PlaneBuffers[1] = (BYTE*) & (messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 1) + 16]); messages[i].PlaneBuffers[2] = (BYTE*) & (messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 2) + 16]); messages[i].PlaneBuffers[3] = (BYTE*) & (messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 3) + 16]); messages[i].PlaneBuffers[4] = (BYTE*) & (messages[i].PlaneBuffer[(PaddedMaxPlaneSize * 4) + 16]); } for (i = 0; i < *numMessages; i++) { context->width = messages[i].width; context->height = messages[i].height; context->OrgByteCount[0] = messages[i].OrgByteCount[0]; context->OrgByteCount[1] = messages[i].OrgByteCount[1]; context->OrgByteCount[2] = messages[i].OrgByteCount[2]; context->OrgByteCount[3] = messages[i].OrgByteCount[3]; context->priv->PlaneBuffersLength = messages[i].MaxPlaneSize; context->priv->PlaneBuffers[0] = messages[i].PlaneBuffers[0]; context->priv->PlaneBuffers[1] = messages[i].PlaneBuffers[1]; context->priv->PlaneBuffers[2] = messages[i].PlaneBuffers[2]; context->priv->PlaneBuffers[3] = messages[i].PlaneBuffers[3]; context->priv->PlaneBuffers[4] = messages[i].PlaneBuffers[4]; dataOffset = (messages[i].y * messages[i].scanline) + (messages[i].x * BytesPerPixel); PROFILER_ENTER(context->priv->prof_nsc_encode) context->encode(context, &data[dataOffset], scanline); PROFILER_EXIT(context->priv->prof_nsc_encode) PROFILER_ENTER(context->priv->prof_nsc_rle_compress_data) nsc_rle_compress_data(context); PROFILER_EXIT(context->priv->prof_nsc_rle_compress_data) messages[i].LumaPlaneByteCount = context->PlaneByteCount[0]; messages[i].OrangeChromaPlaneByteCount = context->PlaneByteCount[1]; messages[i].GreenChromaPlaneByteCount = context->PlaneByteCount[2]; messages[i].AlphaPlaneByteCount = context->PlaneByteCount[3]; messages[i].ColorLossLevel = context->ColorLossLevel; messages[i].ChromaSubsamplingLevel = context->ChromaSubsamplingLevel; } context->priv->PlaneBuffers[0] = NULL; context->priv->PlaneBuffers[1] = NULL; context->priv->PlaneBuffers[2] = NULL; context->priv->PlaneBuffers[3] = NULL; context->priv->PlaneBuffers[4] = NULL; return messages; fail: for (i = 0; i < *numMessages; i++) BufferPool_Return(context->priv->PlanePool, messages[i].PlaneBuffer); free(messages); return NULL; }
0
[ "CWE-200", "CWE-787" ]
FreeRDP
d1112c279bd1a327e8e4d0b5f371458bf2579659
194,934,541,681,659,650,000,000,000,000,000,000,000
118
Fixed CVE-2018-8788 Thanks to Eyal Itkin from Check Point Software Technologies.
static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa, int attr_len, bool log) { struct sw_flow_actions *acts; int new_acts_size; size_t req_size = NLA_ALIGN(attr_len); int next_offset = offsetof(struct sw_flow_actions, actions) + (*sfa)->actions_len; if (req_size <= (ksize(*sfa) - next_offset)) goto out; new_acts_size = max(next_offset + req_size, ksize(*sfa) * 2); if (new_acts_size > MAX_ACTIONS_BUFSIZE) { if ((next_offset + req_size) > MAX_ACTIONS_BUFSIZE) { OVS_NLERR(log, "Flow action size exceeds max %u", MAX_ACTIONS_BUFSIZE); return ERR_PTR(-EMSGSIZE); } new_acts_size = MAX_ACTIONS_BUFSIZE; } acts = nla_alloc_flow_actions(new_acts_size); if (IS_ERR(acts)) return (void *)acts; memcpy(acts->actions, (*sfa)->actions, (*sfa)->actions_len); acts->actions_len = (*sfa)->actions_len; acts->orig_len = (*sfa)->orig_len; kfree(*sfa); *sfa = acts; out: (*sfa)->actions_len += req_size; return (struct nlattr *) ((unsigned char *)(*sfa) + next_offset); }
0
[ "CWE-362", "CWE-787" ]
linux
cefa91b2332d7009bc0be5d951d6cbbf349f90f8
171,924,850,423,883,400,000,000,000,000,000,000,000
38
openvswitch: fix OOB access in reserve_sfa_size() Given a sufficiently large number of actions, while copying and reserving memory for a new action of a new flow, if next_offset is greater than MAX_ACTIONS_BUFSIZE, the function reserve_sfa_size() does not return -EMSGSIZE as expected, but it allocates MAX_ACTIONS_BUFSIZE bytes increasing actions_len by req_size. This can then lead to an OOB write access, especially when further actions need to be copied. Fix it by rearranging the flow action size check. KASAN splat below: ================================================================== BUG: KASAN: slab-out-of-bounds in reserve_sfa_size+0x1ba/0x380 [openvswitch] Write of size 65360 at addr ffff888147e4001c by task handler15/836 CPU: 1 PID: 836 Comm: handler15 Not tainted 5.18.0-rc1+ #27 ... Call Trace: <TASK> dump_stack_lvl+0x45/0x5a print_report.cold+0x5e/0x5db ? __lock_text_start+0x8/0x8 ? reserve_sfa_size+0x1ba/0x380 [openvswitch] kasan_report+0xb5/0x130 ? reserve_sfa_size+0x1ba/0x380 [openvswitch] kasan_check_range+0xf5/0x1d0 memcpy+0x39/0x60 reserve_sfa_size+0x1ba/0x380 [openvswitch] __add_action+0x24/0x120 [openvswitch] ovs_nla_add_action+0xe/0x20 [openvswitch] ovs_ct_copy_action+0x29d/0x1130 [openvswitch] ? __kernel_text_address+0xe/0x30 ? unwind_get_return_address+0x56/0xa0 ? create_prof_cpu_mask+0x20/0x20 ? ovs_ct_verify+0xf0/0xf0 [openvswitch] ? prep_compound_page+0x198/0x2a0 ? __kasan_check_byte+0x10/0x40 ? kasan_unpoison+0x40/0x70 ? ksize+0x44/0x60 ? reserve_sfa_size+0x75/0x380 [openvswitch] __ovs_nla_copy_actions+0xc26/0x2070 [openvswitch] ? __zone_watermark_ok+0x420/0x420 ? validate_set.constprop.0+0xc90/0xc90 [openvswitch] ? __alloc_pages+0x1a9/0x3e0 ? __alloc_pages_slowpath.constprop.0+0x1da0/0x1da0 ? unwind_next_frame+0x991/0x1e40 ? __mod_node_page_state+0x99/0x120 ? __mod_lruvec_page_state+0x2e3/0x470 ? __kasan_kmalloc_large+0x90/0xe0 ovs_nla_copy_actions+0x1b4/0x2c0 [openvswitch] ovs_flow_cmd_new+0x3cd/0xb10 [openvswitch] ... Cc: [email protected] Fixes: f28cd2af22a0 ("openvswitch: fix flow actions reallocation") Signed-off-by: Paolo Valerio <[email protected]> Acked-by: Eelco Chaudron <[email protected]> Signed-off-by: David S. Miller <[email protected]>
int wolfSSH_SFTP_read(WOLFSSH* ssh) { int maxSz, ret = WS_SUCCESS; WS_SFTP_RECV_STATE* state = NULL; WLOG(WS_LOG_SFTP, "Entering wolfSSH_SFTP_read()"); if (ssh == NULL) return WS_BAD_ARGUMENT; if (ssh->error == WS_WANT_READ || ssh->error == WS_WANT_WRITE) ssh->error = WS_SUCCESS; state = ssh->recvState; if (state == NULL) { state = (WS_SFTP_RECV_STATE*)WMALLOC(sizeof(WS_SFTP_RECV_STATE), ssh->ctx->heap, DYNTYPE_SFTP_STATE); if (state == NULL) { ssh->error = WS_MEMORY_E; return WS_FATAL_ERROR; } WMEMSET(state, 0, sizeof(WS_SFTP_RECV_STATE)); ssh->recvState = state; state->state = STATE_RECV_READ; } switch (state->state) { case STATE_RECV_READ: /* Wait for packet to come in then handle it, maxSz is the size of * packet expected to come. */ ret = SFTP_GetHeader(ssh, (word32*)&state->reqId, &state->type, &state->buffer); if (ret <= 0) { return WS_FATAL_ERROR; } if (wolfSSH_SFTP_buffer_create(ssh, &state->buffer, ret) != WS_SUCCESS) { return WS_MEMORY_E; } ssh->reqId = state->reqId; state->state = STATE_RECV_DO; NO_BREAK; case STATE_RECV_DO: ret = wolfSSH_SFTP_buffer_read(ssh, &state->buffer, state->buffer.sz); if (ret < 0) { if (ssh->error != WS_WANT_READ && ssh->error != WS_WANT_WRITE) wolfSSH_SFTP_ClearState(ssh, STATE_ID_RECV); return ret; } switch (state->type) { case WOLFSSH_FTP_REALPATH: ret = wolfSSH_SFTP_RecvRealPath(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; case WOLFSSH_FTP_RMDIR: ret = wolfSSH_SFTP_RecvRMDIR(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; case WOLFSSH_FTP_MKDIR: ret = wolfSSH_SFTP_RecvMKDIR(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; case WOLFSSH_FTP_STAT: ret = wolfSSH_SFTP_RecvSTAT(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; case WOLFSSH_FTP_LSTAT: ret = wolfSSH_SFTP_RecvLSTAT(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; #ifndef USE_WINDOWS_API case WOLFSSH_FTP_FSTAT: ret = wolfSSH_SFTP_RecvFSTAT(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; #endif case WOLFSSH_FTP_OPEN: ret = wolfSSH_SFTP_RecvOpen(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; case WOLFSSH_FTP_READ: ret = wolfSSH_SFTP_RecvRead(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; case WOLFSSH_FTP_WRITE: ret = wolfSSH_SFTP_RecvWrite(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; case WOLFSSH_FTP_CLOSE: ret = wolfSSH_SFTP_RecvClose(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; case WOLFSSH_FTP_REMOVE: ret = wolfSSH_SFTP_RecvRemove(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; case WOLFSSH_FTP_RENAME: ret = wolfSSH_SFTP_RecvRename(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; #ifndef _WIN32_WCE case WOLFSSH_FTP_SETSTAT: ret = wolfSSH_SFTP_RecvSetSTAT(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; #endif #ifndef NO_WOLFSSH_DIR case WOLFSSH_FTP_OPENDIR: ret = wolfSSH_SFTP_RecvOpenDir(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; case WOLFSSH_FTP_READDIR: ret = wolfSSH_SFTP_RecvReadDir(ssh, state->reqId, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); break; #endif default: WLOG(WS_LOG_SFTP, "Unknown packet type [%d] received", state->type); if (wolfSSH_SFTP_CreateStatus(ssh, WOLFSSH_FTP_FAILURE, state->reqId, "Unknown/Unsupported packet type", "English", NULL, (word32*)&maxSz) != WS_SIZE_ONLY) { wolfSSH_SFTP_ClearState(ssh, STATE_ID_RECV); return WS_FATAL_ERROR; } if (maxSz > (int)wolfSSH_SFTP_buffer_size(&state->buffer)) { if (wolfSSH_SFTP_buffer_create(ssh, &state->buffer, maxSz) != WS_SUCCESS) { wolfSSH_SFTP_ClearState(ssh, STATE_ID_RECV); return WS_FATAL_ERROR; } } maxSz = (int)wolfSSH_SFTP_buffer_size(&state->buffer); ret = wolfSSH_SFTP_CreateStatus(ssh, WOLFSSH_FTP_FAILURE, state->reqId, "Unknown/Unsupported packet type", "English", wolfSSH_SFTP_buffer_data(&state->buffer), (word32*)(&maxSz)); if (ret == WS_SUCCESS) { ret = wolfSSH_SFTP_buffer_set_size(&state->buffer, (word32)maxSz); } if (ret == WS_SUCCESS) { /* set send out buffer, "state->data" is taken by ssh */ wolfSSH_SFTP_RecvSetSend(ssh, wolfSSH_SFTP_buffer_data(&state->buffer), wolfSSH_SFTP_buffer_size(&state->buffer)); } } /* break out if encountering an error with nothing stored to send */ if (ret < 0 && !state->toSend) { if (ssh->error != WS_WANT_READ && ssh->error != WS_WANT_WRITE) wolfSSH_SFTP_ClearState(ssh, STATE_ID_RECV); return ret; } state->buffer.idx = 0; state->state = STATE_RECV_SEND; NO_BREAK; case STATE_RECV_SEND: if (state->toSend) { do { if (state->toSend != 2) { ret = wolfSSH_SFTP_buffer_send(ssh, &state->buffer); if (ret < 0) { if (ssh->error != WS_WANT_READ && ssh->error != WS_WANT_WRITE && ssh->error != WS_REKEYING && ssh->error != WS_WINDOW_FULL) wolfSSH_SFTP_ClearState(ssh, STATE_ID_RECV); return WS_FATAL_ERROR; } } state->toSend = 1; if (wolfSSH_SFTP_buffer_idx(&state->buffer) < wolfSSH_SFTP_buffer_size(&state->buffer)) { ret = wolfSSH_worker(ssh, NULL); if (ret != WS_SUCCESS && ssh->error == WS_WANT_READ) { /* was something there to read, try again */ state->toSend = 2; return WS_FATAL_ERROR; } } } while (wolfSSH_SFTP_buffer_idx(&state->buffer) < wolfSSH_SFTP_buffer_size(&state->buffer)); ret = WS_SUCCESS; state->toSend = 0; } wolfSSH_SFTP_ClearState(ssh, STATE_ID_RECV); return ret; default: WLOG(WS_LOG_SFTP, "Unknown SFTP read state"); wolfSSH_SFTP_ClearState(ssh, STATE_ID_RECV); return WS_FATAL_ERROR; } }
0
[ "CWE-190" ]
wolfssh
edb272e35ee57e7b89f3e127222c6981b6a1e730
150,189,903,248,984,930,000,000,000,000,000,000,000
238
ASAN SFTP Fixes When decoding SFTP messages, fix the size checks so they don't wrap. (ZD12766)
char const * caca_get_dither_charset(caca_dither_t const *d) { return d->glyph_name; }
0
[ "CWE-369" ]
libcaca
84bd155087b93ab2d8d7cb5b1ac94ecd4cf4f93c
240,810,177,009,997,720,000,000,000,000,000,000,000
4
dither: fix integer overflows that were causing a division by zero. Fixes: #36 (CVE-2018-20544)
void KrecipesView::categorizeCurrentRecipe() { QWidget * vis_panel = rightPanel->visiblePanel(); if ( vis_panel == selectPanel ) { selectPanel->getActionsHandler()->categorize(); } else if (vis_panel == inputPanel ) { inputPanel->addCategory(); } }
0
[]
krecipes
cd1490fb5fe82cbe9172a43be13298001b446ecd
312,127,613,497,676,700,000,000,000,000,000,000,000
10
Use WebKit instead of KHTML for printing recipes, fixes sourceforge #2990118 and #2960140. svn path=/trunk/extragear/utils/krecipes/; revision=1137824
SYSCALL_DEFINE2(osf_getitimer, int, which, struct itimerval32 __user *, it) { struct itimerval kit; int error; error = do_getitimer(which, &kit); if (!error && put_it32(it, &kit)) error = -EFAULT; return error; }
0
[ "CWE-703", "CWE-264", "CWE-189" ]
linux
21c5977a836e399fc710ff2c5367845ed5c2527f
147,127,100,263,243,300,000,000,000,000,000,000,000
11
alpha: fix several security issues Fix several security issues in Alpha-specific syscalls. Untested, but mostly trivial. 1. Signedness issue in osf_getdomainname allows copying out-of-bounds kernel memory to userland. 2. Signedness issue in osf_sysinfo allows copying large amounts of kernel memory to userland. 3. Typo (?) in osf_getsysinfo bounds minimum instead of maximum copy size, allowing copying large amounts of kernel memory to userland. 4. Usage of user pointer in osf_wait4 while under KERNEL_DS allows privilege escalation via writing return value of sys_wait4 to kernel memory. Signed-off-by: Dan Rosenberg <[email protected]> Cc: Richard Henderson <[email protected]> Cc: Ivan Kokshaysky <[email protected]> Cc: Matt Turner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
parse_import_options(char *str,unsigned int *options,int noisy) { struct parse_options import_opts[]= { {"import-local-sigs",IMPORT_LOCAL_SIGS,NULL, N_("import signatures that are marked as local-only")}, {"repair-pks-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG,NULL, N_("repair damage from the pks keyserver during import")}, {"fast-import",IMPORT_FAST,NULL, N_("do not update the trustdb after import")}, {"merge-only",IMPORT_MERGE_ONLY,NULL, N_("only accept updates to existing keys")}, {"import-clean",IMPORT_CLEAN,NULL, N_("remove unusable parts from key after import")}, {"import-minimal",IMPORT_MINIMAL|IMPORT_CLEAN,NULL, N_("remove as much as possible from key after import")}, /* Aliases for backward compatibility */ {"allow-local-sigs",IMPORT_LOCAL_SIGS,NULL,NULL}, {"repair-hkp-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG,NULL,NULL}, /* dummy */ {"import-unusable-sigs",0,NULL,NULL}, {"import-clean-sigs",0,NULL,NULL}, {"import-clean-uids",0,NULL,NULL}, {"convert-sk-to-pk",0, NULL,NULL}, /* Not anymore needed due to the new design. */ {NULL,0,NULL,NULL} }; return parse_options(str,options,import_opts,noisy); }
0
[ "CWE-20" ]
gnupg
f0b33b6fb8e0586e9584a7a409dcc31263776a67
259,692,594,442,473,500,000,000,000,000,000,000,000
30
gpg: Import only packets which are allowed in a keyblock. * g10/import.c (valid_keyblock_packet): New. (read_block): Store only valid packets. -- A corrupted key, which for example included a mangled public key encrypted packet, used to corrupt the keyring. This change skips all packets which are not allowed in a keyblock. GnuPG-bug-id: 1455 (cherry-picked from commit f795a0d59e197455f8723c300eebf59e09853efa)
void sctp_transport_update_pmtu(struct sock *sk, struct sctp_transport *t, u32 pmtu) { struct dst_entry *dst; if (unlikely(pmtu < SCTP_DEFAULT_MINSEGMENT)) { pr_warn("%s: Reported pmtu %d too low, using default minimum of %d\n", __func__, pmtu, SCTP_DEFAULT_MINSEGMENT); /* Use default minimum segment size and disable * pmtu discovery on this transport. */ t->pathmtu = SCTP_DEFAULT_MINSEGMENT; } else { t->pathmtu = pmtu; } dst = sctp_transport_dst_check(t); if (!dst) t->af_specific->get_dst(t, &t->saddr, &t->fl, sk); if (dst) { dst->ops->update_pmtu(dst, sk, NULL, pmtu); dst = sctp_transport_dst_check(t); if (!dst) t->af_specific->get_dst(t, &t->saddr, &t->fl, sk); } }
0
[]
linux
196d67593439b03088913227093e374235596e33
28,764,674,618,399,150,000,000,000,000,000,000,000
28
sctp: Add support to per-association statistics via a new SCTP_GET_ASSOC_STATS call The current SCTP stack is lacking a mechanism to have per association statistics. This is an implementation modeled after OpenSolaris' SCTP_GET_ASSOC_STATS. Userspace part will follow on lksctp if/when there is a general ACK on this. V4: - Move ipackets++ before q->immediate.func() for consistency reasons - Move sctp_max_rto() at the end of sctp_transport_update_rto() to avoid returning bogus RTO values - return asoc->rto_min when max_obs_rto value has not changed V3: - Increase ictrlchunks in sctp_assoc_bh_rcv() as well - Move ipackets++ to sctp_inq_push() - return 0 when no rto updates took place since the last call V2: - Implement partial retrieval of stat struct to cope for future expansion - Kill the rtxpackets counter as it cannot be precise anyway - Rename outseqtsns to outofseqtsns to make it clearer that these are out of sequence unexpected TSNs - Move asoc->ipackets++ under a lock to avoid potential miscounts - Fold asoc->opackets++ into the already existing asoc check - Kill unneeded (q->asoc) test when increasing rtxchunks - Do not count octrlchunks if sending failed (SCTP_XMIT_OK != 0) - Don't count SHUTDOWNs as SACKs - Move SCTP_GET_ASSOC_STATS to the private space API - Adjust the len check in sctp_getsockopt_assoc_stats() to allow for future struct growth - Move association statistics in their own struct - Update idupchunks when we send a SACK with dup TSNs - return min_rto in max_rto when RTO has not changed. Also return the transport when max_rto last changed. Signed-off: Michele Baldessari <[email protected]> Acked-by: Vlad Yasevich <[email protected]> Signed-off-by: David S. Miller <[email protected]>
static struct sc_card_driver *sc_get_driver(void) { struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); if (iso_ops == NULL) iso_ops = iso_drv->ops; epass2003_ops = *iso_ops; epass2003_ops.match_card = epass2003_match_card; epass2003_ops.init = epass2003_init; epass2003_ops.finish = epass2003_finish; epass2003_ops.write_binary = NULL; epass2003_ops.write_record = NULL; epass2003_ops.select_file = epass2003_select_file; epass2003_ops.get_response = NULL; epass2003_ops.restore_security_env = epass2003_restore_security_env; epass2003_ops.set_security_env = epass2003_set_security_env; epass2003_ops.decipher = epass2003_decipher; epass2003_ops.compute_signature = epass2003_decipher; epass2003_ops.create_file = epass2003_create_file; epass2003_ops.delete_file = epass2003_delete_file; epass2003_ops.list_files = epass2003_list_files; epass2003_ops.card_ctl = epass2003_card_ctl; epass2003_ops.process_fci = epass2003_process_fci; epass2003_ops.construct_fci = epass2003_construct_fci; epass2003_ops.pin_cmd = epass2003_pin_cmd; epass2003_ops.check_sw = epass2003_check_sw; epass2003_ops.get_challenge = epass2003_get_challenge; return &epass2003_drv; }
0
[ "CWE-415", "CWE-119" ]
OpenSC
360e95d45ac4123255a4c796db96337f332160ad
136,397,504,794,785,830,000,000,000,000,000,000,000
31
fixed out of bounds writes Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting the problems.
perf_event_parse_addr_filter(struct perf_event *event, char *fstr, struct list_head *filters) { struct perf_addr_filter *filter = NULL; char *start, *orig, *filename = NULL; struct path path; substring_t args[MAX_OPT_ARGS]; int state = IF_STATE_ACTION, token; unsigned int kernel = 0; int ret = -EINVAL; orig = fstr = kstrdup(fstr, GFP_KERNEL); if (!fstr) return -ENOMEM; while ((start = strsep(&fstr, " ,\n")) != NULL) { ret = -EINVAL; if (!*start) continue; /* filter definition begins */ if (state == IF_STATE_ACTION) { filter = perf_addr_filter_new(event, filters); if (!filter) goto fail; } token = match_token(start, if_tokens, args); switch (token) { case IF_ACT_FILTER: case IF_ACT_START: filter->filter = 1; case IF_ACT_STOP: if (state != IF_STATE_ACTION) goto fail; state = IF_STATE_SOURCE; break; case IF_SRC_KERNELADDR: case IF_SRC_KERNEL: kernel = 1; case IF_SRC_FILEADDR: case IF_SRC_FILE: if (state != IF_STATE_SOURCE) goto fail; if (token == IF_SRC_FILE || token == IF_SRC_KERNEL) filter->range = 1; *args[0].to = 0; ret = kstrtoul(args[0].from, 0, &filter->offset); if (ret) goto fail; if (filter->range) { *args[1].to = 0; ret = kstrtoul(args[1].from, 0, &filter->size); if (ret) goto fail; } if (token == IF_SRC_FILE || token == IF_SRC_FILEADDR) { int fpos = filter->range ? 2 : 1; filename = match_strdup(&args[fpos]); if (!filename) { ret = -ENOMEM; goto fail; } } state = IF_STATE_END; break; default: goto fail; } /* * Filter definition is fully parsed, validate and install it. * Make sure that it doesn't contradict itself or the event's * attribute. */ if (state == IF_STATE_END) { if (kernel && event->attr.exclude_kernel) goto fail; if (!kernel) { if (!filename) goto fail; /* look up the path and grab its inode */ ret = kern_path(filename, LOOKUP_FOLLOW, &path); if (ret) goto fail_free_name; filter->inode = igrab(d_inode(path.dentry)); path_put(&path); kfree(filename); filename = NULL; ret = -EINVAL; if (!filter->inode || !S_ISREG(filter->inode->i_mode)) /* free_filters_list() will iput() */ goto fail; } /* ready to consume more filters */ state = IF_STATE_ACTION; filter = NULL; } } if (state != IF_STATE_ACTION) goto fail; kfree(orig); return 0; fail_free_name: kfree(filename); fail: free_filters_list(filters); kfree(orig); return ret; }
0
[ "CWE-362", "CWE-125" ]
linux
321027c1fe77f892f4ea07846aeae08cefbbb290
95,218,986,692,665,840,000,000,000,000,000,000,000
133
perf/core: Fix concurrent sys_perf_event_open() vs. 'move_group' race Di Shen reported a race between two concurrent sys_perf_event_open() calls where both try and move the same pre-existing software group into a hardware context. The problem is exactly that described in commit: f63a8daa5812 ("perf: Fix event->ctx locking") ... where, while we wait for a ctx->mutex acquisition, the event->ctx relation can have changed under us. That very same commit failed to recognise sys_perf_event_context() as an external access vector to the events and thereby didn't apply the established locking rules correctly. So while one sys_perf_event_open() call is stuck waiting on mutex_lock_double(), the other (which owns said locks) moves the group about. So by the time the former sys_perf_event_open() acquires the locks, the context we've acquired is stale (and possibly dead). Apply the established locking rules as per perf_event_ctx_lock_nested() to the mutex_lock_double() for the 'move_group' case. This obviously means we need to validate state after we acquire the locks. Reported-by: Di Shen (Keen Lab) Tested-by: John Dias <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kees Cook <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Min Chong <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Fixes: f63a8daa5812 ("perf: Fix event->ctx locking") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags) { return mz_zip_writer_add_mem_ex(pZip, pArchive_name, pBuf, buf_size, NULL, 0, level_and_flags, 0, 0); }
0
[ "CWE-20", "CWE-190" ]
tinyexr
a685e3332f61cd4e59324bf3f669d36973d64270
336,555,532,993,038,930,000,000,000,000,000,000,000
6
Make line_no with too large value(2**20) invalid. Fixes #124
authentic_set_current_files(struct sc_card *card, struct sc_path *path, unsigned char *resp, size_t resplen, struct sc_file **file_out) { struct sc_context *ctx = card->ctx; struct sc_file *file = NULL; int rv; LOG_FUNC_CALLED(ctx); if (resplen) { switch (resp[0]) { case 0x62: case 0x6F: file = sc_file_new(); if (file == NULL) LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY); if (path) file->path = *path; rv = authentic_process_fci(card, file, resp, resplen); LOG_TEST_RET(ctx, rv, "cannot set 'current file': FCI process error"); break; default: LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED); } if (file->type == SC_FILE_TYPE_DF) { struct sc_path cur_df_path; memset(&cur_df_path, 0, sizeof(cur_df_path)); if (card->cache.valid && card->cache.current_df) { cur_df_path = card->cache.current_df->path; sc_file_free(card->cache.current_df); } card->cache.current_df = NULL; sc_file_dup(&card->cache.current_df, file); if (cur_df_path.len) { memcpy(card->cache.current_df->path.value + cur_df_path.len, card->cache.current_df->path.value, card->cache.current_df->path.len); memcpy(card->cache.current_df->path.value, cur_df_path.value, cur_df_path.len); card->cache.current_df->path.len += cur_df_path.len; } sc_file_free(card->cache.current_ef); card->cache.current_ef = NULL; card->cache.valid = 1; } else { sc_file_free(card->cache.current_ef); card->cache.current_ef = NULL; sc_file_dup(&card->cache.current_ef, file); } if (file_out) *file_out = file; else sc_file_free(file); } LOG_FUNC_RETURN(ctx, SC_SUCCESS); }
1
[ "CWE-125" ]
OpenSC
8fe377e93b4b56060e5bbfb6f3142ceaeca744fa
78,410,577,155,919,610,000,000,000,000,000,000,000
64
fixed out of bounds reads Thanks to Eric Sesterhenn from X41 D-SEC GmbH for reporting and suggesting security fixes.
write_ruleset_details(int s) { int proto = 0; unsigned short eport, iport; char desc[64]; char iaddr[32]; char rhost[32]; unsigned int timestamp; u_int64_t packets; u_int64_t bytes; int i = 0; char buffer[256]; int n; write(s, "Ruleset :\n", 10); while(get_redirect_rule_by_index(i, 0/*ifname*/, &eport, iaddr, sizeof(iaddr), &iport, &proto, desc, sizeof(desc), rhost, sizeof(rhost), &timestamp, &packets, &bytes) >= 0) { n = snprintf(buffer, sizeof(buffer), "%2d %s %s:%hu->%s:%hu " "'%s' %u %" PRIu64 " %" PRIu64 "\n", /*"'%s' %llu %llu\n",*/ i, proto_itoa(proto), rhost, eport, iaddr, iport, desc, timestamp, packets, bytes); write(s, buffer, n); i++; } }
0
[ "CWE-476" ]
miniupnp
f321c2066b96d18afa5158dfa2d2873a2957ef38
230,246,772,030,373,260,000,000,000,000,000,000,000
31
upnp_redirect(): accept NULL desc argument
static double mp_gte(_cimg_math_parser& mp) { return (double)(_mp_arg(2)>=_mp_arg(3));
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
218,995,238,826,606,670,000,000,000,000,000,000,000
3
Fix other issues in 'CImg<T>::load_bmp()'.
static const char **get_handler_errmsgs(int nr) { return handler_errmsgs; }
0
[ "CWE-416" ]
server
af810407f78b7f792a9bb8c47c8c532eb3b3a758
246,643,044,436,719,800,000,000,000,000,000,000,000
4
MDEV-28098 incorrect key in "dup value" error after long unique reset errkey after using it, so that it wouldn't affect the next error message in the next statement
static inline int select_idle_smt(struct task_struct *p, int target) { return -1; }
0
[ "CWE-400", "CWE-703" ]
linux
de53fd7aedb100f03e5d2231cfce0e4993282425
296,936,490,862,005,600,000,000,000,000,000,000,000
4
sched/fair: Fix low cpu usage with high throttling by removing expiration of cpu-local slices It has been observed, that highly-threaded, non-cpu-bound applications running under cpu.cfs_quota_us constraints can hit a high percentage of periods throttled while simultaneously not consuming the allocated amount of quota. This use case is typical of user-interactive non-cpu bound applications, such as those running in kubernetes or mesos when run on multiple cpu cores. This has been root caused to cpu-local run queue being allocated per cpu bandwidth slices, and then not fully using that slice within the period. At which point the slice and quota expires. This expiration of unused slice results in applications not being able to utilize the quota for which they are allocated. The non-expiration of per-cpu slices was recently fixed by 'commit 512ac999d275 ("sched/fair: Fix bandwidth timer clock drift condition")'. Prior to that it appears that this had been broken since at least 'commit 51f2176d74ac ("sched/fair: Fix unlocked reads of some cfs_b->quota/period")' which was introduced in v3.16-rc1 in 2014. That added the following conditional which resulted in slices never being expired. if (cfs_rq->runtime_expires != cfs_b->runtime_expires) { /* extend local deadline, drift is bounded above by 2 ticks */ cfs_rq->runtime_expires += TICK_NSEC; Because this was broken for nearly 5 years, and has recently been fixed and is now being noticed by many users running kubernetes (https://github.com/kubernetes/kubernetes/issues/67577) it is my opinion that the mechanisms around expiring runtime should be removed altogether. This allows quota already allocated to per-cpu run-queues to live longer than the period boundary. This allows threads on runqueues that do not use much CPU to continue to use their remaining slice over a longer period of time than cpu.cfs_period_us. However, this helps prevent the above condition of hitting throttling while also not fully utilizing your cpu quota. This theoretically allows a machine to use slightly more than its allotted quota in some periods. This overflow would be bounded by the remaining quota left on each per-cpu runqueueu. This is typically no more than min_cfs_rq_runtime=1ms per cpu. For CPU bound tasks this will change nothing, as they should theoretically fully utilize all of their quota in each period. For user-interactive tasks as described above this provides a much better user/application experience as their cpu utilization will more closely match the amount they requested when they hit throttling. This means that cpu limits no longer strictly apply per period for non-cpu bound applications, but that they are still accurate over longer timeframes. This greatly improves performance of high-thread-count, non-cpu bound applications with low cfs_quota_us allocation on high-core-count machines. In the case of an artificial testcase (10ms/100ms of quota on 80 CPU machine), this commit resulted in almost 30x performance improvement, while still maintaining correct cpu quota restrictions. That testcase is available at https://github.com/indeedeng/fibtest. Fixes: 512ac999d275 ("sched/fair: Fix bandwidth timer clock drift condition") Signed-off-by: Dave Chiluk <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Phil Auld <[email protected]> Reviewed-by: Ben Segall <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: John Hammond <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Kyle Anderson <[email protected]> Cc: Gabriel Munos <[email protected]> Cc: Peter Oskolkov <[email protected]> Cc: Cong Wang <[email protected]> Cc: Brendan Gregg <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
static void do_clip(void) { struct SYMBOL *s, *s2; struct SYSTEM *sy; struct VOICE_S *p_voice; int voice; /* remove the beginning of the tune */ s = tsfirst; if (clip_start.bar > 0 || clip_start.time > 0) { s = go_global_time(s, &clip_start); if (!s) { tsfirst = NULL; return; } /* update the start of voices */ sy = cursys; for (s2 = tsfirst; s2 != s; s2 = s2->ts_next) { if (s->sflags & S_NEW_SY) sy = sy->next; switch (s2->type) { case CLEF: voice_tb[s2->voice].s_clef = s2; break; case KEYSIG: memcpy(&voice_tb[s2->voice].key, &s2->u.key, sizeof voice_tb[0].key); break; case TIMESIG: memcpy(&voice_tb[s2->voice].meter, &s2->u.meter, sizeof voice_tb[0].meter); break; } } cursys = sy; for (p_voice = first_voice; p_voice; p_voice = p_voice->next) { voice = p_voice - voice_tb; for (s2 = s; s2; s2 = s2->ts_next) { if (s2->voice == voice) { s2->prev = NULL; break; } } p_voice->sym = s2; } tsfirst = s; s->ts_prev = NULL; } /* remove the end of the tune */ s = go_global_time(s, &clip_end); if (!s) return; /* keep the current sequence */ do { s = s->ts_next; if (!s) return; } while (!(s->sflags & S_SEQST)); /* cut the voices */ for (p_voice = first_voice; p_voice; p_voice = p_voice->next) { voice = p_voice - voice_tb; for (s2 = s->ts_prev; s2; s2 = s2->ts_prev) { if (s2->voice == voice) { s2->next = NULL; break; } } if (!s2) p_voice->sym = NULL; } s->ts_prev->ts_next = NULL; }
0
[ "CWE-787" ]
abcm2ps
dc0372993674d0b50fedfbf7b9fad1239b8efc5f
57,198,165,715,343,580,000,000,000,000,000,000,000
77
fix: crash when too many accidentals in K: (signature + explicit) Issue #17.
networkstatus_compute_bw_weights_v9(smartlist_t *chunks, int64_t G, int64_t M, int64_t E, int64_t D, int64_t T, int64_t weight_scale) { int64_t Wgg = -1, Wgd = -1; int64_t Wmg = -1, Wme = -1, Wmd = -1; int64_t Wed = -1, Wee = -1; const char *casename; char buf[512]; int r; if (G <= 0 || M <= 0 || E <= 0 || D <= 0) { log_warn(LD_DIR, "Consensus with empty bandwidth: " "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT " D="I64_FORMAT" T="I64_FORMAT, I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E), I64_PRINTF_ARG(D), I64_PRINTF_ARG(T)); return; } /* * Computed from cases in 3.4.3 of dir-spec.txt * * 1. Neither are scarce * 2. Both Guard and Exit are scarce * a. R+D <= S * b. R+D > S * 3. One of Guard or Exit is scarce * a. S+D < T/3 * b. S+D >= T/3 */ if (3*E >= T && 3*G >= T) { // E >= T/3 && G >= T/3 bw_weights_error_t berr = 0; /* Case 1: Neither are scarce. * * Attempt to ensure that we have a large amount of exit bandwidth * in the middle position. */ casename = "Case 1 (Wme*E = Wmd*D)"; Wgg = (weight_scale*(D+E+G+M))/(3*G); if (D==0) Wmd = 0; else Wmd = (weight_scale*(2*D + 2*E - G - M))/(6*D); Wme = (weight_scale*(2*D + 2*E - G - M))/(6*E); Wee = (weight_scale*(-2*D + 4*E + G + M))/(6*E); Wgd = 0; Wmg = weight_scale - Wgg; Wed = weight_scale - Wmd; berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed, weight_scale, G, M, E, D, T, 10, 1); if (berr) { log_warn(LD_DIR, "Bw Weights error %d for case %s. " "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT " D="I64_FORMAT" T="I64_FORMAT, berr, casename, I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E), I64_PRINTF_ARG(D), I64_PRINTF_ARG(T)); } } else if (3*E < T && 3*G < T) { // E < T/3 && G < T/3 int64_t R = MIN(E, G); int64_t S = MAX(E, G); /* * Case 2: Both Guards and Exits are scarce * Balance D between E and G, depending upon * D capacity and scarcity. */ if (R+D < S) { // Subcase a Wgg = weight_scale; Wee = weight_scale; Wmg = 0; Wme = 0; Wmd = 0; if (E < G) { casename = "Case 2a (E scarce)"; Wed = weight_scale; Wgd = 0; } else { /* E >= G */ casename = "Case 2a (G scarce)"; Wed = 0; Wgd = weight_scale; } } else { // Subcase b: R+D > S bw_weights_error_t berr = 0; casename = "Case 2b (Wme*E == Wmd*D)"; if (D != 0) { Wgg = weight_scale; Wgd = (weight_scale*(D + E - 2*G + M))/(3*D); // T/3 >= G (Ok) Wmd = (weight_scale*(D + E + G - 2*M))/(6*D); // T/3 >= M Wme = (weight_scale*(D + E + G - 2*M))/(6*E); Wee = (weight_scale*(-D + 5*E - G + 2*M))/(6*E); // 2E+M >= T/3 Wmg = 0; Wed = weight_scale - Wgd - Wmd; berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed, weight_scale, G, M, E, D, T, 10, 1); } if (D == 0 || berr) { // Can happen if M > T/3 casename = "Case 2b (E=G)"; Wgg = weight_scale; Wee = weight_scale; Wmg = 0; Wme = 0; Wmd = 0; if (D == 0) Wgd = 0; else Wgd = (weight_scale*(D+E-G))/(2*D); Wed = weight_scale - Wgd; berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed, weight_scale, G, M, E, D, T, 10, 1); } if (berr != BW_WEIGHTS_NO_ERROR && berr != BW_WEIGHTS_BALANCE_MID_ERROR) { log_warn(LD_DIR, "Bw Weights error %d for case %s. " "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT " D="I64_FORMAT" T="I64_FORMAT, berr, casename, I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E), I64_PRINTF_ARG(D), I64_PRINTF_ARG(T)); } } } else { // if (E < T/3 || G < T/3) { int64_t S = MIN(E, G); // Case 3: Exactly one of Guard or Exit is scarce if (!(3*E < T || 3*G < T) || !(3*G >= T || 3*E >= T)) { log_warn(LD_BUG, "Bw-Weights Case 3 but with G="I64_FORMAT" M=" I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT" T="I64_FORMAT, I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E), I64_PRINTF_ARG(D), I64_PRINTF_ARG(T)); } if (3*(S+D) < T) { // Subcase a: S+D < T/3 if (G < E) { casename = "Case 3a (G scarce)"; Wgg = Wgd = weight_scale; Wmd = Wed = Wmg = 0; // Minor subcase, if E is more scarce than M, // keep its bandwidth in place. if (E < M) Wme = 0; else Wme = (weight_scale*(E-M))/(2*E); Wee = weight_scale-Wme; } else { // G >= E casename = "Case 3a (E scarce)"; Wee = Wed = weight_scale; Wmd = Wgd = Wme = 0; // Minor subcase, if G is more scarce than M, // keep its bandwidth in place. if (G < M) Wmg = 0; else Wmg = (weight_scale*(G-M))/(2*G); Wgg = weight_scale-Wmg; } } else { // Subcase b: S+D >= T/3 bw_weights_error_t berr = 0; // D != 0 because S+D >= T/3 if (G < E) { casename = "Case 3b (G scarce, Wme*E == Wmd*D)"; Wgd = (weight_scale*(D + E - 2*G + M))/(3*D); Wmd = (weight_scale*(D + E + G - 2*M))/(6*D); Wme = (weight_scale*(D + E + G - 2*M))/(6*E); Wee = (weight_scale*(-D + 5*E - G + 2*M))/(6*E); Wgg = weight_scale; Wmg = 0; Wed = weight_scale - Wgd - Wmd; berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed, weight_scale, G, M, E, D, T, 10, 1); } else { // G >= E casename = "Case 3b (E scarce, Wme*E == Wmd*D)"; Wgg = (weight_scale*(D + E + G + M))/(3*G); Wmd = (weight_scale*(2*D + 2*E - G - M))/(6*D); Wme = (weight_scale*(2*D + 2*E - G - M))/(6*E); Wee = (weight_scale*(-2*D + 4*E + G + M))/(6*E); Wgd = 0; Wmg = weight_scale - Wgg; Wed = weight_scale - Wmd; berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed, weight_scale, G, M, E, D, T, 10, 1); } if (berr) { log_warn(LD_DIR, "Bw Weights error %d for case %s. " "G="I64_FORMAT" M="I64_FORMAT " E="I64_FORMAT" D="I64_FORMAT" T="I64_FORMAT, berr, casename, I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E), I64_PRINTF_ARG(D), I64_PRINTF_ARG(T)); } } } /* We cast down the weights to 32 bit ints on the assumption that * weight_scale is ~= 10000. We need to ensure a rogue authority * doesn't break this assumption to rig our weights */ tor_assert(0 < weight_scale && weight_scale < INT32_MAX); if (Wgg < 0 || Wgg > weight_scale) { log_warn(LD_DIR, "Bw %s: Wgg="I64_FORMAT"! G="I64_FORMAT " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT " T="I64_FORMAT, casename, I64_PRINTF_ARG(Wgg), I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E), I64_PRINTF_ARG(D), I64_PRINTF_ARG(T)); Wgg = MAX(MIN(Wgg, weight_scale), 0); } if (Wgd < 0 || Wgd > weight_scale) { log_warn(LD_DIR, "Bw %s: Wgd="I64_FORMAT"! G="I64_FORMAT " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT " T="I64_FORMAT, casename, I64_PRINTF_ARG(Wgd), I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E), I64_PRINTF_ARG(D), I64_PRINTF_ARG(T)); Wgd = MAX(MIN(Wgd, weight_scale), 0); } if (Wmg < 0 || Wmg > weight_scale) { log_warn(LD_DIR, "Bw %s: Wmg="I64_FORMAT"! G="I64_FORMAT " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT " T="I64_FORMAT, casename, I64_PRINTF_ARG(Wmg), I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E), I64_PRINTF_ARG(D), I64_PRINTF_ARG(T)); Wmg = MAX(MIN(Wmg, weight_scale), 0); } if (Wme < 0 || Wme > weight_scale) { log_warn(LD_DIR, "Bw %s: Wme="I64_FORMAT"! G="I64_FORMAT " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT " T="I64_FORMAT, casename, I64_PRINTF_ARG(Wme), I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E), I64_PRINTF_ARG(D), I64_PRINTF_ARG(T)); Wme = MAX(MIN(Wme, weight_scale), 0); } if (Wmd < 0 || Wmd > weight_scale) { log_warn(LD_DIR, "Bw %s: Wmd="I64_FORMAT"! G="I64_FORMAT " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT " T="I64_FORMAT, casename, I64_PRINTF_ARG(Wmd), I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E), I64_PRINTF_ARG(D), I64_PRINTF_ARG(T)); Wmd = MAX(MIN(Wmd, weight_scale), 0); } if (Wee < 0 || Wee > weight_scale) { log_warn(LD_DIR, "Bw %s: Wee="I64_FORMAT"! G="I64_FORMAT " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT " T="I64_FORMAT, casename, I64_PRINTF_ARG(Wee), I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E), I64_PRINTF_ARG(D), I64_PRINTF_ARG(T)); Wee = MAX(MIN(Wee, weight_scale), 0); } if (Wed < 0 || Wed > weight_scale) { log_warn(LD_DIR, "Bw %s: Wed="I64_FORMAT"! G="I64_FORMAT " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT " T="I64_FORMAT, casename, I64_PRINTF_ARG(Wed), I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E), I64_PRINTF_ARG(D), I64_PRINTF_ARG(T)); Wed = MAX(MIN(Wed, weight_scale), 0); } // Add consensus weight keywords smartlist_add(chunks, tor_strdup("bandwidth-weights ")); /* * Provide Wgm=Wgg, Wmm=1, Wem=Wee, Weg=Wed. May later determine * that middle nodes need different bandwidth weights for dirport traffic, * or that weird exit policies need special weight, or that bridges * need special weight. * * NOTE: This list is sorted. */ r = tor_snprintf(buf, sizeof(buf), "Wbd=%d Wbe=%d Wbg=%d Wbm=%d " "Wdb=%d " "Web=%d Wed=%d Wee=%d Weg=%d Wem=%d " "Wgb=%d Wgd=%d Wgg=%d Wgm=%d " "Wmb=%d Wmd=%d Wme=%d Wmg=%d Wmm=%d\n", (int)Wmd, (int)Wme, (int)Wmg, (int)weight_scale, (int)weight_scale, (int)weight_scale, (int)Wed, (int)Wee, (int)Wed, (int)Wee, (int)weight_scale, (int)Wgd, (int)Wgg, (int)Wgg, (int)weight_scale, (int)Wmd, (int)Wme, (int)Wmg, (int)weight_scale); if (r<0) { log_warn(LD_BUG, "Not enough space in buffer for bandwidth-weights line."); *buf = '\0'; } smartlist_add(chunks, tor_strdup(buf)); log_notice(LD_CIRC, "Computed bandwidth weights for %s with v9: " "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT " T="I64_FORMAT, casename, I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E), I64_PRINTF_ARG(D), I64_PRINTF_ARG(T)); }
0
[]
tor
973c18bf0e84d14d8006a9ae97fde7f7fb97e404
118,000,785,672,084,840,000,000,000,000,000,000,000
295
Fix assertion failure in tor_timegm. Fixes bug 6811.
static int channel_wait_eof(LIBSSH2_CHANNEL *channel) { LIBSSH2_SESSION *session = channel->session; int rc; if(channel->wait_eof_state == libssh2_NB_state_idle) { _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Awaiting EOF for channel %lu/%lu", channel->local.id, channel->remote.id); channel->wait_eof_state = libssh2_NB_state_created; } /* * While channel is not eof, read more packets from the network. * Either the EOF will be set or network timeout will occur. */ do { if(channel->remote.eof) { break; } if((channel->remote.window_size == channel->read_avail) && session->api_block_mode) return _libssh2_error(session, LIBSSH2_ERROR_CHANNEL_WINDOW_FULL, "Receiving channel window has been exhausted"); rc = _libssh2_transport_read(session); if(rc == LIBSSH2_ERROR_EAGAIN) { return rc; } else if(rc < 0) { channel->wait_eof_state = libssh2_NB_state_idle; return _libssh2_error(session, rc, "_libssh2_transport_read() bailed out!"); } } while(1); channel->wait_eof_state = libssh2_NB_state_idle; return 0; }
0
[ "CWE-787" ]
libssh2
dc109a7f518757741590bb993c0c8412928ccec2
6,757,862,307,331,965,000,000,000,000,000,000,000
42
Security fixes (#315) * Bounds checks Fixes for CVEs https://www.libssh2.org/CVE-2019-3863.html https://www.libssh2.org/CVE-2019-3856.html * Packet length bounds check CVE https://www.libssh2.org/CVE-2019-3855.html * Response length check CVE https://www.libssh2.org/CVE-2019-3859.html * Bounds check CVE https://www.libssh2.org/CVE-2019-3857.html * Bounds checking CVE https://www.libssh2.org/CVE-2019-3859.html and additional data validation * Check bounds before reading into buffers * Bounds checking CVE https://www.libssh2.org/CVE-2019-3859.html * declare SIZE_MAX and UINT_MAX if needed
const std::string& name() const override { return name_; }
0
[ "CWE-400" ]
envoy
dfddb529e914d794ac552e906b13d71233609bf7
213,085,046,386,306,330,000,000,000,000,000,000,000
1
listener: Add configurable accepted connection limits (#153) Add support for per-listener limits on accepted connections. Signed-off-by: Tony Allen <[email protected]>