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 CSteamNetworkListenSocketDirectUDP::SendMsg( uint8 nMsgID, const google::protobuf::MessageLite &msg, const netadr_t &adrTo ) { if ( !m_pSock ) { Assert( false ); return; } uint8 pkt[ k_cbSteamNetworkingSocketsMaxUDPMsgLen ]; pkt[0] = nMsgID; int cbPkt = ProtoMsgByteSize( msg )+1; if ( cbPkt > sizeof(pkt) ) { AssertMsg3( false, "Msg type %d is %d bytes, larger than MTU of %d bytes", int( nMsgID ), int( cbPkt ), (int)sizeof(pkt) ); return; } uint8 *pEnd = msg.SerializeWithCachedSizesToArray( pkt+1 ); Assert( cbPkt == pEnd - pkt ); // Send the reply m_pSock->BSendRawPacket( pkt, cbPkt, adrTo ); }
0
[ "CWE-703" ]
GameNetworkingSockets
d944a10808891d202bb1d5e1998de6e0423af678
56,442,304,845,885,990,000,000,000,000,000,000,000
22
Tweak pointer math to avoid possible integer overflow
nautilus_find_file_insensitive (GFile *parent, const gchar *name) { gchar **split_path; gchar *component; GFile *file, *next; gint i; split_path = g_strsplit (name, G_DIR_SEPARATOR_S, -1); file = g_object_ref (parent); for (i = 0; (component = split_path[i]) != NULL; i++) { if (!(next = nautilus_find_file_insensitive_next (file, component))) { /* File does not exist */ g_object_unref (file); file = NULL; break; } g_object_unref (file); file = next; } g_strfreev (split_path); if (file) { return file; } return g_file_get_child (parent, name); }
0
[]
nautilus
a0f7bb5f2e9af8ecb463b13da834fa8559b0a481
281,445,382,944,275,900,000,000,000,000,000,000,000
29
Use $XDG_DATA_HOME/.converted-launchers as marker for one-time desktop 2009-02-25 Alexander Larsson <[email protected]> * src/nautilus-application.c: Use $XDG_DATA_HOME/.converted-launchers as marker for one-time desktop file trust operation. * libnautilus-private/nautilus-file-utilities.[ch]: Add nautilus_is_in_system_dir() to check if path is in XDG_DATA_DIR or in ~/.gnome2. * libnautilus-private/nautilus-directory-async.c: (is_link_trusted): Use new nautilus_is_in_system_dir() instead of open coding it. * libnautilus-private/nautilus-file-operations.c: When copying a desktop file from a trusted location to the desktop, mark it as trusted. svn path=/trunk/; revision=15018
inline bool abs(const bool a) { return a; }
0
[ "CWE-770" ]
cimg
619cb58dd90b4e03ac68286c70ed98acbefd1c90
248,381,506,204,814,640,000,000,000,000,000,000,000
3
CImg<>::load_bmp() and CImg<>::load_pandore(): Check that dimensions encoded in file does not exceed file size.
close_all_tables_for_name(THD *thd, TABLE_SHARE *share, ha_extra_function extra, TABLE *skip_table) { DBUG_ASSERT(!share->tmp_table); char key[MAX_DBKEY_LENGTH]; uint key_length= share->table_cache_key.length; const char *db= key; const char *table_name= db + share->db.length + 1; bool remove_from_locked_tables= extra != HA_EXTRA_NOT_USED; memcpy(key, share->table_cache_key.str, key_length); for (TABLE **prev= &thd->open_tables; *prev; ) { TABLE *table= *prev; if (table->s->table_cache_key.length == key_length && !memcmp(table->s->table_cache_key.str, key, key_length) && table != skip_table) { thd->locked_tables_list.unlink_from_list(thd, table->pos_in_locked_tables, remove_from_locked_tables); /* Inform handler that there is a drop table or a rename going on */ if (extra != HA_EXTRA_NOT_USED && table->db_stat) { table->file->extra(extra); extra= HA_EXTRA_NOT_USED; // Call extra once! } /* Does nothing if the table is not locked. This allows one to use this function after a table has been unlocked, e.g. in partition management. */ mysql_lock_remove(thd, thd->lock, table); close_thread_table(thd, prev); } else { /* Step to next entry in open_tables list. */ prev= &table->next; } } if (skip_table == NULL) { /* Remove the table share from the cache. */ tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db, table_name, FALSE); } }
0
[]
server
0168d1eda30dad4b517659422e347175eb89e923
223,472,250,899,209,460,000,000,000,000,000,000,000
53
MDEV-25766 Unused CTE lead to a crash in find_field_in_tables/find_order_in_list Do not assume that subquery Item always present.
static void setup_wait_parent_capabilities(void) { capng_setpid(syscall(SYS_gettid)); capng_clear(CAPNG_SELECT_BOTH); capng_apply(CAPNG_SELECT_BOTH); }
0
[]
qemu
6084633dff3a05d63176e06d7012c7e15aba15be
107,094,427,662,703,060,000,000,000,000,000,000,000
6
tools/virtiofsd: xattr name mappings: Add option Add an option to define mappings of xattr names so that the client and server filesystems see different views. This can be used to have different SELinux mappings as seen by the guest, to run the virtiofsd with less privileges (e.g. in a case where it can't set trusted/system/security xattrs but you want the guest to be able to), or to isolate multiple users of the same name; e.g. trusted attributes used by stacking overlayfs. A mapping engine is used with 3 simple rules; the rules can be combined to allow most useful mapping scenarios. The ruleset is defined by -o xattrmap='rules...'. This patch doesn't use the rule maps yet. Signed-off-by: Dr. David Alan Gilbert <[email protected]> Message-Id: <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]> Signed-off-by: Dr. David Alan Gilbert <[email protected]>
bool ValidateBoxes(const TfLiteTensor* decoded_boxes, const int num_boxes) { for (int i = 0; i < num_boxes; ++i) { // ymax>=ymin, xmax>=xmin auto& box = ReInterpretTensor<const BoxCornerEncoding*>(decoded_boxes)[i]; if (box.ymin >= box.ymax || box.xmin >= box.xmax) { return false; } } return true; }
0
[ "CWE-125", "CWE-787" ]
tensorflow
1970c2158b1ffa416d159d03c3370b9a462aee35
154,726,884,412,349,650,000,000,000,000,000,000,000
10
[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
load_put(UnpicklerObject *self) { PyObject *key, *value; Py_ssize_t idx; Py_ssize_t len; char *s = NULL; if ((len = _Unpickler_Readline(self, &s)) < 0) return -1; if (len < 2) return bad_readline(); if (Py_SIZE(self->stack) <= self->stack->fence) return Pdata_stack_underflow(self->stack); value = self->stack->data[Py_SIZE(self->stack) - 1]; key = PyLong_FromString(s, NULL, 10); if (key == NULL) return -1; idx = PyLong_AsSsize_t(key); Py_DECREF(key); if (idx < 0) { if (!PyErr_Occurred()) PyErr_SetString(PyExc_ValueError, "negative PUT argument"); return -1; } return _Unpickler_MemoPut(self, idx, value); }
0
[ "CWE-190", "CWE-369" ]
cpython
a4ae828ee416a66d8c7bf5ee71d653c2cc6a26dd
187,697,193,606,510,430,000,000,000,000,000,000,000
29
closes bpo-34656: Avoid relying on signed overflow in _pickle memos. (GH-9261)
xsltLREInfoCreate(xsltCompilerCtxtPtr cctxt, xmlNodePtr elem, int isLRE) { xsltStyleItemLRElementInfoPtr item; if ((cctxt == NULL) || (cctxt->inode == NULL)) return(-1); item = (xsltStyleItemLRElementInfoPtr) xmlMalloc(sizeof(xsltStyleItemLRElementInfo)); if (item == NULL) { xsltTransformError(NULL, cctxt->style, NULL, "Internal error in xsltLREInfoCreate(): " "memory allocation failed.\n"); cctxt->style->errors++; return(-1); } memset(item, 0, sizeof(xsltStyleItemLRElementInfo)); item->type = XSLT_FUNC_LITERAL_RESULT_ELEMENT; /* * Store it in the stylesheet. */ item->next = cctxt->style->preComps; cctxt->style->preComps = (xsltElemPreCompPtr) item; /* * @inScopeNs are used for execution of XPath expressions * in AVTs. */ item->inScopeNs = cctxt->inode->inScopeNs; if (elem) xsltLREBuildEffectiveNsNodes(cctxt, item, elem, isLRE); cctxt->inode->litResElemInfo = item; cctxt->inode->nsChanged = 0; cctxt->maxLREs++; return(0); }
0
[]
libxslt
e03553605b45c88f0b4b2980adfbbb8f6fca2fd6
274,443,633,775,641,900,000,000,000,000,000,000,000
39
Fix security framework bypass xsltCheckRead and xsltCheckWrite return -1 in case of error but callers don't check for this condition and allow access. With a specially crafted URL, xsltCheckRead could be tricked into returning an error because of a supposedly invalid URL that would still be loaded succesfully later on. Fixes #12. Thanks to Felix Wilhelm for the report.
res1 = cimg::eval("cos(x)^2 + sin(y)^2",2,2), // will return '1'. res2 = cimg::eval(0,1,1); // will return '1' too. \endcode **/
0
[ "CWE-125" ]
CImg
10af1e8c1ad2a58a0a3342a856bae63e8f257abb
89,474,405,585,371,070,000,000,000,000,000,000,000
4
Fix other issues in 'CImg<T>::load_bmp()'.
asmlinkage long sys32_sigreturn(struct pt_regs *regs) { struct sigframe __user *frame = (struct sigframe __user *)(regs->sp-8); sigset_t set; unsigned int ax; if (!access_ok(VERIFY_READ, frame, sizeof(*frame))) goto badframe; if (__get_user(set.sig[0], &frame->sc.oldmask) || (_COMPAT_NSIG_WORDS > 1 && __copy_from_user((((char *) &set.sig) + 4), &frame->extramask, sizeof(frame->extramask)))) goto badframe; sigdelsetmask(&set, ~_BLOCKABLE); spin_lock_irq(&current->sighand->siglock); current->blocked = set; recalc_sigpending(); spin_unlock_irq(&current->sighand->siglock); if (ia32_restore_sigcontext(regs, &frame->sc, &ax)) goto badframe; return ax; badframe: signal_fault(regs, frame, "32bit sigreturn"); return 0; }
0
[ "CWE-399" ]
linux-2.6
e40cd10ccff3d9fbffd57b93780bee4b7b9bff51
240,150,414,475,018,300,000,000,000,000,000,000,000
29
x86: clear DF before calling signal handler The Linux kernel currently does not clear the direction flag before calling a signal handler, whereas the x86/x86-64 ABI requires that. Linux had this behavior/bug forever, but this becomes a real problem with gcc version 4.3, which assumes that the direction flag is correctly cleared at the entry of a function. This patches changes the setup_frame() functions to clear the direction before entering the signal handler. Signed-off-by: Aurelien Jarno <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: H. Peter Anvin <[email protected]>
send_agree_unix_fd (DBusAuth *auth) { _dbus_assert(auth->unix_fd_possible); auth->unix_fd_negotiated = TRUE; _dbus_verbose("Agreed to UNIX FD passing\n"); if (!_dbus_string_append (&auth->outgoing, "AGREE_UNIX_FD\r\n")) return FALSE; goto_state (auth, &server_state_waiting_for_begin); return TRUE; }
0
[ "CWE-59" ]
dbus
47b1a4c41004bf494b87370987b222c934b19016
41,244,741,600,673,354,000,000,000,000,000,000,000
14
auth: Reject DBUS_COOKIE_SHA1 for users other than the server owner The DBUS_COOKIE_SHA1 authentication mechanism aims to prove ownership of a shared home directory by having the server write a secret "cookie" into a .dbus-keyrings subdirectory of the desired identity's home directory with 0700 permissions, and having the client prove that it can read the cookie. This never actually worked for non-malicious clients in the case where server uid != client uid (unless the server and client both have privileges, such as Linux CAP_DAC_OVERRIDE or traditional Unix uid 0) because an unprivileged server would fail to write out the cookie, and an unprivileged client would be unable to read the resulting file owned by the server. Additionally, since dbus 1.7.10 we have checked that ~/.dbus-keyrings is owned by the uid of the server (a side-effect of a check added to harden our use of XDG_RUNTIME_DIR), further ruling out successful use by a non-malicious client with a uid differing from the server's. Joe Vennix of Apple Information Security discovered that the implementation of DBUS_COOKIE_SHA1 was susceptible to a symbolic link attack: a malicious client with write access to its own home directory could manipulate a ~/.dbus-keyrings symlink to cause the DBusServer to read and write in unintended locations. In the worst case this could result in the DBusServer reusing a cookie that is known to the malicious client, and treating that cookie as evidence that a subsequent client connection came from an attacker-chosen uid, allowing authentication bypass. This is mitigated by the fact that by default, the well-known system dbus-daemon (since 2003) and the well-known session dbus-daemon (in stable releases since dbus 1.10.0 in 2015) only accept the EXTERNAL authentication mechanism, and as a result will reject DBUS_COOKIE_SHA1 at an early stage, before manipulating cookies. As a result, this vulnerability only applies to: * system or session dbus-daemons with non-standard configuration * third-party dbus-daemon invocations such as at-spi2-core (although in practice at-spi2-core also only accepts EXTERNAL by default) * third-party uses of DBusServer such as the one in Upstart Avoiding symlink attacks in a portable way is difficult, because APIs like openat() and Linux /proc/self/fd are not universally available. However, because DBUS_COOKIE_SHA1 already doesn't work in practice for a non-matching uid, we can solve this vulnerability in an easier way without regressions, by rejecting it early (before looking at ~/.dbus-keyrings) whenever the requested identity doesn't match the identity of the process hosting the DBusServer. Signed-off-by: Simon McVittie <[email protected]> Closes: https://gitlab.freedesktop.org/dbus/dbus/issues/269 Closes: CVE-2019-12749
int kprobe_int3_handler(struct pt_regs *regs) { kprobe_opcode_t *addr; struct kprobe *p; struct kprobe_ctlblk *kcb; if (user_mode(regs)) return 0; addr = (kprobe_opcode_t *)(regs->ip - sizeof(kprobe_opcode_t)); /* * We don't want to be preempted for the entire * duration of kprobe processing. We conditionally * re-enable preemption at the end of this function, * and also in reenter_kprobe() and setup_singlestep(). */ preempt_disable(); kcb = get_kprobe_ctlblk(); p = get_kprobe(addr); if (p) { if (kprobe_running()) { if (reenter_kprobe(p, regs, kcb)) return 1; } else { set_current_kprobe(p, regs, kcb); kcb->kprobe_status = KPROBE_HIT_ACTIVE; /* * If we have no pre-handler or it returned 0, we * continue with normal processing. If we have a * pre-handler and it returned non-zero, it prepped * for calling the break_handler below on re-entry * for jprobe processing, so get out doing nothing * more here. */ if (!p->pre_handler || !p->pre_handler(p, regs)) setup_singlestep(p, regs, kcb, 0); return 1; } } else if (*addr != BREAKPOINT_INSTRUCTION) { /* * The breakpoint instruction was removed right * after we hit it. Another cpu has removed * either a probepoint or a debugger breakpoint * at this address. In either case, no further * handling of this interrupt is appropriate. * Back up over the (now missing) int3 and run * the original instruction. */ regs->ip = (unsigned long)addr; preempt_enable_no_resched(); return 1; } else if (kprobe_running()) { p = __this_cpu_read(current_kprobe); if (p->break_handler && p->break_handler(p, regs)) { if (!skip_singlestep(p, regs, kcb)) setup_singlestep(p, regs, kcb, 0); return 1; } } /* else: not a kprobe fault; let the kernel handle it */ preempt_enable_no_resched(); return 0; }
0
[ "CWE-264" ]
linux
548acf19234dbda5a52d5a8e7e205af46e9da840
69,426,317,640,498,660,000,000,000,000,000,000,000
66
x86/mm: Expand the exception table logic to allow new handling options Huge amounts of help from Andy Lutomirski and Borislav Petkov to produce this. Andy provided the inspiration to add classes to the exception table with a clever bit-squeezing trick, Boris pointed out how much cleaner it would all be if we just had a new field. Linus Torvalds blessed the expansion with: ' I'd rather not be clever in order to save just a tiny amount of space in the exception table, which isn't really criticial for anybody. ' The third field is another relative function pointer, this one to a handler that executes the actions. We start out with three handlers: 1: Legacy - just jumps the to fixup IP 2: Fault - provide the trap number in %ax to the fixup code 3: Cleaned up legacy for the uaccess error hack Signed-off-by: Tony Luck <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/f6af78fcbd348cf4939875cfda9c19689b5e50b8.1455732970.git.tony.luck@intel.com Signed-off-by: Ingo Molnar <[email protected]>
ldns_bget_keyword_data(ldns_buffer *b, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit) { /* we assume: keyword|sep|data */ char *fkeyword; ssize_t i; if(strlen(keyword) >= LDNS_MAX_KEYWORDLEN) return -1; fkeyword = LDNS_XMALLOC(char, LDNS_MAX_KEYWORDLEN); if(!fkeyword) return -1; /* out of memory */ i = ldns_bget_token(b, fkeyword, k_del, data_limit); if(i==0 || i==-1) { LDNS_FREE(fkeyword); return -1; /* nothing read */ } /* case??? */ if (strncmp(fkeyword, keyword, strlen(keyword)) == 0) { LDNS_FREE(fkeyword); /* whee, the match! */ /* retrieve it's data */ i = ldns_bget_token(b, data, d_del, 0); return i; } else { LDNS_FREE(fkeyword); return -1; } }
0
[]
ldns
c8391790c96d4c8a2c10f9ab1460fda83b509fc2
313,786,729,964,036,500,000,000,000,000,000,000,000
31
Check parse limit before t increment Thanks Stephan Zeisberg
Status RoleGraph::getBSONForRole(RoleGraph* graph, const RoleName& roleName, mutablebson::Element result) try { if (!graph->roleExists(roleName)) { return Status(ErrorCodes::RoleNotFound, mongoutils::str::stream() << roleName.getFullName() << "does not name an existing role"); } std::string id = mongoutils::str::stream() << roleName.getDB() << "." << roleName.getRole(); uassertStatusOK(result.appendString("_id", id)); uassertStatusOK( result.appendString(AuthorizationManager::ROLE_NAME_FIELD_NAME, roleName.getRole())); uassertStatusOK( result.appendString(AuthorizationManager::ROLE_DB_FIELD_NAME, roleName.getDB())); // Build privileges array mutablebson::Element privilegesArrayElement = result.getDocument().makeElementArray("privileges"); uassertStatusOK(result.pushBack(privilegesArrayElement)); const PrivilegeVector& privileges = graph->getDirectPrivileges(roleName); uassertStatusOK(Privilege::getBSONForPrivileges(privileges, privilegesArrayElement)); // Build roles array mutablebson::Element rolesArrayElement = result.getDocument().makeElementArray("roles"); uassertStatusOK(result.pushBack(rolesArrayElement)); for (RoleNameIterator roles = graph->getDirectSubordinates(roleName); roles.more(); roles.next()) { const RoleName& subRole = roles.get(); mutablebson::Element roleObj = result.getDocument().makeElementObject(""); uassertStatusOK( roleObj.appendString(AuthorizationManager::ROLE_NAME_FIELD_NAME, subRole.getRole())); uassertStatusOK( roleObj.appendString(AuthorizationManager::ROLE_DB_FIELD_NAME, subRole.getDB())); uassertStatusOK(rolesArrayElement.pushBack(roleObj)); } // Build authentication restrictions auto restrictions = graph->getDirectAuthenticationRestrictions(roleName); mutablebson::Element authenticationRestrictionsElement = result.getDocument().makeElementArray("authenticationRestrictions"); uassertStatusOK(result.pushBack(authenticationRestrictionsElement)); if (restrictions) { uassertStatusOK(authenticationRestrictionsElement.setValueArray(restrictions->toBSON())); } return Status::OK(); } catch (...) {
0
[ "CWE-863" ]
mongo
fb87cc88ecb5d300f14cda7bc238d7d5132118f5
170,933,332,931,042,560,000,000,000,000,000,000,000
47
SERVER-45472 Ensure RoleGraph can serialize authentication restrictions to BSON (cherry picked from commit 521e56b407ac72bc69a97a24d1253f51a5b6e81b) (cherry picked from commit a10d0a22d5d009d27664967181042933ec1bef36)
static int sl_alloc_bufs(struct slip *sl, int mtu) { int err = -ENOBUFS; unsigned long len; char *rbuff = NULL; char *xbuff = NULL; #ifdef SL_INCLUDE_CSLIP char *cbuff = NULL; struct slcompress *slcomp = NULL; #endif /* * Allocate the SLIP frame buffers: * * rbuff Receive buffer. * xbuff Transmit buffer. * cbuff Temporary compression buffer. */ len = mtu * 2; /* * allow for arrival of larger UDP packets, even if we say not to * also fixes a bug in which SunOS sends 512-byte packets even with * an MSS of 128 */ if (len < 576 * 2) len = 576 * 2; rbuff = kmalloc(len + 4, GFP_KERNEL); if (rbuff == NULL) goto err_exit; xbuff = kmalloc(len + 4, GFP_KERNEL); if (xbuff == NULL) goto err_exit; #ifdef SL_INCLUDE_CSLIP cbuff = kmalloc(len + 4, GFP_KERNEL); if (cbuff == NULL) goto err_exit; slcomp = slhc_init(16, 16); if (slcomp == NULL) goto err_exit; #endif spin_lock_bh(&sl->lock); if (sl->tty == NULL) { spin_unlock_bh(&sl->lock); err = -ENODEV; goto err_exit; } sl->mtu = mtu; sl->buffsize = len; sl->rcount = 0; sl->xleft = 0; rbuff = xchg(&sl->rbuff, rbuff); xbuff = xchg(&sl->xbuff, xbuff); #ifdef SL_INCLUDE_CSLIP cbuff = xchg(&sl->cbuff, cbuff); slcomp = xchg(&sl->slcomp, slcomp); #endif #ifdef CONFIG_SLIP_MODE_SLIP6 sl->xdata = 0; sl->xbits = 0; #endif spin_unlock_bh(&sl->lock); err = 0; /* Cleanup */ err_exit: #ifdef SL_INCLUDE_CSLIP kfree(cbuff); slhc_free(slcomp); #endif kfree(xbuff); kfree(rbuff); return err; }
1
[]
linux
4ab42d78e37a294ac7bc56901d563c642e03c4ae
232,841,574,353,644,500,000,000,000,000,000,000,000
74
ppp, slip: Validate VJ compression slot parameters completely Currently slhc_init() treats out-of-range values of rslots and tslots as equivalent to 0, except that if tslots is too large it will dereference a null pointer (CVE-2015-7799). Add a range-check at the top of the function and make it return an ERR_PTR() on error instead of NULL. Change the callers accordingly. Compile-tested only. Reported-by: 郭永刚 <[email protected]> References: http://article.gmane.org/gmane.comp.security.oss.general/17908 Signed-off-by: Ben Hutchings <[email protected]> Signed-off-by: David S. Miller <[email protected]>
void Perl_reg_numbered_buff_fetch(pTHX_ REGEXP * const r, const I32 paren, SV * const sv) { struct regexp *const rx = ReANY(r); char *s = NULL; SSize_t i = 0; SSize_t s1, t1; I32 n = paren; PERL_ARGS_ASSERT_REG_NUMBERED_BUFF_FETCH; if ( n == RX_BUFF_IDX_CARET_PREMATCH || n == RX_BUFF_IDX_CARET_FULLMATCH || n == RX_BUFF_IDX_CARET_POSTMATCH ) { bool keepcopy = cBOOL(rx->extflags & RXf_PMf_KEEPCOPY); if (!keepcopy) { /* on something like * $r = qr/.../; * /$qr/p; * the KEEPCOPY is set on the PMOP rather than the regex */ if (PL_curpm && r == PM_GETRE(PL_curpm)) keepcopy = cBOOL(PL_curpm->op_pmflags & PMf_KEEPCOPY); } if (!keepcopy) goto ret_undef; } if (!rx->subbeg) goto ret_undef; if (n == RX_BUFF_IDX_CARET_FULLMATCH) /* no need to distinguish between them any more */ n = RX_BUFF_IDX_FULLMATCH; if ((n == RX_BUFF_IDX_PREMATCH || n == RX_BUFF_IDX_CARET_PREMATCH) && rx->offs[0].start != -1) { /* $`, ${^PREMATCH} */ i = rx->offs[0].start; s = rx->subbeg; } else if ((n == RX_BUFF_IDX_POSTMATCH || n == RX_BUFF_IDX_CARET_POSTMATCH) && rx->offs[0].end != -1) { /* $', ${^POSTMATCH} */ s = rx->subbeg - rx->suboffset + rx->offs[0].end; i = rx->sublen + rx->suboffset - rx->offs[0].end; } else if ( 0 <= n && n <= (I32)rx->nparens && (s1 = rx->offs[n].start) != -1 && (t1 = rx->offs[n].end) != -1) { /* $&, ${^MATCH}, $1 ... */ i = t1 - s1; s = rx->subbeg + s1 - rx->suboffset; } else { goto ret_undef; } assert(s >= rx->subbeg); assert((STRLEN)rx->sublen >= (STRLEN)((s - rx->subbeg) + i) ); if (i >= 0) { #ifdef NO_TAINT_SUPPORT sv_setpvn(sv, s, i); #else const int oldtainted = TAINT_get; TAINT_NOT; sv_setpvn(sv, s, i); TAINT_set(oldtainted); #endif if (RXp_MATCH_UTF8(rx)) SvUTF8_on(sv); else SvUTF8_off(sv); if (TAINTING_get) { if (RXp_MATCH_TAINTED(rx)) { if (SvTYPE(sv) >= SVt_PVMG) { MAGIC* const mg = SvMAGIC(sv); MAGIC* mgt; TAINT; SvMAGIC_set(sv, mg->mg_moremagic); SvTAINT(sv); if ((mgt = SvMAGIC(sv))) { mg->mg_moremagic = mgt; SvMAGIC_set(sv, mg); } } else { TAINT; SvTAINT(sv); } } else SvTAINTED_off(sv); } } else { ret_undef: sv_set_undef(sv); return; }
0
[ "CWE-190", "CWE-787" ]
perl5
897d1f7fd515b828e4b198d8b8bef76c6faf03ed
323,603,427,169,139,970,000,000,000,000,000,000,000
103
regcomp.c: Prevent integer overflow from nested regex quantifiers. (CVE-2020-10543) On 32bit systems the size calculations for nested regular expression quantifiers could overflow causing heap memory corruption. Fixes: Perl/perl5-security#125 (cherry picked from commit bfd31397db5dc1a5c5d3e0a1f753a4f89a736e71)
static void tulip_idblock_crc(TULIPState *s, uint16_t *srom) { int word, n; int bit; unsigned char bitval, crc; const int len = 9; n = 0; crc = -1; for (word = 0; word < len; word++) { for (bit = 15; bit >= 0; bit--) { if ((word == (len - 1)) && (bit == 7)) { /* * Insert the correct CRC result into input data stream * in place. */ srom[len - 1] = (srom[len - 1] & 0xff00) | (unsigned short)crc; break; } n++; bitval = ((srom[word] >> bit) & 1) ^ ((crc >> 7) & 1); crc = crc << 1; if (bitval == 1) { crc ^= 6; crc |= 0x01; } } } }
0
[ "CWE-787" ]
qemu
8ffb7265af64ec81748335ec8f20e7ab542c3850
116,261,916,272,417,120,000,000,000,000,000,000,000
29
net: tulip: check frame size and r/w data length Tulip network driver while copying tx/rx buffers does not check frame size against r/w data length. This may lead to OOB buffer access. Add check to avoid it. Limit iterations over descriptors to avoid potential infinite loop issue in tulip_xmit_list_update. Reported-by: Li Qiang <[email protected]> Reported-by: Ziming Zhang <[email protected]> Reported-by: Jason Wang <[email protected]> Tested-by: Li Qiang <[email protected]> Reviewed-by: Li Qiang <[email protected]> Signed-off-by: Prasad J Pandit <[email protected]> Signed-off-by: Jason Wang <[email protected]>
Item_args(THD *thd, Item *a, Item *b, Item *c, Item *d) { arg_count= 0; if (likely((args= (Item**) thd_alloc(thd, sizeof(Item*) * 4)))) { arg_count= 4; args[0]= a; args[1]= b; args[2]= c; args[3]= d; } }
0
[ "CWE-617" ]
server
807945f2eb5fa22e6f233cc17b85a2e141efe2c8
46,481,648,496,608,020,000,000,000,000,000,000,000
9
MDEV-26402: A SEGV in Item_field::used_tables/update_depend_map_for_order... When doing condition pushdown from HAVING into WHERE, Item_equal::create_pushable_equalities() calls item->set_extraction_flag(IMMUTABLE_FL) for constant items. Then, Item::cleanup_excluding_immutables_processor() checks for this flag to see if it should call item->cleanup() or leave the item as-is. The failure happens when a constant item has a non-constant one inside it, like: (tbl.col=0 AND impossible_cond) item->walk(cleanup_excluding_immutables_processor) works in a bottom-up way so it 1. will call Item_func_eq(tbl.col=0)->cleanup() 2. will not call Item_cond_and->cleanup (as the AND is constant) This creates an item tree where a fixed Item has an un-fixed Item inside it which eventually causes an assertion failure. Fixed by introducing this rule: instead of just calling item->set_extraction_flag(IMMUTABLE_FL); we call Item::walk() to set the flag for all sub-items of the item.
int proto_register(struct proto *prot, int alloc_slab) { if (alloc_slab) { prot->slab = kmem_cache_create(prot->name, prot->obj_size, 0, SLAB_HWCACHE_ALIGN | prot->slab_flags, NULL); if (prot->slab == NULL) { printk(KERN_CRIT "%s: Can't create sock SLAB cache!\n", prot->name); goto out; } if (prot->rsk_prot != NULL) { prot->rsk_prot->slab_name = kasprintf(GFP_KERNEL, "request_sock_%s", prot->name); if (prot->rsk_prot->slab_name == NULL) goto out_free_sock_slab; prot->rsk_prot->slab = kmem_cache_create(prot->rsk_prot->slab_name, prot->rsk_prot->obj_size, 0, SLAB_HWCACHE_ALIGN, NULL); if (prot->rsk_prot->slab == NULL) { printk(KERN_CRIT "%s: Can't create request sock SLAB cache!\n", prot->name); goto out_free_request_sock_slab_name; } } if (prot->twsk_prot != NULL) { prot->twsk_prot->twsk_slab_name = kasprintf(GFP_KERNEL, "tw_sock_%s", prot->name); if (prot->twsk_prot->twsk_slab_name == NULL) goto out_free_request_sock_slab; prot->twsk_prot->twsk_slab = kmem_cache_create(prot->twsk_prot->twsk_slab_name, prot->twsk_prot->twsk_obj_size, 0, SLAB_HWCACHE_ALIGN | prot->slab_flags, NULL); if (prot->twsk_prot->twsk_slab == NULL) goto out_free_timewait_sock_slab_name; } } write_lock(&proto_list_lock); list_add(&prot->node, &proto_list); assign_proto_idx(prot); write_unlock(&proto_list_lock); return 0; out_free_timewait_sock_slab_name: kfree(prot->twsk_prot->twsk_slab_name); out_free_request_sock_slab: if (prot->rsk_prot && prot->rsk_prot->slab) { kmem_cache_destroy(prot->rsk_prot->slab); prot->rsk_prot->slab = NULL; } out_free_request_sock_slab_name: if (prot->rsk_prot) kfree(prot->rsk_prot->slab_name); out_free_sock_slab: kmem_cache_destroy(prot->slab); prot->slab = NULL; out: return -ENOBUFS; }
0
[ "CWE-400" ]
linux-2.6
c377411f2494a931ff7facdbb3a6839b1266bcf6
226,514,902,155,101,020,000,000,000,000,000,000,000
69
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 iwl_trans_pcie_d3_suspend(struct iwl_trans *trans, bool test, bool reset) { int ret; struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); /* * Family IWL_DEVICE_FAMILY_AX210 and above persist mode is set by FW. */ if (!reset && trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_AX210) { /* Enable persistence mode to avoid reset */ iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_PERSIST_MODE); } if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210) { iwl_write_umac_prph(trans, UREG_DOORBELL_TO_ISR6, UREG_DOORBELL_TO_ISR6_SUSPEND); ret = wait_event_timeout(trans_pcie->sx_waitq, trans_pcie->sx_complete, 2 * HZ); /* * Invalidate it toward resume. */ trans_pcie->sx_complete = false; if (!ret) { IWL_ERR(trans, "Timeout entering D3\n"); return -ETIMEDOUT; } } iwl_pcie_d3_complete_suspend(trans, test, reset); return 0; }
0
[ "CWE-476" ]
linux
8188a18ee2e48c9a7461139838048363bfce3fef
333,449,422,249,936,000,000,000,000,000,000,000,000
35
iwlwifi: pcie: fix rb_allocator workqueue allocation We don't handle failures in the rb_allocator workqueue allocation correctly. To fix that, move the code earlier so the cleanup is easier and we don't have to undo all the interrupt allocations in this case. Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Luca Coelho <[email protected]>
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-401" ]
ImageMagick
d3ae9c19125c8704b4866381f7a064ca2cbdc006
339,187,440,551,814,100,000,000,000,000,000,000,000
1,337
https://github.com/ImageMagick/ImageMagick/issues/1533
PHP_FUNCTION(ldap_get_option) { zval *link, *retval; ldap_linkdata *ld; long option; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &link, &option, &retval) != SUCCESS) { return; } ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link); switch (option) { /* options with int value */ case LDAP_OPT_DEREF: case LDAP_OPT_SIZELIMIT: case LDAP_OPT_TIMELIMIT: case LDAP_OPT_PROTOCOL_VERSION: case LDAP_OPT_ERROR_NUMBER: case LDAP_OPT_REFERRALS: #ifdef LDAP_OPT_RESTART case LDAP_OPT_RESTART: #endif { int val; if (ldap_get_option(ld->link, option, &val)) { RETURN_FALSE; } zval_dtor(retval); ZVAL_LONG(retval, val); } break; #ifdef LDAP_OPT_NETWORK_TIMEOUT case LDAP_OPT_NETWORK_TIMEOUT: { struct timeval *timeout = NULL; if (ldap_get_option(ld->link, LDAP_OPT_NETWORK_TIMEOUT, (void *) &timeout)) { if (timeout) { ldap_memfree(timeout); } RETURN_FALSE; } if (!timeout) { RETURN_FALSE; } zval_dtor(retval); ZVAL_LONG(retval, timeout->tv_sec); ldap_memfree(timeout); } break; #elif defined(LDAP_X_OPT_CONNECT_TIMEOUT) case LDAP_X_OPT_CONNECT_TIMEOUT: { int timeout; if (ldap_get_option(ld->link, LDAP_X_OPT_CONNECT_TIMEOUT, &timeout)) { RETURN_FALSE; } zval_dtor(retval); ZVAL_LONG(retval, (timeout / 1000)); } break; #endif #ifdef LDAP_OPT_TIMEOUT case LDAP_OPT_TIMEOUT: { struct timeval *timeout = NULL; if (ldap_get_option(ld->link, LDAP_OPT_TIMEOUT, (void *) &timeout)) { if (timeout) { ldap_memfree(timeout); } RETURN_FALSE; } if (!timeout) { RETURN_FALSE; } zval_dtor(retval); ZVAL_LONG(retval, timeout->tv_sec); ldap_memfree(timeout); } break; #endif /* options with string value */ case LDAP_OPT_ERROR_STRING: #ifdef LDAP_OPT_HOST_NAME case LDAP_OPT_HOST_NAME: #endif #ifdef HAVE_LDAP_SASL case LDAP_OPT_X_SASL_MECH: case LDAP_OPT_X_SASL_REALM: case LDAP_OPT_X_SASL_AUTHCID: case LDAP_OPT_X_SASL_AUTHZID: #endif #ifdef LDAP_OPT_MATCHED_DN case LDAP_OPT_MATCHED_DN: #endif { char *val = NULL; if (ldap_get_option(ld->link, option, &val) || val == NULL || *val == '\0') { if (val) { ldap_memfree(val); } RETURN_FALSE; } zval_dtor(retval); ZVAL_STRING(retval, val, 1); ldap_memfree(val); } break; /* options not implemented case LDAP_OPT_SERVER_CONTROLS: case LDAP_OPT_CLIENT_CONTROLS: case LDAP_OPT_API_INFO: case LDAP_OPT_API_FEATURE_INFO: */ default: RETURN_FALSE; } RETURN_TRUE; }
0
[ "CWE-476" ]
php-src
49782c54994ecca2ef2a061063bd5a7079c43527
301,811,320,276,358,400,000,000,000,000,000,000,000
119
Fix bug #76248 - Malicious LDAP-Server Response causes Crash
static int pin_rcv_pages(struct hfi1_filedata *fd, struct tid_user_buf *tidbuf) { int pinned; unsigned int npages; unsigned long vaddr = tidbuf->vaddr; struct page **pages = NULL; struct hfi1_devdata *dd = fd->uctxt->dd; /* Get the number of pages the user buffer spans */ npages = num_user_pages(vaddr, tidbuf->length); if (!npages) return -EINVAL; if (npages > fd->uctxt->expected_count) { dd_dev_err(dd, "Expected buffer too big\n"); return -EINVAL; } /* Allocate the array of struct page pointers needed for pinning */ pages = kcalloc(npages, sizeof(*pages), GFP_KERNEL); if (!pages) return -ENOMEM; /* * Pin all the pages of the user buffer. If we can't pin all the * pages, accept the amount pinned so far and program only that. * User space knows how to deal with partially programmed buffers. */ if (!hfi1_can_pin_pages(dd, fd->mm, fd->tid_n_pinned, npages)) { kfree(pages); return -ENOMEM; } pinned = hfi1_acquire_user_pages(fd->mm, vaddr, npages, true, pages); if (pinned <= 0) { kfree(pages); return pinned; } tidbuf->pages = pages; tidbuf->npages = npages; fd->tid_n_pinned += pinned; return pinned; }
1
[ "CWE-416" ]
linux
3d2a9d642512c21a12d19b9250e7a835dcb41a79
102,001,683,919,728,200,000,000,000,000,000,000,000
43
IB/hfi1: Ensure correct mm is used at all times Two earlier bug fixes have created a security problem in the hfi1 driver. One fix aimed to solve an issue where current->mm was not valid when closing the hfi1 cdev. It attempted to do this by saving a cached value of the current->mm pointer at file open time. This is a problem if another process with access to the FD calls in via write() or ioctl() to pin pages via the hfi driver. The other fix tried to solve a use after free by taking a reference on the mm. To fix this correctly we use the existing cached value of the mm in the mmu notifier. Now we can check in the insert, evict, etc. routines that current->mm matched what the notifier was registered for. If not, then don't allow access. The register of the mmu notifier will save the mm pointer. Since in do_exit() the exit_mm() is called before exit_files(), which would call our close routine a reference is needed on the mm. We rely on the mmgrab done by the registration of the notifier, whereas before it was explicit. The mmu notifier deregistration happens when the user context is torn down, the creation of which triggered the registration. Also of note is we do not do any explicit work to protect the interval tree notifier. It doesn't seem that this is going to be needed since we aren't actually doing anything with current->mm. The interval tree notifier stuff still has a FIXME noted from a previous commit that will be addressed in a follow on patch. Cc: <[email protected]> Fixes: e0cf75deab81 ("IB/hfi1: Fix mm_struct use after free") Fixes: 3faa3d9a308e ("IB/hfi1: Make use of mm consistent") Link: https://lore.kernel.org/r/[email protected] Suggested-by: Jann Horn <[email protected]> Reported-by: Jason Gunthorpe <[email protected]> Reviewed-by: Ira Weiny <[email protected]> Reviewed-by: Mike Marciniszyn <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID) { xmlDtdPtr cur; if ((doc != NULL) && (xmlGetIntSubset(doc) != NULL)) { #ifdef DEBUG_TREE xmlGenericError(xmlGenericErrorContext, "xmlCreateIntSubset(): document %s already have an internal subset\n", doc->name); #endif return(NULL); } /* * Allocate a new DTD and fill the fields. */ cur = (xmlDtdPtr) xmlMalloc(sizeof(xmlDtd)); if (cur == NULL) { xmlTreeErrMemory("building internal subset"); return(NULL); } memset(cur, 0, sizeof(xmlDtd)); cur->type = XML_DTD_NODE; if (name != NULL) { cur->name = xmlStrdup(name); if (cur->name == NULL) { xmlTreeErrMemory("building internal subset"); xmlFree(cur); return(NULL); } } if (ExternalID != NULL) { cur->ExternalID = xmlStrdup(ExternalID); if (cur->ExternalID == NULL) { xmlTreeErrMemory("building internal subset"); if (cur->name != NULL) xmlFree((char *)cur->name); xmlFree(cur); return(NULL); } } if (SystemID != NULL) { cur->SystemID = xmlStrdup(SystemID); if (cur->SystemID == NULL) { xmlTreeErrMemory("building internal subset"); if (cur->name != NULL) xmlFree((char *)cur->name); if (cur->ExternalID != NULL) xmlFree((char *)cur->ExternalID); xmlFree(cur); return(NULL); } } if (doc != NULL) { doc->intSubset = cur; cur->parent = doc; cur->doc = doc; if (doc->children == NULL) { doc->children = (xmlNodePtr) cur; doc->last = (xmlNodePtr) cur; } else { if (doc->type == XML_HTML_DOCUMENT_NODE) { xmlNodePtr prev; prev = doc->children; prev->prev = (xmlNodePtr) cur; cur->next = prev; doc->children = (xmlNodePtr) cur; } else { xmlNodePtr next; next = doc->children; while ((next != NULL) && (next->type != XML_ELEMENT_NODE)) next = next->next; if (next == NULL) { cur->prev = doc->last; cur->prev->next = (xmlNodePtr) cur; cur->next = NULL; doc->last = (xmlNodePtr) cur; } else { cur->next = next; cur->prev = next->prev; if (cur->prev == NULL) doc->children = (xmlNodePtr) cur; else cur->prev->next = (xmlNodePtr) cur; next->prev = (xmlNodePtr) cur; } } } } if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue)) xmlRegisterNodeDefaultValue((xmlNodePtr)cur); return(cur); }
0
[ "CWE-20" ]
libxml2
bdd66182ef53fe1f7209ab6535fda56366bd7ac9
266,592,681,752,067,130,000,000,000,000,000,000,000
98
Avoid building recursive entities For https://bugzilla.gnome.org/show_bug.cgi?id=762100 When we detect a recusive entity we should really not build the associated data, moreover if someone bypass libxml2 fatal errors and still tries to serialize a broken entity make sure we don't risk to get ito a recursion * parser.c: xmlParserEntityCheck() don't build if entity loop were found and remove the associated text content * tree.c: xmlStringGetNodeList() avoid a potential recursion
int __close_fd_get_file(unsigned int fd, struct file **res) { struct files_struct *files = current->files; struct file *file; struct fdtable *fdt; fdt = files_fdtable(files); if (fd >= fdt->max_fds) goto out_err; file = fdt->fd[fd]; if (!file) goto out_err; rcu_assign_pointer(fdt->fd[fd], NULL); __put_unused_fd(files, fd); get_file(file); *res = file; return 0; out_err: *res = NULL; return -ENOENT; }
0
[]
linux
054aa8d439b9185d4f5eb9a90282d1ce74772969
166,736,889,672,292,140,000,000,000,000,000,000,000
21
fget: check that the fd still exists after getting a ref to it Jann Horn points out that there is another possible race wrt Unix domain socket garbage collection, somewhat reminiscent of the one fixed in commit cbcf01128d0a ("af_unix: fix garbage collect vs MSG_PEEK"). See the extended comment about the garbage collection requirements added to unix_peek_fds() by that commit for details. The race comes from how we can locklessly look up a file descriptor just as it is in the process of being closed, and with the right artificial timing (Jann added a few strategic 'mdelay(500)' calls to do that), the Unix domain socket garbage collector could see the reference count decrement of the close() happen before fget() took its reference to the file and the file was attached onto a new file descriptor. This is all (intentionally) correct on the 'struct file *' side, with RCU lookups and lockless reference counting very much part of the design. Getting that reference count out of order isn't a problem per se. But the garbage collector can get confused by seeing this situation of having seen a file not having any remaining external references and then seeing it being attached to an fd. In commit cbcf01128d0a ("af_unix: fix garbage collect vs MSG_PEEK") the fix was to serialize the file descriptor install with the garbage collector by taking and releasing the unix_gc_lock. That's not really an option here, but since this all happens when we are in the process of looking up a file descriptor, we can instead simply just re-check that the file hasn't been closed in the meantime, and just re-do the lookup if we raced with a concurrent close() of the same file descriptor. Reported-and-tested-by: Jann Horn <[email protected]> Acked-by: Miklos Szeredi <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
void Downstream::set_addr(const DownstreamAddr *addr) { addr_ = addr; }
0
[]
nghttp2
319d5ab1c6d916b6b8a0d85b2ae3f01b3ad04f2c
303,165,510,491,441,450,000,000,000,000,000,000,000
1
nghttpx: Fix request stall Fix request stall if backend connection is reused and buffer is full.
bson_iter_value (bson_iter_t *iter) /* IN */ { bson_value_t *value; BSON_ASSERT (iter); value = &iter->value; value->value_type = ITER_TYPE (iter); switch (value->value_type) { case BSON_TYPE_DOUBLE: value->value.v_double = bson_iter_double (iter); break; case BSON_TYPE_UTF8: value->value.v_utf8.str = (char *) bson_iter_utf8 (iter, &value->value.v_utf8.len); break; case BSON_TYPE_DOCUMENT: bson_iter_document (iter, &value->value.v_doc.data_len, (const uint8_t **) &value->value.v_doc.data); break; case BSON_TYPE_ARRAY: bson_iter_array (iter, &value->value.v_doc.data_len, (const uint8_t **) &value->value.v_doc.data); break; case BSON_TYPE_BINARY: bson_iter_binary (iter, &value->value.v_binary.subtype, &value->value.v_binary.data_len, (const uint8_t **) &value->value.v_binary.data); break; case BSON_TYPE_OID: bson_oid_copy (bson_iter_oid (iter), &value->value.v_oid); break; case BSON_TYPE_BOOL: value->value.v_bool = bson_iter_bool (iter); break; case BSON_TYPE_DATE_TIME: value->value.v_datetime = bson_iter_date_time (iter); break; case BSON_TYPE_REGEX: value->value.v_regex.regex = (char *) bson_iter_regex ( iter, (const char **) &value->value.v_regex.options); break; case BSON_TYPE_DBPOINTER: { const bson_oid_t *oid; bson_iter_dbpointer (iter, &value->value.v_dbpointer.collection_len, (const char **) &value->value.v_dbpointer.collection, &oid); bson_oid_copy (oid, &value->value.v_dbpointer.oid); break; } case BSON_TYPE_CODE: value->value.v_code.code = (char *) bson_iter_code (iter, &value->value.v_code.code_len); break; case BSON_TYPE_SYMBOL: value->value.v_symbol.symbol = (char *) bson_iter_symbol (iter, &value->value.v_symbol.len); break; case BSON_TYPE_CODEWSCOPE: value->value.v_codewscope.code = (char *) bson_iter_codewscope ( iter, &value->value.v_codewscope.code_len, &value->value.v_codewscope.scope_len, (const uint8_t **) &value->value.v_codewscope.scope_data); break; case BSON_TYPE_INT32: value->value.v_int32 = bson_iter_int32 (iter); break; case BSON_TYPE_TIMESTAMP: bson_iter_timestamp (iter, &value->value.v_timestamp.timestamp, &value->value.v_timestamp.increment); break; case BSON_TYPE_INT64: value->value.v_int64 = bson_iter_int64 (iter); break; case BSON_TYPE_DECIMAL128: bson_iter_decimal128 (iter, &(value->value.v_decimal128)); break; case BSON_TYPE_NULL: case BSON_TYPE_UNDEFINED: case BSON_TYPE_MAXKEY: case BSON_TYPE_MINKEY: break; case BSON_TYPE_EOD: default: return NULL; } return value; }
0
[ "CWE-125" ]
libbson
42900956dc461dfe7fb91d93361d10737c1602b3
196,755,313,139,803,700,000,000,000,000,000,000,000
97
CDRIVER-2269 Check for zero string length in codewscope
int ovs_nla_put_tunnel_info(struct sk_buff *skb, struct ip_tunnel_info *tun_info) { return __ip_tun_to_nlattr(skb, &tun_info->key, ip_tunnel_info_opts(tun_info), tun_info->options_len, ip_tunnel_info_af(tun_info), tun_info->mode); }
0
[ "CWE-362", "CWE-787" ]
linux
cefa91b2332d7009bc0be5d951d6cbbf349f90f8
307,938,068,443,115,160,000,000,000,000,000,000,000
8
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]>
should_skip_file (NautilusDirectory *directory, GFileInfo *info) { static gboolean show_hidden_files_changed_callback_installed = FALSE; static gboolean show_backup_files_changed_callback_installed = FALSE; /* Add the callback once for the life of our process */ if (!show_hidden_files_changed_callback_installed) { eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES, show_hidden_files_changed_callback, NULL); show_hidden_files_changed_callback_installed = TRUE; /* Peek for the first time */ show_hidden_files_changed_callback (NULL); } /* Add the callback once for the life of our process */ if (!show_backup_files_changed_callback_installed) { eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_BACKUP_FILES, show_backup_files_changed_callback, NULL); show_backup_files_changed_callback_installed = TRUE; /* Peek for the first time */ show_backup_files_changed_callback (NULL); } if (!show_hidden_files && (g_file_info_get_is_hidden (info) || (directory != NULL && directory->details->hidden_file_hash != NULL && g_hash_table_lookup (directory->details->hidden_file_hash, g_file_info_get_name (info)) != NULL))) { return TRUE; } if (!show_backup_files && g_file_info_get_is_backup (info)) { return TRUE; } return FALSE; }
0
[]
nautilus
7632a3e13874a2c5e8988428ca913620a25df983
253,498,121,633,050,760,000,000,000,000,000,000,000
41
Check for trusted desktop file launchers. 2009-02-24 Alexander Larsson <[email protected]> * libnautilus-private/nautilus-directory-async.c: Check for trusted desktop file launchers. * libnautilus-private/nautilus-file-private.h: * libnautilus-private/nautilus-file.c: * libnautilus-private/nautilus-file.h: Add nautilus_file_is_trusted_link. Allow unsetting of custom display name. * libnautilus-private/nautilus-mime-actions.c: Display dialog when trying to launch a non-trusted desktop file. svn path=/trunk/; revision=15003
htp_status_t htp_tx_state_request_line(htp_tx_t *tx) { if (tx == NULL) return HTP_ERROR; // Determine how to process the request URI. if (tx->request_method_number == HTP_M_CONNECT) { // When CONNECT is used, the request URI contains an authority string. if (htp_parse_uri_hostport(tx->connp, tx->request_uri, tx->parsed_uri_raw) != HTP_OK) { return HTP_ERROR; } } else { // Parse the request URI into htp_tx_t::parsed_uri_raw. if (htp_parse_uri(tx->request_uri, &(tx->parsed_uri_raw)) != HTP_OK) { return HTP_ERROR; } } // Build htp_tx_t::parsed_uri, but only if it was not explicitly set already. if (tx->parsed_uri == NULL) { tx->parsed_uri = htp_uri_alloc(); if (tx->parsed_uri == NULL) return HTP_ERROR; // Keep the original URI components, but create a copy which we can normalize and use internally. if (htp_normalize_parsed_uri(tx, tx->parsed_uri_raw, tx->parsed_uri) != HTP_OK) { return HTP_ERROR; } } // Check parsed_uri hostname. if (tx->parsed_uri->hostname != NULL) { if (htp_validate_hostname(tx->parsed_uri->hostname) == 0) { tx->flags |= HTP_HOSTU_INVALID; } } // Run hook REQUEST_URI_NORMALIZE. htp_status_t rc = htp_hook_run_all(tx->connp->cfg->hook_request_uri_normalize, tx); if (rc != HTP_OK) return rc; // Run hook REQUEST_LINE. rc = htp_hook_run_all(tx->connp->cfg->hook_request_line, tx); if (rc != HTP_OK) return rc; // Move on to the next phase. tx->connp->in_state = htp_connp_REQ_PROTOCOL; return HTP_OK; }
0
[]
libhtp
c7c03843cd6b1cbf44eb435d160ba53aec948828
54,000,041,618,129,160,000,000,000,000,000,000,000
49
Harden decompress code against memory stress Under severe memory pressure the decompress code can fail to setup properly. Add checks before dereferencing pointers.
display_showcmd(void) { int len; cursor_off(); len = (int)STRLEN(showcmd_buf); if (len == 0) showcmd_is_clear = TRUE; else { screen_puts(showcmd_buf, (int)Rows - 1, sc_col, 0); showcmd_is_clear = FALSE; } /* * clear the rest of an old message by outputting up to SHOWCMD_COLS * spaces */ screen_puts((char_u *)" " + len, (int)Rows - 1, sc_col + len, 0); setcursor(); // put cursor back where it belongs }
0
[ "CWE-416" ]
vim
35a9a00afcb20897d462a766793ff45534810dc3
294,499,671,582,657,370,000,000,000,000,000,000,000
23
patch 8.2.3428: using freed memory when replacing Problem: Using freed memory when replacing. (Dhiraj Mishra) Solution: Get the line pointer after calling ins_copychar().
int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry) { if (unlikely(IS_PRIVATE(dentry->d_inode))) return 0; return security_ops->inode_getattr(mnt, dentry); }
0
[]
linux-2.6
ee18d64c1f632043a02e6f5ba5e045bb26a5465f
155,026,187,775,587,550,000,000,000,000,000,000,000
6
KEYS: Add a keyctl to install a process's session keyring on its parent [try #6] Add a keyctl to install a process's session keyring onto its parent. This replaces the parent's session keyring. Because the COW credential code does not permit one process to change another process's credentials directly, the change is deferred until userspace next starts executing again. Normally this will be after a wait*() syscall. To support this, three new security hooks have been provided: cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in the blank security creds and key_session_to_parent() - which asks the LSM if the process may replace its parent's session keyring. The replacement may only happen if the process has the same ownership details as its parent, and the process has LINK permission on the session keyring, and the session keyring is owned by the process, and the LSM permits it. Note that this requires alteration to each architecture's notify_resume path. This has been done for all arches barring blackfin, m68k* and xtensa, all of which need assembly alteration to support TIF_NOTIFY_RESUME. This allows the replacement to be performed at the point the parent process resumes userspace execution. This allows the userspace AFS pioctl emulation to fully emulate newpag() and the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to alter the parent process's PAG membership. However, since kAFS doesn't use PAGs per se, but rather dumps the keys into the session keyring, the session keyring of the parent must be replaced if, for example, VIOCSETTOK is passed the newpag flag. This can be tested with the following program: #include <stdio.h> #include <stdlib.h> #include <keyutils.h> #define KEYCTL_SESSION_TO_PARENT 18 #define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0) int main(int argc, char **argv) { key_serial_t keyring, key; long ret; keyring = keyctl_join_session_keyring(argv[1]); OSERROR(keyring, "keyctl_join_session_keyring"); key = add_key("user", "a", "b", 1, keyring); OSERROR(key, "add_key"); ret = keyctl(KEYCTL_SESSION_TO_PARENT); OSERROR(ret, "KEYCTL_SESSION_TO_PARENT"); return 0; } Compiled and linked with -lkeyutils, you should see something like: [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 355907932 --alswrv 4043 -1 \_ keyring: _uid.4043 [dhowells@andromeda ~]$ /tmp/newpag [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: _ses 1055658746 --alswrv 4043 4043 \_ user: a [dhowells@andromeda ~]$ /tmp/newpag hello [dhowells@andromeda ~]$ keyctl show Session Keyring -3 --alswrv 4043 4043 keyring: hello 340417692 --alswrv 4043 4043 \_ user: a Where the test program creates a new session keyring, sticks a user key named 'a' into it and then installs it on its parent. Signed-off-by: David Howells <[email protected]> Signed-off-by: James Morris <[email protected]>
static int atusb_read_subreg(struct atusb *lp, unsigned int addr, unsigned int mask, unsigned int shift) { int rc; rc = atusb_read_reg(lp, addr); rc = (rc & mask) >> shift; return rc; }
0
[ "CWE-416" ]
linux
7fd25e6fc035f4b04b75bca6d7e8daa069603a76
318,951,323,166,199,130,000,000,000,000,000,000,000
11
ieee802154: atusb: fix use-after-free at disconnect The disconnect callback was accessing the hardware-descriptor private data after having having freed it. Fixes: 7490b008d123 ("ieee802154: add support for atusb transceiver") Cc: stable <[email protected]> # 4.2 Cc: Alexander Aring <[email protected]> Reported-by: [email protected] Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: Stefan Schmidt <[email protected]>
jas_image_t *jas_image_create0() { jas_image_t *image; if (!(image = jas_malloc(sizeof(jas_image_t)))) { return 0; } image->tlx_ = 0; image->tly_ = 0; image->brx_ = 0; image->bry_ = 0; image->clrspc_ = JAS_CLRSPC_UNKNOWN; image->numcmpts_ = 0; image->maxcmpts_ = 0; image->cmpts_ = 0; // image->inmem_ = true; image->cmprof_ = 0; return image; }
0
[ "CWE-20", "CWE-190" ]
jasper
d42b2388f7f8e0332c846675133acea151fc557a
180,443,795,149,699,600,000,000,000,000,000,000,000
21
The generation of the configuration file jas_config.h has been completely reworked in order to avoid pollution of the global namespace. Some problematic types like uchar, ulong, and friends have been replaced with names with a jas_ prefix. An option max_samples has been added to the BMP and JPEG decoders to restrict the maximum size of image that they can decode. This change was made as a (possibly temporary) fix to address security concerns. A max_samples command-line option has also been added to imginfo. Whether an image component (for jas_image_t) is stored in memory or on disk is now based on the component size (rather than the image size). Some debug log message were added. Some new integer overflow checks were added. Some new safe integer add/multiply functions were added. More pre-C99 cruft was removed. JasPer has numerous "hacks" to handle pre-C99 compilers. JasPer now assumes C99 support. So, this pre-C99 cruft is unnecessary and can be removed. The regression jasper-doublefree-mem_close.jpg has been re-enabled. Theoretically, it should work more predictably now.
void ext4_journal_abort_handle(const char *caller, const char *err_fn, struct buffer_head *bh, handle_t *handle, int err) { char nbuf[16]; const char *errstr = ext4_decode_error(NULL, err, nbuf); BUG_ON(!ext4_handle_valid(handle)); if (bh) BUFFER_TRACE(bh, "abort"); if (!handle->h_err) handle->h_err = err; if (is_handle_aborted(handle)) return; printk(KERN_ERR "%s: aborting transaction: %s in %s\n", caller, errstr, err_fn); jbd2_journal_abort_handle(handle); }
0
[ "CWE-20" ]
linux-2.6
4ec110281379826c5cf6ed14735e47027c3c5765
148,157,434,488,259,670,000,000,000,000,000,000,000
22
ext4: Add sanity checks for the superblock before mounting the filesystem This avoids insane superblock configurations that could lead to kernel oops due to null pointer derefences. http://bugzilla.kernel.org/show_bug.cgi?id=12371 Thanks to David Maciejak at Fortinet's FortiGuard Global Security Research Team who discovered this bug independently (but at approximately the same time) as Thiemo Nagel, who submitted the patch. Signed-off-by: Thiemo Nagel <[email protected]> Signed-off-by: "Theodore Ts'o" <[email protected]> Cc: [email protected]
Perl_reg_named_buff_fetch(pTHX_ REGEXP * const r, SV * const namesv, const U32 flags) { SV *ret; struct regexp *const rx = ReANY(r); PERL_ARGS_ASSERT_REG_NAMED_BUFF_FETCH; if (rx && RXp_PAREN_NAMES(rx)) { HE *he_str = hv_fetch_ent( RXp_PAREN_NAMES(rx), namesv, 0, 0 ); if (he_str) { IV i; SV* sv_dat=HeVAL(he_str); I32 *nums=(I32*)SvPVX(sv_dat); AV * const retarray = (flags & RXapif_ALL) ? newAV() : NULL; for ( i=0; i<SvIVX(sv_dat); i++ ) { if ((I32)(rx->nparens) >= nums[i] && rx->offs[nums[i]].start != -1 && rx->offs[nums[i]].end != -1) { ret = newSVpvs(""); CALLREG_NUMBUF_FETCH(r,nums[i],ret); if (!retarray) return ret; } else { if (retarray) ret = newSVsv(&PL_sv_undef); } if (retarray) av_push(retarray, ret); } if (retarray) return newRV_noinc(MUTABLE_SV(retarray)); } } return NULL; }
0
[ "CWE-125" ]
perl5
43b2f4ef399e2fd7240b4eeb0658686ad95f8e62
35,212,099,507,801,450,000,000,000,000,000,000,000
37
regcomp.c: Convert some strchr to memchr This allows things to work properly in the face of embedded NULs. See the branch merge message for more information.
cmsToneCurve* ReadEmbeddedCurve(struct _cms_typehandler_struct* self, cmsIOHANDLER* io) { cmsTagTypeSignature BaseType; cmsUInt32Number nItems; BaseType = _cmsReadTypeBase(io); switch (BaseType) { case cmsSigCurveType: return (cmsToneCurve*) Type_Curve_Read(self, io, &nItems, 0); case cmsSigParametricCurveType: return (cmsToneCurve*) Type_ParametricCurve_Read(self, io, &nItems, 0); default: { char String[5]; _cmsTagSignature2String(String, (cmsTagSignature) BaseType); cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown curve type '%s'", String); } return NULL; } }
0
[]
Little-CMS
41d222df1bc6188131a8f46c32eab0a4d4cdf1b6
12,686,521,589,502,423,000,000,000,000,000,000,000
24
Memory squeezing fix: lcms2 cmsPipeline construction When creating a new pipeline, lcms would often try to allocate a stage and pass it to cmsPipelineInsertStage without checking whether the allocation succeeded. cmsPipelineInsertStage would then assert (or crash) if it had not. The fix here is to change cmsPipelineInsertStage to check and return an error value. All calling code is then checked to test this return value and cope.
static void read_dce_straps( struct dc_context *ctx, struct resource_straps *straps) { REG_GET_2(CC_DC_HDMI_STRAPS, HDMI_DISABLE, &straps->hdmi_disable, AUDIO_STREAM_NUMBER, &straps->audio_stream_number); REG_GET(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO, &straps->dc_pinstraps_audio); }
0
[ "CWE-400", "CWE-401" ]
linux
104c307147ad379617472dd91a5bcb368d72bd6d
114,240,256,915,784,400,000,000,000,000,000,000,000
10
drm/amd/display: prevent memory leak In dcn*_create_resource_pool the allocated memory should be released if construct pool fails. Reviewed-by: Harry Wentland <[email protected]> Signed-off-by: Navid Emamdoost <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
int ext4_wait_block_bitmap(struct super_block *sb, ext4_group_t block_group, struct buffer_head *bh) { struct ext4_group_desc *desc; if (!buffer_new(bh)) return 0; desc = ext4_get_group_desc(sb, block_group, NULL); if (!desc) return -EFSCORRUPTED; wait_on_buffer(bh); if (!buffer_uptodate(bh)) { ext4_error(sb, "Cannot read block bitmap - " "block_group = %u, block_bitmap = %llu", block_group, (unsigned long long) bh->b_blocknr); return -EIO; } clear_buffer_new(bh); /* Panic or remount fs read-only if block bitmap is invalid */ return ext4_validate_block_bitmap(sb, desc, block_group, bh); }
0
[]
linux
7dac4a1726a9c64a517d595c40e95e2d0d135f6f
175,834,774,097,528,400,000,000,000,000,000,000,000
21
ext4: add validity checks for bitmap block numbers An privileged attacker can cause a crash by mounting a crafted ext4 image which triggers a out-of-bounds read in the function ext4_valid_block_bitmap() in fs/ext4/balloc.c. This issue has been assigned CVE-2018-1093. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199181 BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1560782 Reported-by: Wen Xu <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected]
static inline unsigned nested_cpu_vmx_misc_cr3_count(struct kvm_vcpu *vcpu) { return vmx_misc_cr3_count(to_vmx(vcpu)->nested.msrs.misc_low); }
0
[ "CWE-284" ]
linux
727ba748e110b4de50d142edca9d6a9b7e6111d8
294,054,786,722,828,760,000,000,000,000,000,000,000
4
kvm: nVMX: Enforce cpl=0 for VMX instructions VMX instructions executed inside a L1 VM will always trigger a VM exit even when executed with cpl 3. This means we must perform the privilege check in software. Fixes: 70f3aac964ae("kvm: nVMX: Remove superfluous VMX instruction fault checks") Cc: [email protected] Signed-off-by: Felix Wilhelm <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
cib_remote_free(cib_t * cib) { int rc = pcmk_ok; crm_warn("Freeing CIB"); if (cib->state != cib_disconnected) { rc = cib_remote_signoff(cib); if (rc == pcmk_ok) { cib_remote_opaque_t *private = cib->variant_opaque; free(private->server); free(private->user); free(private->passwd); free(cib->cmds); free(private); free(cib); } } return rc; }
0
[ "CWE-399" ]
pacemaker
564f7cc2a51dcd2f28ab12a13394f31be5aa3c93
287,527,034,279,235,700,000,000,000,000,000,000,000
21
High: core: Internal tls api improvements for reuse with future LRMD tls backend.
virDomainDiskDefPostParse(virDomainDiskDefPtr disk, const virDomainDef *def, virDomainXMLOptionPtr xmlopt) { /* internal snapshots and config files are currently supported * only with rbd: */ if (virStorageSourceGetActualType(disk->src) != VIR_STORAGE_TYPE_NETWORK && disk->src->protocol != VIR_STORAGE_NET_PROTOCOL_RBD) { if (disk->src->snapshot) { virReportError(VIR_ERR_XML_ERROR, "%s", _("<snapshot> element is currently supported " "only with 'rbd' disks")); return -1; } if (disk->src->configFile) { virReportError(VIR_ERR_XML_ERROR, "%s", _("<config> element is currently supported " "only with 'rbd' disks")); return -1; } } if (disk->src->type == VIR_STORAGE_TYPE_NETWORK && disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_ISCSI && virDomainPostParseCheckISCSIPath(&disk->src->path) < 0) { return -1; } if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO && virDomainCheckVirtioOptions(disk->virtio) < 0) { return -1; } if (disk->src->type == VIR_STORAGE_TYPE_NVME) { if (disk->src->nvme->managed == VIR_TRISTATE_BOOL_ABSENT) disk->src->nvme->managed = VIR_TRISTATE_BOOL_YES; } if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && virDomainDiskDefAssignAddress(xmlopt, disk, def) < 0) { return -1; } virDomainDiskExpandGroupIoTune(disk, def); return 0; }
0
[ "CWE-212" ]
libvirt
a5b064bf4b17a9884d7d361733737fb614ad8979
75,721,943,555,755,730,000,000,000,000,000,000,000
48
conf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410 (v6.1.0-122-g3b076391be) we support http cookies. Since they may contain somewhat sensitive information we should not format them into the XML unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted. Reported-by: Han Han <[email protected]> Signed-off-by: Peter Krempa <[email protected]> Reviewed-by: Erik Skultety <[email protected]>
GF_Err gf_odf_delete_command(GF_ODCom *com) { switch (com->tag) { case GF_ODF_OD_UPDATE_TAG: return gf_odf_del_od_update((GF_ODUpdate *)com); case GF_ODF_OD_REMOVE_TAG: return gf_odf_del_od_remove((GF_ODRemove *)com); case GF_ODF_ESD_UPDATE_TAG: return gf_odf_del_esd_update((GF_ESDUpdate *)com); case GF_ODF_ESD_REMOVE_TAG: case GF_ODF_ESD_REMOVE_REF_TAG: return gf_odf_del_esd_remove((GF_ESDRemove *)com); #ifndef GPAC_MINIMAL_ODF case GF_ODF_IPMP_UPDATE_TAG: return gf_odf_del_ipmp_update((GF_IPMPUpdate *)com); case GF_ODF_IPMP_REMOVE_TAG: return gf_odf_del_ipmp_remove((GF_IPMPRemove *)com); default: return gf_odf_del_base_command((GF_BaseODCom *)com); #else default: return GF_NOT_SUPPORTED; #endif } }
0
[ "CWE-787" ]
gpac
4e56ad72ac1afb4e049a10f2d99e7512d7141f9d
256,766,581,020,560,270,000,000,000,000,000,000,000
28
fixed #2216
TEST(MessageCompressorManager, MessageSizeTooSmall) { auto registry = buildRegistry(); MessageCompressorManager compManager(&registry); auto badMessageBuffer = SharedBuffer::allocate(128); MsgData::View badMessage(badMessageBuffer.get()); badMessage.setId(1); badMessage.setResponseToMsgId(0); badMessage.setOperation(dbCompressed); badMessage.setLen(128); DataRangeCursor cursor(badMessage.data(), badMessage.data() + badMessage.dataLen()); cursor.writeAndAdvance<LittleEndian<int32_t>>(dbQuery); cursor.writeAndAdvance<LittleEndian<int32_t>>(-1); cursor.writeAndAdvance<LittleEndian<uint8_t>>(registry.getCompressor("noop")->getId()); auto status = compManager.decompressMessage(Message(badMessageBuffer), nullptr).getStatus(); ASSERT_NOT_OK(status); }
0
[ "CWE-697" ]
mongo
1411cf602a21e45a5ef42b6869c480eb420976ee
215,802,945,041,399,800,000,000,000,000,000,000,000
19
SERVER-43751 Recompute compressor manager message parameters
int i40e_free_virt_mem_d(struct i40e_hw *hw, struct i40e_virt_mem *mem) { /* it's ok to kfree a NULL pointer */ kfree(mem->va); mem->va = NULL; mem->size = 0; return 0; }
0
[ "CWE-400", "CWE-401" ]
linux
27d461333459d282ffa4a2bdb6b215a59d493a8f
2,117,515,854,631,201,800,000,000,000,000,000,000
9
i40e: prevent memory leak in i40e_setup_macvlans In i40e_setup_macvlans if i40e_setup_channel fails the allocated memory for ch should be released. Signed-off-by: Navid Emamdoost <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
bool st_select_lex::test_limit() { if (select_limit != 0) { my_error(ER_NOT_SUPPORTED_YET, MYF(0), "LIMIT & IN/ALL/ANY/SOME subquery"); return(1); } return(0); }
0
[ "CWE-476" ]
server
3a52569499e2f0c4d1f25db1e81617a9d9755400
275,532,722,449,001,560,000,000,000,000,000,000,000
10
MDEV-25636: Bug report: abortion in sql/sql_parse.cc:6294 The asserion failure was caused by this query select /*id=1*/ from t1 where col= ( select /*id=2*/ from ... where corr_cond1 union select /*id=4*/ from ... where corr_cond2) Here, - select with id=2 was correlated due to corr_cond1. - select with id=4 was initially correlated due to corr_cond2, but then the optimizer optimized away the correlation, making the select with id=4 uncorrelated. However, since select with id=2 remained correlated, the execution had to re-compute the whole UNION. When it tried to execute select with id=4, it hit an assertion (join buffer already free'd). This is because select with id=4 has freed its execution structures after it has been executed once. The select is uncorrelated, so it did not expect it would need to be executed for the second time. Fixed this by adding this logic in st_select_lex::optimize_unflattened_subqueries(): If a member of a UNION is correlated, mark all its members as correlated, so that they are prepared to be executed multiple times.
may_prefix_autoload(char_u *name) { if (SCRIPT_ID_VALID(current_sctx.sc_sid)) { scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); if (si->sn_autoload_prefix != NULL) { char_u *basename = name; size_t len; char_u *res; if (*name == K_SPECIAL) { char_u *p = vim_strchr(name, '_'); // skip over "<SNR>99_" if (p != NULL) basename = p + 1; } len = STRLEN(si->sn_autoload_prefix) + STRLEN(basename) + 2; res = alloc(len); if (res != NULL) { vim_snprintf((char *)res, len, "%s%s", si->sn_autoload_prefix, basename); return res; } } } return name; }
0
[ "CWE-122" ]
vim
2bdad6126778f907c0b98002bfebf0e611a3f5db
299,740,063,066,893,060,000,000,000,000,000,000,000
33
patch 8.2.4647: "source" can read past end of copied line Problem: "source" can read past end of copied line. Solution: Add a terminating NUL.
static void lru_maintainer_crawler_check(struct crawler_expired_data *cdata) { int i; static rel_time_t next_crawls[MAX_NUMBER_OF_SLAB_CLASSES]; static rel_time_t next_crawl_wait[MAX_NUMBER_OF_SLAB_CLASSES]; uint8_t todo[MAX_NUMBER_OF_SLAB_CLASSES]; memset(todo, 0, sizeof(uint8_t) * MAX_NUMBER_OF_SLAB_CLASSES); bool do_run = false; if (!cdata->crawl_complete) { return; } for (i = POWER_SMALLEST; i < MAX_NUMBER_OF_SLAB_CLASSES; i++) { crawlerstats_t *s = &cdata->crawlerstats[i]; /* We've not successfully kicked off a crawl yet. */ if (s->run_complete) { pthread_mutex_lock(&cdata->lock); int x; /* Should we crawl again? */ uint64_t possible_reclaims = s->seen - s->noexp; uint64_t available_reclaims = 0; /* Need to think we can free at least 1% of the items before * crawling. */ /* FIXME: Configurable? */ uint64_t low_watermark = (s->seen / 100) + 1; rel_time_t since_run = current_time - s->end_time; /* Don't bother if the payoff is too low. */ if (settings.verbose > 1) fprintf(stderr, "maint crawler[%d]: low_watermark: %llu, possible_reclaims: %llu, since_run: %u\n", i, (unsigned long long)low_watermark, (unsigned long long)possible_reclaims, (unsigned int)since_run); for (x = 0; x < 60; x++) { available_reclaims += s->histo[x]; if (available_reclaims > low_watermark) { if (next_crawl_wait[i] < (x * 60)) { next_crawl_wait[i] += 60; } else if (next_crawl_wait[i] >= 60) { next_crawl_wait[i] -= 60; } break; } } if (available_reclaims == 0) { next_crawl_wait[i] += 60; } if (next_crawl_wait[i] > MAX_MAINTCRAWL_WAIT) { next_crawl_wait[i] = MAX_MAINTCRAWL_WAIT; } next_crawls[i] = current_time + next_crawl_wait[i] + 5; if (settings.verbose > 1) fprintf(stderr, "maint crawler[%d]: next_crawl: %u, [%d] now: [%d]\n", i, next_crawl_wait[i], next_crawls[i], current_time); // Got our calculation, avoid running until next actual run. s->run_complete = false; pthread_mutex_unlock(&cdata->lock); } if (current_time > next_crawls[i]) { todo[i] = 1; do_run = true; next_crawls[i] = current_time + 5; // minimum retry wait. } } if (do_run) { lru_crawler_start(todo, 0, CRAWLER_EXPIRED, cdata, NULL, 0); } }
0
[ "CWE-190" ]
memcached
bd578fc34b96abe0f8d99c1409814a09f51ee71c
108,387,065,814,781,470,000,000,000,000,000,000,000
68
CVE reported by cisco talos
Http::ForwardClientCertType forwardClientCert() const override { return Http::ForwardClientCertType::Sanitize; }
0
[ "CWE-400" ]
envoy
dfddb529e914d794ac552e906b13d71233609bf7
233,294,546,197,080,570,000,000,000,000,000,000,000
3
listener: Add configurable accepted connection limits (#153) Add support for per-listener limits on accepted connections. Signed-off-by: Tony Allen <[email protected]>
static void test_bug56976() { MYSQL_STMT *stmt; MYSQL_BIND bind[1]; int rc; const char* query = "SELECT LENGTH(?)"; char *long_buffer; unsigned long i, packet_len = 256 * 1024L; unsigned long dos_len = 8 * 1024 * 1024L; DBUG_ENTER("test_bug56976"); myheader("test_bug56976"); stmt= mysql_stmt_init(mysql); check_stmt(stmt); rc= mysql_stmt_prepare(stmt, query, strlen(query)); check_execute(stmt, rc); memset(bind, 0, sizeof(bind)); bind[0].buffer_type = MYSQL_TYPE_TINY_BLOB; rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); long_buffer= (char*) my_malloc(packet_len, MYF(0)); DIE_UNLESS(long_buffer); memset(long_buffer, 'a', packet_len); for (i= 0; i < dos_len / packet_len; i++) { rc= mysql_stmt_send_long_data(stmt, 0, long_buffer, packet_len); check_execute(stmt, rc); } my_free(long_buffer); rc= mysql_stmt_execute(stmt); DIE_UNLESS(rc && mysql_stmt_errno(stmt) == ER_UNKNOWN_ERROR); mysql_stmt_close(stmt); DBUG_VOID_RETURN; }
0
[ "CWE-416" ]
mysql-server
4797ea0b772d5f4c5889bc552424132806f46e93
154,154,400,544,338,970,000,000,000,000,000,000,000
45
BUG#17512527: LIST HANDLING INCORRECT IN MYSQL_PRUNE_STMT_LIST() Analysis: --------- Invalid memory access maybe observed when using prepared statements if: a) The mysql client connection is lost after statement preparation is complete and b) There is at least one statement which is in initialized state but not prepared yet. When the client detects a closed connection, it calls end_server() to shutdown the connection. As part of the clean up, the mysql_prune_stmt_list() removes the statements which has transitioned beyond the initialized state and retains only the statements which are in a initialized state. During this processing, the initialized statements are moved from 'mysql->stmts' to a temporary 'pruned_list'. When moving the first 'INIT_DONE' element to the pruned_list, 'element->next' is set to NULL. Hence the rest of the list is never traversed and the statements which have transitioned beyond the initialized state are never invalidated. When the mysql_stmt_close() is called for the statement which is not invalidated; the statements list is updated in order to remove the statement. This would end up accessing freed memory(freed by the mysql_stmt_close() for a previous statement in the list). Fix: --- mysql_prune_stmt_list() called list_add() incorrectly to create a temporary list. The use case of list_add() is to add a single element to the front of the doubly linked list. mysql_prune_stmt_list() called list_add() by passing an entire list as the 'element'. mysql_prune_stmt_list() now uses list_delete() to remove the statement which has transitioned beyond the initialized phase. Thus the statement list would contain only elements where the the state of the statement is initialized. Note: Run the test with valgrind-mysqltest and leak-check=full option to see the invalid memory access.
static inline pte_t pte_mkold(pte_t pte) { return pte_clear_flags(pte, _PAGE_ACCESSED); }
0
[ "CWE-119", "CWE-787" ]
linux
027ef6c87853b0a9df53175063028edb4950d476
233,191,907,556,979,850,000,000,000,000,000,000,000
4
mm: thp: fix pmd_present for split_huge_page and PROT_NONE with THP In many places !pmd_present has been converted to pmd_none. For pmds that's equivalent and pmd_none is quicker so using pmd_none is better. However (unless we delete pmd_present) we should provide an accurate pmd_present too. This will avoid the risk of code thinking the pmd is non present because it's under __split_huge_page_map, see the pmd_mknotpresent there and the comment above it. If the page has been mprotected as PROT_NONE, it would also lead to a pmd_present false negative in the same way as the race with split_huge_page. Because the PSE bit stays on at all times (both during split_huge_page and when the _PAGE_PROTNONE bit get set), we could only check for the PSE bit, but checking the PROTNONE bit too is still good to remember pmd_present must always keep PROT_NONE into account. This explains a not reproducible BUG_ON that was seldom reported on the lists. The same issue is in pmd_large, it would go wrong with both PROT_NONE and if it races with split_huge_page. Signed-off-by: Andrea Arcangeli <[email protected]> Acked-by: Rik van Riel <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Mel Gorman <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
char *lxc_string_replace(const char *needle, const char *replacement, const char *haystack) { ssize_t len = -1, saved_len = -1; char *result = NULL; size_t replacement_len = strlen(replacement); size_t needle_len = strlen(needle); /* should be executed exactly twice */ while (len == -1 || result == NULL) { char *p; char *last_p; ssize_t part_len; if (len != -1) { result = calloc(1, len + 1); if (!result) return NULL; saved_len = len; } len = 0; for (last_p = (char *)haystack, p = strstr(last_p, needle); p; last_p = p, p = strstr(last_p, needle)) { part_len = (ssize_t)(p - last_p); if (result && part_len > 0) memcpy(&result[len], last_p, part_len); len += part_len; if (result && replacement_len > 0) memcpy(&result[len], replacement, replacement_len); len += replacement_len; p += needle_len; } part_len = strlen(last_p); if (result && part_len > 0) memcpy(&result[len], last_p, part_len); len += part_len; } /* make sure we did the same thing twice, * once for calculating length, the other * time for copying data */ if (saved_len != len) { free(result); return NULL; } /* make sure we didn't overwrite any buffer, * due to calloc the string should be 0-terminated */ if (result[len] != '\0') { free(result); return NULL; } return result; }
0
[ "CWE-417" ]
lxc
5eb45428b312e978fb9e294dde16efb14dd9fa4d
59,335,194,262,083,740,000,000,000,000,000,000,000
54
CVE 2018-6556: verify netns fd in lxc-user-nic Signed-off-by: Christian Brauner <[email protected]>
static int pf_detect(void) { struct pf_unit *pf = units; int k, unit; printk("%s: %s version %s, major %d, cluster %d, nice %d\n", name, name, PF_VERSION, major, cluster, nice); par_drv = pi_register_driver(name); if (!par_drv) { pr_err("failed to register %s driver\n", name); return -1; } k = 0; if (pf_drive_count == 0) { if (pi_init(pf->pi, 1, -1, -1, -1, -1, -1, pf_scratch, PI_PF, verbose, pf->name)) { if (!pf_probe(pf) && pf->disk) { pf->present = 1; k++; } else pi_release(pf->pi); } } else for (unit = 0; unit < PF_UNITS; unit++, pf++) { int *conf = *drives[unit]; if (!conf[D_PRT]) continue; if (pi_init(pf->pi, 0, conf[D_PRT], conf[D_MOD], conf[D_UNI], conf[D_PRO], conf[D_DLY], pf_scratch, PI_PF, verbose, pf->name)) { if (pf->disk && !pf_probe(pf)) { pf->present = 1; k++; } else pi_release(pf->pi); } } if (k) return 0; printk("%s: No ATAPI disk detected\n", name); for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) { blk_cleanup_queue(pf->disk->queue); pf->disk->queue = NULL; blk_mq_free_tag_set(&pf->tag_set); put_disk(pf->disk); } pi_unregister_driver(par_drv); return -1; }
1
[ "CWE-476", "CWE-125" ]
linux
58ccd2d31e502c37e108b285bf3d343eb00c235b
24,477,384,682,871,660,000,000,000,000,000,000,000
52
paride/pf: Fix potential NULL pointer dereference Syzkaller report this: pf: pf version 1.04, major 47, cluster 64, nice 0 pf: No ATAPI disk detected kasan: CONFIG_KASAN_INLINE enabled kasan: GPF could be caused by NULL-ptr deref or user memory access general protection fault: 0000 [#1] SMP KASAN PTI CPU: 0 PID: 9887 Comm: syz-executor.0 Tainted: G C 5.1.0-rc3+ #8 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 RIP: 0010:pf_init+0x7af/0x1000 [pf] Code: 46 77 d2 48 89 d8 48 c1 e8 03 80 3c 28 00 74 08 48 89 df e8 03 25 a6 d2 4c 8b 23 49 8d bc 24 80 05 00 00 48 89 f8 48 c1 e8 03 <80> 3c 28 00 74 05 e8 e6 24 a6 d2 49 8b bc 24 80 05 00 00 e8 79 34 RSP: 0018:ffff8881abcbf998 EFLAGS: 00010202 RAX: 00000000000000b0 RBX: ffffffffc1e4a8a8 RCX: ffffffffaec50788 RDX: 0000000000039b10 RSI: ffffc9000153c000 RDI: 0000000000000580 RBP: dffffc0000000000 R08: ffffed103ee44e59 R09: ffffed103ee44e59 R10: 0000000000000001 R11: ffffed103ee44e58 R12: 0000000000000000 R13: ffffffffc1e4b028 R14: 0000000000000000 R15: 0000000000000020 FS: 00007f1b78a91700(0000) GS:ffff8881f7200000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f6d72b207f8 CR3: 00000001d5790004 CR4: 00000000007606f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: ? 0xffffffffc1e50000 do_one_initcall+0xbc/0x47d init/main.c:901 do_init_module+0x1b5/0x547 kernel/module.c:3456 load_module+0x6405/0x8c10 kernel/module.c:3804 __do_sys_finit_module+0x162/0x190 kernel/module.c:3898 do_syscall_64+0x9f/0x450 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x462e99 Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f1b78a90c58 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 RAX: ffffffffffffffda RBX: 000000000073bf00 RCX: 0000000000462e99 RDX: 0000000000000000 RSI: 0000000020000180 RDI: 0000000000000003 RBP: 00007f1b78a90c70 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f1b78a916bc R13: 00000000004bcefa R14: 00000000006f6fb0 R15: 0000000000000004 Modules linked in: pf(+) paride gpio_tps65218 tps65218 i2c_cht_wc ati_remote dc395x act_meta_skbtcindex act_ife ife ecdh_generic rc_xbox_dvd sky81452_regulator v4l2_fwnode leds_blinkm snd_usb_hiface comedi(C) aes_ti slhc cfi_cmdset_0020 mtd cfi_util sx8654 mdio_gpio of_mdio fixed_phy mdio_bitbang libphy alcor_pci matrix_keymap hid_uclogic usbhid scsi_transport_fc videobuf2_v4l2 videobuf2_dma_sg snd_soc_pcm179x_spi snd_soc_pcm179x_codec i2c_demux_pinctrl mdev snd_indigodj isl6405 mii enc28j60 cmac adt7316_i2c(C) adt7316(C) fmc_trivial fmc nf_reject_ipv4 authenc rc_dtt200u rtc_ds1672 dvb_usb_dibusb_mc dvb_usb_dibusb_mc_common dib3000mc dibx000_common dvb_usb_dibusb_common dvb_usb dvb_core videobuf2_common videobuf2_vmalloc videobuf2_memops regulator_haptic adf7242 mac802154 ieee802154 s5h1409 da9034_ts snd_intel8x0m wmi cx24120 usbcore sdhci_cadence sdhci_pltfm sdhci mmc_core joydev i2c_algo_bit scsi_transport_iscsi iscsi_boot_sysfs ves1820 lockd grace nfs_acl auth_rpcgss sunrp c ip_vs snd_soc_adau7002 snd_cs4281 snd_rawmidi gameport snd_opl3_lib snd_seq_device snd_hwdep snd_ac97_codec ad7418 hid_primax hid snd_soc_cs4265 snd_soc_core snd_pcm_dmaengine snd_pcm snd_timer ac97_bus snd_compress snd soundcore ti_adc108s102 eeprom_93cx6 i2c_algo_pca mlxreg_hotplug st_pressure st_sensors industrialio_triggered_buffer kfifo_buf industrialio v4l2_common videodev media snd_soc_adau_utils rc_pinnacle_grey rc_core pps_gpio leds_lm3692x nandcore ledtrig_pattern iptable_security iptable_raw iptable_mangle iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 iptable_filter bpfilter ip6_vti ip_vti ip_gre ipip sit tunnel4 ip_tunnel hsr veth netdevsim vxcan batman_adv cfg80211 rfkill chnl_net caif nlmon dummy team bonding vcan bridge stp llc ip6_gre gre ip6_tunnel tunnel6 tun mousedev ppdev tpm kvm_intel kvm irqbypass crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel aesni_intel ide_pci_generic aes_x86_64 piix crypto_simd input_leds psmouse cryp td glue_helper ide_core intel_agp serio_raw intel_gtt agpgart ata_generic i2c_piix4 pata_acpi parport_pc parport rtc_cmos floppy sch_fq_codel ip_tables x_tables sha1_ssse3 sha1_generic ipv6 [last unloaded: paride] Dumping ftrace buffer: (ftrace buffer empty) ---[ end trace 7a818cf5f210d79e ]--- If alloc_disk fails in pf_init_units, pf->disk will be NULL, however in pf_detect and pf_exit, it's not check this before free.It may result a NULL pointer dereference. Also when register_blkdev failed, blk_cleanup_queue() and blk_mq_free_tag_set() should be called to free resources. Reported-by: Hulk Robot <[email protected]> Fixes: 6ce59025f118 ("paride/pf: cleanup queues when detection fails") Signed-off-by: YueHaibing <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
static int pxa3xx_gcu_open(struct inode *inode, struct file *file) { return 0; }
0
[ "CWE-190", "CWE-703" ]
linux
a09d2d00af53b43c6f11e6ab3cb58443c2cac8a7
156,132,745,627,799,280,000,000,000,000,000,000,000
4
video: fbdev: pxa3xx-gcu: Fix integer overflow in pxa3xx_gcu_write In pxa3xx_gcu_write, a count parameter of type size_t is passed to words of type int. Then, copy_from_user() may cause a heap overflow because it is used as the third argument of copy_from_user(). Signed-off-by: Hyunwoo Kim <[email protected]> Signed-off-by: Helge Deller <[email protected]>
static bool Equals(const std::vector<double> &one, const std::vector<double> &other) { if (one.size() != other.size()) return false; for (int i = 0; i < int(one.size()); ++i) { if (!TINYGLTF_DOUBLE_EQUAL(one[size_t(i)], other[size_t(i)])) return false; } return true; }
0
[ "CWE-20" ]
tinygltf
52ff00a38447f06a17eab1caa2cf0730a119c751
188,535,042,234,339,140,000,000,000,000,000,000,000
8
Do not expand file path since its not necessary for glTF asset path(URI) and for security reason(`wordexp`).
scanner_pop_binding_list (scanner_context_t *scanner_context_p) /**< scanner context */ { scanner_binding_list_t *binding_list_p = scanner_context_p->active_binding_list_p; JERRY_ASSERT (binding_list_p != NULL); scanner_binding_item_t *item_p = binding_list_p->items_p; scanner_binding_list_t *prev_binding_list_p = binding_list_p->prev_p; bool is_nested = binding_list_p->is_nested; scanner_free (binding_list_p, sizeof (scanner_binding_list_t)); scanner_context_p->active_binding_list_p = prev_binding_list_p; if (!is_nested) { while (item_p != NULL) { scanner_binding_item_t *next_p = item_p->next_p; JERRY_ASSERT (item_p->literal_p->type & (SCANNER_LITERAL_IS_LOCAL | SCANNER_LITERAL_IS_ARG)); scanner_free (item_p, sizeof (scanner_binding_item_t)); item_p = next_p; } return; } JERRY_ASSERT (prev_binding_list_p != NULL); while (item_p != NULL) { scanner_binding_item_t *next_p = item_p->next_p; item_p->next_p = prev_binding_list_p->items_p; prev_binding_list_p->items_p = item_p; item_p = next_p; } } /* scanner_pop_binding_list */
0
[ "CWE-416" ]
jerryscript
3bcd48f72d4af01d1304b754ef19fe1a02c96049
294,047,805,967,138,560,000,000,000,000,000,000,000
38
Improve parse_identifier (#4691) Ascii string length is no longer computed during string allocation. JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz [email protected]
MagickExport size_t GetQuantumExtent(const Image *image, const QuantumInfo *quantum_info,const QuantumType quantum_type) { size_t extent, packet_size; assert(quantum_info != (QuantumInfo *) NULL); assert(quantum_info->signature == MagickCoreSignature); packet_size=1; switch (quantum_type) { case GrayAlphaQuantum: packet_size=2; break; case IndexAlphaQuantum: packet_size=2; break; case RGBQuantum: packet_size=3; break; case BGRQuantum: packet_size=3; break; case RGBAQuantum: packet_size=4; break; case RGBOQuantum: packet_size=4; break; case BGRAQuantum: packet_size=4; break; case CMYKQuantum: packet_size=4; break; case CMYKAQuantum: packet_size=5; break; case CbYCrAQuantum: packet_size=4; break; case CbYCrQuantum: packet_size=3; break; case CbYCrYQuantum: packet_size=4; break; default: break; } extent=MagickMax(image->columns,image->rows); if (quantum_info->pack == MagickFalse) return((size_t) (packet_size*extent*((quantum_info->depth+7)/8))); return((size_t) ((packet_size*extent*quantum_info->depth+7)/8)); }
0
[ "CWE-125" ]
ImageMagick
430403b0029b37decf216d57f810899cab2317dd
57,242,389,715,798,330,000,000,000,000,000,000,000
31
https://github.com/ImageMagick/ImageMagick/issues/126
RGWOp* RGWHandler_REST_Service_S3Website::get_obj_op(bool get_data) { /** If we are in website mode, then it is explicitly impossible to run GET or * HEAD on the actual directory. We must convert the request to run on the * suffix object instead! */ RGWGetObj_ObjStore_S3Website* op = new RGWGetObj_ObjStore_S3Website; op->set_get_data(get_data); return op; }
0
[ "CWE-79" ]
ceph
8f90658c731499722d5f4393c8ad70b971d05f77
198,827,055,528,152,230,000,000,000,000,000,000,000
10
rgw: reject unauthenticated response-header actions Signed-off-by: Matt Benjamin <[email protected]> Reviewed-by: Casey Bodley <[email protected]> (cherry picked from commit d8dd5e513c0c62bbd7d3044d7e2eddcd897bd400)
static inline void __pipe_lock(struct pipe_inode_info *pipe) { mutex_lock_nested(&pipe->mutex, I_MUTEX_PARENT); }
0
[ "CWE-17" ]
linux
f0d1bec9d58d4c038d0ac958c9af82be6eb18045
306,369,544,561,748,520,000,000,000,000,000,000,000
4
new helper: copy_page_from_iter() parallel to copy_page_to_iter(). pipe_write() switched to it (and became ->write_iter()). Signed-off-by: Al Viro <[email protected]>
spell_read_aff(spellinfo_T *spin, char_u *fname) { FILE *fd; afffile_T *aff; char_u rline[MAXLINELEN]; char_u *line; char_u *pc = NULL; #define MAXITEMCNT 30 char_u *(items[MAXITEMCNT]); int itemcnt; char_u *p; int lnum = 0; affheader_T *cur_aff = NULL; int did_postpone_prefix = FALSE; int aff_todo = 0; hashtab_T *tp; char_u *low = NULL; char_u *fol = NULL; char_u *upp = NULL; int do_rep; int do_repsal; int do_sal; int do_mapline; int found_map = FALSE; hashitem_T *hi; int l; int compminlen = 0; // COMPOUNDMIN value int compsylmax = 0; // COMPOUNDSYLMAX value int compoptions = 0; // COMP_ flags int compmax = 0; // COMPOUNDWORDMAX value char_u *compflags = NULL; // COMPOUNDFLAG and COMPOUNDRULE // concatenated char_u *midword = NULL; // MIDWORD value char_u *syllable = NULL; // SYLLABLE value char_u *sofofrom = NULL; // SOFOFROM value char_u *sofoto = NULL; // SOFOTO value /* * Open the file. */ fd = mch_fopen((char *)fname, "r"); if (fd == NULL) { semsg(_(e_cant_open_file_str), fname); return NULL; } vim_snprintf((char *)IObuff, IOSIZE, _("Reading affix file %s..."), fname); spell_message(spin, IObuff); // Only do REP lines when not done in another .aff file already. do_rep = spin->si_rep.ga_len == 0; // Only do REPSAL lines when not done in another .aff file already. do_repsal = spin->si_repsal.ga_len == 0; // Only do SAL lines when not done in another .aff file already. do_sal = spin->si_sal.ga_len == 0; // Only do MAP lines when not done in another .aff file already. do_mapline = spin->si_map.ga_len == 0; /* * Allocate and init the afffile_T structure. */ aff = (afffile_T *)getroom(spin, sizeof(afffile_T), TRUE); if (aff == NULL) { fclose(fd); return NULL; } hash_init(&aff->af_pref); hash_init(&aff->af_suff); hash_init(&aff->af_comp); /* * Read all the lines in the file one by one. */ while (!vim_fgets(rline, MAXLINELEN, fd) && !got_int) { line_breakcheck(); ++lnum; // Skip comment lines. if (*rline == '#') continue; // Convert from "SET" to 'encoding' when needed. vim_free(pc); if (spin->si_conv.vc_type != CONV_NONE) { pc = string_convert(&spin->si_conv, rline, NULL); if (pc == NULL) { smsg(_("Conversion failure for word in %s line %d: %s"), fname, lnum, rline); continue; } line = pc; } else { pc = NULL; line = rline; } // Split the line up in white separated items. Put a NUL after each // item. itemcnt = 0; for (p = line; ; ) { while (*p != NUL && *p <= ' ') // skip white space and CR/NL ++p; if (*p == NUL) break; if (itemcnt == MAXITEMCNT) // too many items break; items[itemcnt++] = p; // A few items have arbitrary text argument, don't split them. if (itemcnt == 2 && spell_info_item(items[0])) while (*p >= ' ' || *p == TAB) // skip until CR/NL ++p; else while (*p > ' ') // skip until white space or CR/NL ++p; if (*p == NUL) break; *p++ = NUL; } // Handle non-empty lines. if (itemcnt > 0) { if (is_aff_rule(items, itemcnt, "SET", 2) && aff->af_enc == NULL) { // Setup for conversion from "ENC" to 'encoding'. aff->af_enc = enc_canonize(items[1]); if (aff->af_enc != NULL && !spin->si_ascii && convert_setup(&spin->si_conv, aff->af_enc, p_enc) == FAIL) smsg(_("Conversion in %s not supported: from %s to %s"), fname, aff->af_enc, p_enc); spin->si_conv.vc_fail = TRUE; } else if (is_aff_rule(items, itemcnt, "FLAG", 2) && aff->af_flagtype == AFT_CHAR) { if (STRCMP(items[1], "long") == 0) aff->af_flagtype = AFT_LONG; else if (STRCMP(items[1], "num") == 0) aff->af_flagtype = AFT_NUM; else if (STRCMP(items[1], "caplong") == 0) aff->af_flagtype = AFT_CAPLONG; else smsg(_("Invalid value for FLAG in %s line %d: %s"), fname, lnum, items[1]); if (aff->af_rare != 0 || aff->af_keepcase != 0 || aff->af_bad != 0 || aff->af_needaffix != 0 || aff->af_circumfix != 0 || aff->af_needcomp != 0 || aff->af_comproot != 0 || aff->af_nosuggest != 0 || compflags != NULL || aff->af_suff.ht_used > 0 || aff->af_pref.ht_used > 0) smsg(_("FLAG after using flags in %s line %d: %s"), fname, lnum, items[1]); } else if (spell_info_item(items[0])) { p = (char_u *)getroom(spin, (spin->si_info == NULL ? 0 : STRLEN(spin->si_info)) + STRLEN(items[0]) + STRLEN(items[1]) + 3, FALSE); if (p != NULL) { if (spin->si_info != NULL) { STRCPY(p, spin->si_info); STRCAT(p, "\n"); } STRCAT(p, items[0]); STRCAT(p, " "); STRCAT(p, items[1]); spin->si_info = p; } } else if (is_aff_rule(items, itemcnt, "MIDWORD", 2) && midword == NULL) { midword = getroom_save(spin, items[1]); } else if (is_aff_rule(items, itemcnt, "TRY", 2)) { // ignored, we look in the tree for what chars may appear } // TODO: remove "RAR" later else if ((is_aff_rule(items, itemcnt, "RAR", 2) || is_aff_rule(items, itemcnt, "RARE", 2)) && aff->af_rare == 0) { aff->af_rare = affitem2flag(aff->af_flagtype, items[1], fname, lnum); } // TODO: remove "KEP" later else if ((is_aff_rule(items, itemcnt, "KEP", 2) || is_aff_rule(items, itemcnt, "KEEPCASE", 2)) && aff->af_keepcase == 0) { aff->af_keepcase = affitem2flag(aff->af_flagtype, items[1], fname, lnum); } else if ((is_aff_rule(items, itemcnt, "BAD", 2) || is_aff_rule(items, itemcnt, "FORBIDDENWORD", 2)) && aff->af_bad == 0) { aff->af_bad = affitem2flag(aff->af_flagtype, items[1], fname, lnum); } else if (is_aff_rule(items, itemcnt, "NEEDAFFIX", 2) && aff->af_needaffix == 0) { aff->af_needaffix = affitem2flag(aff->af_flagtype, items[1], fname, lnum); } else if (is_aff_rule(items, itemcnt, "CIRCUMFIX", 2) && aff->af_circumfix == 0) { aff->af_circumfix = affitem2flag(aff->af_flagtype, items[1], fname, lnum); } else if (is_aff_rule(items, itemcnt, "NOSUGGEST", 2) && aff->af_nosuggest == 0) { aff->af_nosuggest = affitem2flag(aff->af_flagtype, items[1], fname, lnum); } else if ((is_aff_rule(items, itemcnt, "NEEDCOMPOUND", 2) || is_aff_rule(items, itemcnt, "ONLYINCOMPOUND", 2)) && aff->af_needcomp == 0) { aff->af_needcomp = affitem2flag(aff->af_flagtype, items[1], fname, lnum); } else if (is_aff_rule(items, itemcnt, "COMPOUNDROOT", 2) && aff->af_comproot == 0) { aff->af_comproot = affitem2flag(aff->af_flagtype, items[1], fname, lnum); } else if (is_aff_rule(items, itemcnt, "COMPOUNDFORBIDFLAG", 2) && aff->af_compforbid == 0) { aff->af_compforbid = affitem2flag(aff->af_flagtype, items[1], fname, lnum); if (aff->af_pref.ht_used > 0) smsg(_("Defining COMPOUNDFORBIDFLAG after PFX item may give wrong results in %s line %d"), fname, lnum); } else if (is_aff_rule(items, itemcnt, "COMPOUNDPERMITFLAG", 2) && aff->af_comppermit == 0) { aff->af_comppermit = affitem2flag(aff->af_flagtype, items[1], fname, lnum); if (aff->af_pref.ht_used > 0) smsg(_("Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in %s line %d"), fname, lnum); } else if (is_aff_rule(items, itemcnt, "COMPOUNDFLAG", 2) && compflags == NULL) { // Turn flag "c" into COMPOUNDRULE compatible string "c+", // "Na" into "Na+", "1234" into "1234+". p = getroom(spin, STRLEN(items[1]) + 2, FALSE); if (p != NULL) { STRCPY(p, items[1]); STRCAT(p, "+"); compflags = p; } } else if (is_aff_rule(items, itemcnt, "COMPOUNDRULES", 2)) { // We don't use the count, but do check that it's a number and // not COMPOUNDRULE mistyped. if (atoi((char *)items[1]) == 0) smsg(_("Wrong COMPOUNDRULES value in %s line %d: %s"), fname, lnum, items[1]); } else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2)) { // Don't use the first rule if it is a number. if (compflags != NULL || *skipdigits(items[1]) != NUL) { // Concatenate this string to previously defined ones, // using a slash to separate them. l = (int)STRLEN(items[1]) + 1; if (compflags != NULL) l += (int)STRLEN(compflags) + 1; p = getroom(spin, l, FALSE); if (p != NULL) { if (compflags != NULL) { STRCPY(p, compflags); STRCAT(p, "/"); } STRCAT(p, items[1]); compflags = p; } } } else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2) && compmax == 0) { compmax = atoi((char *)items[1]); if (compmax == 0) smsg(_("Wrong COMPOUNDWORDMAX value in %s line %d: %s"), fname, lnum, items[1]); } else if (is_aff_rule(items, itemcnt, "COMPOUNDMIN", 2) && compminlen == 0) { compminlen = atoi((char *)items[1]); if (compminlen == 0) smsg(_("Wrong COMPOUNDMIN value in %s line %d: %s"), fname, lnum, items[1]); } else if (is_aff_rule(items, itemcnt, "COMPOUNDSYLMAX", 2) && compsylmax == 0) { compsylmax = atoi((char *)items[1]); if (compsylmax == 0) smsg(_("Wrong COMPOUNDSYLMAX value in %s line %d: %s"), fname, lnum, items[1]); } else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDDUP", 1)) { compoptions |= COMP_CHECKDUP; } else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDREP", 1)) { compoptions |= COMP_CHECKREP; } else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDCASE", 1)) { compoptions |= COMP_CHECKCASE; } else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDTRIPLE", 1)) { compoptions |= COMP_CHECKTRIPLE; } else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 2)) { if (atoi((char *)items[1]) == 0) smsg(_("Wrong CHECKCOMPOUNDPATTERN value in %s line %d: %s"), fname, lnum, items[1]); } else if (is_aff_rule(items, itemcnt, "CHECKCOMPOUNDPATTERN", 3)) { garray_T *gap = &spin->si_comppat; int i; // Only add the couple if it isn't already there. for (i = 0; i < gap->ga_len - 1; i += 2) if (STRCMP(((char_u **)(gap->ga_data))[i], items[1]) == 0 && STRCMP(((char_u **)(gap->ga_data))[i + 1], items[2]) == 0) break; if (i >= gap->ga_len && ga_grow(gap, 2) == OK) { ((char_u **)(gap->ga_data))[gap->ga_len++] = getroom_save(spin, items[1]); ((char_u **)(gap->ga_data))[gap->ga_len++] = getroom_save(spin, items[2]); } } else if (is_aff_rule(items, itemcnt, "SYLLABLE", 2) && syllable == NULL) { syllable = getroom_save(spin, items[1]); } else if (is_aff_rule(items, itemcnt, "NOBREAK", 1)) { spin->si_nobreak = TRUE; } else if (is_aff_rule(items, itemcnt, "NOSPLITSUGS", 1)) { spin->si_nosplitsugs = TRUE; } else if (is_aff_rule(items, itemcnt, "NOCOMPOUNDSUGS", 1)) { spin->si_nocompoundsugs = TRUE; } else if (is_aff_rule(items, itemcnt, "NOSUGFILE", 1)) { spin->si_nosugfile = TRUE; } else if (is_aff_rule(items, itemcnt, "PFXPOSTPONE", 1)) { aff->af_pfxpostpone = TRUE; } else if (is_aff_rule(items, itemcnt, "IGNOREEXTRA", 1)) { aff->af_ignoreextra = TRUE; } else if ((STRCMP(items[0], "PFX") == 0 || STRCMP(items[0], "SFX") == 0) && aff_todo == 0 && itemcnt >= 4) { int lasti = 4; char_u key[AH_KEY_LEN]; if (*items[0] == 'P') tp = &aff->af_pref; else tp = &aff->af_suff; // Myspell allows the same affix name to be used multiple // times. The affix files that do this have an undocumented // "S" flag on all but the last block, thus we check for that // and store it in ah_follows. vim_strncpy(key, items[1], AH_KEY_LEN - 1); hi = hash_find(tp, key); if (!HASHITEM_EMPTY(hi)) { cur_aff = HI2AH(hi); if (cur_aff->ah_combine != (*items[2] == 'Y')) smsg(_("Different combining flag in continued affix block in %s line %d: %s"), fname, lnum, items[1]); if (!cur_aff->ah_follows) smsg(_("Duplicate affix in %s line %d: %s"), fname, lnum, items[1]); } else { // New affix letter. cur_aff = (affheader_T *)getroom(spin, sizeof(affheader_T), TRUE); if (cur_aff == NULL) break; cur_aff->ah_flag = affitem2flag(aff->af_flagtype, items[1], fname, lnum); if (cur_aff->ah_flag == 0 || STRLEN(items[1]) >= AH_KEY_LEN) break; if (cur_aff->ah_flag == aff->af_bad || cur_aff->ah_flag == aff->af_rare || cur_aff->ah_flag == aff->af_keepcase || cur_aff->ah_flag == aff->af_needaffix || cur_aff->ah_flag == aff->af_circumfix || cur_aff->ah_flag == aff->af_nosuggest || cur_aff->ah_flag == aff->af_needcomp || cur_aff->ah_flag == aff->af_comproot) smsg(_("Affix also used for BAD/RARE/KEEPCASE/NEEDAFFIX/NEEDCOMPOUND/NOSUGGEST in %s line %d: %s"), fname, lnum, items[1]); STRCPY(cur_aff->ah_key, items[1]); hash_add(tp, cur_aff->ah_key); cur_aff->ah_combine = (*items[2] == 'Y'); } // Check for the "S" flag, which apparently means that another // block with the same affix name is following. if (itemcnt > lasti && STRCMP(items[lasti], "S") == 0) { ++lasti; cur_aff->ah_follows = TRUE; } else cur_aff->ah_follows = FALSE; // Myspell allows extra text after the item, but that might // mean mistakes go unnoticed. Require a comment-starter. if (itemcnt > lasti && *items[lasti] != '#') smsg(_(e_afftrailing), fname, lnum, items[lasti]); if (STRCMP(items[2], "Y") != 0 && STRCMP(items[2], "N") != 0) smsg(_("Expected Y or N in %s line %d: %s"), fname, lnum, items[2]); if (*items[0] == 'P' && aff->af_pfxpostpone) { if (cur_aff->ah_newID == 0) { // Use a new number in the .spl file later, to be able // to handle multiple .aff files. check_renumber(spin); cur_aff->ah_newID = ++spin->si_newprefID; // We only really use ah_newID if the prefix is // postponed. We know that only after handling all // the items. did_postpone_prefix = FALSE; } else // Did use the ID in a previous block. did_postpone_prefix = TRUE; } aff_todo = atoi((char *)items[3]); } else if ((STRCMP(items[0], "PFX") == 0 || STRCMP(items[0], "SFX") == 0) && aff_todo > 0 && STRCMP(cur_aff->ah_key, items[1]) == 0 && itemcnt >= 5) { affentry_T *aff_entry; int upper = FALSE; int lasti = 5; // Myspell allows extra text after the item, but that might // mean mistakes go unnoticed. Require a comment-starter, // unless IGNOREEXTRA is used. Hunspell uses a "-" item. if (itemcnt > lasti && !aff->af_ignoreextra && *items[lasti] != '#' && (STRCMP(items[lasti], "-") != 0 || itemcnt != lasti + 1)) smsg(_(e_afftrailing), fname, lnum, items[lasti]); // New item for an affix letter. --aff_todo; aff_entry = (affentry_T *)getroom(spin, sizeof(affentry_T), TRUE); if (aff_entry == NULL) break; if (STRCMP(items[2], "0") != 0) aff_entry->ae_chop = getroom_save(spin, items[2]); if (STRCMP(items[3], "0") != 0) { aff_entry->ae_add = getroom_save(spin, items[3]); // Recognize flags on the affix: abcd/XYZ aff_entry->ae_flags = vim_strchr(aff_entry->ae_add, '/'); if (aff_entry->ae_flags != NULL) { *aff_entry->ae_flags++ = NUL; aff_process_flags(aff, aff_entry); } } // Don't use an affix entry with non-ASCII characters when // "spin->si_ascii" is TRUE. if (!spin->si_ascii || !(has_non_ascii(aff_entry->ae_chop) || has_non_ascii(aff_entry->ae_add))) { aff_entry->ae_next = cur_aff->ah_first; cur_aff->ah_first = aff_entry; if (STRCMP(items[4], ".") != 0) { char_u buf[MAXLINELEN]; aff_entry->ae_cond = getroom_save(spin, items[4]); if (*items[0] == 'P') sprintf((char *)buf, "^%s", items[4]); else sprintf((char *)buf, "%s$", items[4]); aff_entry->ae_prog = vim_regcomp(buf, RE_MAGIC + RE_STRING + RE_STRICT); if (aff_entry->ae_prog == NULL) smsg(_("Broken condition in %s line %d: %s"), fname, lnum, items[4]); } // For postponed prefixes we need an entry in si_prefcond // for the condition. Use an existing one if possible. // Can't be done for an affix with flags, ignoring // COMPOUNDFORBIDFLAG and COMPOUNDPERMITFLAG. if (*items[0] == 'P' && aff->af_pfxpostpone && aff_entry->ae_flags == NULL) { // When the chop string is one lower-case letter and // the add string ends in the upper-case letter we set // the "upper" flag, clear "ae_chop" and remove the // letters from "ae_add". The condition must either // be empty or start with the same letter. if (aff_entry->ae_chop != NULL && aff_entry->ae_add != NULL && aff_entry->ae_chop[(*mb_ptr2len)( aff_entry->ae_chop)] == NUL) { int c, c_up; c = PTR2CHAR(aff_entry->ae_chop); c_up = SPELL_TOUPPER(c); if (c_up != c && (aff_entry->ae_cond == NULL || PTR2CHAR(aff_entry->ae_cond) == c)) { p = aff_entry->ae_add + STRLEN(aff_entry->ae_add); MB_PTR_BACK(aff_entry->ae_add, p); if (PTR2CHAR(p) == c_up) { upper = TRUE; aff_entry->ae_chop = NULL; *p = NUL; // The condition is matched with the // actual word, thus must check for the // upper-case letter. if (aff_entry->ae_cond != NULL) { char_u buf[MAXLINELEN]; if (has_mbyte) { onecap_copy(items[4], buf, TRUE); aff_entry->ae_cond = getroom_save( spin, buf); } else *aff_entry->ae_cond = c_up; if (aff_entry->ae_cond != NULL) { sprintf((char *)buf, "^%s", aff_entry->ae_cond); vim_regfree(aff_entry->ae_prog); aff_entry->ae_prog = vim_regcomp( buf, RE_MAGIC + RE_STRING); } } } } } if (aff_entry->ae_chop == NULL && aff_entry->ae_flags == NULL) { int idx; char_u **pp; int n; // Find a previously used condition. for (idx = spin->si_prefcond.ga_len - 1; idx >= 0; --idx) { p = ((char_u **)spin->si_prefcond.ga_data)[idx]; if (str_equal(p, aff_entry->ae_cond)) break; } if (idx < 0 && ga_grow(&spin->si_prefcond, 1) == OK) { // Not found, add a new condition. idx = spin->si_prefcond.ga_len++; pp = ((char_u **)spin->si_prefcond.ga_data) + idx; if (aff_entry->ae_cond == NULL) *pp = NULL; else *pp = getroom_save(spin, aff_entry->ae_cond); } // Add the prefix to the prefix tree. if (aff_entry->ae_add == NULL) p = (char_u *)""; else p = aff_entry->ae_add; // PFX_FLAGS is a negative number, so that // tree_add_word() knows this is the prefix tree. n = PFX_FLAGS; if (!cur_aff->ah_combine) n |= WFP_NC; if (upper) n |= WFP_UP; if (aff_entry->ae_comppermit) n |= WFP_COMPPERMIT; if (aff_entry->ae_compforbid) n |= WFP_COMPFORBID; tree_add_word(spin, p, spin->si_prefroot, n, idx, cur_aff->ah_newID); did_postpone_prefix = TRUE; } // Didn't actually use ah_newID, backup si_newprefID. if (aff_todo == 0 && !did_postpone_prefix) { --spin->si_newprefID; cur_aff->ah_newID = 0; } } } } else if (is_aff_rule(items, itemcnt, "FOL", 2) && fol == NULL) { fol = vim_strsave(items[1]); } else if (is_aff_rule(items, itemcnt, "LOW", 2) && low == NULL) { low = vim_strsave(items[1]); } else if (is_aff_rule(items, itemcnt, "UPP", 2) && upp == NULL) { upp = vim_strsave(items[1]); } else if (is_aff_rule(items, itemcnt, "REP", 2) || is_aff_rule(items, itemcnt, "REPSAL", 2)) { // Ignore REP/REPSAL count if (!isdigit(*items[1])) smsg(_("Expected REP(SAL) count in %s line %d"), fname, lnum); } else if ((STRCMP(items[0], "REP") == 0 || STRCMP(items[0], "REPSAL") == 0) && itemcnt >= 3) { // REP/REPSAL item // Myspell ignores extra arguments, we require it starts with // # to detect mistakes. if (itemcnt > 3 && items[3][0] != '#') smsg(_(e_afftrailing), fname, lnum, items[3]); if (items[0][3] == 'S' ? do_repsal : do_rep) { // Replace underscore with space (can't include a space // directly). for (p = items[1]; *p != NUL; MB_PTR_ADV(p)) if (*p == '_') *p = ' '; for (p = items[2]; *p != NUL; MB_PTR_ADV(p)) if (*p == '_') *p = ' '; add_fromto(spin, items[0][3] == 'S' ? &spin->si_repsal : &spin->si_rep, items[1], items[2]); } } else if (is_aff_rule(items, itemcnt, "MAP", 2)) { // MAP item or count if (!found_map) { // First line contains the count. found_map = TRUE; if (!isdigit(*items[1])) smsg(_("Expected MAP count in %s line %d"), fname, lnum); } else if (do_mapline) { int c; // Check that every character appears only once. for (p = items[1]; *p != NUL; ) { c = mb_ptr2char_adv(&p); if ((spin->si_map.ga_len > 0 && vim_strchr(spin->si_map.ga_data, c) != NULL) || vim_strchr(p, c) != NULL) smsg(_("Duplicate character in MAP in %s line %d"), fname, lnum); } // We simply concatenate all the MAP strings, separated by // slashes. ga_concat(&spin->si_map, items[1]); ga_append(&spin->si_map, '/'); } } // Accept "SAL from to" and "SAL from to #comment". else if (is_aff_rule(items, itemcnt, "SAL", 3)) { if (do_sal) { // SAL item (sounds-a-like) // Either one of the known keys or a from-to pair. if (STRCMP(items[1], "followup") == 0) spin->si_followup = sal_to_bool(items[2]); else if (STRCMP(items[1], "collapse_result") == 0) spin->si_collapse = sal_to_bool(items[2]); else if (STRCMP(items[1], "remove_accents") == 0) spin->si_rem_accents = sal_to_bool(items[2]); else // when "to" is "_" it means empty add_fromto(spin, &spin->si_sal, items[1], STRCMP(items[2], "_") == 0 ? (char_u *)"" : items[2]); } } else if (is_aff_rule(items, itemcnt, "SOFOFROM", 2) && sofofrom == NULL) { sofofrom = getroom_save(spin, items[1]); } else if (is_aff_rule(items, itemcnt, "SOFOTO", 2) && sofoto == NULL) { sofoto = getroom_save(spin, items[1]); } else if (STRCMP(items[0], "COMMON") == 0) { int i; for (i = 1; i < itemcnt; ++i) { if (HASHITEM_EMPTY(hash_find(&spin->si_commonwords, items[i]))) { p = vim_strsave(items[i]); if (p == NULL) break; hash_add(&spin->si_commonwords, p); } } } else smsg(_("Unrecognized or duplicate item in %s line %d: %s"), fname, lnum, items[0]); } } if (fol != NULL || low != NULL || upp != NULL) { if (spin->si_clear_chartab) { // Clear the char type tables, don't want to use any of the // currently used spell properties. init_spell_chartab(); spin->si_clear_chartab = FALSE; } /* * Don't write a word table for an ASCII file, so that we don't check * for conflicts with a word table that matches 'encoding'. * Don't write one for utf-8 either, we use utf_*() and * mb_get_class(), the list of chars in the file will be incomplete. */ if (!spin->si_ascii && !enc_utf8) { if (fol == NULL || low == NULL || upp == NULL) smsg(_("Missing FOL/LOW/UPP line in %s"), fname); else (void)set_spell_chartab(fol, low, upp); } vim_free(fol); vim_free(low); vim_free(upp); } // Use compound specifications of the .aff file for the spell info. if (compmax != 0) { aff_check_number(spin->si_compmax, compmax, "COMPOUNDWORDMAX"); spin->si_compmax = compmax; } if (compminlen != 0) { aff_check_number(spin->si_compminlen, compminlen, "COMPOUNDMIN"); spin->si_compminlen = compminlen; } if (compsylmax != 0) { if (syllable == NULL) smsg(_("COMPOUNDSYLMAX used without SYLLABLE")); aff_check_number(spin->si_compsylmax, compsylmax, "COMPOUNDSYLMAX"); spin->si_compsylmax = compsylmax; } if (compoptions != 0) { aff_check_number(spin->si_compoptions, compoptions, "COMPOUND options"); spin->si_compoptions |= compoptions; } if (compflags != NULL) process_compflags(spin, aff, compflags); // Check that we didn't use too many renumbered flags. if (spin->si_newcompID < spin->si_newprefID) { if (spin->si_newcompID == 127 || spin->si_newcompID == 255) msg(_("Too many postponed prefixes")); else if (spin->si_newprefID == 0 || spin->si_newprefID == 127) msg(_("Too many compound flags")); else msg(_("Too many postponed prefixes and/or compound flags")); } if (syllable != NULL) { aff_check_string(spin->si_syllable, syllable, "SYLLABLE"); spin->si_syllable = syllable; } if (sofofrom != NULL || sofoto != NULL) { if (sofofrom == NULL || sofoto == NULL) smsg(_("Missing SOFO%s line in %s"), sofofrom == NULL ? "FROM" : "TO", fname); else if (spin->si_sal.ga_len > 0) smsg(_("Both SAL and SOFO lines in %s"), fname); else { aff_check_string(spin->si_sofofr, sofofrom, "SOFOFROM"); aff_check_string(spin->si_sofoto, sofoto, "SOFOTO"); spin->si_sofofr = sofofrom; spin->si_sofoto = sofoto; } } if (midword != NULL) { aff_check_string(spin->si_midword, midword, "MIDWORD"); spin->si_midword = midword; } vim_free(pc); fclose(fd); return aff; }
0
[ "CWE-787" ]
vim
7c824682d2028432ee082703ef0ab399867a089b
278,598,451,212,993,380,000,000,000,000,000,000,000
922
patch 8.2.4919: can add invalid bytes with :spellgood Problem: Can add invalid bytes with :spellgood. Solution: Check for a valid word string.
has_column_privilege_id_name_name(PG_FUNCTION_ARGS) { Oid roleid = PG_GETARG_OID(0); text *tablename = PG_GETARG_TEXT_P(1); text *column = PG_GETARG_TEXT_P(2); text *priv_type_text = PG_GETARG_TEXT_P(3); Oid tableoid; AttrNumber colattnum; AclMode mode; int privresult; tableoid = convert_table_name(tablename); colattnum = convert_column_name(tableoid, column); mode = convert_column_priv_string(priv_type_text); privresult = column_privilege_check(tableoid, colattnum, roleid, mode); if (privresult < 0) PG_RETURN_NULL(); PG_RETURN_BOOL(privresult); }
0
[ "CWE-264" ]
postgres
fea164a72a7bfd50d77ba5fb418d357f8f2bb7d0
81,481,417,430,108,840,000,000,000,000,000,000,000
20
Shore up ADMIN OPTION restrictions. Granting a role without ADMIN OPTION is supposed to prevent the grantee from adding or removing members from the granted role. Issuing SET ROLE before the GRANT bypassed that, because the role itself had an implicit right to add or remove members. Plug that hole by recognizing that implicit right only when the session user matches the current role. Additionally, do not recognize it during a security-restricted operation or during execution of a SECURITY DEFINER function. The restriction on SECURITY DEFINER is not security-critical. However, it seems best for a user testing his own SECURITY DEFINER function to see the same behavior others will see. Back-patch to 8.4 (all supported versions). The SQL standards do not conflate roles and users as PostgreSQL does; only SQL roles have members, and only SQL users initiate sessions. An application using PostgreSQL users and roles as SQL users and roles will never attempt to grant membership in the role that is the session user, so the implicit right to add or remove members will never arise. The security impact was mostly that a role member could revoke access from others, contrary to the wishes of his own grantor. Unapproved role member additions are less notable, because the member can still largely achieve that by creating a view or a SECURITY DEFINER function. Reviewed by Andres Freund and Tom Lane. Reported, independently, by Jonas Sundman and Noah Misch. Security: CVE-2014-0060
R_API RList *r_buf_nonempty_list(RBuffer *b) { return b->methods->nonempty_list? b->methods->nonempty_list (b): NULL; }
0
[ "CWE-400", "CWE-703" ]
radare2
634b886e84a5c568d243e744becc6b3223e089cf
48,221,939,246,517,920,000,000,000,000,000,000,000
3
Fix DoS in PE/QNX/DYLDCACHE/PSX parsers ##crash * Reported by lazymio * Reproducer: AAA4AAAAAB4=
static int handle_NPP_Print(rpc_connection_t *connection) { D(bug("handle_NPP_Print\n")); PluginInstance *plugin; NPPrint printInfo; uint32_t platform_print_id; int error = rpc_method_get_args(connection, RPC_TYPE_NPW_PLUGIN_INSTANCE, &plugin, RPC_TYPE_UINT32, &platform_print_id, RPC_TYPE_NP_PRINT, &printInfo, RPC_TYPE_INVALID); if (error != RPC_ERROR_NO_ERROR) { npw_perror("NPP_Print() get args", error); return error; } // reconstruct printer info NPPrintCallbackStruct printer; printer.type = NP_PRINT; printer.fp = platform_print_id ? tmpfile() : NULL; switch (printInfo.mode) { case NP_FULL: printInfo.print.fullPrint.platformPrint = &printer; break; case NP_EMBED: printInfo.print.embedPrint.platformPrint = &printer; // XXX the window ID is unlikely to work here as is. The NPWindow // is probably only used as a bounding box? create_window_attributes(printInfo.print.embedPrint.window.ws_info); break; } g_NPP_Print(PLUGIN_INSTANCE_NPP(plugin), &printInfo); // send back the printed data if (printer.fp) { long file_size = ftell(printer.fp); D(bug(" writeback data [%d bytes]\n", file_size)); rewind(printer.fp); if (file_size > 0) { NPPrintData printData; const int printDataMaxSize = sizeof(printData.data); int n = file_size / printDataMaxSize; while (--n >= 0) { printData.size = printDataMaxSize; if (fread(&printData.data, sizeof(printData.data), 1, printer.fp) != 1) { npw_printf("ERROR: unexpected end-of-file or error condition in NPP_Print\n"); break; } npw_plugin_instance_ref(plugin); invoke_NPN_PrintData(plugin, platform_print_id, &printData); npw_plugin_instance_unref(plugin); } printData.size = file_size % printDataMaxSize; if (fread(&printData.data, printData.size, 1, printer.fp) != 1) npw_printf("ERROR: unexpected end-of-file or error condition in NPP_Print\n"); npw_plugin_instance_ref(plugin); invoke_NPN_PrintData(plugin, platform_print_id, &printData); npw_plugin_instance_unref(plugin); } fclose(printer.fp); } if (printInfo.mode == NP_EMBED) { NPWindow *window = &printInfo.print.embedPrint.window; if (window->ws_info) { destroy_window_attributes(window->ws_info); window->ws_info = NULL; } } uint32_t plugin_printed = FALSE; if (printInfo.mode == NP_FULL) plugin_printed = printInfo.print.fullPrint.pluginPrinted; return rpc_method_send_reply(connection, RPC_TYPE_BOOLEAN, plugin_printed, RPC_TYPE_INVALID); }
0
[ "CWE-264" ]
nspluginwrapper
7e4ab8e1189846041f955e6c83f72bc1624e7a98
244,477,791,854,920,400,000,000,000,000,000,000,000
78
Support all the new variables added
SSL_CIPHER *ssl3_get_cipher(unsigned int u) { if (u < SSL3_NUM_CIPHERS) return(&(ssl3_ciphers[SSL3_NUM_CIPHERS-1-u])); else return(NULL); }
0
[]
openssl
8671b898609777c95aedf33743419a523874e6e8
75,853,330,383,608,070,000,000,000,000,000,000,000
7
Memory saving patch.
static void svm_set_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg) { struct vcpu_svm *svm = to_svm(vcpu); struct vmcb_seg *s = svm_seg(vcpu, seg); s->base = var->base; s->limit = var->limit; s->selector = var->selector; if (var->unusable) s->attrib = 0; else { s->attrib = (var->type & SVM_SELECTOR_TYPE_MASK); s->attrib |= (var->s & 1) << SVM_SELECTOR_S_SHIFT; s->attrib |= (var->dpl & 3) << SVM_SELECTOR_DPL_SHIFT; s->attrib |= (var->present & 1) << SVM_SELECTOR_P_SHIFT; s->attrib |= (var->avl & 1) << SVM_SELECTOR_AVL_SHIFT; s->attrib |= (var->l & 1) << SVM_SELECTOR_L_SHIFT; s->attrib |= (var->db & 1) << SVM_SELECTOR_DB_SHIFT; s->attrib |= (var->g & 1) << SVM_SELECTOR_G_SHIFT; } /* * This is always accurate, except if SYSRET returned to a segment * with SS.DPL != 3. Intel does not have this quirk, and always * forces SS.DPL to 3 on sysret, so we ignore that case; fixing it * would entail passing the CPL to userspace and back. */ if (seg == VCPU_SREG_SS) svm->vmcb->save.cpl = (s->attrib >> SVM_SELECTOR_DPL_SHIFT) & 3; mark_dirty(svm->vmcb, VMCB_SEG); }
0
[]
kvm
854e8bb1aa06c578c2c9145fa6bfe3680ef63b23
96,058,137,238,601,950,000,000,000,000,000,000,000
33
KVM: x86: Check non-canonical addresses upon WRMSR Upon WRMSR, the CPU should inject #GP if a non-canonical value (address) is written to certain MSRs. The behavior is "almost" identical for AMD and Intel (ignoring MSRs that are not implemented in either architecture since they would anyhow #GP). However, IA32_SYSENTER_ESP and IA32_SYSENTER_EIP cause #GP if non-canonical address is written on Intel but not on AMD (which ignores the top 32-bits). Accordingly, this patch injects a #GP on the MSRs which behave identically on Intel and AMD. To eliminate the differences between the architecutres, the value which is written to IA32_SYSENTER_ESP and IA32_SYSENTER_EIP is turned to canonical value before writing instead of injecting a #GP. Some references from Intel and AMD manuals: According to Intel SDM description of WRMSR instruction #GP is expected on WRMSR "If the source register contains a non-canonical address and ECX specifies one of the following MSRs: IA32_DS_AREA, IA32_FS_BASE, IA32_GS_BASE, IA32_KERNEL_GS_BASE, IA32_LSTAR, IA32_SYSENTER_EIP, IA32_SYSENTER_ESP." According to AMD manual instruction manual: LSTAR/CSTAR (SYSCALL): "The WRMSR instruction loads the target RIP into the LSTAR and CSTAR registers. If an RIP written by WRMSR is not in canonical form, a general-protection exception (#GP) occurs." IA32_GS_BASE and IA32_FS_BASE (WRFSBASE/WRGSBASE): "The address written to the base field must be in canonical form or a #GP fault will occur." IA32_KERNEL_GS_BASE (SWAPGS): "The address stored in the KernelGSbase MSR must be in canonical form." This patch fixes CVE-2014-3610. Cc: [email protected] Signed-off-by: Nadav Amit <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
static int lang_run_file(RCore *core, RLang *lang, const char *file) { r_core_sysenv_begin (core, NULL); return r_lang_run_file (core->lang, file); }
0
[ "CWE-78" ]
radare2
dd739f5a45b3af3d1f65f00fe19af1dbfec7aea7
289,083,185,711,954,130,000,000,000,000,000,000,000
4
Fix #14990 - multiple quoted command parsing issue ##core > "?e hello""?e world" hello world" > "?e hello";"?e world" hello world
static struct mount *clone_mnt(struct mount *old, struct dentry *root, int flag) { struct super_block *sb = old->mnt.mnt_sb; struct mount *mnt; int err; mnt = alloc_vfsmnt(old->mnt_devname); if (!mnt) return ERR_PTR(-ENOMEM); if (flag & (CL_SLAVE | CL_PRIVATE | CL_SHARED_TO_SLAVE)) mnt->mnt_group_id = 0; /* not a peer of original */ else mnt->mnt_group_id = old->mnt_group_id; if ((flag & CL_MAKE_SHARED) && !mnt->mnt_group_id) { err = mnt_alloc_group_id(mnt); if (err) goto out_free; } mnt->mnt.mnt_flags = old->mnt.mnt_flags & ~(MNT_WRITE_HOLD|MNT_MARKED); /* Don't allow unprivileged users to change mount flags */ if (flag & CL_UNPRIVILEGED) { mnt->mnt.mnt_flags |= MNT_LOCK_ATIME; if (mnt->mnt.mnt_flags & MNT_READONLY) mnt->mnt.mnt_flags |= MNT_LOCK_READONLY; if (mnt->mnt.mnt_flags & MNT_NODEV) mnt->mnt.mnt_flags |= MNT_LOCK_NODEV; if (mnt->mnt.mnt_flags & MNT_NOSUID) mnt->mnt.mnt_flags |= MNT_LOCK_NOSUID; if (mnt->mnt.mnt_flags & MNT_NOEXEC) mnt->mnt.mnt_flags |= MNT_LOCK_NOEXEC; } /* Don't allow unprivileged users to reveal what is under a mount */ if ((flag & CL_UNPRIVILEGED) && list_empty(&old->mnt_expire)) mnt->mnt.mnt_flags |= MNT_LOCKED; atomic_inc(&sb->s_active); mnt->mnt.mnt_sb = sb; mnt->mnt.mnt_root = dget(root); mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_parent = mnt; lock_mount_hash(); list_add_tail(&mnt->mnt_instance, &sb->s_mounts); unlock_mount_hash(); if ((flag & CL_SLAVE) || ((flag & CL_SHARED_TO_SLAVE) && IS_MNT_SHARED(old))) { list_add(&mnt->mnt_slave, &old->mnt_slave_list); mnt->mnt_master = old; CLEAR_MNT_SHARED(mnt); } else if (!(flag & CL_PRIVATE)) { if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(old)) list_add(&mnt->mnt_share, &old->mnt_share); if (IS_MNT_SLAVE(old)) list_add(&mnt->mnt_slave, &old->mnt_slave); mnt->mnt_master = old->mnt_master; } if (flag & CL_MAKE_SHARED) set_mnt_shared(mnt); /* stick the duplicate mount on the same expiry list * as the original if that was on one */ if (flag & CL_EXPIRE) { if (!list_empty(&old->mnt_expire)) list_add(&mnt->mnt_expire, &old->mnt_expire); } return mnt; out_free: mnt_free_id(mnt); free_vfsmnt(mnt); return ERR_PTR(err); }
0
[ "CWE-269" ]
user-namespace
9566d6742852c527bf5af38af5cbb878dad75705
236,872,032,172,955,300,000,000,000,000,000,000,000
82
mnt: Correct permission checks in do_remount While invesgiating the issue where in "mount --bind -oremount,ro ..." would result in later "mount --bind -oremount,rw" succeeding even if the mount started off locked I realized that there are several additional mount flags that should be locked and are not. In particular MNT_NOSUID, MNT_NODEV, MNT_NOEXEC, and the atime flags in addition to MNT_READONLY should all be locked. These flags are all per superblock, can all be changed with MS_BIND, and should not be changable if set by a more privileged user. The following additions to the current logic are added in this patch. - nosuid may not be clearable by a less privileged user. - nodev may not be clearable by a less privielged user. - noexec may not be clearable by a less privileged user. - atime flags may not be changeable by a less privileged user. The logic with atime is that always setting atime on access is a global policy and backup software and auditing software could break if atime bits are not updated (when they are configured to be updated), and serious performance degradation could result (DOS attack) if atime updates happen when they have been explicitly disabled. Therefore an unprivileged user should not be able to mess with the atime bits set by a more privileged user. The additional restrictions are implemented with the addition of MNT_LOCK_NOSUID, MNT_LOCK_NODEV, MNT_LOCK_NOEXEC, and MNT_LOCK_ATIME mnt flags. Taken together these changes and the fixes for MNT_LOCK_READONLY should make it safe for an unprivileged user to create a user namespace and to call "mount --bind -o remount,... ..." without the danger of mount flags being changed maliciously. Cc: [email protected] Acked-by: Serge E. Hallyn <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
static struct uvc_format_desc *uvc_format_by_guid(const __u8 guid[16]) { unsigned int len = ARRAY_SIZE(uvc_fmts); unsigned int i; for (i = 0; i < len; ++i) { if (memcmp(guid, uvc_fmts[i].guid, 16) == 0) return &uvc_fmts[i]; } return NULL; }
0
[ "CWE-120" ]
linux-2.6
233548a2fd934a0220db8b1521c0bc88c82e5e53
94,089,433,778,230,930,000,000,000,000,000,000,000
12
V4L/DVB (8207): uvcvideo: Fix a buffer overflow in format descriptor parsing Thanks to Oliver Neukum for catching and reporting this bug. Signed-off-by: Laurent Pinchart <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
static int __net_init sock_inuse_init_net(struct net *net) { net->core.inuse = alloc_percpu(struct prot_inuse); return net->core.inuse ? 0 : -ENOMEM; }
0
[ "CWE-400" ]
linux-2.6
c377411f2494a931ff7facdbb3a6839b1266bcf6
244,168,576,680,858,000,000,000,000,000,000,000,000
5
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]>
apply_colormap (guchar *dest, const guchar *src, guint width, const guchar *cmap, gboolean alpha, guint16 index) { guint x; if (alpha) { for (x = 0; x < width; x++) { *(dest++) = cmap[(*src - index) * 4]; *(dest++) = cmap[(*src - index) * 4 + 1]; *(dest++) = cmap[(*src - index) * 4 + 2]; *(dest++) = cmap[(*src - index) * 4 + 3]; src++; } } else { for (x = 0; x < width; x++) { *(dest++) = cmap[(*src - index) * 3]; *(dest++) = cmap[(*src - index) * 3 + 1]; *(dest++) = cmap[(*src - index) * 3 + 2]; src++; } } }
0
[ "CWE-125" ]
GIMP
674b62ad45b6579ec6d7923dc3cb1ef4e8b5498b
198,254,961,185,680,970,000,000,000,000,000,000,000
33
Bug 739134 - (CVE-2017-17786) Out of bounds read / heap overflow in... ... TGA importer. Be more thorough on valid TGA RGB and RGBA images. In particular current TGA plug-in can import RGBA as 32 bits (8 bits per channel) and 16 bits (5 bits per color channel and 1 bit for alpha), and RGB as 15 and 24 bits. Maybe there exist more variants, but if they do exist, we simply don't support them yet. Thanks to Hanno Böck for the report and a first patch attempt.
static void binder_vma_open(struct vm_area_struct *vma) { struct binder_proc *proc = vma->vm_private_data; binder_debug(BINDER_DEBUG_OPEN_CLOSE, "%d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n", proc->pid, vma->vm_start, vma->vm_end, (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags, (unsigned long)pgprot_val(vma->vm_page_prot)); }
0
[ "CWE-416" ]
linux
7bada55ab50697861eee6bb7d60b41e68a961a9c
314,152,498,563,245,800,000,000,000,000,000,000,000
10
binder: fix race that allows malicious free of live buffer Malicious code can attempt to free buffers using the BC_FREE_BUFFER ioctl to binder. There are protections against a user freeing a buffer while in use by the kernel, however there was a window where BC_FREE_BUFFER could be used to free a recently allocated buffer that was not completely initialized. This resulted in a use-after-free detected by KASAN with a malicious test program. This window is closed by setting the buffer's allow_user_free attribute to 0 when the buffer is allocated or when the user has previously freed it instead of waiting for the caller to set it. The problem was that when the struct buffer was recycled, allow_user_free was stale and set to 1 allowing a free to go through. Signed-off-by: Todd Kjos <[email protected]> Acked-by: Arve Hjønnevåg <[email protected]> Cc: stable <[email protected]> # 4.14 Signed-off-by: Greg Kroah-Hartman <[email protected]>
static int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags) { const struct io_op_def *def = &io_op_defs[req->opcode]; struct io_ring_ctx *ctx = req->ctx; struct async_poll *apoll; struct io_poll_table ipt; __poll_t mask = EPOLLONESHOT | POLLERR | POLLPRI; int ret; if (!def->pollin && !def->pollout) return IO_APOLL_ABORTED; if (!file_can_poll(req->file) || (req->flags & REQ_F_POLLED)) return IO_APOLL_ABORTED; if (def->pollin) { mask |= POLLIN | POLLRDNORM; /* If reading from MSG_ERRQUEUE using recvmsg, ignore POLLIN */ if ((req->opcode == IORING_OP_RECVMSG) && (req->sr_msg.msg_flags & MSG_ERRQUEUE)) mask &= ~POLLIN; } else { mask |= POLLOUT | POLLWRNORM; } if (def->poll_exclusive) mask |= EPOLLEXCLUSIVE; if (!(issue_flags & IO_URING_F_UNLOCKED) && !list_empty(&ctx->apoll_cache)) { apoll = list_first_entry(&ctx->apoll_cache, struct async_poll, poll.wait.entry); list_del_init(&apoll->poll.wait.entry); } else { apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC); if (unlikely(!apoll)) return IO_APOLL_ABORTED; } apoll->double_poll = NULL; req->apoll = apoll; req->flags |= REQ_F_POLLED; ipt.pt._qproc = io_async_queue_proc; io_kbuf_recycle(req, issue_flags); ret = __io_arm_poll_handler(req, &apoll->poll, &ipt, mask); if (ret || ipt.error) return ret ? IO_APOLL_READY : IO_APOLL_ABORTED; trace_io_uring_poll_arm(ctx, req, req->user_data, req->opcode, mask, apoll->poll.events); return IO_APOLL_OK;
0
[ "CWE-416" ]
linux
e677edbcabee849bfdd43f1602bccbecf736a646
226,690,854,425,533,050,000,000,000,000,000,000,000
51
io_uring: fix race between timeout flush and removal io_flush_timeouts() assumes the timeout isn't in progress of triggering or being removed/canceled, so it unconditionally removes it from the timeout list and attempts to cancel it. Leave it on the list and let the normal timeout cancelation take care of it. Cc: [email protected] # 5.5+ Signed-off-by: Jens Axboe <[email protected]>
void SparseSlice<T>::Initialize( const typename SparseSlice<T>::ConstMatrixMap& mat, int col_offset) { const int mat_rows = Transpose ? mat.dimension(1) : mat.dimension(0); const int mat_cols = Transpose ? mat.dimension(0) : mat.dimension(1); DCHECK_LE(num_rows, mat_rows); DCHECK_LE(num_cols + col_offset, mat_cols); int num_blocks = (num_cols + block_size - 1) / block_size; int mat_size = num_rows * num_cols; index3_offset.reserve(num_blocks); data3.reserve(mat_size); index3.reserve(mat_size / 3); index_offset.reserve(num_blocks); data.reserve(num_blocks * num_rows * 2); index.reserve(num_blocks * num_rows * 2); Index3 idx3; const int stride = Transpose ? mat.dimension(1) : 1; for (int i = 0; i < num_blocks; ++i) { int num_block_cols = std::min(block_size, num_cols - block_size * i); for (int row = 0; row < num_rows; ++row) { idx3.m = static_cast<uint8>(row); // Safety note: The following code has a race, since it checks whether // *curr is nonzero and then reads it again on use. However, the result // of the race is only that some of the "nonzeros" in the resulting sparse // representation may actually be zero, which is harmless. const auto* start = Transpose ? &mat(col_offset, row) : &mat(row, col_offset); const auto* curr = start; const auto* end = start + stride * num_block_cols; uint8 k = 0; #define NEXT_ELEM \ curr += stride; \ ++k; #define EAT_ZEROS \ while (curr < end && IsZero<T>(*curr)) { \ NEXT_ELEM; \ } while (true) { EAT_ZEROS if (curr >= end) break; idx3.k1 = k; const T value1 = *curr; NEXT_ELEM; EAT_ZEROS if (curr >= end) { data.push_back(value1); index.push_back({idx3.m, idx3.k1}); break; } idx3.k2 = k; const T value2 = *curr; NEXT_ELEM; EAT_ZEROS if (curr >= end) { data.push_back(value2); index.push_back({idx3.m, idx3.k2}); data.push_back(value1); index.push_back({idx3.m, idx3.k1}); break; } idx3.k3 = k; data3.push_back(value1); data3.push_back(value2); data3.push_back(*curr); NEXT_ELEM; index3.push_back(idx3); #undef NEXT_ELEM #undef EAT_ZEROS } } col_offset += block_size; index3_offset.push_back(index3.size()); index_offset.push_back(index.size()); } DCHECK_EQ(index3_offset.size(), num_blocks); DCHECK_EQ(index_offset.size(), num_blocks); DCHECK_EQ(3 * index3.size(), data3.size()); DCHECK_EQ(index.size(), data.size()); }
0
[ "CWE-125" ]
tensorflow
e6cf28c72ba2eb949ca950d834dd6d66bb01cfae
310,103,051,188,565,900,000,000,000,000,000,000,000
85
Validate that matrix dimension sizes in SparseMatMul are positive. PiperOrigin-RevId: 401149683 Change-Id: Ib33eafc561a39c8741ece80b2edce6d4aae9a57d
int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *limit, int *al) { unsigned short type; unsigned short size; unsigned short len; unsigned char *data = *p; int renegotiate_seen = 0; int sigalg_seen = 0; s->servername_done = 0; s->tlsext_status_type = -1; # ifndef OPENSSL_NO_NEXTPROTONEG s->s3->next_proto_neg_seen = 0; # endif # ifndef OPENSSL_NO_HEARTBEATS s->tlsext_heartbeat &= ~(SSL_TLSEXT_HB_ENABLED | SSL_TLSEXT_HB_DONT_SEND_REQUESTS); # endif # ifndef OPENSSL_NO_EC if (s->options & SSL_OP_SAFARI_ECDHE_ECDSA_BUG) ssl_check_for_safari(s, data, limit); # endif /* !OPENSSL_NO_EC */ # ifndef OPENSSL_NO_SRP if (s->srp_ctx.login != NULL) { OPENSSL_free(s->srp_ctx.login); s->srp_ctx.login = NULL; } # endif s->srtp_profile = NULL; if (data == limit) goto ri_check; if (limit - data < 2) goto err; n2s(data, len); if (limit - data != len) goto err; while (limit - data >= 4) { n2s(data, type); n2s(data, size); if (limit - data < size) goto err; # if 0 fprintf(stderr, "Received extension type %d size %d\n", type, size); # endif if (s->tlsext_debug_cb) s->tlsext_debug_cb(s, 0, type, data, size, s->tlsext_debug_arg); /*- * The servername extension is treated as follows: * * - Only the hostname type is supported with a maximum length of 255. * - The servername is rejected if too long or if it contains zeros, * in which case an fatal alert is generated. * - The servername field is maintained together with the session cache. * - When a session is resumed, the servername call back invoked in order * to allow the application to position itself to the right context. * - The servername is acknowledged if it is new for a session or when * it is identical to a previously used for the same session. * Applications can control the behaviour. They can at any time * set a 'desirable' servername for a new SSL object. This can be the * case for example with HTTPS when a Host: header field is received and * a renegotiation is requested. In this case, a possible servername * presented in the new client hello is only acknowledged if it matches * the value of the Host: field. * - Applications must use SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION * if they provide for changing an explicit servername context for the * session, i.e. when the session has been established with a servername * extension. * - On session reconnect, the servername extension may be absent. * */ if (type == TLSEXT_TYPE_server_name) { unsigned char *sdata; int servname_type; int dsize; if (size < 2) goto err; n2s(data, dsize); size -= 2; if (dsize > size) goto err; sdata = data; while (dsize > 3) { servname_type = *(sdata++); n2s(sdata, len); dsize -= 3; if (len > dsize) goto err; if (s->servername_done == 0) switch (servname_type) { case TLSEXT_NAMETYPE_host_name: if (!s->hit) { if (s->session->tlsext_hostname) goto err; if (len > TLSEXT_MAXLEN_host_name) { *al = TLS1_AD_UNRECOGNIZED_NAME; return 0; } if ((s->session->tlsext_hostname = OPENSSL_malloc(len + 1)) == NULL) { *al = TLS1_AD_INTERNAL_ERROR; return 0; } memcpy(s->session->tlsext_hostname, sdata, len); s->session->tlsext_hostname[len] = '\0'; if (strlen(s->session->tlsext_hostname) != len) { OPENSSL_free(s->session->tlsext_hostname); s->session->tlsext_hostname = NULL; *al = TLS1_AD_UNRECOGNIZED_NAME; return 0; } s->servername_done = 1; } else s->servername_done = s->session->tlsext_hostname && strlen(s->session->tlsext_hostname) == len && strncmp(s->session->tlsext_hostname, (char *)sdata, len) == 0; break; default: break; } dsize -= len; } if (dsize != 0) goto err; } # ifndef OPENSSL_NO_SRP else if (type == TLSEXT_TYPE_srp) { if (size == 0 || ((len = data[0])) != (size - 1)) goto err; if (s->srp_ctx.login != NULL) goto err; if ((s->srp_ctx.login = OPENSSL_malloc(len + 1)) == NULL) return -1; memcpy(s->srp_ctx.login, &data[1], len); s->srp_ctx.login[len] = '\0'; if (strlen(s->srp_ctx.login) != len) goto err; } # endif # ifndef OPENSSL_NO_EC else if (type == TLSEXT_TYPE_ec_point_formats) { unsigned char *sdata = data; int ecpointformatlist_length = *(sdata++); if (ecpointformatlist_length != size - 1) goto err; if (!s->hit) { if (s->session->tlsext_ecpointformatlist) { OPENSSL_free(s->session->tlsext_ecpointformatlist); s->session->tlsext_ecpointformatlist = NULL; } s->session->tlsext_ecpointformatlist_length = 0; if ((s->session->tlsext_ecpointformatlist = OPENSSL_malloc(ecpointformatlist_length)) == NULL) { *al = TLS1_AD_INTERNAL_ERROR; return 0; } s->session->tlsext_ecpointformatlist_length = ecpointformatlist_length; memcpy(s->session->tlsext_ecpointformatlist, sdata, ecpointformatlist_length); } # if 0 fprintf(stderr, "ssl_parse_clienthello_tlsext s->session->tlsext_ecpointformatlist (length=%i) ", s->session->tlsext_ecpointformatlist_length); sdata = s->session->tlsext_ecpointformatlist; for (i = 0; i < s->session->tlsext_ecpointformatlist_length; i++) fprintf(stderr, "%i ", *(sdata++)); fprintf(stderr, "\n"); # endif } else if (type == TLSEXT_TYPE_elliptic_curves) { unsigned char *sdata = data; int ellipticcurvelist_length = (*(sdata++) << 8); ellipticcurvelist_length += (*(sdata++)); if (ellipticcurvelist_length != size - 2 || ellipticcurvelist_length < 1 || /* Each NamedCurve is 2 bytes. */ ellipticcurvelist_length & 1) goto err; if (!s->hit) { if (s->session->tlsext_ellipticcurvelist) goto err; s->session->tlsext_ellipticcurvelist_length = 0; if ((s->session->tlsext_ellipticcurvelist = OPENSSL_malloc(ellipticcurvelist_length)) == NULL) { *al = TLS1_AD_INTERNAL_ERROR; return 0; } s->session->tlsext_ellipticcurvelist_length = ellipticcurvelist_length; memcpy(s->session->tlsext_ellipticcurvelist, sdata, ellipticcurvelist_length); } # if 0 fprintf(stderr, "ssl_parse_clienthello_tlsext s->session->tlsext_ellipticcurvelist (length=%i) ", s->session->tlsext_ellipticcurvelist_length); sdata = s->session->tlsext_ellipticcurvelist; for (i = 0; i < s->session->tlsext_ellipticcurvelist_length; i++) fprintf(stderr, "%i ", *(sdata++)); fprintf(stderr, "\n"); # endif } # endif /* OPENSSL_NO_EC */ # ifdef TLSEXT_TYPE_opaque_prf_input else if (type == TLSEXT_TYPE_opaque_prf_input && s->version != DTLS1_VERSION) { unsigned char *sdata = data; if (size < 2) { *al = SSL_AD_DECODE_ERROR; return 0; } n2s(sdata, s->s3->client_opaque_prf_input_len); if (s->s3->client_opaque_prf_input_len != size - 2) { *al = SSL_AD_DECODE_ERROR; return 0; } if (s->s3->client_opaque_prf_input != NULL) { /* shouldn't really happen */ OPENSSL_free(s->s3->client_opaque_prf_input); } /* dummy byte just to get non-NULL */ if (s->s3->client_opaque_prf_input_len == 0) s->s3->client_opaque_prf_input = OPENSSL_malloc(1); else s->s3->client_opaque_prf_input = BUF_memdup(sdata, s->s3->client_opaque_prf_input_len); if (s->s3->client_opaque_prf_input == NULL) { *al = TLS1_AD_INTERNAL_ERROR; return 0; } } # endif else if (type == TLSEXT_TYPE_session_ticket) { if (s->tls_session_ticket_ext_cb && !s->tls_session_ticket_ext_cb(s, data, size, s->tls_session_ticket_ext_cb_arg)) { *al = TLS1_AD_INTERNAL_ERROR; return 0; } } else if (type == TLSEXT_TYPE_renegotiate) { if (!ssl_parse_clienthello_renegotiate_ext(s, data, size, al)) return 0; renegotiate_seen = 1; } else if (type == TLSEXT_TYPE_signature_algorithms) { int dsize; if (sigalg_seen || size < 2) goto err; sigalg_seen = 1; n2s(data, dsize); size -= 2; if (dsize != size || dsize & 1) goto err; if (!tls1_process_sigalgs(s, data, dsize)) goto err; } else if (type == TLSEXT_TYPE_status_request && s->version != DTLS1_VERSION) { if (size < 5) goto err; s->tlsext_status_type = *data++; size--; if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp) { const unsigned char *sdata; int dsize; /* Read in responder_id_list */ n2s(data, dsize); size -= 2; if (dsize > size) goto err; while (dsize > 0) { OCSP_RESPID *id; int idsize; if (dsize < 4) goto err; n2s(data, idsize); dsize -= 2 + idsize; size -= 2 + idsize; if (dsize < 0) goto err; sdata = data; data += idsize; id = d2i_OCSP_RESPID(NULL, &sdata, idsize); if (!id) goto err; if (data != sdata) { OCSP_RESPID_free(id); goto err; } if (!s->tlsext_ocsp_ids && !(s->tlsext_ocsp_ids = sk_OCSP_RESPID_new_null())) { OCSP_RESPID_free(id); *al = SSL_AD_INTERNAL_ERROR; return 0; } if (!sk_OCSP_RESPID_push(s->tlsext_ocsp_ids, id)) { OCSP_RESPID_free(id); *al = SSL_AD_INTERNAL_ERROR; return 0; } } /* Read in request_extensions */ if (size < 2) goto err; n2s(data, dsize); size -= 2; if (dsize != size) goto err; sdata = data; if (dsize > 0) { if (s->tlsext_ocsp_exts) { sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts, X509_EXTENSION_free); } s->tlsext_ocsp_exts = d2i_X509_EXTENSIONS(NULL, &sdata, dsize); if (!s->tlsext_ocsp_exts || (data + dsize != sdata)) goto err; } } /* * We don't know what to do with any other type * so ignore it. */ else s->tlsext_status_type = -1; } # ifndef OPENSSL_NO_HEARTBEATS else if (type == TLSEXT_TYPE_heartbeat) { switch (data[0]) { case 0x01: /* Client allows us to send HB requests */ s->tlsext_heartbeat |= SSL_TLSEXT_HB_ENABLED; break; case 0x02: /* Client doesn't accept HB requests */ s->tlsext_heartbeat |= SSL_TLSEXT_HB_ENABLED; s->tlsext_heartbeat |= SSL_TLSEXT_HB_DONT_SEND_REQUESTS; break; default: *al = SSL_AD_ILLEGAL_PARAMETER; return 0; } } # endif # ifndef OPENSSL_NO_NEXTPROTONEG else if (type == TLSEXT_TYPE_next_proto_neg && s->s3->tmp.finish_md_len == 0) { /*- * We shouldn't accept this extension on a * renegotiation. * * s->new_session will be set on renegotiation, but we * probably shouldn't rely that it couldn't be set on * the initial renegotation too in certain cases (when * there's some other reason to disallow resuming an * earlier session -- the current code won't be doing * anything like that, but this might change). * * A valid sign that there's been a previous handshake * in this connection is if s->s3->tmp.finish_md_len > * 0. (We are talking about a check that will happen * in the Hello protocol round, well before a new * Finished message could have been computed.) */ s->s3->next_proto_neg_seen = 1; } # endif /* session ticket processed earlier */ # ifndef OPENSSL_NO_SRTP else if (SSL_IS_DTLS(s) && SSL_get_srtp_profiles(s) && type == TLSEXT_TYPE_use_srtp) { if (ssl_parse_clienthello_use_srtp_ext(s, data, size, al)) return 0; } # endif data += size; } /* Spurious data on the end */ if (data != limit) goto err; *p = data; ri_check: /* Need RI if renegotiating */ if (!renegotiate_seen && s->renegotiate && !(s->options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) { *al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT, SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); return 0; } return 1; err: *al = SSL_AD_DECODE_ERROR; return 0; }
1
[ "CWE-399", "CWE-401" ]
openssl
2c0d295e26306e15a92eb23a84a1802005c1c137
67,819,194,235,838,110,000,000,000,000,000,000,000
437
Fix OCSP Status Request extension unbounded memory growth A malicious client can send an excessively large OCSP Status Request extension. If that client continually requests renegotiation, sending a large OCSP Status Request extension each time, then there will be unbounded memory growth on the server. This will eventually lead to a Denial Of Service attack through memory exhaustion. Servers with a default configuration are vulnerable even if they do not support OCSP. Builds using the "no-ocsp" build time option are not affected. I have also checked other extensions to see if they suffer from a similar problem but I could not find any other issues. CVE-2016-6304 Issue reported by Shi Lei. Reviewed-by: Rich Salz <[email protected]>
static char *make_output_option(struct output_struct *words, short *levels, uchar where) { char *str = words == info_words ? "--info=" : "--debug="; int j, counts[MAX_OUT_LEVEL+1], pos, skipped = 0, len = 0, max = 0, lev = 0; int word_count = words == info_words ? COUNT_INFO : COUNT_DEBUG; char *buf; memset(counts, 0, sizeof counts); for (j = 0; words[j].name; j++) { if (words[j].flag != j) { rprintf(FERROR, "rsync: internal error on %s%s: %d != %d\n", words == info_words ? "INFO_" : "DEBUG_", words[j].name, words[j].flag, j); exit_cleanup(RERR_UNSUPPORTED); } if (!(words[j].where & where)) continue; if (words[j].priority == DEFAULT_PRIORITY) { /* Implied items don't need to be mentioned. */ skipped++; continue; } len += len ? 1 : strlen(str); len += strlen(words[j].name); len += levels[j] == 1 ? 0 : 1; if (words[j].priority == HELP_PRIORITY) continue; /* no abbreviating for help */ assert(levels[j] <= MAX_OUT_LEVEL); if (++counts[levels[j]] > max) { /* Determine which level has the most items. */ lev = levels[j]; max = counts[lev]; } } /* Sanity check the COUNT_* define against the length of the table. */ if (j != word_count) { rprintf(FERROR, "rsync: internal error: %s is wrong! (%d != %d)\n", words == info_words ? "COUNT_INFO" : "COUNT_DEBUG", j, word_count); exit_cleanup(RERR_UNSUPPORTED); } if (!len) return NULL; len++; if (!(buf = new_array(char, len))) out_of_memory("make_output_option"); pos = 0; if (skipped || max < 5) lev = -1; else { if (lev == 0) pos += snprintf(buf, len, "%sNONE", str); else if (lev == 1) pos += snprintf(buf, len, "%sALL", str); else pos += snprintf(buf, len, "%sALL%d", str, lev); } for (j = 0; words[j].name && pos < len; j++) { if (words[j].priority == DEFAULT_PRIORITY || levels[j] == lev || !(words[j].where & where)) continue; if (pos) buf[pos++] = ','; else pos += strlcpy(buf+pos, str, len-pos); if (pos < len) pos += strlcpy(buf+pos, words[j].name, len-pos); /* Level 1 is implied by the name alone. */ if (levels[j] != 1 && pos < len) buf[pos++] = '0' + levels[j]; } buf[pos] = '\0'; return buf; }
0
[]
rsync
eac858085e3ac94ec0ab5061d11f52652c90a869
72,373,524,058,110,620,000,000,000,000,000,000,000
83
Add compat flag to allow proper seed checksum order. Fixes the equivalent of librsync's CVE-2014-8242 issue.
void btrfs_rm_dev_replace_remove_srcdev(struct btrfs_device *srcdev) { struct btrfs_fs_devices *fs_devices; lockdep_assert_held(&srcdev->fs_info->fs_devices->device_list_mutex); /* * in case of fs with no seed, srcdev->fs_devices will point * to fs_devices of fs_info. However when the dev being replaced is * a seed dev it will point to the seed's local fs_devices. In short * srcdev will have its correct fs_devices in both the cases. */ fs_devices = srcdev->fs_devices; list_del_rcu(&srcdev->dev_list); list_del(&srcdev->dev_alloc_list); fs_devices->num_devices--; if (test_bit(BTRFS_DEV_STATE_MISSING, &srcdev->dev_state)) fs_devices->missing_devices--; if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &srcdev->dev_state)) fs_devices->rw_devices--; if (srcdev->bdev) fs_devices->open_devices--; }
0
[ "CWE-476", "CWE-284" ]
linux
09ba3bc9dd150457c506e4661380a6183af651c1
287,691,250,254,926,030,000,000,000,000,000,000,000
26
btrfs: merge btrfs_find_device and find_device Both btrfs_find_device() and find_device() does the same thing except that the latter does not take the seed device onto account in the device scanning context. We can merge them. Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
xps_finish_image_path(gx_device_vector *vdev) { gx_device_xps *xps = (gx_device_xps *)vdev; char line[300]; const char *fmt; gs_matrix matrix; /* If an error occurs during an image, we can get here after the enumerator * has been freed - if that's the case, just bail out immediately */ if (xps->xps_pie == NULL) return; /* Path is started. Do the image brush image brush and close the path */ write_str_to_current_page(xps, "\t<Path.Fill>\n"); write_str_to_current_page(xps, "\t\t<ImageBrush "); fmt = "ImageSource = \"{ColorConvertedBitmap /%s /%s}\" Viewbox=\"%d, %d, %d, %d\" ViewboxUnits = \"Absolute\" Viewport = \"%d, %d, %d, %d\" ViewportUnits = \"Absolute\" TileMode = \"None\" >\n"; gs_sprintf(line, fmt, xps->xps_pie->file_name, xps->xps_pie->icc_name, 0, 0, xps->xps_pie->width, xps->xps_pie->height, 0, 0, xps->xps_pie->width, xps->xps_pie->height); write_str_to_current_page(xps, line); /* Now the render transform. This is applied to the image brush. Path is already transformed */ write_str_to_current_page(xps, "\t\t\t<ImageBrush.Transform>\n"); fmt = "\t\t\t\t<MatrixTransform Matrix = \"%g,%g,%g,%g,%g,%g\" />\n"; matrix = xps->xps_pie->mat; gs_sprintf(line, fmt, matrix.xx, matrix.xy, matrix.yx, matrix.yy, matrix.tx, matrix.ty); write_str_to_current_page(xps, line); write_str_to_current_page(xps, "\t\t\t</ImageBrush.Transform>\n"); write_str_to_current_page(xps, "\t\t</ImageBrush>\n"); write_str_to_current_page(xps, "\t</Path.Fill>\n"); /* End this path */ write_str_to_current_page(xps, "</Path>\n"); }
0
[]
ghostpdl
94d8955cb7725eb5f3557ddc02310c76124fdd1a
106,732,982,458,717,800,000,000,000,000,000,000,000
35
Bug 701818: better handling of error during PS/PDF image In the xps device, if an error occurred after xps_begin_image() but before xps_image_end_image(), *if* the Postscript had called 'restore' as part of the error handling, the image enumerator would have been freed (by the restore) despite the xps device still holding a reference to it. Simply changing to an allocator unaffected save/restore doesn't work because the enumerator holds references to other objects (graphics state, color space, possibly others) whose lifespans are inherently controlled by save/restore. So, add a finalize method for the XPS device's image enumerator (xps_image_enum_finalize()) which takes over cleaning up the memory it allocates and also deals with cleaning up references from the device to the enumerator and from the enumerator to the device.
static void update_write_refresh_rect(wStream* s, BYTE count, const RECTANGLE_16* areas) { int i; Stream_Write_UINT8(s, count); /* numberOfAreas (1 byte) */ Stream_Seek(s, 3); /* pad3Octets (3 bytes) */ for (i = 0; i < count; i++) { Stream_Write_UINT16(s, areas[i].left); /* left (2 bytes) */ Stream_Write_UINT16(s, areas[i].top); /* top (2 bytes) */ Stream_Write_UINT16(s, areas[i].right); /* right (2 bytes) */ Stream_Write_UINT16(s, areas[i].bottom); /* bottom (2 bytes) */ } }
0
[ "CWE-125" ]
FreeRDP
f8890a645c221823ac133dbf991f8a65ae50d637
21,166,193,569,470,071,000,000,000,000,000,000,000
14
Fixed #6005: Bounds checks in update_read_bitmap_data
Ptr<FileStorageEmitter> createXMLEmitter(FileStorage_API* fs) { return makePtr<XMLEmitter>(fs); }
0
[ "CWE-787" ]
opencv
f42d5399aac80d371b17d689851406669c9b9111
163,064,821,390,916,200,000,000,000,000,000,000,000
4
core(persistence): add more checks for implementation limitations
const char* writing_app() const { return writing_app_; }
0
[ "CWE-20" ]
libvpx
f00890eecdf8365ea125ac16769a83aa6b68792d
171,039,804,410,124,560,000,000,000,000,000,000,000
1
update libwebm to libwebm-1.0.0.27-352-g6ab9fcf https://chromium.googlesource.com/webm/libwebm/+log/af81f26..6ab9fcf Change-Id: I9d56e1fbaba9b96404b4fbabefddc1a85b79c25d
void Drainer::onData(Buffer::Instance& data, bool) { if (data.length() > 0) { // There is no downstream connection to send any data to, but the upstream // sent some data. Try to behave similar to what the kernel would do // when it receives data on a connection where the application has closed // the socket or ::shutdown(fd, SHUT_RD), and close/reset the connection. cancelDrain(); } }
0
[ "CWE-416" ]
envoy
ce0ae309057a216aba031aff81c445c90c6ef145
76,079,197,219,969,440,000,000,000,000,000,000,000
9
CVE-2021-43826 Signed-off-by: Yan Avlasov <[email protected]>
int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0p, int num) { BN_ULONG c0,c1,ml,*tp,n0; #ifdef mul64 BN_ULONG mh; #endif volatile BN_ULONG *vp; int i=0,j; #if 0 /* template for platform-specific implementation */ if (ap==bp) return bn_sqr_mont(rp,ap,np,n0p,num); #endif vp = tp = alloca((num+2)*sizeof(BN_ULONG)); n0 = *n0p; c0 = 0; ml = bp[0]; #ifdef mul64 mh = HBITS(ml); ml = LBITS(ml); for (j=0;j<num;++j) mul(tp[j],ap[j],ml,mh,c0); #else for (j=0;j<num;++j) mul(tp[j],ap[j],ml,c0); #endif tp[num] = c0; tp[num+1] = 0; goto enter; for(i=0;i<num;i++) { c0 = 0; ml = bp[i]; #ifdef mul64 mh = HBITS(ml); ml = LBITS(ml); for (j=0;j<num;++j) mul_add(tp[j],ap[j],ml,mh,c0); #else for (j=0;j<num;++j) mul_add(tp[j],ap[j],ml,c0); #endif c1 = (tp[num] + c0)&BN_MASK2; tp[num] = c1; tp[num+1] = (c1<c0?1:0); enter: c1 = tp[0]; ml = (c1*n0)&BN_MASK2; c0 = 0; #ifdef mul64 mh = HBITS(ml); ml = LBITS(ml); mul_add(c1,np[0],ml,mh,c0); #else mul_add(c1,ml,np[0],c0); #endif for(j=1;j<num;j++) { c1 = tp[j]; #ifdef mul64 mul_add(c1,np[j],ml,mh,c0); #else mul_add(c1,ml,np[j],c0); #endif tp[j-1] = c1&BN_MASK2; } c1 = (tp[num] + c0)&BN_MASK2; tp[num-1] = c1; tp[num] = tp[num+1] + (c1<c0?1:0); } if (tp[num]!=0 || tp[num-1]>=np[num-1]) { c0 = bn_sub_words(rp,tp,np,num); if (tp[num]!=0 || c0==0) { for(i=0;i<num+2;i++) vp[i] = 0; return 1; } } for(i=0;i<num;i++) rp[i] = tp[i], vp[i] = 0; vp[num] = 0; vp[num+1] = 0; return 1; }
0
[ "CWE-310" ]
openssl
a7a44ba55cb4f884c6bc9ceac90072dea38e66d0
33,055,952,717,757,355,000,000,000,000,000,000,000
88
Fix for CVE-2014-3570 (with minor bn_asm.c revamp). Reviewed-by: Emilia Kasper <[email protected]>
static void module_enable_ro(const struct module *mod, bool after_init) {}
0
[ "CWE-362", "CWE-347" ]
linux
0c18f29aae7ce3dadd26d8ee3505d07cc982df75
336,478,244,355,197,350,000,000,000,000,000,000,000
1
module: limit enabling module.sig_enforce Irrespective as to whether CONFIG_MODULE_SIG is configured, specifying "module.sig_enforce=1" on the boot command line sets "sig_enforce". Only allow "sig_enforce" to be set when CONFIG_MODULE_SIG is configured. This patch makes the presence of /sys/module/module/parameters/sig_enforce dependent on CONFIG_MODULE_SIG=y. Fixes: fda784e50aac ("module: export module signature enforcement status") Reported-by: Nayna Jain <[email protected]> Tested-by: Mimi Zohar <[email protected]> Tested-by: Jessica Yu <[email protected]> Signed-off-by: Mimi Zohar <[email protected]> Signed-off-by: Jessica Yu <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
_outNestLoopParam(StringInfo str, const NestLoopParam *node) { WRITE_NODE_TYPE("NESTLOOPPARAM"); WRITE_INT_FIELD(paramno); WRITE_NODE_FIELD(paramval); }
0
[ "CWE-362" ]
postgres
5f173040e324f6c2eebb90d86cf1b0cdb5890f0a
178,655,874,100,546,780,000,000,000,000,000,000,000
7
Avoid repeated name lookups during table and index DDL. If the name lookups come to different conclusions due to concurrent activity, we might perform some parts of the DDL on a different table than other parts. At least in the case of CREATE INDEX, this can be used to cause the permissions checks to be performed against a different table than the index creation, allowing for a privilege escalation attack. This changes the calling convention for DefineIndex, CreateTrigger, transformIndexStmt, transformAlterTableStmt, CheckIndexCompatible (in 9.2 and newer), and AlterTable (in 9.1 and older). In addition, CheckRelationOwnership is removed in 9.2 and newer and the calling convention is changed in older branches. A field has also been added to the Constraint node (FkConstraint in 8.4). Third-party code calling these functions or using the Constraint node will require updating. Report by Andres Freund. Patch by Robert Haas and Andres Freund, reviewed by Tom Lane. Security: CVE-2014-0062
size_t decompression_memory_bound() { if (ofiletype == UJG || filetype == UJG) { return 0; } size_t cumulative_buffer_size = 0; size_t streaming_buffer_size = 0; size_t current_run_size = 0; for (int i = 0; i < colldata.get_num_components(); ++i) { size_t streaming_size = colldata.block_width(i) * 2 * NUM_THREADS * 64 * sizeof(uint16_t); size_t frame_buffer_size = colldata.component_size_allocated(i); if (cs_cmpc != colldata.get_num_components() || jpegtype != 1) { streaming_size = frame_buffer_size; } else if (filetype != JPEG) { if (!g_threaded) { frame_buffer_size = colldata.block_width(i) * 2 * 64 * sizeof(uint16_t); } else { frame_buffer_size = streaming_size; } } cumulative_buffer_size += frame_buffer_size; streaming_buffer_size += streaming_size; } current_run_size = cumulative_buffer_size; size_t bit_writer_augmentation = 0; if (g_allow_progressive) { for (size_t cur_size = jpgfilesize - 1; cur_size; cur_size >>=1) { bit_writer_augmentation |= cur_size; } bit_writer_augmentation += 1; // this is used to compute the buffer size of the abit_writer for writing } size_t garbage_augmentation = 0; for (size_t cur_size = hdrs - 1; cur_size; cur_size >>=1) { garbage_augmentation |= cur_size; } garbage_augmentation += 1; // this is used to compute the buffer size of the abit_writer for writing int non_preloaded_mux = 4096 * 1024 + 131072; // only 1 thread hence only one extra 131072 size_t decode_header_needed_size = hdrs + zlib_hdrs * 3; if (zlib_hdrs && zlib_hdrs * 2 < hdrs) { size_t doubled = zlib_hdrs * 2; do { decode_header_needed_size += doubled; doubled *= 2; } while (doubled < (size_t)hdrs); } size_t single_threaded_model_bonus = 0; size_t single_threaded_buffer_bonus = 0; //the threads have to save their output to 3/4 of the jpeg before writing it if (g_decoder) { single_threaded_model_bonus += g_decoder->get_model_worker_memory_usage(); } else if (g_encoder) { single_threaded_model_bonus += g_encoder->get_decode_model_worker_memory_usage(); } if (filetype != JPEG && !g_threaded) { single_threaded_buffer_bonus += jpgfilesize; } size_t abit_writer = 0; if (g_allow_progressive) { if (zlib_hdrs * 3 < ABIT_WRITER_PRELOAD * 2 + 64) { if (zlib_hdrs * 3 < ABIT_WRITER_PRELOAD + 64) { abit_writer += ABIT_WRITER_PRELOAD * 2 + 64;// these can't be reused memory } else { abit_writer += ABIT_WRITER_PRELOAD + 64;// these can't be reused } } } else { abit_writer += 65536 + 64; } if (g_allow_progressive && jpgfilesize > ABIT_WRITER_PRELOAD) { // we currently buffer the whole jpeg in memory while streaming out abit_writer += 3 * jpgfilesize; } size_t total = Sirikata::memmgr_size_allocated(); ptrdiff_t decom_memory_bound = total; decom_memory_bound -= current_run_size; decom_memory_bound += streaming_buffer_size; decom_memory_bound -= single_threaded_model_bonus; decom_memory_bound += single_threaded_buffer_bonus; if (decom_memory_bound < 1){ decom_memory_bound = 1; } if (filetype == JPEG) { decom_memory_bound = streaming_buffer_size + abit_writer + jpgfilesize + sizeof(ProbabilityTablesBase) + garbage_augmentation + decode_header_needed_size + non_preloaded_mux; } return decom_memory_bound; }
0
[ "CWE-399", "CWE-190" ]
lepton
6a5ceefac1162783fffd9506a3de39c85c725761
252,804,541,223,883,200,000,000,000,000,000,000,000
92
fix #111
void cil_destroy_policycap(struct cil_policycap *polcap) { if (polcap == NULL) { return; } cil_symtab_datum_destroy(&polcap->datum); free(polcap); }
0
[ "CWE-125" ]
selinux
340f0eb7f3673e8aacaf0a96cbfcd4d12a405521
233,116,909,806,747,630,000,000,000,000,000,000,000
9
libsepol/cil: Check for statements not allowed in optional blocks While there are some checks for invalid statements in an optional block when resolving the AST, there are no checks when building the AST. OSS-Fuzz found the following policy which caused a null dereference in cil_tree_get_next_path(). (blockinherit b3) (sid SID) (sidorder(SID)) (optional o (ibpkeycon :(1 0)s) (block b3 (filecon""block()) (filecon""block()))) The problem is that the blockinherit copies block b3 before the optional block is disabled. When the optional is disabled, block b3 is deleted along with everything else in the optional. Later, when filecon statements with the same path are found an error message is produced and in trying to find out where the block was copied from, the reference to the deleted block is used. The error handling code assumes (rightly) that if something was copied from a block then that block should still exist. It is clear that in-statements, blocks, and macros cannot be in an optional, because that allows nodes to be copied from the optional block to somewhere outside even though the optional could be disabled later. When optionals are disabled the AST is reset and the resolution is restarted at the point of resolving macro calls, so anything resolved before macro calls will never be re-resolved. This includes tunableifs, in-statements, blockinherits, blockabstracts, and macro definitions. Tunable declarations also cannot be in an optional block because they are needed to resolve tunableifs. It should be fine to allow blockinherit statements in an optional, because that is copying nodes from outside the optional to the optional and if the optional is later disabled, everything will be deleted anyway. Check and quit with an error if a tunable declaration, in-statement, block, blockabstract, or macro definition is found within an optional when either building or resolving the AST. Signed-off-by: James Carter <[email protected]>
static void nci_target_auto_activated(struct nci_dev *ndev, struct nci_rf_intf_activated_ntf *ntf) { struct nfc_target *target; int rc; target = &ndev->targets[ndev->n_targets]; rc = nci_add_new_protocol(ndev, target, ntf->rf_protocol, ntf->activation_rf_tech_and_mode, &ntf->rf_tech_specific_params); if (rc) return; target->logical_idx = ntf->rf_discovery_id; ndev->n_targets++; pr_debug("logical idx %d, n_targets %d\n", target->logical_idx, ndev->n_targets); nfc_targets_found(ndev->nfc_dev, ndev->targets, ndev->n_targets); }
0
[ "CWE-119", "CWE-787" ]
linux
67de956ff5dc1d4f321e16cfbd63f5be3b691b43
158,374,803,234,567,110,000,000,000,000,000,000,000
22
NFC: Prevent multiple buffer overflows in NCI Fix multiple remotely-exploitable stack-based buffer overflows due to the NCI code pulling length fields directly from incoming frames and copying too much data into statically-sized arrays. Signed-off-by: Dan Rosenberg <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Lauro Ramos Venancio <[email protected]> Cc: Aloisio Almeida Jr <[email protected]> Cc: Samuel Ortiz <[email protected]> Cc: David S. Miller <[email protected]> Acked-by: Ilan Elias <[email protected]> Signed-off-by: Samuel Ortiz <[email protected]>
static void floppy_rb0_cb(struct bio *bio) { struct rb0_cbdata *cbdata = (struct rb0_cbdata *)bio->bi_private; int drive = cbdata->drive; if (bio->bi_status) { pr_info("floppy: error %d while reading block 0\n", bio->bi_status); set_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags); } complete(&cbdata->complete); }
0
[ "CWE-416" ]
linux
233087ca063686964a53c829d547c7571e3f67bf
126,173,234,673,861,360,000,000,000,000,000,000,000
12
floppy: disable FDRAWCMD by default Minh Yuan reported a concurrency use-after-free issue in the floppy code between raw_cmd_ioctl and seek_interrupt. [ It turns out this has been around, and that others have reported the KASAN splats over the years, but Minh Yuan had a reproducer for it and so gets primary credit for reporting it for this fix - Linus ] The problem is, this driver tends to break very easily and nowadays, nobody is expected to use FDRAWCMD anyway since it was used to manipulate non-standard formats. The risk of breaking the driver is higher than the risk presented by this race, and accessing the device requires privileges anyway. Let's just add a config option to completely disable this ioctl and leave it disabled by default. Distros shouldn't use it, and only those running on antique hardware might need to enable it. Link: https://lore.kernel.org/all/[email protected]/ Link: https://lore.kernel.org/lkml/CAKcFiNC=MfYVW-Jt9A3=FPJpTwCD2PL_ULNCpsCVE5s8ZeBQgQ@mail.gmail.com Link: https://lore.kernel.org/all/CAEAjamu1FRhz6StCe_55XY5s389ZP_xmCF69k987En+1z53=eg@mail.gmail.com Reported-by: Minh Yuan <[email protected]> Reported-by: [email protected] Reported-by: cruise k <[email protected]> Reported-by: Kyungtae Kim <[email protected]> Suggested-by: Linus Torvalds <[email protected]> Tested-by: Denis Efremov <[email protected]> Signed-off-by: Willy Tarreau <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
static void acm_read_bulk_callback(struct urb *urb) { struct acm_rb *rb = urb->context; struct acm *acm = rb->instance; unsigned long flags; int status = urb->status; dev_vdbg(&acm->data->dev, "%s - urb %d, len %d\n", __func__, rb->index, urb->actual_length); if (!acm->dev) { set_bit(rb->index, &acm->read_urbs_free); dev_dbg(&acm->data->dev, "%s - disconnected\n", __func__); return; } if (status) { set_bit(rb->index, &acm->read_urbs_free); dev_dbg(&acm->data->dev, "%s - non-zero urb status: %d\n", __func__, status); if ((status != -ENOENT) || (urb->actual_length == 0)) return; } usb_mark_last_busy(acm->dev); acm_process_read_urb(acm, urb); /* * Unthrottle may run on another CPU which needs to see events * in the same order. Submission has an implict barrier */ smp_mb__before_atomic(); set_bit(rb->index, &acm->read_urbs_free); /* throttle device if requested by tty */ spin_lock_irqsave(&acm->read_lock, flags); acm->throttled = acm->throttle_req; if (!acm->throttled) { spin_unlock_irqrestore(&acm->read_lock, flags); acm_submit_read_urb(acm, rb->index, GFP_ATOMIC); } else { spin_unlock_irqrestore(&acm->read_lock, flags); } }
0
[ "CWE-703" ]
linux
8835ba4a39cf53f705417b3b3a94eb067673f2c9
33,980,916,340,029,845,000,000,000,000,000,000,000
44
USB: cdc-acm: more sanity checking An attack has become available which pretends to be a quirky device circumventing normal sanity checks and crashes the kernel by an insufficient number of interfaces. This patch adds a check to the code path for quirky devices. Signed-off-by: Oliver Neukum <[email protected]> CC: [email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
static int synchronize_sched_expedited_cpu_stop(void *data) { /* * There must be a full memory barrier on each affected CPU * between the time that try_stop_cpus() is called and the * time that it returns. * * In the current initial implementation of cpu_stop, the * above condition is already met when the control reaches * this point and the following smp_mb() is not strictly * necessary. Do smp_mb() anyway for documentation and * robustness against future implementation changes. */ smp_mb(); /* See above comment block. */ return 0; }
0
[ "CWE-703", "CWE-835" ]
linux
f26f9aff6aaf67e9a430d16c266f91b13a5bff64
160,234,113,442,912,230,000,000,000,000,000,000,000
16
Sched: fix skip_clock_update optimization idle_balance() drops/retakes rq->lock, leaving the previous task vulnerable to set_tsk_need_resched(). Clear it after we return from balancing instead, and in setup_thread_stack() as well, so no successfully descheduled or never scheduled task has it set. Need resched confused the skip_clock_update logic, which assumes that the next call to update_rq_clock() will come nearly immediately after being set. Make the optimization robust against the waking a sleeper before it sucessfully deschedules case by checking that the current task has not been dequeued before setting the flag, since it is that useless clock update we're trying to save, and clear unconditionally in schedule() proper instead of conditionally in put_prev_task(). Signed-off-by: Mike Galbraith <[email protected]> Reported-by: Bjoern B. Brandenburg <[email protected]> Tested-by: Yong Zhang <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]> Cc: [email protected] LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
ZEND_API zval * zend_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC) /* {{{ */ { zval *ex; MAKE_STD_ZVAL(ex); if (exception_ce) { if (!instanceof_function(exception_ce, default_exception_ce TSRMLS_CC)) { zend_error(E_NOTICE, "Exceptions must be derived from the Exception base class"); exception_ce = default_exception_ce; } } else { exception_ce = default_exception_ce; } object_init_ex(ex, exception_ce); if (message) { zend_update_property_string(default_exception_ce, ex, "message", sizeof("message")-1, message TSRMLS_CC); } if (code) { zend_update_property_long(default_exception_ce, ex, "code", sizeof("code")-1, code TSRMLS_CC); } zend_throw_exception_internal(ex TSRMLS_CC); return ex; }
0
[]
php-src
a894a8155fab068d68a04bf181dbaddfa01ccbb0
61,832,353,851,167,110,000,000,000,000,000,000,000
26
More fixes for bug #69152
ExecFreeExprContext(PlanState *planstate) { /* * Per above discussion, don't actually delete the ExprContext. We do * unlink it from the plan node, though. */ planstate->ps_ExprContext = NULL; }
0
[ "CWE-209" ]
postgres
804b6b6db4dcfc590a468e7be390738f9f7755fb
13,199,032,640,911,683,000,000,000,000,000,000,000
8
Fix column-privilege leak in error-message paths While building error messages to return to the user, BuildIndexValueDescription, ExecBuildSlotValueDescription and ri_ReportViolation would happily include the entire key or entire row in the result returned to the user, even if the user didn't have access to view all of the columns being included. Instead, include only those columns which the user is providing or which the user has select rights on. If the user does not have any rights to view the table or any of the columns involved then no detail is provided and a NULL value is returned from BuildIndexValueDescription and ExecBuildSlotValueDescription. Note that, for key cases, the user must have access to all of the columns for the key to be shown; a partial key will not be returned. Further, in master only, do not return any data for cases where row security is enabled on the relation and row security should be applied for the user. This required a bit of refactoring and moving of things around related to RLS- note the addition of utils/misc/rls.c. Back-patch all the way, as column-level privileges are now in all supported versions. This has been assigned CVE-2014-8161, but since the issue and the patch have already been publicized on pgsql-hackers, there's no point in trying to hide this commit.
njs_typed_array_from(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t unused) { double num; int64_t length, i; njs_int_t ret; njs_value_t *this, *source, *mapfn; njs_value_t arguments[3], retval; njs_function_t *function; njs_typed_array_t *array; this = njs_argument(args, 0); if (njs_slow_path(!njs_is_constructor(this))) { njs_type_error(vm, "%s is not a constructor", njs_type_string(this->type)); return NJS_ERROR; } mapfn = njs_arg(args, nargs, 2); if (njs_slow_path(!njs_is_function_or_undefined(mapfn))) { njs_type_error(vm, "\"mapfn\" argument is not callable"); return NJS_ERROR; } function = NULL; if (njs_is_function(mapfn)) { function = njs_function(mapfn); } source = njs_arg(args, nargs, 1); ret = njs_value_to_object(vm, source); if (njs_slow_path(ret != NJS_OK)) { return ret; } ret = njs_object_length(vm, source, &length); if (njs_slow_path(ret == NJS_ERROR)) { return ret; } njs_set_number(&arguments[0], length); ret = njs_typed_array_create(vm, this, arguments, 1, &vm->retval); if (njs_slow_path(ret != NJS_OK)) { return NJS_ERROR; } array = njs_typed_array(&vm->retval); arguments[0] = *njs_arg(args, nargs, 3); for (i = 0; i < length; i++) { ret = njs_value_property_i64(vm, source, i, &retval); if (njs_slow_path(ret == NJS_ERROR)) { return NJS_ERROR; } if (function != NULL) { arguments[1] = retval; njs_set_number(&arguments[2], i); ret = njs_function_apply(vm, function, arguments, 3, &retval); if (njs_slow_path(ret != NJS_OK)) { return NJS_ERROR; } } ret = njs_value_to_number(vm, &retval, &num); if (njs_slow_path(ret != NJS_OK)) { return NJS_ERROR; } njs_typed_array_prop_set(vm, array, i, num); } njs_set_typed_array(&vm->retval, array); return NJS_OK; }
0
[ "CWE-703" ]
njs
5c6130a2a0b4c41ab415f6b8992aa323636338b9
188,664,629,832,466,900,000,000,000,000,000,000,000
79
Fixed Array.prototype.fill() for typed-arrays. This closes #478 issue on Github.
static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *array_ptr = &EX_T(opline->result.u.var).tmp_var; zval *expr_ptr; zval *offset=_get_zval_ptr_cv(&opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); #if 0 || IS_VAR == IS_VAR || IS_VAR == IS_CV zval **expr_ptr_ptr = NULL; if (opline->extended_value) { expr_ptr_ptr=_get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); expr_ptr = *expr_ptr_ptr; } else { expr_ptr=_get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); } #else expr_ptr=_get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); #endif if (0) { /* temporary variable */ zval *new_expr; ALLOC_ZVAL(new_expr); INIT_PZVAL_COPY(new_expr, expr_ptr); expr_ptr = new_expr; } else { #if 0 || IS_VAR == IS_VAR || IS_VAR == IS_CV if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; Z_ADDREF_P(expr_ptr); } else #endif if (IS_VAR == IS_CONST || PZVAL_IS_REF(expr_ptr)) { zval *new_expr; ALLOC_ZVAL(new_expr); INIT_PZVAL_COPY(new_expr, expr_ptr); expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { Z_ADDREF_P(expr_ptr); } } if (offset) { switch (Z_TYPE_P(offset)) { case IS_DOUBLE: zend_hash_index_update(Z_ARRVAL_P(array_ptr), zend_dval_to_lval(Z_DVAL_P(offset)), &expr_ptr, sizeof(zval *), NULL); break; case IS_LONG: case IS_BOOL: zend_hash_index_update(Z_ARRVAL_P(array_ptr), Z_LVAL_P(offset), &expr_ptr, sizeof(zval *), NULL); break; case IS_STRING: zend_symtable_update(Z_ARRVAL_P(array_ptr), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, &expr_ptr, sizeof(zval *), NULL); break; case IS_NULL: zend_hash_update(Z_ARRVAL_P(array_ptr), "", sizeof(""), &expr_ptr, sizeof(zval *), NULL); break; default: zend_error(E_WARNING, "Illegal offset type"); zval_ptr_dtor(&expr_ptr); /* do nothing */ break; } } else { zend_hash_next_index_insert(Z_ARRVAL_P(array_ptr), &expr_ptr, sizeof(zval *), NULL); } if (opline->extended_value) { if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; } else { if (free_op1.var) {zval_ptr_dtor(&free_op1.var);}; } ZEND_VM_NEXT_OPCODE(); }
0
[]
php-src
ce96fd6b0761d98353761bf78d5bfb55291179fd
3,663,092,525,078,243,300,000,000,000,000,000,000
78
- fix #39863, do not accept paths with NULL in them. See http://news.php.net/php.internals/50191, trunk will have the patch later (adding a macro and/or changing (some) APIs. Patch by Rasmus
juniper_parse_header(netdissect_options *ndo, const u_char *p, const struct pcap_pkthdr *h, struct juniper_l2info_t *l2info) { const struct juniper_cookie_table_t *lp = juniper_cookie_table; u_int idx, jnx_ext_len, jnx_header_len = 0; uint8_t tlv_type,tlv_len; uint32_t control_word; int tlv_value; const u_char *tptr; l2info->header_len = 0; l2info->cookie_len = 0; l2info->proto = 0; l2info->length = h->len; l2info->caplen = h->caplen; ND_TCHECK2(p[0], 4); l2info->flags = p[3]; l2info->direction = p[3]&JUNIPER_BPF_PKT_IN; if (EXTRACT_24BITS(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */ ND_PRINT((ndo, "no magic-number found!")); return 0; } if (ndo->ndo_eflag) /* print direction */ ND_PRINT((ndo, "%3s ", tok2str(juniper_direction_values, "---", l2info->direction))); /* magic number + flags */ jnx_header_len = 4; if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "\n\tJuniper PCAP Flags [%s]", bittok2str(jnx_flag_values, "none", l2info->flags))); /* extensions present ? - calculate how much bytes to skip */ if ((l2info->flags & JUNIPER_BPF_EXT ) == JUNIPER_BPF_EXT ) { tptr = p+jnx_header_len; /* ok to read extension length ? */ ND_TCHECK2(tptr[0], 2); jnx_ext_len = EXTRACT_16BITS(tptr); jnx_header_len += 2; tptr +=2; /* nail up the total length - * just in case something goes wrong * with TLV parsing */ jnx_header_len += jnx_ext_len; if (ndo->ndo_vflag > 1) ND_PRINT((ndo, ", PCAP Extension(s) total length %u", jnx_ext_len)); ND_TCHECK2(tptr[0], jnx_ext_len); while (jnx_ext_len > JUNIPER_EXT_TLV_OVERHEAD) { tlv_type = *(tptr++); tlv_len = *(tptr++); tlv_value = 0; /* sanity checks */ if (tlv_type == 0 || tlv_len == 0) break; if (tlv_len+JUNIPER_EXT_TLV_OVERHEAD > jnx_ext_len) goto trunc; if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "\n\t %s Extension TLV #%u, length %u, value ", tok2str(jnx_ext_tlv_values,"Unknown",tlv_type), tlv_type, tlv_len)); tlv_value = juniper_read_tlv_value(tptr, tlv_type, tlv_len); switch (tlv_type) { case JUNIPER_EXT_TLV_IFD_NAME: /* FIXME */ break; case JUNIPER_EXT_TLV_IFD_MEDIATYPE: case JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE: if (tlv_value != -1) { if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "%s (%u)", tok2str(juniper_ifmt_values, "Unknown", tlv_value), tlv_value)); } break; case JUNIPER_EXT_TLV_IFL_ENCAPS: case JUNIPER_EXT_TLV_TTP_IFL_ENCAPS: if (tlv_value != -1) { if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "%s (%u)", tok2str(juniper_ifle_values, "Unknown", tlv_value), tlv_value)); } break; case JUNIPER_EXT_TLV_IFL_IDX: /* fall through */ case JUNIPER_EXT_TLV_IFL_UNIT: case JUNIPER_EXT_TLV_IFD_IDX: default: if (tlv_value != -1) { if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "%u", tlv_value)); } break; } tptr+=tlv_len; jnx_ext_len -= tlv_len+JUNIPER_EXT_TLV_OVERHEAD; } if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "\n\t-----original packet-----\n\t")); } if ((l2info->flags & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) { if (ndo->ndo_eflag) ND_PRINT((ndo, "no-L2-hdr, ")); /* there is no link-layer present - * perform the v4/v6 heuristics * to figure out what it is */ ND_TCHECK2(p[jnx_header_len + 4], 1); if (ip_heuristic_guess(ndo, p + jnx_header_len + 4, l2info->length - (jnx_header_len + 4)) == 0) ND_PRINT((ndo, "no IP-hdr found!")); l2info->header_len=jnx_header_len+4; return 0; /* stop parsing the output further */ } l2info->header_len = jnx_header_len; p+=l2info->header_len; l2info->length -= l2info->header_len; l2info->caplen -= l2info->header_len; /* search through the cookie table and copy values matching for our PIC type */ ND_TCHECK(p[0]); while (lp->s != NULL) { if (lp->pictype == l2info->pictype) { l2info->cookie_len += lp->cookie_len; switch (p[0]) { case LS_COOKIE_ID: l2info->cookie_type = LS_COOKIE_ID; l2info->cookie_len += 2; break; case AS_COOKIE_ID: l2info->cookie_type = AS_COOKIE_ID; l2info->cookie_len = 8; break; default: l2info->bundle = l2info->cookie[0]; break; } #ifdef DLT_JUNIPER_MFR /* MFR child links don't carry cookies */ if (l2info->pictype == DLT_JUNIPER_MFR && (p[0] & MFR_BE_MASK) == MFR_BE_MASK) { l2info->cookie_len = 0; } #endif l2info->header_len += l2info->cookie_len; l2info->length -= l2info->cookie_len; l2info->caplen -= l2info->cookie_len; if (ndo->ndo_eflag) ND_PRINT((ndo, "%s-PIC, cookie-len %u", lp->s, l2info->cookie_len)); if (l2info->cookie_len > 0) { ND_TCHECK2(p[0], l2info->cookie_len); if (ndo->ndo_eflag) ND_PRINT((ndo, ", cookie 0x")); for (idx = 0; idx < l2info->cookie_len; idx++) { l2info->cookie[idx] = p[idx]; /* copy cookie data */ if (ndo->ndo_eflag) ND_PRINT((ndo, "%02x", p[idx])); } } if (ndo->ndo_eflag) ND_PRINT((ndo, ": ")); /* print demarc b/w L2/L3*/ ND_TCHECK_16BITS(p+l2info->cookie_len); l2info->proto = EXTRACT_16BITS(p+l2info->cookie_len); break; } ++lp; } p+=l2info->cookie_len; /* DLT_ specific parsing */ switch(l2info->pictype) { #ifdef DLT_JUNIPER_MLPPP case DLT_JUNIPER_MLPPP: switch (l2info->cookie_type) { case LS_COOKIE_ID: l2info->bundle = l2info->cookie[1]; break; case AS_COOKIE_ID: l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; break; default: l2info->bundle = l2info->cookie[0]; break; } break; #endif #ifdef DLT_JUNIPER_MLFR case DLT_JUNIPER_MLFR: switch (l2info->cookie_type) { case LS_COOKIE_ID: ND_TCHECK2(p[0], 2); l2info->bundle = l2info->cookie[1]; l2info->proto = EXTRACT_16BITS(p); l2info->header_len += 2; l2info->length -= 2; l2info->caplen -= 2; break; case AS_COOKIE_ID: l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; break; default: l2info->bundle = l2info->cookie[0]; l2info->header_len += 2; l2info->length -= 2; l2info->caplen -= 2; break; } break; #endif #ifdef DLT_JUNIPER_MFR case DLT_JUNIPER_MFR: switch (l2info->cookie_type) { case LS_COOKIE_ID: ND_TCHECK2(p[0], 2); l2info->bundle = l2info->cookie[1]; l2info->proto = EXTRACT_16BITS(p); l2info->header_len += 2; l2info->length -= 2; l2info->caplen -= 2; break; case AS_COOKIE_ID: l2info->bundle = (EXTRACT_16BITS(&l2info->cookie[6])>>3)&0xfff; l2info->proto = (l2info->cookie[5])&JUNIPER_LSQ_L3_PROTO_MASK; break; default: l2info->bundle = l2info->cookie[0]; break; } break; #endif #ifdef DLT_JUNIPER_ATM2 case DLT_JUNIPER_ATM2: ND_TCHECK2(p[0], 4); /* ATM cell relay control word present ? */ if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK) { control_word = EXTRACT_32BITS(p); /* some control word heuristics */ switch(control_word) { case 0: /* zero control word */ case 0x08000000: /* < JUNOS 7.4 control-word */ case 0x08380000: /* cntl word plus cell length (56) >= JUNOS 7.4*/ l2info->header_len += 4; break; default: break; } if (ndo->ndo_eflag) ND_PRINT((ndo, "control-word 0x%08x ", control_word)); } break; #endif #ifdef DLT_JUNIPER_GGSN case DLT_JUNIPER_GGSN: break; #endif #ifdef DLT_JUNIPER_ATM1 case DLT_JUNIPER_ATM1: break; #endif #ifdef DLT_JUNIPER_PPP case DLT_JUNIPER_PPP: break; #endif #ifdef DLT_JUNIPER_CHDLC case DLT_JUNIPER_CHDLC: break; #endif #ifdef DLT_JUNIPER_ETHER case DLT_JUNIPER_ETHER: break; #endif #ifdef DLT_JUNIPER_FRELAY case DLT_JUNIPER_FRELAY: break; #endif default: ND_PRINT((ndo, "Unknown Juniper DLT_ type %u: ", l2info->pictype)); break; } if (ndo->ndo_eflag > 1) ND_PRINT((ndo, "hlen %u, proto 0x%04x, ", l2info->header_len, l2info->proto)); return 1; /* everything went ok so far. continue parsing */ trunc: ND_PRINT((ndo, "[|juniper_hdr], length %u", h->len)); return 0; }
0
[ "CWE-125" ]
tcpdump
42073d54c53a496be40ae84152bbfe2c923ac7bc
124,722,570,916,073,970,000,000,000,000,000,000,000
322
CVE-2017-13004/Juniper: Add a bounds check. This fixes a buffer over-read discovered by Forcepoint's security researchers Otto Airamo & Antti Levomäki. Add tests using the capture files supplied by the reporter(s).
qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr, int is_file_stack) { struct dir_stack_T *ds_new; struct dir_stack_T *ds_ptr; // allocate new stack element and hook it in ds_new = ALLOC_ONE_ID(struct dir_stack_T, aid_qf_dirstack); if (ds_new == NULL) return NULL; ds_new->next = *stackptr; *stackptr = ds_new; // store directory on the stack if (vim_isAbsName(dirbuf) || (*stackptr)->next == NULL || is_file_stack) (*stackptr)->dirname = vim_strsave(dirbuf); else { // Okay we don't have an absolute path. // dirbuf must be a subdir of one of the directories on the stack. // Let's search... ds_new = (*stackptr)->next; (*stackptr)->dirname = NULL; while (ds_new) { vim_free((*stackptr)->dirname); (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf, TRUE); if (mch_isdir((*stackptr)->dirname) == TRUE) break; ds_new = ds_new->next; } // clean up all dirs we already left while ((*stackptr)->next != ds_new) { ds_ptr = (*stackptr)->next; (*stackptr)->next = (*stackptr)->next->next; vim_free(ds_ptr->dirname); vim_free(ds_ptr); } // Nothing found -> it must be on top level if (ds_new == NULL) { vim_free((*stackptr)->dirname); (*stackptr)->dirname = vim_strsave(dirbuf); } } if ((*stackptr)->dirname != NULL) return (*stackptr)->dirname; else { ds_ptr = *stackptr; *stackptr = (*stackptr)->next; vim_free(ds_ptr); return NULL; } }
0
[ "CWE-416" ]
vim
4f1b083be43f351bc107541e7b0c9655a5d2c0bb
88,698,906,390,216,850,000,000,000,000,000,000,000
63
patch 9.0.0322: crash when no errors and 'quickfixtextfunc' is set Problem: Crash when no errors and 'quickfixtextfunc' is set. Solution: Do not handle errors if there aren't any.
void io_uring_cmd_done(struct io_uring_cmd *ioucmd, ssize_t ret, ssize_t res2) { struct io_kiocb *req = container_of(ioucmd, struct io_kiocb, uring_cmd); if (ret < 0) req_set_fail(req); if (req->ctx->flags & IORING_SETUP_CQE32) __io_req_complete32(req, 0, ret, 0, res2, 0); else io_req_complete(req, ret); }
0
[ "CWE-416" ]
linux
9cae36a094e7e9d6e5fe8b6dcd4642138b3eb0c7
197,360,743,752,634,130,000,000,000,000,000,000,000
11
io_uring: reinstate the inflight tracking After some debugging, it was realized that we really do still need the old inflight tracking for any file type that has io_uring_fops assigned. If we don't, then trivial circular references will mean that we never get the ctx cleaned up and hence it'll leak. Just bring back the inflight tracking, which then also means we can eliminate the conditional dropping of the file when task_work is queued. Fixes: d5361233e9ab ("io_uring: drop the old style inflight file tracking") Signed-off-by: Jens Axboe <[email protected]>
TEST_P(Http2CodecImplTestAll, TestCodecHeaderCompression) { initialize(); TestHeaderMapImpl request_headers; HttpTestUtility::addDefaultHeaders(request_headers); EXPECT_CALL(request_decoder_, decodeHeaders_(_, true)); request_encoder_->encodeHeaders(request_headers, true); TestHeaderMapImpl response_headers{{":status", "200"}, {"compression", "test"}}; EXPECT_CALL(response_decoder_, decodeHeaders_(_, true)); response_encoder_->encodeHeaders(response_headers, true); // Sanity check to verify that state of encoders and decoders matches. EXPECT_EQ(nghttp2_session_get_hd_deflate_dynamic_table_size(server_->session()), nghttp2_session_get_hd_inflate_dynamic_table_size(client_->session())); EXPECT_EQ(nghttp2_session_get_hd_deflate_dynamic_table_size(client_->session()), nghttp2_session_get_hd_inflate_dynamic_table_size(server_->session())); // Verify that headers are compressed only when both client and server advertise table size > 0: if (client_http2settings_.hpack_table_size_ && server_http2settings_.hpack_table_size_) { EXPECT_NE(0, nghttp2_session_get_hd_deflate_dynamic_table_size(client_->session())); EXPECT_NE(0, nghttp2_session_get_hd_deflate_dynamic_table_size(server_->session())); } else { EXPECT_EQ(0, nghttp2_session_get_hd_deflate_dynamic_table_size(client_->session())); EXPECT_EQ(0, nghttp2_session_get_hd_deflate_dynamic_table_size(server_->session())); } }
0
[ "CWE-400", "CWE-703" ]
envoy
afc39bea36fd436e54262f150c009e8d72db5014
294,129,296,645,985,080,000,000,000,000,000,000,000
27
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]>
void AOClient::pktSelectChar(AreaData* area, int argc, QStringList argv, AOPacket packet) { bool argument_ok; int selected_char_id = argv[1].toInt(&argument_ok); if (!argument_ok) { selected_char_id = -1; return; } if (changeCharacter(selected_char_id)) char_id = selected_char_id; }
0
[ "CWE-703", "CWE-129" ]
akashi
5566cdfedddef1f219aee33477d9c9690bf2f78b
146,264,602,616,582,280,000,000,000,000,000,000,000
12
Fix out of bounds crash on evidence
static int do_move_mount(struct nameidata *nd, char *old_name) { struct nameidata old_nd, parent_nd; struct vfsmount *p; int err = 0; if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (!old_name || !*old_name) return -EINVAL; err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd); if (err) return err; down_write(&namespace_sem); while (d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry)) ; err = -EINVAL; if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) goto out; err = -ENOENT; mutex_lock(&nd->dentry->d_inode->i_mutex); if (IS_DEADDIR(nd->dentry->d_inode)) goto out1; if (!IS_ROOT(nd->dentry) && d_unhashed(nd->dentry)) goto out1; err = -EINVAL; if (old_nd.dentry != old_nd.mnt->mnt_root) goto out1; if (old_nd.mnt == old_nd.mnt->mnt_parent) goto out1; if (S_ISDIR(nd->dentry->d_inode->i_mode) != S_ISDIR(old_nd.dentry->d_inode->i_mode)) goto out1; /* * Don't move a mount residing in a shared parent. */ if (old_nd.mnt->mnt_parent && IS_MNT_SHARED(old_nd.mnt->mnt_parent)) goto out1; /* * Don't move a mount tree containing unbindable mounts to a destination * mount which is shared. */ if (IS_MNT_SHARED(nd->mnt) && tree_contains_unbindable(old_nd.mnt)) goto out1; err = -ELOOP; for (p = nd->mnt; p->mnt_parent != p; p = p->mnt_parent) if (p == old_nd.mnt) goto out1; if ((err = attach_recursive_mnt(old_nd.mnt, nd, &parent_nd))) goto out1; spin_lock(&vfsmount_lock); /* if the mount is moved, it should no longer be expire * automatically */ list_del_init(&old_nd.mnt->mnt_expire); spin_unlock(&vfsmount_lock); out1: mutex_unlock(&nd->dentry->d_inode->i_mutex); out: up_write(&namespace_sem); if (!err) path_release(&parent_nd); path_release(&old_nd); return err; }
0
[ "CWE-269" ]
linux-2.6
ee6f958291e2a768fd727e7a67badfff0b67711a
160,554,477,402,575,080,000,000,000,000,000,000,000
71
check privileges before setting mount propagation There's a missing check for CAP_SYS_ADMIN in do_change_type(). Signed-off-by: Miklos Szeredi <[email protected]> Cc: Al Viro <[email protected]> Cc: Christoph Hellwig <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>