func
stringlengths 0
484k
| target
int64 0
1
| cwe
sequencelengths 0
4
| project
stringclasses 799
values | commit_id
stringlengths 40
40
| hash
float64 1,215,700,430,453,689,100,000,000B
340,281,914,521,452,260,000,000,000,000B
| size
int64 1
24k
| message
stringlengths 0
13.3k
|
---|---|---|---|---|---|---|---|
xfs_ilock_attr_map_shared(
struct xfs_inode *ip)
{
uint lock_mode = XFS_ILOCK_SHARED;
if (ip->i_afp &&
ip->i_afp->if_format == XFS_DINODE_FMT_BTREE &&
(ip->i_afp->if_flags & XFS_IFEXTENTS) == 0)
lock_mode = XFS_ILOCK_EXCL;
xfs_ilock(ip, lock_mode);
return lock_mode;
} | 0 | [] | linux | 01ea173e103edd5ec41acec65b9261b87e123fc2 | 106,523,469,506,465,060,000,000,000,000,000,000,000 | 12 | xfs: fix up non-directory creation in SGID directories
XFS always inherits the SGID bit if it is set on the parent inode, while
the generic inode_init_owner does not do this in a few cases where it can
create a possible security problem, see commit 0fa3ecd87848
("Fix up non-directory creation in SGID directories") for details.
Switch XFS to use the generic helper for the normal path to fix this,
just keeping the simple field inheritance open coded for the case of the
non-sgid case with the bsdgrpid mount option.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Christian Brauner <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Signed-off-by: Darrick J. Wong <[email protected]> |
int
__libc_mallopt (int param_number, int value)
{
mstate av = &main_arena;
int res = 1;
if (__malloc_initialized < 0)
ptmalloc_init ();
__libc_lock_lock (av->mutex);
LIBC_PROBE (memory_mallopt, 2, param_number, value);
/* We must consolidate main arena before changing max_fast
(see definition of set_max_fast). */
malloc_consolidate (av);
switch (param_number)
{
case M_MXFAST:
if (value >= 0 && value <= MAX_FAST_SIZE)
{
LIBC_PROBE (memory_mallopt_mxfast, 2, value, get_max_fast ());
set_max_fast (value);
}
else
res = 0;
break;
case M_TRIM_THRESHOLD:
do_set_trim_threshold (value);
break;
case M_TOP_PAD:
do_set_top_pad (value);
break;
case M_MMAP_THRESHOLD:
res = do_set_mmap_threshold (value);
break;
case M_MMAP_MAX:
do_set_mmaps_max (value);
break;
case M_CHECK_ACTION:
do_set_mallopt_check (value);
break;
case M_PERTURB:
do_set_perturb_byte (value);
break;
case M_ARENA_TEST:
if (value > 0)
do_set_arena_test (value);
break;
case M_ARENA_MAX:
if (value > 0)
do_set_arena_max (value);
break;
}
__libc_lock_unlock (av->mutex);
return res; | 0 | [
"CWE-787"
] | glibc | d6db68e66dff25d12c3bc5641b60cbd7fb6ab44f | 269,200,116,214,775,480,000,000,000,000,000,000,000 | 64 | malloc: Mitigate null-byte overflow attacks
* malloc/malloc.c (_int_free): Check for corrupt prev_size vs size.
(malloc_consolidate): Likewise. |
static int rds_conn_info_visitor(struct rds_conn_path *cp, void *buffer)
{
struct rds_info_connection *cinfo = buffer;
struct rds_connection *conn = cp->cp_conn;
if (conn->c_isv6)
return 0;
cinfo->next_tx_seq = cp->cp_next_tx_seq;
cinfo->next_rx_seq = cp->cp_next_rx_seq;
cinfo->laddr = conn->c_laddr.s6_addr32[3];
cinfo->faddr = conn->c_faddr.s6_addr32[3];
cinfo->tos = conn->c_tos;
strncpy(cinfo->transport, conn->c_trans->t_name,
sizeof(cinfo->transport));
cinfo->flags = 0;
rds_conn_info_set(cinfo->flags, test_bit(RDS_IN_XMIT, &cp->cp_flags),
SENDING);
/* XXX Future: return the state rather than these funky bits */
rds_conn_info_set(cinfo->flags,
atomic_read(&cp->cp_state) == RDS_CONN_CONNECTING,
CONNECTING);
rds_conn_info_set(cinfo->flags,
atomic_read(&cp->cp_state) == RDS_CONN_UP,
CONNECTED);
return 1;
} | 0 | [
"CWE-401"
] | linux | 5f9562ebe710c307adc5f666bf1a2162ee7977c0 | 61,449,343,161,371,690,000,000,000,000,000,000,000 | 28 | rds: memory leak in __rds_conn_create()
__rds_conn_create() did not release conn->c_path when loop_trans != 0 and
trans->t_prefer_loopback != 0 and is_outgoing == 0.
Fixes: aced3ce57cd3 ("RDS tcp loopback connection can hang")
Signed-off-by: Hangyu Hua <[email protected]>
Reviewed-by: Sharath Srinivasan <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
ext4_journalled_write_inline_data(struct inode *inode,
unsigned len,
struct page *page)
{
int ret, no_expand;
void *kaddr;
struct ext4_iloc iloc;
ret = ext4_get_inode_loc(inode, &iloc);
if (ret) {
ext4_std_error(inode->i_sb, ret);
return NULL;
}
ext4_write_lock_xattr(inode, &no_expand);
kaddr = kmap_atomic(page);
ext4_write_inline_data(inode, &iloc, kaddr, 0, len);
kunmap_atomic(kaddr);
ext4_write_unlock_xattr(inode, &no_expand);
return iloc.bh;
} | 0 | [
"CWE-416"
] | linux | 117166efb1ee8f13c38f9e96b258f16d4923f888 | 298,031,638,454,843,740,000,000,000,000,000,000,000 | 22 | ext4: do not allow external inodes for inline data
The inline data feature was implemented before we added support for
external inodes for xattrs. It makes no sense to support that
combination, but the problem is that there are a number of extended
attribute checks that are skipped if e_value_inum is non-zero.
Unfortunately, the inline data code is completely e_value_inum
unaware, and attempts to interpret the xattr fields as if it were an
inline xattr --- at which point, Hilarty Ensues.
This addresses CVE-2018-11412.
https://bugzilla.kernel.org/show_bug.cgi?id=199803
Reported-by: Jann Horn <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
Signed-off-by: Theodore Ts'o <[email protected]>
Fixes: e50e5129f384 ("ext4: xattr-in-inode support")
Cc: [email protected] |
parser_parse_script (void *source_p, /**< source code */
uint32_t parse_opts, /**< ecma_parse_opts_t option bits */
const jerry_parse_options_t *options_p) /**< additional configuration options */
{
#if JERRY_PARSER
ecma_compiled_code_t *bytecode_p = parser_parse_source (source_p,
parse_opts,
options_p);
if (JERRY_UNLIKELY (bytecode_p == NULL))
{
/* Exception has already thrown. */
return NULL;
}
#if JERRY_DEBUGGER
if ((JERRY_CONTEXT (debugger_flags) & (JERRY_DEBUGGER_CONNECTED | JERRY_DEBUGGER_PARSER_WAIT))
== (JERRY_DEBUGGER_CONNECTED | JERRY_DEBUGGER_PARSER_WAIT))
{
JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_PARSER_WAIT_MODE);
jerry_debugger_send_type (JERRY_DEBUGGER_WAITING_AFTER_PARSE);
while (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_PARSER_WAIT_MODE)
{
jerry_debugger_receive (NULL);
if (!(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED))
{
break;
}
jerry_debugger_transport_sleep ();
}
}
#endif /* JERRY_DEBUGGER */
return bytecode_p;
#else /* !JERRY_PARSER */
JERRY_UNUSED (arg_list_p);
JERRY_UNUSED (arg_list_size);
JERRY_UNUSED (source_p);
JERRY_UNUSED (source_size);
JERRY_UNUSED (parse_opts);
JERRY_UNUSED (resource_name);
ecma_raise_syntax_error (ECMA_ERR_MSG ("Source code parsing is disabled"));
return NULL;
#endif /* JERRY_PARSER */
} /* parser_parse_script */ | 0 | [
"CWE-416"
] | jerryscript | 3bcd48f72d4af01d1304b754ef19fe1a02c96049 | 273,712,587,265,824,760,000,000,000,000,000,000,000 | 49 | 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] |
TEST_F(ExprMatchTest, InWithLhsFieldPathAndArrayAsConstMatchesCorrectly) {
createMatcher(fromjson("{$expr: {$in: ['$x', {$const: [1, 2, 3]}]}}"));
ASSERT_TRUE(matches(BSON("x" << 1)));
ASSERT_TRUE(matches(BSON("x" << 3)));
ASSERT_FALSE(matches(BSON("x" << 5)));
ASSERT_FALSE(matches(BSON("y" << 2)));
ASSERT_FALSE(matches(BSON("x" << BSON("y" << 2))));
} | 0 | [] | mongo | ee97c0699fd55b498310996ee002328e533681a3 | 145,686,362,923,844,570,000,000,000,000,000,000,000 | 10 | SERVER-36993 Fix crash due to incorrect $or pushdown for indexed $expr. |
boost::optional<TimeZone> makeTimeZone(const TimeZoneDatabase* tzdb,
const Document& root,
const Expression* timeZone,
Variables* variables) {
invariant(tzdb);
if (!timeZone) {
return mongo::TimeZoneDatabase::utcZone();
}
auto timeZoneId = timeZone->evaluate(root, variables);
if (timeZoneId.nullish()) {
return boost::none;
}
uassert(40517,
str::stream() << "timezone must evaluate to a string, found "
<< typeName(timeZoneId.getType()),
timeZoneId.getType() == BSONType::String);
return tzdb->getTimeZone(timeZoneId.getString());
} | 0 | [] | mongo | 1772b9a0393b55e6a280a35e8f0a1f75c014f301 | 55,594,180,848,523,150,000,000,000,000,000,000,000 | 23 | SERVER-49404 Enforce additional checks in $arrayToObject |
cssp_read_tsrequest(STREAM token, STREAM pubkey)
{
STREAM s;
int length;
int tagval;
s = tcp_recv(NULL, 4);
if (s == NULL)
return False;
// verify ASN.1 header
if (s->p[0] != (BER_TAG_SEQUENCE | BER_TAG_CONSTRUCTED))
{
error("Expected BER_TAG_SEQUENCE|BER_TAG_CONSTRUCTED, got %x", s->p[0]);
return False;
}
// peek at first 4 bytes to get full message length
if (s->p[1] < 0x80)
length = s->p[1] - 2;
else if (s->p[1] == 0x81)
length = s->p[2] - 1;
else if (s->p[1] == 0x82)
length = (s->p[2] << 8) | s->p[3];
else
return False;
// receive the remainings of message
s = tcp_recv(s, length);
#if WITH_DEBUG_CREDSSP
streamsave(s, "tsrequest_in.raw");
printf("In TSRequest token %ld bytes\n", s_length(s));
hexdump(s->data, s_length(s));
#endif
// parse the response and into nego token
if (!ber_in_header(s, &tagval, &length) ||
tagval != (BER_TAG_SEQUENCE | BER_TAG_CONSTRUCTED))
return False;
// version [0]
if (!ber_in_header(s, &tagval, &length) ||
tagval != (BER_TAG_CTXT_SPECIFIC | BER_TAG_CONSTRUCTED | 0))
return False;
in_uint8s(s, length);
// negoToken [1]
if (token)
{
if (!ber_in_header(s, &tagval, &length)
|| tagval != (BER_TAG_CTXT_SPECIFIC | BER_TAG_CONSTRUCTED | 1))
return False;
if (!ber_in_header(s, &tagval, &length)
|| tagval != (BER_TAG_SEQUENCE | BER_TAG_CONSTRUCTED))
return False;
if (!ber_in_header(s, &tagval, &length)
|| tagval != (BER_TAG_SEQUENCE | BER_TAG_CONSTRUCTED))
return False;
if (!ber_in_header(s, &tagval, &length)
|| tagval != (BER_TAG_CTXT_SPECIFIC | BER_TAG_CONSTRUCTED | 0))
return False;
if (!ber_in_header(s, &tagval, &length) || tagval != BER_TAG_OCTET_STRING)
return False;
token->end = token->p = token->data;
out_uint8p(token, s->p, length);
s_mark_end(token);
}
// pubKey [3]
if (pubkey)
{
if (!ber_in_header(s, &tagval, &length)
|| tagval != (BER_TAG_CTXT_SPECIFIC | BER_TAG_CONSTRUCTED | 3))
return False;
if (!ber_in_header(s, &tagval, &length) || tagval != BER_TAG_OCTET_STRING)
return False;
pubkey->data = pubkey->p = s->p;
pubkey->end = pubkey->data + length;
pubkey->size = length;
}
return True;
} | 1 | [
"CWE-787"
] | rdesktop | 766ebcf6f23ccfe8323ac10242ae6e127d4505d2 | 187,804,206,189,936,650,000,000,000,000,000,000,000 | 90 | Malicious RDP server security fixes
This commit includes fixes for a set of 21 vulnerabilities in
rdesktop when a malicious RDP server is used.
All vulnerabilities was identified and reported by Eyal Itkin.
* Add rdp_protocol_error function that is used in several fixes
* Refactor of process_bitmap_updates
* Fix possible integer overflow in s_check_rem() on 32bit arch
* Fix memory corruption in process_bitmap_data - CVE-2018-8794
* Fix remote code execution in process_bitmap_data - CVE-2018-8795
* Fix remote code execution in process_plane - CVE-2018-8797
* Fix Denial of Service in mcs_recv_connect_response - CVE-2018-20175
* Fix Denial of Service in mcs_parse_domain_params - CVE-2018-20175
* Fix Denial of Service in sec_parse_crypt_info - CVE-2018-20176
* Fix Denial of Service in sec_recv - CVE-2018-20176
* Fix minor information leak in rdpdr_process - CVE-2018-8791
* Fix Denial of Service in cssp_read_tsrequest - CVE-2018-8792
* Fix remote code execution in cssp_read_tsrequest - CVE-2018-8793
* Fix Denial of Service in process_bitmap_data - CVE-2018-8796
* Fix minor information leak in rdpsnd_process_ping - CVE-2018-8798
* Fix Denial of Service in process_secondary_order - CVE-2018-8799
* Fix remote code execution in in ui_clip_handle_data - CVE-2018-8800
* Fix major information leak in ui_clip_handle_data - CVE-2018-20174
* Fix memory corruption in rdp_in_unistr - CVE-2018-20177
* Fix Denial of Service in process_demand_active - CVE-2018-20178
* Fix remote code execution in lspci_process - CVE-2018-20179
* Fix remote code execution in rdpsnddbg_process - CVE-2018-20180
* Fix remote code execution in seamless_process - CVE-2018-20181
* Fix remote code execution in seamless_process_line - CVE-2018-20182 |
const uchar *unpack(uchar* to, const uchar *from, const uchar *from_end,
uint param_data __attribute__((unused)))
{
return unpack_int64(to, from, from_end);
} | 0 | [
"CWE-416",
"CWE-703"
] | server | 08c7ab404f69d9c4ca6ca7a9cf7eec74c804f917 | 55,799,002,048,288,140,000,000,000,000,000,000,000 | 5 | MDEV-24176 Server crashes after insert in the table with virtual
column generated using date_format() and if()
vcol_info->expr is allocated on expr_arena at parsing stage. Since
expr item is allocated on expr_arena all its containee items must be
allocated on expr_arena too. Otherwise fix_session_expr() will
encounter prematurely freed item.
When table is reopened from cache vcol_info contains stale
expression. We refresh expression via TABLE::vcol_fix_exprs() but
first we must prepare a proper context (Vcol_expr_context) which meets
some requirements:
1. As noted above expr update must be done on expr_arena as there may
be new items created. It was a bug in fix_session_expr_for_read() and
was just not reproduced because of no second refix. Now refix is done
for more cases so it does reproduce. Tests affected: vcol.binlog
2. Also name resolution context must be narrowed to the single table.
Tested by: vcol.update main.default vcol.vcol_syntax gcol.gcol_bugfixes
3. sql_mode must be clean and not fail expr update.
sql_mode such as MODE_NO_BACKSLASH_ESCAPES, MODE_NO_ZERO_IN_DATE, etc
must not affect vcol expression update. If the table was created
successfully any further evaluation must not fail. Tests affected:
main.func_like
Reviewed by: Sergei Golubchik <[email protected]> |
cmsBool Type_ParametricCurve_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
cmsToneCurve* Curve = (cmsToneCurve*) Ptr;
int i, nParams, typen;
static const int ParamsByType[] = { 0, 1, 3, 4, 5, 7 };
typen = Curve -> Segments[0].Type;
if (Curve ->nSegments > 1 || typen < 1) {
cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Multisegment or Inverted parametric curves cannot be written");
return FALSE;
}
if (typen > 5) {
cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported parametric curve");
return FALSE;
}
nParams = ParamsByType[typen];
if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) (Curve ->Segments[0].Type - 1))) return FALSE;
if (!_cmsWriteUInt16Number(io, 0)) return FALSE; // Reserved
for (i=0; i < nParams; i++) {
if (!_cmsWrite15Fixed16Number(io, Curve -> Segments[0].Params[i])) return FALSE;
}
return TRUE;
cmsUNUSED_PARAMETER(nItems);
} | 0 | [] | Little-CMS | 41d222df1bc6188131a8f46c32eab0a4d4cdf1b6 | 210,792,086,046,338,060,000,000,000,000,000,000,000 | 33 | 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. |
void xaddCommand(client *c) {
streamID id;
int id_given = 0; /* Was an ID different than "*" specified? */
long long maxlen = -1; /* If left to -1 no trimming is performed. */
int approx_maxlen = 0; /* If 1 only delete whole radix tree nodes, so
the maximum length is not applied verbatim. */
int maxlen_arg_idx = 0; /* Index of the count in MAXLEN, for rewriting. */
/* Parse options. */
int i = 2; /* This is the first argument position where we could
find an option, or the ID. */
for (; i < c->argc; i++) {
int moreargs = (c->argc-1) - i; /* Number of additional arguments. */
char *opt = c->argv[i]->ptr;
if (opt[0] == '*' && opt[1] == '\0') {
/* This is just a fast path for the common case of auto-ID
* creation. */
break;
} else if (!strcasecmp(opt,"maxlen") && moreargs) {
approx_maxlen = 0;
char *next = c->argv[i+1]->ptr;
/* Check for the form MAXLEN ~ <count>. */
if (moreargs >= 2 && next[0] == '~' && next[1] == '\0') {
approx_maxlen = 1;
i++;
} else if (moreargs >= 2 && next[0] == '=' && next[1] == '\0') {
i++;
}
if (getLongLongFromObjectOrReply(c,c->argv[i+1],&maxlen,NULL)
!= C_OK) return;
if (maxlen < 0) {
addReplyError(c,"The MAXLEN argument must be >= 0.");
return;
}
i++;
maxlen_arg_idx = i;
} else {
/* If we are here is a syntax error or a valid ID. */
if (streamParseStrictIDOrReply(c,c->argv[i],&id,0) != C_OK) return;
id_given = 1;
break;
}
}
int field_pos = i+1;
/* Check arity. */
if ((c->argc - field_pos) < 2 || ((c->argc-field_pos) % 2) == 1) {
addReplyError(c,"wrong number of arguments for XADD");
return;
}
/* Return ASAP if minimal ID (0-0) was given so we avoid possibly creating
* a new stream and have streamAppendItem fail, leaving an empty key in the
* database. */
if (id_given && id.ms == 0 && id.seq == 0) {
addReplyError(c,"The ID specified in XADD must be greater than 0-0");
return;
}
/* Lookup the stream at key. */
robj *o;
stream *s;
if ((o = streamTypeLookupWriteOrCreate(c,c->argv[1])) == NULL) return;
s = o->ptr;
/* Return ASAP if the stream has reached the last possible ID */
if (s->last_id.ms == UINT64_MAX && s->last_id.seq == UINT64_MAX) {
addReplyError(c,"The stream has exhausted the last possible ID, "
"unable to add more items");
return;
}
/* Append using the low level function and return the ID. */
if (streamAppendItem(s,c->argv+field_pos,(c->argc-field_pos)/2,
&id, id_given ? &id : NULL)
== C_ERR)
{
addReplyError(c,"The ID specified in XADD is equal or smaller than the "
"target stream top item");
return;
}
addReplyStreamID(c,&id);
signalModifiedKey(c,c->db,c->argv[1]);
notifyKeyspaceEvent(NOTIFY_STREAM,"xadd",c->argv[1],c->db->id);
server.dirty++;
if (maxlen >= 0) {
/* Notify xtrim event if needed. */
if (streamTrimByLength(s,maxlen,approx_maxlen)) {
notifyKeyspaceEvent(NOTIFY_STREAM,"xtrim",c->argv[1],c->db->id);
}
if (approx_maxlen) streamRewriteApproxMaxlen(c,s,maxlen_arg_idx);
}
/* Let's rewrite the ID argument with the one actually generated for
* AOF/replication propagation. */
robj *idarg = createObjectFromStreamID(&id);
rewriteClientCommandArgument(c,i,idarg);
decrRefCount(idarg);
/* We need to signal to blocked clients that there is new data on this
* stream. */
if (server.blocked_clients_by_type[BLOCKED_STREAM])
signalKeyAsReady(c->db, c->argv[1]);
} | 1 | [
"CWE-190"
] | redis | f6a40570fa63d5afdd596c78083d754081d80ae3 | 172,555,350,341,445,700,000,000,000,000,000,000,000 | 107 | Fix ziplist and listpack overflows and truncations (CVE-2021-32627, CVE-2021-32628)
- fix possible heap corruption in ziplist and listpack resulting by trying to
allocate more than the maximum size of 4GB.
- prevent ziplist (hash and zset) from reaching size of above 1GB, will be
converted to HT encoding, that's not a useful size.
- prevent listpack (stream) from reaching size of above 1GB.
- XADD will start a new listpack if the new record may cause the previous
listpack to grow over 1GB.
- XADD will respond with an error if a single stream record is over 1GB
- List type (ziplist in quicklist) was truncating strings that were over 4GB,
now it'll respond with an error. |
void save_in_comment_state()
{
m_echo_saved= m_echo;
in_comment_saved= in_comment;
} | 0 | [
"CWE-703"
] | server | 39feab3cd31b5414aa9b428eaba915c251ac34a2 | 110,739,814,737,899,050,000,000,000,000,000,000,000 | 5 | MDEV-26412 Server crash in Item_field::fix_outer_field for INSERT SELECT
IF an INSERT/REPLACE SELECT statement contained an ON expression in the top
level select and this expression used a subquery with a column reference
that could not be resolved then an attempt to resolve this reference as
an outer reference caused a crash of the server. This happened because the
outer context field in the Name_resolution_context structure was not set
to NULL for such references. Rather it pointed to the first element in
the select_stack.
Note that starting from 10.4 we cannot use the SELECT_LEX::outer_select()
method when parsing a SELECT construct.
Approved by Oleksandr Byelkin <[email protected]> |
static uint8_t *read_vblock(AVIOContext *src, uint32_t *size,
uint32_t key, uint32_t *k2, int align)
{
uint8_t tmp[4];
uint8_t *buf;
unsigned n;
if (avio_read(src, tmp, 4) != 4)
return NULL;
decode_block(tmp, tmp, 4, key, k2, align);
n = get_v(tmp, 4);
if (n < 4)
return NULL;
buf = av_malloc(n);
if (!buf)
return NULL;
*size = n;
n -= 4;
memcpy(buf, tmp, 4);
if (avio_read(src, buf + 4, n) == n) {
decode_block(buf + 4, buf + 4, n, key, k2, align);
} else {
av_free(buf);
buf = NULL;
}
return buf;
} | 0 | [
"CWE-787"
] | FFmpeg | 27a99e2c7d450fef15594671eef4465c8a166bd7 | 75,162,066,353,964,890,000,000,000,000,000,000,000 | 34 | avformat/vividas: improve extradata packing checks in track_header()
Fixes: out of array accesses
Fixes: 26622/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6581200338288640
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <[email protected]> |
void serialize(DataRangeCursor* cursor) {
uassertStatusOK(cursor->writeAndAdvance<LittleEndian<int32_t>>(originalOpCode));
uassertStatusOK(cursor->writeAndAdvance<LittleEndian<int32_t>>(uncompressedSize));
uassertStatusOK(cursor->writeAndAdvance<LittleEndian<uint8_t>>(compressorId));
} | 0 | [] | mongo | 5ad69b851801edadbfde8fdf271f4ba7c21170b5 | 284,847,839,512,401,980,000,000,000,000,000,000,000 | 5 | SERVER-31273 Use Source/Sink version of snappy functions
(cherry picked from commit 59ead734faa8aa51f0c53bf2bd39d0a0247ddf99) |
bool LEX::sp_exit_block(THD *thd, sp_label *lab)
{
/*
When jumping to a BEGIN-END block end, the target jump
points to the block hpop/cpop cleanup instructions,
so we should exclude the block context here.
When jumping to something else (i.e., SP_LAB_ITER),
there are no hpop/cpop at the jump destination,
so we should include the block context here for cleanup.
*/
bool exclusive= (lab->type == sp_label::BEGIN);
return sp_change_context(thd, lab->ctx, exclusive) ||
sphead->add_instr_jump_forward_with_backpatch(thd, spcont, lab);
} | 0 | [
"CWE-703"
] | server | 39feab3cd31b5414aa9b428eaba915c251ac34a2 | 185,881,251,538,075,960,000,000,000,000,000,000,000 | 14 | MDEV-26412 Server crash in Item_field::fix_outer_field for INSERT SELECT
IF an INSERT/REPLACE SELECT statement contained an ON expression in the top
level select and this expression used a subquery with a column reference
that could not be resolved then an attempt to resolve this reference as
an outer reference caused a crash of the server. This happened because the
outer context field in the Name_resolution_context structure was not set
to NULL for such references. Rather it pointed to the first element in
the select_stack.
Note that starting from 10.4 we cannot use the SELECT_LEX::outer_select()
method when parsing a SELECT construct.
Approved by Oleksandr Byelkin <[email protected]> |
static void enriched_wrap (struct enriched_state *stte)
{
int x;
int extra;
if (stte->line_len)
{
if (stte->tag_level[RICH_CENTER] || stte->tag_level[RICH_FLUSHRIGHT])
{
/* Strip trailing white space */
size_t y = stte->line_used - 1;
while (y && iswspace (stte->line[y]))
{
stte->line[y] = (wchar_t) '\0';
y--;
stte->line_used--;
stte->line_len--;
}
if (stte->tag_level[RICH_CENTER])
{
/* Strip leading whitespace */
y = 0;
while (stte->line[y] && iswspace (stte->line[y]))
y++;
if (y)
{
size_t z;
for (z = y ; z <= stte->line_used; z++)
{
stte->line[z - y] = stte->line[z];
}
stte->line_len -= y;
stte->line_used -= y;
}
}
}
extra = stte->WrapMargin - stte->line_len - stte->indent_len -
(stte->tag_level[RICH_INDENT_RIGHT] * IndentSize);
if (extra > 0)
{
if (stte->tag_level[RICH_CENTER])
{
x = extra / 2;
while (x)
{
state_putc (' ', stte->s);
x--;
}
}
else if (stte->tag_level[RICH_FLUSHRIGHT])
{
x = extra-1;
while (x)
{
state_putc (' ', stte->s);
x--;
}
}
}
state_putws ((const wchar_t*) stte->line, stte->s);
}
state_putc ('\n', stte->s);
stte->line[0] = (wchar_t) '\0';
stte->line_len = 0;
stte->line_used = 0;
stte->indent_len = 0;
if (stte->s->prefix)
{
state_puts (stte->s->prefix, stte->s);
stte->indent_len += mutt_strlen (stte->s->prefix);
}
if (stte->tag_level[RICH_EXCERPT])
{
x = stte->tag_level[RICH_EXCERPT];
while (x)
{
if (stte->s->prefix)
{
state_puts (stte->s->prefix, stte->s);
stte->indent_len += mutt_strlen (stte->s->prefix);
}
else
{
state_puts ("> ", stte->s);
stte->indent_len += mutt_strlen ("> ");
}
x--;
}
}
else
stte->indent_len = 0;
if (stte->tag_level[RICH_INDENT])
{
x = stte->tag_level[RICH_INDENT] * IndentSize;
stte->indent_len += x;
while (x)
{
state_putc (' ', stte->s);
x--;
}
}
} | 0 | [
"CWE-120"
] | mutt | e5ed080c00e59701ca62ef9b2a6d2612ebf765a5 | 147,220,683,308,390,000,000,000,000,000,000,000,000 | 109 | Fix uudecode buffer overflow.
mutt_decode_uuencoded() used each line's initial "length character"
without any validation. It would happily read past the end of the
input line, and with a suitable value even past the length of the
input buffer.
As I noted in ticket 404, there are several other changes that could
be added to make the parser more robust. However, to avoid
accidentally introducing another bug or regression, I'm restricting
this patch to simply addressing the overflow.
Thanks to Tavis Ormandy for reporting the issue, along with a sample
message demonstrating the problem. |
unsigned long ERR_peek_error()
{
return err_helper(true);
} | 0 | [
"CWE-254"
] | mysql-server | e7061f7e5a96c66cb2e0bf46bec7f6ff35801a69 | 137,500,078,429,088,720,000,000,000,000,000,000,000 | 4 | Bug #22738607: YASSL FUNCTION X509_NAME_GET_INDEX_BY_NID IS NOT WORKING AS EXPECTED. |
int mnt_fs_print_debug(struct libmnt_fs *fs, FILE *file)
{
if (!fs || !file)
return -EINVAL;
fprintf(file, "------ fs:\n");
fprintf(file, "source: %s\n", mnt_fs_get_source(fs));
fprintf(file, "target: %s\n", mnt_fs_get_target(fs));
fprintf(file, "fstype: %s\n", mnt_fs_get_fstype(fs));
if (mnt_fs_get_options(fs))
fprintf(file, "optstr: %s\n", mnt_fs_get_options(fs));
if (mnt_fs_get_vfs_options(fs))
fprintf(file, "VFS-optstr: %s\n", mnt_fs_get_vfs_options(fs));
if (mnt_fs_get_fs_options(fs))
fprintf(file, "FS-opstr: %s\n", mnt_fs_get_fs_options(fs));
if (mnt_fs_get_user_options(fs))
fprintf(file, "user-optstr: %s\n", mnt_fs_get_user_options(fs));
if (mnt_fs_get_optional_fields(fs))
fprintf(file, "optional-fields: '%s'\n", mnt_fs_get_optional_fields(fs));
if (mnt_fs_get_attributes(fs))
fprintf(file, "attributes: %s\n", mnt_fs_get_attributes(fs));
if (mnt_fs_get_root(fs))
fprintf(file, "root: %s\n", mnt_fs_get_root(fs));
if (mnt_fs_get_swaptype(fs))
fprintf(file, "swaptype: %s\n", mnt_fs_get_swaptype(fs));
if (mnt_fs_get_size(fs))
fprintf(file, "size: %jd\n", mnt_fs_get_size(fs));
if (mnt_fs_get_usedsize(fs))
fprintf(file, "usedsize: %jd\n", mnt_fs_get_usedsize(fs));
if (mnt_fs_get_priority(fs))
fprintf(file, "priority: %d\n", mnt_fs_get_priority(fs));
if (mnt_fs_get_bindsrc(fs))
fprintf(file, "bindsrc: %s\n", mnt_fs_get_bindsrc(fs));
if (mnt_fs_get_freq(fs))
fprintf(file, "freq: %d\n", mnt_fs_get_freq(fs));
if (mnt_fs_get_passno(fs))
fprintf(file, "pass: %d\n", mnt_fs_get_passno(fs));
if (mnt_fs_get_id(fs))
fprintf(file, "id: %d\n", mnt_fs_get_id(fs));
if (mnt_fs_get_parent_id(fs))
fprintf(file, "parent: %d\n", mnt_fs_get_parent_id(fs));
if (mnt_fs_get_devno(fs))
fprintf(file, "devno: %d:%d\n", major(mnt_fs_get_devno(fs)),
minor(mnt_fs_get_devno(fs)));
if (mnt_fs_get_tid(fs))
fprintf(file, "tid: %d\n", mnt_fs_get_tid(fs));
if (mnt_fs_get_comment(fs))
fprintf(file, "comment: '%s'\n", mnt_fs_get_comment(fs));
return 0;
} | 0 | [
"CWE-552",
"CWE-703"
] | util-linux | 166e87368ae88bf31112a30e078cceae637f4cdb | 184,415,041,039,452,360,000,000,000,000,000,000,000 | 54 | libmount: remove support for deleted mount table entries
The "(deleted)" suffix has been originally used by kernel for deleted
mountpoints. Since kernel commit 9d4d65748a5ca26ea8650e50ba521295549bf4e3
(Dec 2014) kernel does not use this suffix for mount stuff in /proc at
all. Let's remove this support from libmount too.
Signed-off-by: Karel Zak <[email protected]> |
inline ulonglong val_uint() { return (ulonglong) val_int(); } | 0 | [] | mysql-server | f7316aa0c9a3909fc7498e7b95d5d3af044a7e21 | 61,107,946,368,233,460,000,000,000,000,000,000,000 | 1 | Bug#26361149 MYSQL SERVER CRASHES AT: COL IN(IFNULL(CONST,
COL), NAME_CONST('NAME', NULL))
Backport of Bug#19143243 fix.
NAME_CONST item can return NULL_ITEM type in case of incorrect arguments.
NULL_ITEM has special processing in Item_func_in function.
In Item_func_in::fix_length_and_dec an array of possible comparators is
created. Since NAME_CONST function has NULL_ITEM type, corresponding
array element is empty. Then NAME_CONST is wrapped to ITEM_CACHE.
ITEM_CACHE can not return proper type(NULL_ITEM) in Item_func_in::val_int(),
so the NULL_ITEM is attempted compared with an empty comparator.
The fix is to disable the caching of Item_name_const item. |
struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx)
{
struct ldb_context *ldb;
int ret;
const char *modules_path = getenv("LDB_MODULES_PATH");
if (modules_path == NULL) {
modules_path = LDB_MODULESDIR;
}
ret = ldb_modules_load(modules_path, LDB_VERSION);
if (ret != LDB_SUCCESS) {
return NULL;
}
ldb = talloc_zero(mem_ctx, struct ldb_context);
if (ldb == NULL) {
return NULL;
}
/* A new event context so that callers who don't want ldb
* operating on their global event context can work without
* having to provide their own private one explicitly */
if (ev_ctx == NULL) {
ev_ctx = tevent_context_init(ldb);
if (ev_ctx == NULL) {
talloc_free(ldb);
return NULL;
}
tevent_set_debug(ev_ctx, ldb_tevent_debug, ldb);
tevent_loop_allow_nesting(ev_ctx);
}
ret = ldb_setup_wellknown_attributes(ldb);
if (ret != LDB_SUCCESS) {
talloc_free(ldb);
return NULL;
}
ldb_set_utf8_default(ldb);
ldb_set_create_perms(ldb, 0666);
ldb_set_modules_dir(ldb, LDB_MODULESDIR);
ldb_set_event_context(ldb, ev_ctx);
ret = ldb_register_extended_match_rules(ldb);
if (ret != LDB_SUCCESS) {
talloc_free(ldb);
return NULL;
}
/* TODO: get timeout from options if available there */
ldb->default_timeout = 300; /* set default to 5 minutes */
talloc_set_destructor((TALLOC_CTX *)ldb, ldb_context_destructor);
return ldb;
} | 0 | [
"CWE-476"
] | samba | d8b9bb274b7e7a390cf3bda9cd732cb2227bdbde | 337,971,201,417,570,300,000,000,000,000,000,000,000 | 56 | CVE-2020-10730: lib ldb: Check if ldb_lock_backend_callback called twice
Prevent use after free issues if ldb_lock_backend_callback is called
twice, usually due to ldb_module_done being called twice. This can happen if a
module ignores the return value from function a function that calls
ldb_module_done as part of it's error handling.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14364
Signed-off-by: Gary Lockyer <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]> |
void sctp_v4_err(struct sk_buff *skb, __u32 info)
{
struct iphdr *iph = (struct iphdr *)skb->data;
const int ihlen = iph->ihl * 4;
const int type = icmp_hdr(skb)->type;
const int code = icmp_hdr(skb)->code;
struct sock *sk;
struct sctp_association *asoc = NULL;
struct sctp_transport *transport;
struct inet_sock *inet;
sk_buff_data_t saveip, savesctp;
int err;
if (skb->len < ihlen + 8) {
ICMP_INC_STATS_BH(&init_net, ICMP_MIB_INERRORS);
return;
}
/* Fix up skb to look at the embedded net header. */
saveip = skb->network_header;
savesctp = skb->transport_header;
skb_reset_network_header(skb);
skb_set_transport_header(skb, ihlen);
sk = sctp_err_lookup(AF_INET, skb, sctp_hdr(skb), &asoc, &transport);
/* Put back, the original values. */
skb->network_header = saveip;
skb->transport_header = savesctp;
if (!sk) {
ICMP_INC_STATS_BH(&init_net, ICMP_MIB_INERRORS);
return;
}
/* Warning: The sock lock is held. Remember to call
* sctp_err_finish!
*/
switch (type) {
case ICMP_PARAMETERPROB:
err = EPROTO;
break;
case ICMP_DEST_UNREACH:
if (code > NR_ICMP_UNREACH)
goto out_unlock;
/* PMTU discovery (RFC1191) */
if (ICMP_FRAG_NEEDED == code) {
sctp_icmp_frag_needed(sk, asoc, transport, info);
goto out_unlock;
}
else {
if (ICMP_PROT_UNREACH == code) {
sctp_icmp_proto_unreachable(sk, asoc,
transport);
goto out_unlock;
}
}
err = icmp_err_convert[code].errno;
break;
case ICMP_TIME_EXCEEDED:
/* Ignore any time exceeded errors due to fragment reassembly
* timeouts.
*/
if (ICMP_EXC_FRAGTIME == code)
goto out_unlock;
err = EHOSTUNREACH;
break;
default:
goto out_unlock;
}
inet = inet_sk(sk);
if (!sock_owned_by_user(sk) && inet->recverr) {
sk->sk_err = err;
sk->sk_error_report(sk);
} else { /* Only an error on timeout */
sk->sk_err_soft = err;
}
out_unlock:
sctp_err_finish(sk, asoc);
} | 0 | [
"CWE-362"
] | linux | ae53b5bd77719fed58086c5be60ce4f22bffe1c6 | 210,540,265,983,098,640,000,000,000,000,000,000,000 | 81 | sctp: Fix another socket race during accept/peeloff
There is a race between sctp_rcv() and sctp_accept() where we
have moved the association from the listening socket to the
accepted socket, but sctp_rcv() processing cached the old
socket and continues to use it.
The easy solution is to check for the socket mismatch once we've
grabed the socket lock. If we hit a mis-match, that means
that were are currently holding the lock on the listening socket,
but the association is refrencing a newly accepted socket. We need
to drop the lock on the old socket and grab the lock on the new one.
A more proper solution might be to create accepted sockets when
the new association is established, similar to TCP. That would
eliminate the race for 1-to-1 style sockets, but it would still
existing for 1-to-many sockets where a user wished to peeloff an
association. For now, we'll live with this easy solution as
it addresses the problem.
Reported-by: Michal Hocko <[email protected]>
Reported-by: Karsten Keil <[email protected]>
Signed-off-by: Vlad Yasevich <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
static void test_bug28075()
{
int rc;
DBUG_ENTER("test_bug28075");
myheader("test_bug28075");
rc= mysql_dump_debug_info(mysql);
DIE_UNLESS(rc == 0);
rc= mysql_ping(mysql);
DIE_UNLESS(rc == 0);
DBUG_VOID_RETURN;
} | 0 | [
"CWE-284",
"CWE-295"
] | mysql-server | 3bd5589e1a5a93f9c224badf983cd65c45215390 | 47,576,808,463,694,270,000,000,000,000,000,000,000 | 15 | WL#6791 : Redefine client --ssl option to imply enforced encryption
# Changed the meaning of the --ssl=1 option of all client binaries
to mean force ssl, not try ssl and fail over to eunecrypted
# Added a new MYSQL_OPT_SSL_ENFORCE mysql_options()
option to specify that an ssl connection is required.
# Added a new macro SSL_SET_OPTIONS() to the client
SSL handling headers that sets all the relevant SSL options at
once.
# Revamped all of the current native clients to use the new macro
# Removed some Windows line endings.
# Added proper handling of the new option into the ssl helper
headers.
# If SSL is mandatory assume that the media is secure enough
for the sha256 plugin to do unencrypted password exchange even
before establishing a connection.
# Set the default ssl cipher to DHE-RSA-AES256-SHA if none is
specified.
# updated test cases that require a non-default cipher to spawn
a mysql command line tool binary since mysqltest has no support
for specifying ciphers.
# updated the replication slave connection code to always enforce
SSL if any of the SSL config options is present.
# test cases added and updated.
# added a mysql_get_option() API to return mysql_options()
values. Used the new API inside the sha256 plugin.
# Fixed compilation warnings because of unused variables.
# Fixed test failures (mysql_ssl and bug13115401)
# Fixed whitespace issues.
# Fully implemented the mysql_get_option() function.
# Added a test case for mysql_get_option()
# fixed some trailing whitespace issues
# fixed some uint/int warnings in mysql_client_test.c
# removed shared memory option from non-windows get_options
tests
# moved MYSQL_OPT_LOCAL_INFILE to the uint options |
ext4_ext_more_to_rm(struct ext4_ext_path *path)
{
BUG_ON(path->p_idx == NULL);
if (path->p_idx < EXT_FIRST_INDEX(path->p_hdr))
return 0;
/*
* if truncate on deeper level happened, it wasn't partial,
* so we have to consider current index for truncation
*/
if (le16_to_cpu(path->p_hdr->eh_entries) == path->p_block)
return 0;
return 1;
} | 0 | [
"CWE-362"
] | linux-2.6 | dee1f973ca341c266229faa5a1a5bb268bed3531 | 333,482,574,762,302,370,000,000,000,000,000,000,000 | 15 | ext4: race-condition protection for ext4_convert_unwritten_extents_endio
We assumed that at the time we call ext4_convert_unwritten_extents_endio()
extent in question is fully inside [map.m_lblk, map->m_len] because
it was already split during submission. But this may not be true due to
a race between writeback vs fallocate.
If extent in question is larger than requested we will split it again.
Special precautions should being done if zeroout required because
[map.m_lblk, map->m_len] already contains valid data.
Signed-off-by: Dmitry Monakhov <[email protected]>
Signed-off-by: "Theodore Ts'o" <[email protected]>
Cc: [email protected] |
static int ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNUSED_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=NULL;
#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 | 43,417,826,200,159,770,000,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 |
static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
s64 nclusters, unsigned int flags)
{
s64 free_clusters, dirty_clusters, rsv, resv_clusters;
struct percpu_counter *fcc = &sbi->s_freeclusters_counter;
struct percpu_counter *dcc = &sbi->s_dirtyclusters_counter;
free_clusters = percpu_counter_read_positive(fcc);
dirty_clusters = percpu_counter_read_positive(dcc);
resv_clusters = atomic64_read(&sbi->s_resv_clusters);
/*
* r_blocks_count should always be multiple of the cluster ratio so
* we are safe to do a plane bit shift only.
*/
rsv = (ext4_r_blocks_count(sbi->s_es) >> sbi->s_cluster_bits) +
resv_clusters;
if (free_clusters - (nclusters + rsv + dirty_clusters) <
EXT4_FREECLUSTERS_WATERMARK) {
free_clusters = percpu_counter_sum_positive(fcc);
dirty_clusters = percpu_counter_sum_positive(dcc);
}
/* Check whether we have space after accounting for current
* dirty clusters & root reserved clusters.
*/
if (free_clusters >= (rsv + nclusters + dirty_clusters))
return 1;
/* Hm, nope. Are (enough) root reserved clusters available? */
if (uid_eq(sbi->s_resuid, current_fsuid()) ||
(!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
capable(CAP_SYS_RESOURCE) ||
(flags & EXT4_MB_USE_ROOT_BLOCKS)) {
if (free_clusters >= (nclusters + dirty_clusters +
resv_clusters))
return 1;
}
/* No free blocks. Let's see if we can dip into reserved pool */
if (flags & EXT4_MB_USE_RESERVED) {
if (free_clusters >= (nclusters + dirty_clusters))
return 1;
}
return 0;
} | 0 | [] | linux | 7dac4a1726a9c64a517d595c40e95e2d0d135f6f | 150,799,520,821,525,900,000,000,000,000,000,000,000 | 47 | 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] |
void kvm_notify_acked_gsi(struct kvm *kvm, int gsi)
{
struct kvm_irq_ack_notifier *kian;
hlist_for_each_entry_rcu(kian, &kvm->irq_ack_notifier_list,
link)
if (kian->gsi == gsi)
kian->irq_acked(kian);
} | 0 | [
"CWE-20",
"CWE-617"
] | linux | 36ae3c0a36b7456432fedce38ae2f7bd3e01a563 | 306,266,098,523,588,670,000,000,000,000,000,000,000 | 9 | KVM: Don't accept obviously wrong gsi values via KVM_IRQFD
We cannot add routes for gsi values >= KVM_MAX_IRQ_ROUTES -- see
kvm_set_irq_routing(). Hence, there is no sense in accepting them
via KVM_IRQFD. Prevent them from entering the system in the first
place.
Signed-off-by: Jan H. Schönherr <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]> |
smb2_is_status_pending(char *buf, struct TCP_Server_Info *server)
{
struct smb2_hdr *shdr = (struct smb2_hdr *)buf;
int scredits, in_flight;
if (shdr->Status != STATUS_PENDING)
return false;
if (shdr->CreditRequest) {
spin_lock(&server->req_lock);
server->credits += le16_to_cpu(shdr->CreditRequest);
scredits = server->credits;
in_flight = server->in_flight;
spin_unlock(&server->req_lock);
wake_up(&server->request_q);
trace_smb3_add_credits(server->CurrentMid,
server->conn_id, server->hostname, scredits,
le16_to_cpu(shdr->CreditRequest), in_flight);
cifs_dbg(FYI, "%s: status pending add %u credits total=%d\n",
__func__, le16_to_cpu(shdr->CreditRequest), scredits);
}
return true;
} | 0 | [
"CWE-476"
] | linux | d6f5e358452479fa8a773b5c6ccc9e4ec5a20880 | 52,456,296,529,458,890,000,000,000,000,000,000,000 | 25 | cifs: fix NULL ptr dereference in smb2_ioctl_query_info()
When calling smb2_ioctl_query_info() with invalid
smb_query_info::flags, a NULL ptr dereference is triggered when trying
to kfree() uninitialised rqst[n].rq_iov array.
This also fixes leaked paths that are created in SMB2_open_init()
which required SMB2_open_free() to properly free them.
Here is a small C reproducer that triggers it
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#define die(s) perror(s), exit(1)
#define QUERY_INFO 0xc018cf07
int main(int argc, char *argv[])
{
int fd;
if (argc < 2)
exit(1);
fd = open(argv[1], O_RDONLY);
if (fd == -1)
die("open");
if (ioctl(fd, QUERY_INFO, (uint32_t[]) { 0, 0, 0, 4, 0, 0}) == -1)
die("ioctl");
close(fd);
return 0;
}
mount.cifs //srv/share /mnt -o ...
gcc repro.c && ./a.out /mnt/f0
[ 1832.124468] CIFS: VFS: \\w22-dc.zelda.test\test Invalid passthru query flags: 0x4
[ 1832.125043] general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN NOPTI
[ 1832.125764] KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
[ 1832.126241] CPU: 3 PID: 1133 Comm: a.out Not tainted 5.17.0-rc8 #2
[ 1832.126630] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-0-g2dd4b9b-rebuilt.opensuse.org 04/01/2014
[ 1832.127322] RIP: 0010:smb2_ioctl_query_info+0x7a3/0xe30 [cifs]
[ 1832.127749] Code: 00 00 00 fc ff df 48 c1 ea 03 80 3c 02 00 0f 85 6c 05 00 00 48 b8 00 00 00 00 00 fc ff df 4d 8b 74 24 28 4c 89 f2 48 c1 ea 03 <80> 3c 02 00 0f 85 cb 04 00 00 49 8b 3e e8 bb fc fa ff 48 89 da 48
[ 1832.128911] RSP: 0018:ffffc90000957b08 EFLAGS: 00010256
[ 1832.129243] RAX: dffffc0000000000 RBX: ffff888117e9b850 RCX: ffffffffa020580d
[ 1832.129691] RDX: 0000000000000000 RSI: 0000000000000004 RDI: ffffffffa043a2c0
[ 1832.130137] RBP: ffff888117e9b878 R08: 0000000000000001 R09: 0000000000000003
[ 1832.130585] R10: fffffbfff4087458 R11: 0000000000000001 R12: ffff888117e9b800
[ 1832.131037] R13: 00000000ffffffea R14: 0000000000000000 R15: ffff888117e9b8a8
[ 1832.131485] FS: 00007fcee9900740(0000) GS:ffff888151a00000(0000) knlGS:0000000000000000
[ 1832.131993] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1832.132354] CR2: 00007fcee9a1ef5e CR3: 0000000114cd2000 CR4: 0000000000350ee0
[ 1832.132801] Call Trace:
[ 1832.132962] <TASK>
[ 1832.133104] ? smb2_query_reparse_tag+0x890/0x890 [cifs]
[ 1832.133489] ? cifs_mapchar+0x460/0x460 [cifs]
[ 1832.133822] ? rcu_read_lock_sched_held+0x3f/0x70
[ 1832.134125] ? cifs_strndup_to_utf16+0x15b/0x250 [cifs]
[ 1832.134502] ? lock_downgrade+0x6f0/0x6f0
[ 1832.134760] ? cifs_convert_path_to_utf16+0x198/0x220 [cifs]
[ 1832.135170] ? smb2_check_message+0x1080/0x1080 [cifs]
[ 1832.135545] cifs_ioctl+0x1577/0x3320 [cifs]
[ 1832.135864] ? lock_downgrade+0x6f0/0x6f0
[ 1832.136125] ? cifs_readdir+0x2e60/0x2e60 [cifs]
[ 1832.136468] ? rcu_read_lock_sched_held+0x3f/0x70
[ 1832.136769] ? __rseq_handle_notify_resume+0x80b/0xbe0
[ 1832.137096] ? __up_read+0x192/0x710
[ 1832.137327] ? __ia32_sys_rseq+0xf0/0xf0
[ 1832.137578] ? __x64_sys_openat+0x11f/0x1d0
[ 1832.137850] __x64_sys_ioctl+0x127/0x190
[ 1832.138103] do_syscall_64+0x3b/0x90
[ 1832.138378] entry_SYSCALL_64_after_hwframe+0x44/0xae
[ 1832.138702] RIP: 0033:0x7fcee9a253df
[ 1832.138937] Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <41> 89 c0 3d 00 f0 ff ff 77 1f 48 8b 44 24 18 64 48 2b 04 25 28 00
[ 1832.140107] RSP: 002b:00007ffeba94a8a0 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[ 1832.140606] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fcee9a253df
[ 1832.141058] RDX: 00007ffeba94a910 RSI: 00000000c018cf07 RDI: 0000000000000003
[ 1832.141503] RBP: 00007ffeba94a930 R08: 00007fcee9b24db0 R09: 00007fcee9b45c4e
[ 1832.141948] R10: 00007fcee9918d40 R11: 0000000000000246 R12: 00007ffeba94aa48
[ 1832.142396] R13: 0000000000401176 R14: 0000000000403df8 R15: 00007fcee9b78000
[ 1832.142851] </TASK>
[ 1832.142994] Modules linked in: cifs cifs_arc4 cifs_md4 bpf_preload [last unloaded: cifs]
Cc: [email protected]
Signed-off-by: Paulo Alcantara (SUSE) <[email protected]>
Signed-off-by: Steve French <[email protected]> |
T3FontCache::T3FontCache(const Ref *fontIDA, double m11A, double m12A,
double m21A, double m22A,
int glyphXA, int glyphYA, int glyphWA, int glyphHA,
bool validBBoxA, bool aa) {
fontID = *fontIDA;
m11 = m11A;
m12 = m12A;
m21 = m21A;
m22 = m22A;
glyphX = glyphXA;
glyphY = glyphYA;
glyphW = glyphWA;
glyphH = glyphHA;
validBBox = validBBoxA;
// sanity check for excessively large glyphs (which most likely
// indicate an incorrect BBox)
if (glyphW > INT_MAX / glyphH || glyphW <= 0 || glyphH <= 0 || glyphW * glyphH > 100000) {
glyphW = glyphH = 100;
validBBox = false;
}
if (aa) {
glyphSize = glyphW * glyphH;
} else {
glyphSize = ((glyphW + 7) >> 3) * glyphH;
}
cacheAssoc = type3FontCacheAssoc;
for (cacheSets = type3FontCacheMaxSets;
cacheSets > 1 &&
cacheSets * cacheAssoc * glyphSize > type3FontCacheSize;
cacheSets >>= 1) ;
if (glyphSize < 10485760 / cacheAssoc / cacheSets) {
cacheData = (unsigned char *)gmallocn_checkoverflow(cacheSets * cacheAssoc, glyphSize);
} else {
error(errSyntaxWarning, -1, "Not creating cacheData for T3FontCache, it asked for too much memory.\n"
" This could teoretically result in wrong rendering,\n"
" but most probably the document is bogus.\n"
" Please report a bug if you think the rendering may be wrong because of this.");
cacheData = nullptr;
}
if (cacheData != nullptr)
{
cacheTags = (T3FontCacheTag *)gmallocn(cacheSets * cacheAssoc,
sizeof(T3FontCacheTag));
for (int i = 0; i < cacheSets * cacheAssoc; ++i) {
cacheTags[i].mru = i & (cacheAssoc - 1);
}
}
else
{
cacheTags = nullptr;
}
} | 0 | [
"CWE-369"
] | poppler | b224e2f5739fe61de9fa69955d016725b2a4b78d | 58,522,977,416,640,970,000,000,000,000,000,000,000 | 53 | SplashOutputDev::tilingPatternFill: Fix crash on broken file
Issue #802 |
static void phar_postprocess_ru_web(char *fname, int fname_len, char **entry, int *entry_len, char **ru, int *ru_len) /* {{{ */
{
char *e = *entry + 1, *u = NULL, *u1 = NULL, *saveu = NULL;
int e_len = *entry_len - 1, u_len = 0;
phar_archive_data *pphar;
/* we already know we can retrieve the phar if we reach here */
pphar = zend_hash_str_find_ptr(&(PHAR_G(phar_fname_map)), fname, fname_len);
if (!pphar && PHAR_G(manifest_cached)) {
pphar = zend_hash_str_find_ptr(&cached_phars, fname, fname_len);
}
do {
if (zend_hash_str_exists(&(pphar->manifest), e, e_len)) {
if (u) {
u[0] = '/';
*ru = estrndup(u, u_len+1);
++u_len;
u[0] = '\0';
} else {
*ru = NULL;
}
*ru_len = u_len;
*entry_len = e_len + 1;
return;
}
if (u) {
u1 = strrchr(e, '/');
u[0] = '/';
saveu = u;
e_len += u_len + 1;
u = u1;
if (!u) {
return;
}
} else {
u = strrchr(e, '/');
if (!u) {
if (saveu) {
saveu[0] = '/';
}
return;
}
}
u[0] = '\0';
u_len = (int)strlen(u + 1);
e_len -= u_len + 1;
if (e_len < 0) {
if (saveu) {
saveu[0] = '/';
}
return;
}
} while (1);
} | 0 | [
"CWE-281"
] | php-src | e5c95234d87fcb8f6b7569a96a89d1e1544749a6 | 333,610,475,531,593,000,000,000,000,000,000,000,000 | 59 | Fix bug #79082 - Files added to tar with Phar::buildFromIterator have all-access permissions |
static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp)
{
stbi__result_info ri;
void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8);
if (result == NULL)
return NULL;
// it is the responsibility of the loaders to make sure we get either 8 or 16 bit.
STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16);
if (ri.bits_per_channel != 8) {
result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp);
ri.bits_per_channel = 8;
}
// @TODO: move stbi__convert_format to here
if (stbi__vertically_flip_on_load) {
int channels = req_comp ? req_comp : *comp;
stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc));
}
return (unsigned char *) result;
} | 0 | [
"CWE-787"
] | stb | 5ba0baaa269b3fd681828e0e3b3ac0f1472eaf40 | 80,315,741,579,054,350,000,000,000,000,000,000,000 | 25 | stb_image: Reject fractional JPEG component subsampling ratios
The component resamplers are not written to support this and I've
never seen it happen in a real (non-crafted) JPEG file so I'm
fine rejecting this as outright corrupt.
Fixes issue #1178. |
int __fastcall TNullConsole::Choice(
UnicodeString /*Options*/, int /*Cancel*/, int Break, int /*Continue*/, int Timeouted, bool Timeouting,
unsigned int Timer, UnicodeString /*Message*/)
{
int Result;
if (Timeouting)
{
Sleep(Timer);
Result = Timeouted;
}
else
{
Result = Break;
}
return Result;
}
| 0 | [
"CWE-787"
] | winscp | faa96e8144e6925a380f94a97aa382c9427f688d | 240,196,228,455,991,470,000,000,000,000,000,000,000 | 16 | Bug 1943: Prevent loading session settings that can lead to remote code execution from handled URLs
https://winscp.net/tracker/1943
(cherry picked from commit ec584f5189a856cd79509f754722a6898045c5e0)
Source commit: 0f4be408b3f01132b00682da72d925d6c4ee649b |
u8 gf_filter_get_sep(GF_Filter *filter, GF_FilterSessionSepType sep_type)
{
switch (sep_type) {
case GF_FS_SEP_ARGS: return filter->session->sep_args;
case GF_FS_SEP_NAME: return filter->session->sep_name;
case GF_FS_SEP_FRAG: return filter->session->sep_frag;
case GF_FS_SEP_LIST: return filter->session->sep_list;
case GF_FS_SEP_NEG: return filter->session->sep_neg;
default: return 0;
}
} | 0 | [
"CWE-787"
] | gpac | da37ec8582266983d0ec4b7550ec907401ec441e | 333,409,280,834,103,600,000,000,000,000,000,000,000 | 11 | fixed crashes for very long path - cf #1908 |
exif_mnote_data_canon_free (ExifMnoteData *n)
{
if (!n) return;
exif_mnote_data_canon_clear ((ExifMnoteDataCanon *) n);
} | 0 | [
"CWE-125"
] | libexif | 435e21f05001fb03f9f186fa7cbc69454afd00d1 | 13,021,832,616,528,490,000,000,000,000,000,000,000 | 6 | Fix MakerNote tag size overflow issues at read time.
Check for a size overflow while reading tags, which ensures that the
size is always consistent for the given components and type of the
entry, making checking further down superfluous.
This provides an alternate fix for
https://sourceforge.net/p/libexif/bugs/125/ CVE-2016-6328 and for all
the MakerNote types. Likely, this makes both commits 41bd0423 and
89e5b1c1 redundant as it ensures that MakerNote entries are well-formed
when they're populated.
Some improvements on top by Marcus Meissner <[email protected]>
CVE-2020-13112 |
xmlIOFTPClose (void * context) {
return ( xmlNanoFTPClose(context) );
} | 0 | [
"CWE-134"
] | libxml2 | 4472c3a5a5b516aaf59b89be602fbce52756c3e9 | 31,172,700,467,776,940,000,000,000,000,000,000,000 | 3 | Fix some format string warnings with possible format string vulnerability
For https://bugzilla.gnome.org/show_bug.cgi?id=761029
Decorate every method in libxml2 with the appropriate
LIBXML_ATTR_FORMAT(fmt,args) macro and add some cleanups
following the reports. |
static ssize_t disk_capability_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct gendisk *disk = dev_to_disk(dev);
return sprintf(buf, "%x\n", disk->flags);
} | 0 | [
"CWE-416"
] | linux-stable | 77da160530dd1dc94f6ae15a981f24e5f0021e84 | 216,999,468,768,981,600,000,000,000,000,000,000,000 | 7 | block: fix use-after-free in seq file
I got a KASAN report of use-after-free:
==================================================================
BUG: KASAN: use-after-free in klist_iter_exit+0x61/0x70 at addr ffff8800b6581508
Read of size 8 by task trinity-c1/315
=============================================================================
BUG kmalloc-32 (Not tainted): kasan: bad access detected
-----------------------------------------------------------------------------
Disabling lock debugging due to kernel taint
INFO: Allocated in disk_seqf_start+0x66/0x110 age=144 cpu=1 pid=315
___slab_alloc+0x4f1/0x520
__slab_alloc.isra.58+0x56/0x80
kmem_cache_alloc_trace+0x260/0x2a0
disk_seqf_start+0x66/0x110
traverse+0x176/0x860
seq_read+0x7e3/0x11a0
proc_reg_read+0xbc/0x180
do_loop_readv_writev+0x134/0x210
do_readv_writev+0x565/0x660
vfs_readv+0x67/0xa0
do_preadv+0x126/0x170
SyS_preadv+0xc/0x10
do_syscall_64+0x1a1/0x460
return_from_SYSCALL_64+0x0/0x6a
INFO: Freed in disk_seqf_stop+0x42/0x50 age=160 cpu=1 pid=315
__slab_free+0x17a/0x2c0
kfree+0x20a/0x220
disk_seqf_stop+0x42/0x50
traverse+0x3b5/0x860
seq_read+0x7e3/0x11a0
proc_reg_read+0xbc/0x180
do_loop_readv_writev+0x134/0x210
do_readv_writev+0x565/0x660
vfs_readv+0x67/0xa0
do_preadv+0x126/0x170
SyS_preadv+0xc/0x10
do_syscall_64+0x1a1/0x460
return_from_SYSCALL_64+0x0/0x6a
CPU: 1 PID: 315 Comm: trinity-c1 Tainted: G B 4.7.0+ #62
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
ffffea0002d96000 ffff880119b9f918 ffffffff81d6ce81 ffff88011a804480
ffff8800b6581500 ffff880119b9f948 ffffffff8146c7bd ffff88011a804480
ffffea0002d96000 ffff8800b6581500 fffffffffffffff4 ffff880119b9f970
Call Trace:
[<ffffffff81d6ce81>] dump_stack+0x65/0x84
[<ffffffff8146c7bd>] print_trailer+0x10d/0x1a0
[<ffffffff814704ff>] object_err+0x2f/0x40
[<ffffffff814754d1>] kasan_report_error+0x221/0x520
[<ffffffff8147590e>] __asan_report_load8_noabort+0x3e/0x40
[<ffffffff83888161>] klist_iter_exit+0x61/0x70
[<ffffffff82404389>] class_dev_iter_exit+0x9/0x10
[<ffffffff81d2e8ea>] disk_seqf_stop+0x3a/0x50
[<ffffffff8151f812>] seq_read+0x4b2/0x11a0
[<ffffffff815f8fdc>] proc_reg_read+0xbc/0x180
[<ffffffff814b24e4>] do_loop_readv_writev+0x134/0x210
[<ffffffff814b4c45>] do_readv_writev+0x565/0x660
[<ffffffff814b8a17>] vfs_readv+0x67/0xa0
[<ffffffff814b8de6>] do_preadv+0x126/0x170
[<ffffffff814b92ec>] SyS_preadv+0xc/0x10
This problem can occur in the following situation:
open()
- pread()
- .seq_start()
- iter = kmalloc() // succeeds
- seqf->private = iter
- .seq_stop()
- kfree(seqf->private)
- pread()
- .seq_start()
- iter = kmalloc() // fails
- .seq_stop()
- class_dev_iter_exit(seqf->private) // boom! old pointer
As the comment in disk_seqf_stop() says, stop is called even if start
failed, so we need to reinitialise the private pointer to NULL when seq
iteration stops.
An alternative would be to set the private pointer to NULL when the
kmalloc() in disk_seqf_start() fails.
Cc: [email protected]
Signed-off-by: Vegard Nossum <[email protected]>
Acked-by: Tejun Heo <[email protected]>
Signed-off-by: Jens Axboe <[email protected]> |
void bson_fatal( int ok ) {
bson_fatal_msg( ok, "" );
} | 0 | [
"CWE-190"
] | mongo-c-driver-legacy | 1a1f5e26a4309480d88598913f9eebf9e9cba8ca | 35,794,743,147,074,260,000,000,000,000,000,000,000 | 3 | don't mix up int and size_t (first pass to fix that) |
Simple_Selector_Obj Parser::parse_pseudo_selector() {
if (lex< sequence<
pseudo_prefix,
// we keep the space within the name, strange enough
// ToDo: refactor output to schedule the space for it
// or do we really want to keep the real white-space?
sequence< identifier, optional < block_comment >, exactly<'('> >
> >())
{
std::string name(lexed);
name.erase(name.size() - 1);
ParserState p = pstate;
// specially parse static stuff
// ToDo: really everything static?
if (peek_css <
sequence <
alternatives <
static_value,
binomial
>,
optional_css_whitespace,
exactly<')'>
>
>()
) {
lex_css< alternatives < static_value, binomial > >();
String_Constant_Obj expr = SASS_MEMORY_NEW(String_Constant, pstate, lexed);
if (lex_css< exactly<')'> >()) {
expr->can_compress_whitespace(true);
return SASS_MEMORY_NEW(Pseudo_Selector, p, name, expr);
}
}
else if (Selector_List_Obj wrapped = parse_selector_list(true)) {
if (wrapped && lex_css< exactly<')'> >()) {
return SASS_MEMORY_NEW(Wrapped_Selector, p, name, wrapped);
}
}
}
// EO if pseudo selector
else if (lex < sequence< optional < pseudo_prefix >, identifier > >()) {
return SASS_MEMORY_NEW(Pseudo_Selector, pstate, lexed);
}
else if(lex < pseudo_prefix >()) {
css_error("Invalid CSS", " after ", ": expected pseudoclass or pseudoelement, was ");
}
css_error("Invalid CSS", " after ", ": expected \")\", was ");
// unreachable statement
return {};
} | 0 | [
"CWE-674"
] | libsass | f2db04883e5fff4e03777dcc1eb60d4373c45be1 | 174,620,808,846,431,000,000,000,000,000,000,000,000 | 55 | Make `parse_css_variable_value` non-recursive
Fixes #2658 stack overflow |
void gs_lib_ctx_fin(gs_memory_t *mem)
{
gs_lib_ctx_t *ctx;
gs_memory_t *ctx_mem;
if (!mem || !mem->gs_lib_ctx)
return;
ctx = mem->gs_lib_ctx;
ctx_mem = ctx->memory;
sjpxd_destroy(mem);
gscms_destroy(ctx_mem);
gs_free_object(ctx_mem, ctx->profiledir,
"gs_lib_ctx_fin");
gs_free_object(ctx_mem, ctx->default_device_list,
"gs_lib_ctx_fin");
#ifndef GS_THREADSAFE
mem_err_print = NULL;
#endif
remove_ctx_pointers(ctx_mem);
gs_free_object(ctx_mem, ctx, "gs_lib_ctx_init");
} | 0 | [] | ghostpdl | 6d444c273da5499a4cd72f21cb6d4c9a5256807d | 148,896,501,622,541,740,000,000,000,000,000,000,000 | 25 | Bug 697178: Add a file permissions callback
For the rare occasions when the graphics library directly opens a file
(currently for reading), this allows us to apply any restrictions on
file access normally applied in the interpteter. |
int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
{
struct cmsghdr *cmsg;
int err;
for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg))
{
err = -EINVAL;
/* Verify that cmsg_len is at least sizeof(struct cmsghdr) */
/* The first check was omitted in <= 2.2.5. The reasoning was
that parser checks cmsg_len in any case, so that
additional check would be work duplication.
But if cmsg_level is not SOL_SOCKET, we do not check
for too short ancillary data object at all! Oops.
OK, let's add it...
*/
if (!CMSG_OK(msg, cmsg))
goto error;
if (cmsg->cmsg_level != SOL_SOCKET)
continue;
switch (cmsg->cmsg_type)
{
case SCM_RIGHTS:
if (!sock->ops || sock->ops->family != PF_UNIX)
goto error;
err=scm_fp_copy(cmsg, &p->fp);
if (err<0)
goto error;
break;
case SCM_CREDENTIALS:
{
struct ucred creds;
kuid_t uid;
kgid_t gid;
if (cmsg->cmsg_len != CMSG_LEN(sizeof(struct ucred)))
goto error;
memcpy(&creds, CMSG_DATA(cmsg), sizeof(struct ucred));
err = scm_check_creds(&creds);
if (err)
goto error;
p->creds.pid = creds.pid;
if (!p->pid || pid_vnr(p->pid) != creds.pid) {
struct pid *pid;
err = -ESRCH;
pid = find_get_pid(creds.pid);
if (!pid)
goto error;
put_pid(p->pid);
p->pid = pid;
}
err = -EINVAL;
uid = make_kuid(current_user_ns(), creds.uid);
gid = make_kgid(current_user_ns(), creds.gid);
if (!uid_valid(uid) || !gid_valid(gid))
goto error;
p->creds.uid = uid;
p->creds.gid = gid;
if (!p->cred ||
!uid_eq(p->cred->euid, uid) ||
!gid_eq(p->cred->egid, gid)) {
struct cred *cred;
err = -ENOMEM;
cred = prepare_creds();
if (!cred)
goto error;
cred->uid = cred->euid = uid;
cred->gid = cred->egid = gid;
if (p->cred)
put_cred(p->cred);
p->cred = cred;
}
break;
}
default:
goto error;
}
}
if (p->fp && !p->fp->count)
{
kfree(p->fp);
p->fp = NULL;
}
return 0;
error:
scm_destroy(p);
return err;
} | 0 | [
"CWE-284",
"CWE-264"
] | linux | 92f28d973cce45ef5823209aab3138eb45d8b349 | 128,352,795,846,518,230,000,000,000,000,000,000,000 | 97 | scm: Require CAP_SYS_ADMIN over the current pidns to spoof pids.
Don't allow spoofing pids over unix domain sockets in the corner
cases where a user has created a user namespace but has not yet
created a pid namespace.
Cc: [email protected]
Reported-by: Andy Lutomirski <[email protected]>
Signed-off-by: "Eric W. Biederman" <[email protected]> |
static void enc_getline(void)
{
char *p;
char c;
restart:
if (enc_eof())
normal_error("type 1","unexpected end of file");
p = enc_line;
do {
c = (char) enc_getchar();
append_char_to_buf(c, p, enc_line, ENC_BUF_SIZE);
}
while (c != 10 && !enc_eof());
append_eol(p, enc_line, ENC_BUF_SIZE);
if (p - enc_line < 2 || *enc_line == '%')
goto restart;
} | 0 | [
"CWE-119"
] | texlive-source | 6ed0077520e2b0da1fd060c7f88db7b2e6068e4c | 240,780,173,683,444,300,000,000,000,000,000,000,000 | 17 | writet1 protection against buffer overflow
git-svn-id: svn://tug.org/texlive/trunk/Build/source@48697 c570f23f-e606-0410-a88d-b1316a301751 |
PHP_FUNCTION(ldap_mod_replace)
{
php_ldap_do_modify(INTERNAL_FUNCTION_PARAM_PASSTHRU, LDAP_MOD_REPLACE);
} | 0 | [
"CWE-476"
] | php-src | 49782c54994ecca2ef2a061063bd5a7079c43527 | 145,684,037,606,379,370,000,000,000,000,000,000,000 | 4 | Fix bug #76248 - Malicious LDAP-Server Response causes Crash |
inline unsigned int wait(const unsigned int milliseconds, cimg_ulong *const p_timer) {
if (!*p_timer) *p_timer = cimg::time();
const cimg_ulong current_time = cimg::time();
if (current_time>=*p_timer + milliseconds) { *p_timer = current_time; return 0; }
const unsigned int time_diff = (unsigned int)(*p_timer + milliseconds - current_time);
*p_timer = current_time + time_diff;
cimg::sleep(time_diff);
return time_diff; | 0 | [
"CWE-119",
"CWE-787"
] | CImg | ac8003393569aba51048c9d67e1491559877b1d1 | 70,745,231,455,794,170,000,000,000,000,000,000,000 | 9 | . |
varyEvaluateMatch(StoreEntry * entry, HttpRequest * request)
{
SBuf vary(request->vary_headers);
const auto &reply = entry->mem().freshestReply();
auto has_vary = reply.header.has(Http::HdrType::VARY);
#if X_ACCELERATOR_VARY
has_vary |=
reply.header.has(Http::HdrType::HDR_X_ACCELERATOR_VARY);
#endif
if (!has_vary || entry->mem_obj->vary_headers.isEmpty()) {
if (!vary.isEmpty()) {
/* Oops... something odd is going on here.. */
debugs(33, DBG_IMPORTANT, "varyEvaluateMatch: Oops. Not a Vary object on second attempt, '" <<
entry->mem_obj->urlXXX() << "' '" << vary << "'");
request->vary_headers.clear();
return VARY_CANCEL;
}
if (!has_vary) {
/* This is not a varying object */
return VARY_NONE;
}
/* virtual "vary" object found. Calculate the vary key and
* continue the search
*/
vary = httpMakeVaryMark(request, &reply);
if (!vary.isEmpty()) {
request->vary_headers = vary;
return VARY_OTHER;
} else {
/* Ouch.. we cannot handle this kind of variance */
/* XXX This cannot really happen, but just to be complete */
return VARY_CANCEL;
}
} else {
if (vary.isEmpty()) {
vary = httpMakeVaryMark(request, &reply);
if (!vary.isEmpty())
request->vary_headers = vary;
}
if (vary.isEmpty()) {
/* Ouch.. we cannot handle this kind of variance */
/* XXX This cannot really happen, but just to be complete */
return VARY_CANCEL;
} else if (vary.cmp(entry->mem_obj->vary_headers) == 0) {
return VARY_MATCH;
} else {
/* Oops.. we have already been here and still haven't
* found the requested variant. Bail out
*/
debugs(33, DBG_IMPORTANT, "varyEvaluateMatch: Oops. Not a Vary match on second attempt, '" <<
entry->mem_obj->urlXXX() << "' '" << vary << "'");
return VARY_CANCEL;
}
}
} | 0 | [
"CWE-116"
] | squid | 7024fb734a59409889e53df2257b3fc817809fb4 | 285,415,817,725,128,400,000,000,000,000,000,000,000 | 62 | Handle more Range requests (#790)
Also removed some effectively unused code. |
ClientRequestContext::checkNoCacheDone(const allow_t &answer)
{
acl_checklist = NULL;
if (answer.denied()) {
http->request->flags.noCache = true; // do not read reply from cache
http->request->flags.cachable = false; // do not store reply into cache
}
http->doCallouts();
} | 0 | [
"CWE-116"
] | squid | e7cf864f938f24eea8af0692c04d16790983c823 | 234,491,878,298,687,500,000,000,000,000,000,000,000 | 9 | Handle more Range requests (#790)
Also removed some effectively unused code. |
*/
static int io_poll_check_events(struct io_kiocb *req, bool locked)
{
struct io_ring_ctx *ctx = req->ctx;
struct io_poll_iocb *poll = io_poll_get_single(req);
int v;
/* req->task == current here, checking PF_EXITING is safe */
if (unlikely(req->task->flags & PF_EXITING))
io_poll_mark_cancelled(req);
do {
v = atomic_read(&req->poll_refs);
/* tw handler should be the owner, and so have some references */
if (WARN_ON_ONCE(!(v & IO_POLL_REF_MASK)))
return 0;
if (v & IO_POLL_CANCEL_FLAG)
return -ECANCELED;
if (!req->result) {
struct poll_table_struct pt = { ._key = req->cflags };
if (unlikely(!io_assign_file(req, IO_URING_F_UNLOCKED)))
req->result = -EBADF;
else
req->result = vfs_poll(req->file, &pt) & req->cflags;
}
/* multishot, just fill an CQE and proceed */
if (req->result && !(req->cflags & EPOLLONESHOT)) {
__poll_t mask = mangle_poll(req->result & poll->events);
bool filled;
spin_lock(&ctx->completion_lock);
filled = io_fill_cqe_aux(ctx, req->user_data, mask,
IORING_CQE_F_MORE);
io_commit_cqring(ctx);
spin_unlock(&ctx->completion_lock);
if (unlikely(!filled))
return -ECANCELED;
io_cqring_ev_posted(ctx);
} else if (req->result) {
return 0;
}
/*
* Release all references, retry if someone tried to restart
* task_work while we were executing it.
*/
} while (atomic_sub_return(v & IO_POLL_REF_MASK, &req->poll_refs));
return 1; | 0 | [
"CWE-416"
] | linux | e677edbcabee849bfdd43f1602bccbecf736a646 | 18,738,530,181,522,608,000,000,000,000,000,000,000 | 53 | 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]> |
float compute_error_of_weight_set_2planes(
const endpoints_and_weights& eai1,
const endpoints_and_weights& eai2,
const decimation_info& di,
const float* dec_weight_quant_uvalue_plane1,
const float* dec_weight_quant_uvalue_plane2
) {
vfloat4 error_summav = vfloat4::zero();
float error_summa = 0.0f;
unsigned int texel_count = di.texel_count;
bool is_decimated = di.texel_count != di.weight_count;
// Process SIMD-width chunks, safe to over-fetch - the extra space is zero initialized
if (is_decimated)
{
for (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)
{
// Plane 1
// Compute the bilinear interpolation of the decimated weight grid
vfloat current_values1 = bilinear_infill_vla(di, dec_weight_quant_uvalue_plane1, i);
// Compute the error between the computed value and the ideal weight
vfloat actual_values1 = loada(eai1.weights + i);
vfloat diff = current_values1 - actual_values1;
vfloat error1 = diff * diff * loada(eai1.weight_error_scale + i);
// Plane 2
// Compute the bilinear interpolation of the decimated weight grid
vfloat current_values2 = bilinear_infill_vla(di, dec_weight_quant_uvalue_plane2, i);
// Compute the error between the computed value and the ideal weight
vfloat actual_values2 = loada(eai2.weights + i);
diff = current_values2 - actual_values2;
vfloat error2 = diff * diff * loada(eai2.weight_error_scale + i);
haccumulate(error_summav, error1 + error2);
}
}
else
{
for (unsigned int i = 0; i < texel_count; i += ASTCENC_SIMD_WIDTH)
{
// Plane 1
// Load the weight set directly, without interpolation
vfloat current_values1 = loada(dec_weight_quant_uvalue_plane1 + i);
// Compute the error between the computed value and the ideal weight
vfloat actual_values1 = loada(eai1.weights + i);
vfloat diff = current_values1 - actual_values1;
vfloat error1 = diff * diff * loada(eai1.weight_error_scale + i);
// Plane 2
// Load the weight set directly, without interpolation
vfloat current_values2 = loada(dec_weight_quant_uvalue_plane2 + i);
// Compute the error between the computed value and the ideal weight
vfloat actual_values2 = loada(eai2.weights + i);
diff = current_values2 - actual_values2;
vfloat error2 = diff * diff * loada(eai2.weight_error_scale + i);
haccumulate(error_summav, error1 + error2);
}
}
// Resolve the final scalar accumulator sum
haccumulate(error_summa, error_summav);
return error_summa;
} | 0 | [
"CWE-787"
] | astc-encoder | bdd385fe19bf2737bead4b5664acdfdeca7aab15 | 321,095,691,461,746,800,000,000,000,000,000,000,000 | 69 | Only load based on texel index if undecimated |
if (datasize > SumOfBytesHashed) {
hashbase = data + SumOfBytesHashed;
hashsize = datasize - SumOfBytesHashed;
check_size(data, datasize, hashbase, hashsize);
if (!(Sha256Update(sha256ctx, hashbase, hashsize)) ||
!(Sha1Update(sha1ctx, hashbase, hashsize))) {
perror(L"Unable to generate hash\n");
efi_status = EFI_OUT_OF_RESOURCES;
goto done;
}
SumOfBytesHashed += hashsize;
} | 0 | [
"CWE-787"
] | shim | 159151b6649008793d6204a34d7b9c41221fb4b0 | 27,755,158,032,618,604,000,000,000,000,000,000,000 | 15 | Also avoid CVE-2022-28737 in verify_image()
PR 446 ("Add verify_image") duplicates some of the code affected by
Chris Coulson's defense in depth patch against CVE-2022-28737 ("pe:
Perform image verification earlier when loading grub").
This patch makes the same change to the new function.
Signed-off-by: Peter Jones <[email protected]> |
static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev,
struct sk_buff *skb)
{
struct inquiry_data data;
int num_rsp = *((__u8 *) skb->data);
BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
if (!num_rsp)
return;
if (hci_dev_test_flag(hdev, HCI_PERIODIC_INQ))
return;
hci_dev_lock(hdev);
if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) {
struct inquiry_info_with_rssi_and_pscan_mode *info;
info = (void *) (skb->data + 1);
for (; num_rsp; num_rsp--, info++) {
u32 flags;
bacpy(&data.bdaddr, &info->bdaddr);
data.pscan_rep_mode = info->pscan_rep_mode;
data.pscan_period_mode = info->pscan_period_mode;
data.pscan_mode = info->pscan_mode;
memcpy(data.dev_class, info->dev_class, 3);
data.clock_offset = info->clock_offset;
data.rssi = info->rssi;
data.ssp_mode = 0x00;
flags = hci_inquiry_cache_update(hdev, &data, false);
mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
info->dev_class, info->rssi,
flags, NULL, 0, NULL, 0);
}
} else {
struct inquiry_info_with_rssi *info = (void *) (skb->data + 1);
for (; num_rsp; num_rsp--, info++) {
u32 flags;
bacpy(&data.bdaddr, &info->bdaddr);
data.pscan_rep_mode = info->pscan_rep_mode;
data.pscan_period_mode = info->pscan_period_mode;
data.pscan_mode = 0x00;
memcpy(data.dev_class, info->dev_class, 3);
data.clock_offset = info->clock_offset;
data.rssi = info->rssi;
data.ssp_mode = 0x00;
flags = hci_inquiry_cache_update(hdev, &data, false);
mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
info->dev_class, info->rssi,
flags, NULL, 0, NULL, 0);
}
}
hci_dev_unlock(hdev);
} | 0 | [
"CWE-290"
] | linux | 3ca44c16b0dcc764b641ee4ac226909f5c421aa3 | 279,763,188,441,669,230,000,000,000,000,000,000,000 | 63 | Bluetooth: Consolidate encryption handling in hci_encrypt_cfm
This makes hci_encrypt_cfm calls hci_connect_cfm in case the connection
state is BT_CONFIG so callers don't have to check the state.
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
Signed-off-by: Marcel Holtmann <[email protected]> |
StreamInfo::StreamInfo* Context::getRequestStreamInfo() const {
if (encoder_callbacks_) {
return &encoder_callbacks_->streamInfo();
} else if (decoder_callbacks_) {
return &decoder_callbacks_->streamInfo();
}
return nullptr;
} | 0 | [
"CWE-476"
] | envoy | 8788a3cf255b647fd14e6b5e2585abaaedb28153 | 260,137,558,313,713,500,000,000,000,000,000,000,000 | 8 | 1.4 - Do not call into the VM unless the VM Context has been created. (#24)
* Ensure that the in VM Context is created before onDone is called.
Signed-off-by: John Plevyak <[email protected]>
* Update as per offline discussion.
Signed-off-by: John Plevyak <[email protected]>
* Set in_vm_context_created_ in onNetworkNewConnection.
Signed-off-by: John Plevyak <[email protected]>
* Add guards to other network calls.
Signed-off-by: John Plevyak <[email protected]>
* Fix common/wasm tests.
Signed-off-by: John Plevyak <[email protected]>
* Patch tests.
Signed-off-by: John Plevyak <[email protected]>
* Remove unecessary file from cherry-pick.
Signed-off-by: John Plevyak <[email protected]> |
echo_string_core(
typval_T *tv,
char_u **tofree,
char_u *numbuf,
int copyID,
int echo_style,
int restore_copyID,
int composite_val)
{
static int recurse = 0;
char_u *r = NULL;
if (recurse >= DICT_MAXNEST)
{
if (!did_echo_string_emsg)
{
// Only give this message once for a recursive call to avoid
// flooding the user with errors. And stop iterating over lists
// and dicts.
did_echo_string_emsg = TRUE;
emsg(_(e_variable_nested_too_deep_for_displaying));
}
*tofree = NULL;
return (char_u *)"{E724}";
}
++recurse;
switch (tv->v_type)
{
case VAR_STRING:
if (echo_style && !composite_val)
{
*tofree = NULL;
r = tv->vval.v_string;
if (r == NULL)
r = (char_u *)"";
}
else
{
*tofree = string_quote(tv->vval.v_string, FALSE);
r = *tofree;
}
break;
case VAR_FUNC:
{
char_u buf[MAX_FUNC_NAME_LEN];
if (echo_style)
{
r = make_ufunc_name_readable(tv->vval.v_string,
buf, MAX_FUNC_NAME_LEN);
if (r == buf)
{
r = vim_strsave(buf);
*tofree = r;
}
else
*tofree = NULL;
}
else
{
*tofree = string_quote(tv->vval.v_string == NULL ? NULL
: make_ufunc_name_readable(
tv->vval.v_string, buf, MAX_FUNC_NAME_LEN),
TRUE);
r = *tofree;
}
}
break;
case VAR_PARTIAL:
{
partial_T *pt = tv->vval.v_partial;
char_u *fname = string_quote(pt == NULL ? NULL
: partial_name(pt), FALSE);
garray_T ga;
int i;
char_u *tf;
ga_init2(&ga, 1, 100);
ga_concat(&ga, (char_u *)"function(");
if (fname != NULL)
{
// When using uf_name prepend "g:" for a global function.
if (pt != NULL && pt->pt_name == NULL && fname[0] == '\''
&& vim_isupper(fname[1]))
{
ga_concat(&ga, (char_u *)"'g:");
ga_concat(&ga, fname + 1);
}
else
ga_concat(&ga, fname);
vim_free(fname);
}
if (pt != NULL && pt->pt_argc > 0)
{
ga_concat(&ga, (char_u *)", [");
for (i = 0; i < pt->pt_argc; ++i)
{
if (i > 0)
ga_concat(&ga, (char_u *)", ");
ga_concat(&ga,
tv2string(&pt->pt_argv[i], &tf, numbuf, copyID));
vim_free(tf);
}
ga_concat(&ga, (char_u *)"]");
}
if (pt != NULL && pt->pt_dict != NULL)
{
typval_T dtv;
ga_concat(&ga, (char_u *)", ");
dtv.v_type = VAR_DICT;
dtv.vval.v_dict = pt->pt_dict;
ga_concat(&ga, tv2string(&dtv, &tf, numbuf, copyID));
vim_free(tf);
}
// terminate with ')' and a NUL
ga_concat_len(&ga, (char_u *)")", 2);
*tofree = ga.ga_data;
r = *tofree;
break;
}
case VAR_BLOB:
r = blob2string(tv->vval.v_blob, tofree, numbuf);
break;
case VAR_LIST:
if (tv->vval.v_list == NULL)
{
// NULL list is equivalent to empty list.
*tofree = NULL;
r = (char_u *)"[]";
}
else if (copyID != 0 && tv->vval.v_list->lv_copyID == copyID
&& tv->vval.v_list->lv_len > 0)
{
*tofree = NULL;
r = (char_u *)"[...]";
}
else
{
int old_copyID = tv->vval.v_list->lv_copyID;
tv->vval.v_list->lv_copyID = copyID;
*tofree = list2string(tv, copyID, restore_copyID);
if (restore_copyID)
tv->vval.v_list->lv_copyID = old_copyID;
r = *tofree;
}
break;
case VAR_DICT:
if (tv->vval.v_dict == NULL)
{
// NULL dict is equivalent to empty dict.
*tofree = NULL;
r = (char_u *)"{}";
}
else if (copyID != 0 && tv->vval.v_dict->dv_copyID == copyID
&& tv->vval.v_dict->dv_hashtab.ht_used != 0)
{
*tofree = NULL;
r = (char_u *)"{...}";
}
else
{
int old_copyID = tv->vval.v_dict->dv_copyID;
tv->vval.v_dict->dv_copyID = copyID;
*tofree = dict2string(tv, copyID, restore_copyID);
if (restore_copyID)
tv->vval.v_dict->dv_copyID = old_copyID;
r = *tofree;
}
break;
case VAR_NUMBER:
case VAR_UNKNOWN:
case VAR_ANY:
case VAR_VOID:
*tofree = NULL;
r = tv_get_string_buf(tv, numbuf);
break;
case VAR_JOB:
case VAR_CHANNEL:
#ifdef FEAT_JOB_CHANNEL
*tofree = NULL;
r = tv->v_type == VAR_JOB ? job_to_string_buf(tv, numbuf)
: channel_to_string_buf(tv, numbuf);
if (composite_val)
{
*tofree = string_quote(r, FALSE);
r = *tofree;
}
#endif
break;
case VAR_INSTR:
*tofree = NULL;
r = (char_u *)"instructions";
break;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
*tofree = NULL;
vim_snprintf((char *)numbuf, NUMBUFLEN, "%g", tv->vval.v_float);
r = numbuf;
break;
#endif
case VAR_BOOL:
case VAR_SPECIAL:
*tofree = NULL;
r = (char_u *)get_var_special_name(tv->vval.v_number);
break;
}
if (--recurse == 0)
did_echo_string_emsg = FALSE;
return r;
} | 0 | [
"CWE-823"
] | vim | 8b91e71441069b1dde9ac9ff9d9a829b1b4aecca | 185,056,559,104,342,150,000,000,000,000,000,000,000 | 226 | patch 8.2.4774: crash when using a number for lambda name
Problem: Crash when using a number for lambda name.
Solution: Check the type of the lambda reference. |
PyString_Repr(PyObject *obj, int smartquotes)
{
register PyStringObject* op = (PyStringObject*) obj;
size_t newsize;
PyObject *v;
if (Py_SIZE(op) > (PY_SSIZE_T_MAX - 2)/4) {
PyErr_SetString(PyExc_OverflowError,
"string is too large to make repr");
return NULL;
}
newsize = 2 + 4*Py_SIZE(op);
v = PyString_FromStringAndSize((char *)NULL, newsize);
if (v == NULL) {
return NULL;
}
else {
register Py_ssize_t i;
register char c;
register char *p;
int quote;
/* figure out which quote to use; single is preferred */
quote = '\'';
if (smartquotes &&
memchr(op->ob_sval, '\'', Py_SIZE(op)) &&
!memchr(op->ob_sval, '"', Py_SIZE(op)))
quote = '"';
p = PyString_AS_STRING(v);
*p++ = quote;
for (i = 0; i < Py_SIZE(op); i++) {
/* There's at least enough room for a hex escape
and a closing quote. */
assert(newsize - (p - PyString_AS_STRING(v)) >= 5);
c = op->ob_sval[i];
if (c == quote || c == '\\')
*p++ = '\\', *p++ = c;
else if (c == '\t')
*p++ = '\\', *p++ = 't';
else if (c == '\n')
*p++ = '\\', *p++ = 'n';
else if (c == '\r')
*p++ = '\\', *p++ = 'r';
else if (c < ' ' || c >= 0x7f) {
/* For performance, we don't want to call
PyOS_snprintf here (extra layers of
function call). */
sprintf(p, "\\x%02x", c & 0xff);
p += 4;
}
else
*p++ = c;
}
assert(newsize - (p - PyString_AS_STRING(v)) >= 1);
*p++ = quote;
*p = '\0';
if (_PyString_Resize(&v, (p - PyString_AS_STRING(v))))
return NULL;
return v;
}
} | 0 | [
"CWE-190"
] | cpython | c3c9db89273fabc62ea1b48389d9a3000c1c03ae | 74,821,794,612,928,740,000,000,000,000,000,000,000 | 61 | [2.7] bpo-30657: Check & prevent integer overflow in PyString_DecodeEscape (#2174) |
png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
png_uint_32 transformations /* Because these may affect the byte layout */)
{
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Offset to next interlace block */
static PNG_CONST unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
png_debug(1, "in png_do_read_interlace");
if (row != NULL && row_info != NULL)
{
png_uint_32 final_width;
final_width = row_info->width * png_pass_inc[pass];
switch (row_info->pixel_depth)
{
case 1:
{
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3);
png_bytep dp = row + (png_size_t)((final_width - 1) >> 3);
unsigned int sshift, dshift;
unsigned int s_start, s_end;
int s_inc;
int jstop = (int)png_pass_inc[pass];
png_byte v;
png_uint_32 i;
int j;
#ifdef PNG_READ_PACKSWAP_SUPPORTED
if ((transformations & PNG_PACKSWAP) != 0)
{
sshift = ((row_info->width + 7) & 0x07);
dshift = ((final_width + 7) & 0x07);
s_start = 7;
s_end = 0;
s_inc = -1;
}
else
#endif
{
sshift = 7 - ((row_info->width + 7) & 0x07);
dshift = 7 - ((final_width + 7) & 0x07);
s_start = 0;
s_end = 7;
s_inc = 1;
}
for (i = 0; i < row_info->width; i++)
{
v = (png_byte)((*sp >> sshift) & 0x01);
for (j = 0; j < jstop; j++)
{
unsigned int tmp = *dp & (0x7f7f >> (7 - dshift));
tmp |= (unsigned int)(v << dshift);
*dp = (png_byte)(tmp & 0xff);
if (dshift == s_end)
{
dshift = s_start;
dp--;
}
else
dshift = (unsigned int)((int)dshift + s_inc);
}
if (sshift == s_end)
{
sshift = s_start;
sp--;
}
else
sshift = (unsigned int)((int)sshift + s_inc);
}
break;
}
case 2:
{
png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2);
png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2);
unsigned int sshift, dshift;
unsigned int s_start, s_end;
int s_inc;
int jstop = (int)png_pass_inc[pass];
png_uint_32 i;
#ifdef PNG_READ_PACKSWAP_SUPPORTED
if ((transformations & PNG_PACKSWAP) != 0)
{
sshift = (((row_info->width + 3) & 0x03) << 1);
dshift = (((final_width + 3) & 0x03) << 1);
s_start = 6;
s_end = 0;
s_inc = -2;
}
else
#endif
{
sshift = ((3 - ((row_info->width + 3) & 0x03)) << 1);
dshift = ((3 - ((final_width + 3) & 0x03)) << 1);
s_start = 0;
s_end = 6;
s_inc = 2;
}
for (i = 0; i < row_info->width; i++)
{
png_byte v;
int j;
v = (png_byte)((*sp >> sshift) & 0x03);
for (j = 0; j < jstop; j++)
{
unsigned int tmp = *dp & (0x3f3f >> (6 - dshift));
tmp |= (unsigned int)(v << dshift);
*dp = (png_byte)(tmp & 0xff);
if (dshift == s_end)
{
dshift = s_start;
dp--;
}
else
dshift = (unsigned int)((int)dshift + s_inc);
}
if (sshift == s_end)
{
sshift = s_start;
sp--;
}
else
sshift = (unsigned int)((int)sshift + s_inc);
}
break;
}
case 4:
{
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1);
png_bytep dp = row + (png_size_t)((final_width - 1) >> 1);
unsigned int sshift, dshift;
unsigned int s_start, s_end;
int s_inc;
png_uint_32 i;
int jstop = (int)png_pass_inc[pass];
#ifdef PNG_READ_PACKSWAP_SUPPORTED
if ((transformations & PNG_PACKSWAP) != 0)
{
sshift = (((row_info->width + 1) & 0x01) << 2);
dshift = (((final_width + 1) & 0x01) << 2);
s_start = 4;
s_end = 0;
s_inc = -4;
}
else
#endif
{
sshift = ((1 - ((row_info->width + 1) & 0x01)) << 2);
dshift = ((1 - ((final_width + 1) & 0x01)) << 2);
s_start = 0;
s_end = 4;
s_inc = 4;
}
for (i = 0; i < row_info->width; i++)
{
png_byte v = (png_byte)((*sp >> sshift) & 0x0f);
int j;
for (j = 0; j < jstop; j++)
{
unsigned int tmp = *dp & (0xf0f >> (4 - dshift));
tmp |= (unsigned int)(v << dshift);
*dp = (png_byte)(tmp & 0xff);
if (dshift == s_end)
{
dshift = s_start;
dp--;
}
else
dshift = (unsigned int)((int)dshift + s_inc);
}
if (sshift == s_end)
{
sshift = s_start;
sp--;
}
else
sshift = (unsigned int)((int)sshift + s_inc);
}
break;
}
default:
{
png_size_t pixel_bytes = (row_info->pixel_depth >> 3);
png_bytep sp = row + (png_size_t)(row_info->width - 1)
* pixel_bytes;
png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes;
int jstop = (int)png_pass_inc[pass];
png_uint_32 i;
for (i = 0; i < row_info->width; i++)
{
png_byte v[8]; /* SAFE; pixel_depth does not exceed 64 */
int j;
memcpy(v, sp, pixel_bytes);
for (j = 0; j < jstop; j++)
{
memcpy(dp, v, pixel_bytes);
dp -= pixel_bytes;
}
sp -= pixel_bytes;
}
break;
}
}
row_info->width = final_width;
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width);
}
#ifndef PNG_READ_PACKSWAP_SUPPORTED
PNG_UNUSED(transformations) /* Silence compiler warning */
#endif
} | 0 | [
"CWE-369"
] | libpng | 2dca15686fadb1b8951cb29b02bad4cae73448da | 285,167,324,483,751,830,000,000,000,000,000,000,000 | 244 | [libpng16] Moved chunk-length check into a png_check_chunk_length() private
function (Suggested by Max Stepin). |
static void shm_open(struct vm_area_struct *vma)
{
struct file *file = vma->vm_file;
struct shm_file_data *sfd = shm_file_data(file);
struct shmid_kernel *shp;
shp = shm_lock(sfd->ns, sfd->id);
shp->shm_atim = get_seconds();
shp->shm_lprid = task_tgid_vnr(current);
shp->shm_nattch++;
shm_unlock(shp);
} | 0 | [
"CWE-362",
"CWE-401"
] | linux | b9a532277938798b53178d5a66af6e2915cb27cf | 176,911,371,707,096,200,000,000,000,000,000,000,000 | 12 | Initialize msg/shm IPC objects before doing ipc_addid()
As reported by Dmitry Vyukov, we really shouldn't do ipc_addid() before
having initialized the IPC object state. Yes, we initialize the IPC
object in a locked state, but with all the lockless RCU lookup work,
that IPC object lock no longer means that the state cannot be seen.
We already did this for the IPC semaphore code (see commit e8577d1f0329:
"ipc/sem.c: fully initialize sem_array before making it visible") but we
clearly forgot about msg and shm.
Reported-by: Dmitry Vyukov <[email protected]>
Cc: Manfred Spraul <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: [email protected]
Signed-off-by: Linus Torvalds <[email protected]> |
Command::Command(StringData name, StringData oldName)
: _name(name.toString()),
_commandsExecutedMetric("commands." + _name + ".total", &_commandsExecuted),
_commandsFailedMetric("commands." + _name + ".failed", &_commandsFailed) {
globalCommandRegistry()->registerCommand(this, name, oldName);
} | 0 | [
"CWE-20"
] | mongo | 722f06f3217c029ef9c50062c8cc775966fd7ead | 270,265,045,704,438,470,000,000,000,000,000,000,000 | 6 | SERVER-38275 ban find explain with UUID |
calc_section_size (MonoDynamicImage *assembly)
{
int nsections = 0;
/* alignment constraints */
mono_image_add_stream_zero (&assembly->code, 4 - (assembly->code.index % 4));
g_assert ((assembly->code.index % 4) == 0);
assembly->meta_size += 3;
assembly->meta_size &= ~3;
mono_image_add_stream_zero (&assembly->resources, 4 - (assembly->resources.index % 4));
g_assert ((assembly->resources.index % 4) == 0);
assembly->sections [MONO_SECTION_TEXT].size = assembly->meta_size + assembly->code.index + assembly->resources.index + assembly->strong_name_size;
assembly->sections [MONO_SECTION_TEXT].attrs = SECT_FLAGS_HAS_CODE | SECT_FLAGS_MEM_EXECUTE | SECT_FLAGS_MEM_READ;
nsections++;
if (assembly->win32_res) {
guint32 res_size = (assembly->win32_res_size + 3) & ~3;
assembly->sections [MONO_SECTION_RSRC].size = res_size;
assembly->sections [MONO_SECTION_RSRC].attrs = SECT_FLAGS_HAS_INITIALIZED_DATA | SECT_FLAGS_MEM_READ;
nsections++;
}
assembly->sections [MONO_SECTION_RELOC].size = 12;
assembly->sections [MONO_SECTION_RELOC].attrs = SECT_FLAGS_MEM_READ | SECT_FLAGS_MEM_DISCARDABLE | SECT_FLAGS_HAS_INITIALIZED_DATA;
nsections++;
return nsections;
} | 0 | [
"CWE-20"
] | mono | 4905ef1130feb26c3150b28b97e4a96752e0d399 | 56,784,669,770,246,000,000,000,000,000,000,000,000 | 30 | Handle invalid instantiation of generic methods.
* verify.c: Add new function to internal verifier API to check
method instantiations.
* reflection.c (mono_reflection_bind_generic_method_parameters):
Check the instantiation before returning it.
Fixes #655847 |
CWD_API char *virtual_getcwd(char *buf, size_t size TSRMLS_DC) /* {{{ */
{
size_t length;
char *cwd;
cwd = virtual_getcwd_ex(&length TSRMLS_CC);
if (buf == NULL) {
return cwd;
}
if (length > size-1) {
free(cwd);
errno = ERANGE; /* Is this OK? */
return NULL;
}
memcpy(buf, cwd, length+1);
free(cwd);
return buf;
} | 0 | [
"CWE-190"
] | php-src | 0218acb7e756a469099c4ccfb22bce6c2bd1ef87 | 112,288,556,559,221,110,000,000,000,000,000,000,000 | 19 | Fix for bug #72513 |
void RGWHandler_REST::put_op(RGWOp* op)
{
delete op;
} /* put_op */ | 0 | [
"CWE-770"
] | ceph | ab29bed2fc9f961fe895de1086a8208e21ddaddc | 166,624,992,736,172,290,000,000,000,000,000,000,000 | 4 | rgw: fix issues with 'enforce bounds' patch
The patch to enforce bounds on max-keys/max-uploads/max-parts had a few
issues that would prevent us from compiling it. Instead of changing the
code provided by the submitter, we're addressing them in a separate
commit to maintain the DCO.
Signed-off-by: Joao Eduardo Luis <[email protected]>
Signed-off-by: Abhishek Lekshmanan <[email protected]>
(cherry picked from commit 29bc434a6a81a2e5c5b8cfc4c8d5c82ca5bf538a)
mimic specific fixes:
As the largeish change from master g_conf() isn't in mimic yet, use the g_conf
global structure, also make rgw_op use the value from req_info ceph context as
we do for all the requests |
PJ_DEF(const char *) pjsip_event_str(pjsip_event_id_e e)
{
return event_str[e];
} | 0 | [
"CWE-297",
"CWE-295"
] | pjproject | 67e46c1ac45ad784db5b9080f5ed8b133c122872 | 329,083,608,761,094,850,000,000,000,000,000,000,000 | 4 | Merge pull request from GHSA-8hcp-hm38-mfph
* Check hostname during TLS transport selection
* revision based on feedback
* remove the code in create_request that has been moved |
nautilus_get_all_group_names (void)
{
GList *list;
struct group *group;
list = NULL;
setgrent ();
while ((group = getgrent ()) != NULL)
list = g_list_prepend (list, g_strdup (group->gr_name));
endgrent ();
return eel_g_str_list_alphabetize (list);
} | 0 | [] | nautilus | 7632a3e13874a2c5e8988428ca913620a25df983 | 54,423,550,505,902,640,000,000,000,000,000,000,000 | 16 | 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 |
auth_entry_new (const char *protocol,
const char *network_id)
{
IceAuthFileEntry *file_entry;
IceAuthDataEntry data_entry;
file_entry = malloc (sizeof (IceAuthFileEntry));
file_entry->protocol_name = strdup (protocol);
file_entry->protocol_data = NULL;
file_entry->protocol_data_length = 0;
file_entry->network_id = strdup (network_id);
file_entry->auth_name = strdup (GSM_ICE_MAGIC_COOKIE_AUTH_NAME);
file_entry->auth_data = IceGenerateMagicCookie (GSM_ICE_MAGIC_COOKIE_LEN);
file_entry->auth_data_length = GSM_ICE_MAGIC_COOKIE_LEN;
/* Also create an in-memory copy, which is what the server will
* actually use for checking client auth.
*/
data_entry.protocol_name = file_entry->protocol_name;
data_entry.network_id = file_entry->network_id;
data_entry.auth_name = file_entry->auth_name;
data_entry.auth_data = file_entry->auth_data;
data_entry.auth_data_length = file_entry->auth_data_length;
IceSetPaAuthData (1, &data_entry);
return file_entry;
} | 0 | [
"CWE-125",
"CWE-835"
] | gnome-session | b0dc999e0b45355314616321dbb6cb71e729fc9d | 241,206,297,204,553,600,000,000,000,000,000,000,000 | 28 | [gsm] Delay the creation of the GsmXSMPClient until it really exists
We used to create the GsmXSMPClient before the XSMP connection is really
accepted. This can lead to some issues, though. An example is:
https://bugzilla.gnome.org/show_bug.cgi?id=598211#c19. Quoting:
"What is happening is that a new client (probably metacity in your
case) is opening an ICE connection in the GSM_MANAGER_PHASE_END_SESSION
phase, which causes a new GsmXSMPClient to be added to the client
store. The GSM_MANAGER_PHASE_EXIT phase then begins before the client
has had a chance to establish a xsmp connection, which means that
client->priv->conn will not be initialized at the point that xsmp_stop
is called on the new unregistered client."
The fix is to create the GsmXSMPClient object when there's a real XSMP
connection. This implies moving the timeout that makes sure we don't
have an empty client to the XSMP server.
https://bugzilla.gnome.org/show_bug.cgi?id=598211 |
const ThreadCommand* Binary::thread_command() const {
return command<ThreadCommand>();
} | 0 | [
"CWE-703"
] | LIEF | 7acf0bc4224081d4f425fcc8b2e361b95291d878 | 156,446,588,360,900,670,000,000,000,000,000,000,000 | 3 | Resolve #764 |
sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net,
const struct sctp_endpoint *ep,
const struct sctp_association *asoc,
const sctp_subtype_t type, void *arg,
sctp_cmd_seq_t *commands)
{
struct sctp_chunk *asconf_ack = arg;
struct sctp_chunk *last_asconf = asoc->addip_last_asconf;
struct sctp_chunk *abort;
struct sctp_paramhdr *err_param = NULL;
sctp_addiphdr_t *addip_hdr;
__u32 sent_serial, rcvd_serial;
if (!sctp_vtag_verify(asconf_ack, asoc)) {
sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG,
SCTP_NULL());
return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
}
/* ADD-IP, Section 4.1.2:
* This chunk MUST be sent in an authenticated way by using
* the mechanism defined in [I-D.ietf-tsvwg-sctp-auth]. If this chunk
* is received unauthenticated it MUST be silently discarded as
* described in [I-D.ietf-tsvwg-sctp-auth].
*/
if (!net->sctp.addip_noauth && !asconf_ack->auth)
return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);
/* Make sure that the ADDIP chunk has a valid length. */
if (!sctp_chunk_length_valid(asconf_ack, sizeof(sctp_addip_chunk_t)))
return sctp_sf_violation_chunklen(net, ep, asoc, type, arg,
commands);
addip_hdr = (sctp_addiphdr_t *)asconf_ack->skb->data;
rcvd_serial = ntohl(addip_hdr->serial);
/* Verify the ASCONF-ACK chunk before processing it. */
if (!sctp_verify_asconf(asoc, asconf_ack, false, &err_param))
return sctp_sf_violation_paramlen(net, ep, asoc, type, arg,
(void *)err_param, commands);
if (last_asconf) {
addip_hdr = (sctp_addiphdr_t *)last_asconf->subh.addip_hdr;
sent_serial = ntohl(addip_hdr->serial);
} else {
sent_serial = asoc->addip_serial - 1;
}
/* D0) If an endpoint receives an ASCONF-ACK that is greater than or
* equal to the next serial number to be used but no ASCONF chunk is
* outstanding the endpoint MUST ABORT the association. Note that a
* sequence number is greater than if it is no more than 2^^31-1
* larger than the current sequence number (using serial arithmetic).
*/
if (ADDIP_SERIAL_gte(rcvd_serial, sent_serial + 1) &&
!(asoc->addip_last_asconf)) {
abort = sctp_make_abort(asoc, asconf_ack,
sizeof(sctp_errhdr_t));
if (abort) {
sctp_init_cause(abort, SCTP_ERROR_ASCONF_ACK, 0);
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
SCTP_CHUNK(abort));
}
/* We are going to ABORT, so we might as well stop
* processing the rest of the chunks in the packet.
*/
sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO));
sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL());
sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
SCTP_ERROR(ECONNABORTED));
sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
SCTP_PERR(SCTP_ERROR_ASCONF_ACK));
SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
return SCTP_DISPOSITION_ABORT;
}
if ((rcvd_serial == sent_serial) && asoc->addip_last_asconf) {
sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO));
if (!sctp_process_asconf_ack((struct sctp_association *)asoc,
asconf_ack)) {
/* Successfully processed ASCONF_ACK. We can
* release the next asconf if we have one.
*/
sctp_add_cmd_sf(commands, SCTP_CMD_SEND_NEXT_ASCONF,
SCTP_NULL());
return SCTP_DISPOSITION_CONSUME;
}
abort = sctp_make_abort(asoc, asconf_ack,
sizeof(sctp_errhdr_t));
if (abort) {
sctp_init_cause(abort, SCTP_ERROR_RSRC_LOW, 0);
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
SCTP_CHUNK(abort));
}
/* We are going to ABORT, so we might as well stop
* processing the rest of the chunks in the packet.
*/
sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL());
sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
SCTP_ERROR(ECONNABORTED));
sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
SCTP_PERR(SCTP_ERROR_ASCONF_ACK));
SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
return SCTP_DISPOSITION_ABORT;
}
return SCTP_DISPOSITION_DISCARD;
} | 0 | [
"CWE-20",
"CWE-399"
] | linux | 9de7922bc709eee2f609cd01d98aaedc4cf5ea74 | 331,668,999,198,811,030,000,000,000,000,000,000,000 | 114 | net: sctp: fix skb_over_panic when receiving malformed ASCONF chunks
Commit 6f4c618ddb0 ("SCTP : Add paramters validity check for
ASCONF chunk") added basic verification of ASCONF chunks, however,
it is still possible to remotely crash a server by sending a
special crafted ASCONF chunk, even up to pre 2.6.12 kernels:
skb_over_panic: text:ffffffffa01ea1c3 len:31056 put:30768
head:ffff88011bd81800 data:ffff88011bd81800 tail:0x7950
end:0x440 dev:<NULL>
------------[ cut here ]------------
kernel BUG at net/core/skbuff.c:129!
[...]
Call Trace:
<IRQ>
[<ffffffff8144fb1c>] skb_put+0x5c/0x70
[<ffffffffa01ea1c3>] sctp_addto_chunk+0x63/0xd0 [sctp]
[<ffffffffa01eadaf>] sctp_process_asconf+0x1af/0x540 [sctp]
[<ffffffff8152d025>] ? _read_unlock_bh+0x15/0x20
[<ffffffffa01e0038>] sctp_sf_do_asconf+0x168/0x240 [sctp]
[<ffffffffa01e3751>] sctp_do_sm+0x71/0x1210 [sctp]
[<ffffffff8147645d>] ? fib_rules_lookup+0xad/0xf0
[<ffffffffa01e6b22>] ? sctp_cmp_addr_exact+0x32/0x40 [sctp]
[<ffffffffa01e8393>] sctp_assoc_bh_rcv+0xd3/0x180 [sctp]
[<ffffffffa01ee986>] sctp_inq_push+0x56/0x80 [sctp]
[<ffffffffa01fcc42>] sctp_rcv+0x982/0xa10 [sctp]
[<ffffffffa01d5123>] ? ipt_local_in_hook+0x23/0x28 [iptable_filter]
[<ffffffff8148bdc9>] ? nf_iterate+0x69/0xb0
[<ffffffff81496d10>] ? ip_local_deliver_finish+0x0/0x2d0
[<ffffffff8148bf86>] ? nf_hook_slow+0x76/0x120
[<ffffffff81496d10>] ? ip_local_deliver_finish+0x0/0x2d0
[<ffffffff81496ded>] ip_local_deliver_finish+0xdd/0x2d0
[<ffffffff81497078>] ip_local_deliver+0x98/0xa0
[<ffffffff8149653d>] ip_rcv_finish+0x12d/0x440
[<ffffffff81496ac5>] ip_rcv+0x275/0x350
[<ffffffff8145c88b>] __netif_receive_skb+0x4ab/0x750
[<ffffffff81460588>] netif_receive_skb+0x58/0x60
This can be triggered e.g., through a simple scripted nmap
connection scan injecting the chunk after the handshake, for
example, ...
-------------- INIT[ASCONF; ASCONF_ACK] ------------->
<----------- INIT-ACK[ASCONF; ASCONF_ACK] ------------
-------------------- COOKIE-ECHO -------------------->
<-------------------- COOKIE-ACK ---------------------
------------------ ASCONF; UNKNOWN ------------------>
... where ASCONF chunk of length 280 contains 2 parameters ...
1) Add IP address parameter (param length: 16)
2) Add/del IP address parameter (param length: 255)
... followed by an UNKNOWN chunk of e.g. 4 bytes. Here, the
Address Parameter in the ASCONF chunk is even missing, too.
This is just an example and similarly-crafted ASCONF chunks
could be used just as well.
The ASCONF chunk passes through sctp_verify_asconf() as all
parameters passed sanity checks, and after walking, we ended
up successfully at the chunk end boundary, and thus may invoke
sctp_process_asconf(). Parameter walking is done with
WORD_ROUND() to take padding into account.
In sctp_process_asconf()'s TLV processing, we may fail in
sctp_process_asconf_param() e.g., due to removal of the IP
address that is also the source address of the packet containing
the ASCONF chunk, and thus we need to add all TLVs after the
failure to our ASCONF response to remote via helper function
sctp_add_asconf_response(), which basically invokes a
sctp_addto_chunk() adding the error parameters to the given
skb.
When walking to the next parameter this time, we proceed
with ...
length = ntohs(asconf_param->param_hdr.length);
asconf_param = (void *)asconf_param + length;
... instead of the WORD_ROUND()'ed length, thus resulting here
in an off-by-one that leads to reading the follow-up garbage
parameter length of 12336, and thus throwing an skb_over_panic
for the reply when trying to sctp_addto_chunk() next time,
which implicitly calls the skb_put() with that length.
Fix it by using sctp_walk_params() [ which is also used in
INIT parameter processing ] macro in the verification *and*
in ASCONF processing: it will make sure we don't spill over,
that we walk parameters WORD_ROUND()'ed. Moreover, we're being
more defensive and guard against unknown parameter types and
missized addresses.
Joint work with Vlad Yasevich.
Fixes: b896b82be4ae ("[SCTP] ADDIP: Support for processing incoming ASCONF_ACK chunks.")
Signed-off-by: Daniel Borkmann <[email protected]>
Signed-off-by: Vlad Yasevich <[email protected]>
Acked-by: Neil Horman <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname,
struct fscrypt_str *cf_name)
{
int len;
if (!IS_CASEFOLDED(dir) || !EXT4_SB(dir->i_sb)->s_encoding) {
cf_name->name = NULL;
return;
}
cf_name->name = kmalloc(EXT4_NAME_LEN, GFP_NOFS);
if (!cf_name->name)
return;
len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding,
iname, cf_name->name,
EXT4_NAME_LEN);
if (len <= 0) {
kfree(cf_name->name);
cf_name->name = NULL;
return;
}
cf_name->len = (unsigned) len;
} | 0 | [
"CWE-125"
] | linux | 5872331b3d91820e14716632ebb56b1399b34fe1 | 142,719,158,780,132,450,000,000,000,000,000,000,000 | 25 | ext4: fix potential negative array index in do_split()
If for any reason a directory passed to do_split() does not have enough
active entries to exceed half the size of the block, we can end up
iterating over all "count" entries without finding a split point.
In this case, count == move, and split will be zero, and we will
attempt a negative index into map[].
Guard against this by detecting this case, and falling back to
split-to-half-of-count instead; in this case we will still have
plenty of space (> half blocksize) in each split block.
Fixes: ef2b02d3e617 ("ext34: ensure do_split leaves enough free space in both blocks")
Signed-off-by: Eric Sandeen <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Theodore Ts'o <[email protected]> |
static int __init init_ipv6_mibs(void)
{
if (snmp_mib_init((void **)ipv6_statistics,
sizeof(struct ipstats_mib)) < 0)
goto err_ip_mib;
if (snmp_mib_init((void **)icmpv6_statistics,
sizeof(struct icmpv6_mib)) < 0)
goto err_icmp_mib;
if (snmp_mib_init((void **)icmpv6msg_statistics,
sizeof(struct icmpv6msg_mib)) < 0)
goto err_icmpmsg_mib;
if (snmp_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib)) < 0)
goto err_udp_mib;
if (snmp_mib_init((void **)udplite_stats_in6,
sizeof (struct udp_mib)) < 0)
goto err_udplite_mib;
return 0;
err_udplite_mib:
snmp_mib_free((void **)udp_stats_in6);
err_udp_mib:
snmp_mib_free((void **)icmpv6msg_statistics);
err_icmpmsg_mib:
snmp_mib_free((void **)icmpv6_statistics);
err_icmp_mib:
snmp_mib_free((void **)ipv6_statistics);
err_ip_mib:
return -ENOMEM;
} | 0 | [] | linux-2.6 | 2e761e0532a784816e7e822dbaaece8c5d4be14d | 17,901,464,016,909,746,000,000,000,000,000,000,000 | 30 | ipv6 netns: init net is used to set bindv6only for new sock
The bindv6only is tuned via sysctl. It is already on a struct net
and per-net sysctls allow for its modification (ipv6_sysctl_net_init).
Despite this the value configured in the init net is used for the
rest of them.
Signed-off-by: Pavel Emelyanov <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
SRC_ReadNumberOfSources(void)
{
return n_sources;
} | 0 | [
"CWE-59"
] | chrony | e18903a6b56341481a2e08469c0602010bf7bfe3 | 112,035,238,419,141,670,000,000,000,000,000,000,000 | 4 | switch to new util file functions
Replace all fopen(), rename(), and unlink() calls with the new util
functions. |
FLAC_API FLAC__bool FLAC__stream_encoder_set_apodization(FLAC__StreamEncoder *encoder, const char *specification)
{
FLAC__ASSERT(0 != encoder);
FLAC__ASSERT(0 != encoder->private_);
FLAC__ASSERT(0 != encoder->protected_);
FLAC__ASSERT(0 != specification);
if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
return false;
#ifdef FLAC__INTEGER_ONLY_LIBRARY
(void)specification; /* silently ignore since we haven't integerized; will always use a rectangular window */
#else
encoder->protected_->num_apodizations = 0;
while(1) {
const char *s = strchr(specification, ';');
const size_t n = s? (size_t)(s - specification) : strlen(specification);
if (n==8 && 0 == strncmp("bartlett" , specification, n))
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_BARTLETT;
else if(n==13 && 0 == strncmp("bartlett_hann", specification, n))
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_BARTLETT_HANN;
else if(n==8 && 0 == strncmp("blackman" , specification, n))
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_BLACKMAN;
else if(n==26 && 0 == strncmp("blackman_harris_4term_92db", specification, n))
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_BLACKMAN_HARRIS_4TERM_92DB_SIDELOBE;
else if(n==6 && 0 == strncmp("connes" , specification, n))
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_CONNES;
else if(n==7 && 0 == strncmp("flattop" , specification, n))
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_FLATTOP;
else if(n>7 && 0 == strncmp("gauss(" , specification, 6)) {
FLAC__real stddev = (FLAC__real)strtod(specification+6, 0);
if (stddev > 0.0 && stddev <= 0.5) {
encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.gauss.stddev = stddev;
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_GAUSS;
}
}
else if(n==7 && 0 == strncmp("hamming" , specification, n))
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_HAMMING;
else if(n==4 && 0 == strncmp("hann" , specification, n))
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_HANN;
else if(n==13 && 0 == strncmp("kaiser_bessel", specification, n))
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_KAISER_BESSEL;
else if(n==7 && 0 == strncmp("nuttall" , specification, n))
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_NUTTALL;
else if(n==9 && 0 == strncmp("rectangle" , specification, n))
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_RECTANGLE;
else if(n==8 && 0 == strncmp("triangle" , specification, n))
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_TRIANGLE;
else if(n>7 && 0 == strncmp("tukey(" , specification, 6)) {
FLAC__real p = (FLAC__real)strtod(specification+6, 0);
if (p >= 0.0 && p <= 1.0) {
encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.tukey.p = p;
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_TUKEY;
}
}
else if(n>15 && 0 == strncmp("partial_tukey(" , specification, 14)) {
FLAC__int32 tukey_parts = (FLAC__int32)strtod(specification+14, 0);
const char *si_1 = strchr(specification, '/');
FLAC__real overlap = si_1?flac_min((FLAC__real)strtod(si_1+1, 0),0.99f):0.1f;
FLAC__real overlap_units = 1.0f/(1.0f - overlap) - 1.0f;
const char *si_2 = strchr((si_1?(si_1+1):specification), '/');
FLAC__real tukey_p = si_2?(FLAC__real)strtod(si_2+1, 0):0.2f;
if (tukey_parts <= 1) {
encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.tukey.p = tukey_p;
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_TUKEY;
}else if (encoder->protected_->num_apodizations + tukey_parts < 32){
FLAC__int32 m;
for(m = 0; m < tukey_parts; m++){
encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.multiple_tukey.p = tukey_p;
encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.multiple_tukey.start = m/(tukey_parts+overlap_units);
encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.multiple_tukey.end = (m+1+overlap_units)/(tukey_parts+overlap_units);
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_PARTIAL_TUKEY;
}
}
}
else if(n>16 && 0 == strncmp("punchout_tukey(" , specification, 15)) {
FLAC__int32 tukey_parts = (FLAC__int32)strtod(specification+15, 0);
const char *si_1 = strchr(specification, '/');
FLAC__real overlap = si_1?flac_min((FLAC__real)strtod(si_1+1, 0),0.99f):0.2f;
FLAC__real overlap_units = 1.0f/(1.0f - overlap) - 1.0f;
const char *si_2 = strchr((si_1?(si_1+1):specification), '/');
FLAC__real tukey_p = si_2?(FLAC__real)strtod(si_2+1, 0):0.2f;
if (tukey_parts <= 1) {
encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.tukey.p = tukey_p;
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_TUKEY;
}else if (encoder->protected_->num_apodizations + tukey_parts < 32){
FLAC__int32 m;
for(m = 0; m < tukey_parts; m++){
encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.multiple_tukey.p = tukey_p;
encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.multiple_tukey.start = m/(tukey_parts+overlap_units);
encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.multiple_tukey.end = (m+1+overlap_units)/(tukey_parts+overlap_units);
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_PUNCHOUT_TUKEY;
}
}
}
else if(n==5 && 0 == strncmp("welch" , specification, n))
encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_WELCH;
if (encoder->protected_->num_apodizations == 32)
break;
if (s)
specification = s+1;
else
break;
}
if(encoder->protected_->num_apodizations == 0) {
encoder->protected_->num_apodizations = 1;
encoder->protected_->apodizations[0].type = FLAC__APODIZATION_TUKEY;
encoder->protected_->apodizations[0].parameters.tukey.p = 0.5;
}
#endif
return true;
} | 0 | [] | flac | c06a44969c1145242a22f75fc8fb2e8b54c55303 | 263,705,646,433,208,260,000,000,000,000,000,000,000 | 112 | flac : Fix for https://sourceforge.net/p/flac/bugs/425/
* flac/encode.c : Validate num_tracks field of cuesheet.
* libFLAC/stream_encoder.c : Add check for a NULL pointer.
* flac/encode.c : Improve bounds checking.
Closes: https://sourceforge.net/p/flac/bugs/425/ |
Http2Priority::Http2Priority(Environment* env,
Local<Value> parent,
Local<Value> weight,
Local<Value> exclusive) {
Local<Context> context = env->context();
int32_t parent_ = parent->Int32Value(context).ToChecked();
int32_t weight_ = weight->Int32Value(context).ToChecked();
bool exclusive_ = exclusive->BooleanValue(context).ToChecked();
DEBUG_HTTP2("Http2Priority: parent: %d, weight: %d, exclusive: %d\n",
parent_, weight_, exclusive_);
nghttp2_priority_spec_init(&spec, parent_, weight_, exclusive_ ? 1 : 0);
} | 0 | [] | node | ce22d6f9178507c7a41b04ac4097b9ea902049e3 | 322,739,931,304,277,930,000,000,000,000,000,000,000 | 12 | http2: add altsvc support
Add support for sending and receiving ALTSVC frames.
PR-URL: https://github.com/nodejs/node/pull/17917
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Matteo Collina <[email protected]> |
static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,
struct msghdr *msg, size_t len)
{
struct sock_iocb *siocb = kiocb_to_siocb(kiocb);
struct sock *sk = sock->sk;
struct netlink_sock *nlk = nlk_sk(sk);
struct sockaddr_nl *addr = msg->msg_name;
u32 dst_pid;
u32 dst_group;
struct sk_buff *skb;
int err;
struct scm_cookie scm;
if (msg->msg_flags&MSG_OOB)
return -EOPNOTSUPP;
if (NULL == siocb->scm)
siocb->scm = &scm;
err = scm_send(sock, msg, siocb->scm);
if (err < 0)
return err;
if (msg->msg_namelen) {
err = -EINVAL;
if (addr->nl_family != AF_NETLINK)
goto out;
dst_pid = addr->nl_pid;
dst_group = ffs(addr->nl_groups);
err = -EPERM;
if (dst_group && !netlink_capable(sock, NL_NONROOT_SEND))
goto out;
} else {
dst_pid = nlk->dst_pid;
dst_group = nlk->dst_group;
}
if (!nlk->pid) {
err = netlink_autobind(sock);
if (err)
goto out;
}
err = -EMSGSIZE;
if (len > sk->sk_sndbuf - 32)
goto out;
err = -ENOBUFS;
skb = alloc_skb(len, GFP_KERNEL);
if (skb == NULL)
goto out;
NETLINK_CB(skb).pid = nlk->pid;
NETLINK_CB(skb).dst_group = dst_group;
memcpy(NETLINK_CREDS(skb), &siocb->scm->creds, sizeof(struct ucred));
err = -EFAULT;
if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
kfree_skb(skb);
goto out;
}
err = security_netlink_send(sk, skb);
if (err) {
kfree_skb(skb);
goto out;
}
if (dst_group) {
atomic_inc(&skb->users);
netlink_broadcast(sk, skb, dst_pid, dst_group, GFP_KERNEL);
}
err = netlink_unicast(sk, skb, dst_pid, msg->msg_flags&MSG_DONTWAIT);
out:
scm_destroy(siocb->scm);
return err;
} | 1 | [
"CWE-287",
"CWE-284"
] | linux | e0e3cea46d31d23dc40df0a49a7a2c04fe8edfea | 149,780,959,227,096,180,000,000,000,000,000,000,000 | 77 | af_netlink: force credentials passing [CVE-2012-3520]
Pablo Neira Ayuso discovered that avahi and
potentially NetworkManager accept spoofed Netlink messages because of a
kernel bug. The kernel passes all-zero SCM_CREDENTIALS ancillary data
to the receiver if the sender did not provide such data, instead of not
including any such data at all or including the correct data from the
peer (as it is the case with AF_UNIX).
This bug was introduced in commit 16e572626961
(af_unix: dont send SCM_CREDENTIALS by default)
This patch forces passing credentials for netlink, as
before the regression.
Another fix would be to not add SCM_CREDENTIALS in
netlink messages if not provided by the sender, but it
might break some programs.
With help from Florian Weimer & Petr Matousek
This issue is designated as CVE-2012-3520
Signed-off-by: Eric Dumazet <[email protected]>
Cc: Petr Matousek <[email protected]>
Cc: Florian Weimer <[email protected]>
Cc: Pablo Neira Ayuso <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
Read the list of mailboxes */
PHP_FUNCTION(imap_list)
{
zval *streamind;
zend_string *ref, *pat;
pils *imap_le_struct;
STRINGLIST *cur=NIL;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rSS", &streamind, &ref, &pat) == FAILURE) {
return;
}
if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) {
RETURN_FALSE;
}
/* set flag for normal, old mailbox list */
IMAPG(folderlist_style) = FLIST_ARRAY;
IMAPG(imap_folders) = IMAPG(imap_folders_tail) = NIL;
mail_list(imap_le_struct->imap_stream, ZSTR_VAL(ref), ZSTR_VAL(pat));
if (IMAPG(imap_folders) == NIL) {
RETURN_FALSE;
}
array_init(return_value);
cur=IMAPG(imap_folders);
while (cur != NIL) {
add_next_index_string(return_value, (char*)cur->LTEXT);
cur=cur->next;
}
mail_free_stringlist (&IMAPG(imap_folders));
IMAPG(imap_folders) = IMAPG(imap_folders_tail) = NIL; | 0 | [
"CWE-88"
] | php-src | 336d2086a9189006909ae06c7e95902d7d5ff77e | 138,065,107,746,811,230,000,000,000,000,000,000,000 | 33 | Disable rsh/ssh functionality in imap by default (bug #77153) |
SharedConnectionWrapper& shared_connection() { return shared_connection_; } | 0 | [
"CWE-400"
] | envoy | dfddb529e914d794ac552e906b13d71233609bf7 | 176,342,298,654,451,100,000,000,000,000,000,000,000 | 1 | listener: Add configurable accepted connection limits (#153)
Add support for per-listener limits on accepted connections.
Signed-off-by: Tony Allen <[email protected]> |
get_tmfromtime(struct tm *tm, time_t *t)
{
#if HAVE_LOCALTIME_R
tzset();
localtime_r(t, tm);
#elif HAVE__LOCALTIME64_S
_localtime64_s(tm, t);
#else
memcpy(tm, localtime(t), sizeof(*tm));
#endif
} | 0 | [
"CWE-190"
] | libarchive | 3014e19820ea53c15c90f9d447ca3e668a0b76c6 | 221,308,945,467,611,830,000,000,000,000,000,000,000 | 11 | Issue 711: Be more careful about verifying filename lengths when writing ISO9660 archives
* Don't cast size_t to int, since this can lead to overflow
on machines where sizeof(int) < sizeof(size_t)
* Check a + b > limit by writing it as
a > limit || b > limit || a + b > limit
to avoid problems when a + b wraps around. |
static int selinux_sb_statfs(struct dentry *dentry)
{
const struct cred *cred = current_cred();
struct common_audit_data ad;
ad.type = LSM_AUDIT_DATA_DENTRY;
ad.u.dentry = dentry->d_sb->s_root;
return superblock_has_perm(cred, dentry->d_sb, FILESYSTEM__GETATTR, &ad);
} | 0 | [
"CWE-264"
] | linux | 7b0d0b40cd78cadb525df760ee4cac151533c2b5 | 145,621,799,786,595,350,000,000,000,000,000,000,000 | 9 | selinux: Permit bounded transitions under NO_NEW_PRIVS or NOSUID.
If the callee SID is bounded by the caller SID, then allowing
the transition to occur poses no risk of privilege escalation and we can
therefore safely allow the transition to occur. Add this exemption
for both the case where a transition was explicitly requested by the
application and the case where an automatic transition is defined in
policy.
Signed-off-by: Stephen Smalley <[email protected]>
Reviewed-by: Andy Lutomirski <[email protected]>
Signed-off-by: Paul Moore <[email protected]> |
vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo)
{
ssize_t l;
uint8_t *ptr;
enum vfp_status vfps = VFP_ERROR;
ssize_t est;
struct vfp_ctx *vfc;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
vfc = bo->vfc;
CHECK_OBJ_NOTNULL(vfc, VFP_CTX_MAGIC);
AN(vfc->vfp_nxt);
est = bo->htc->content_length;
if (est < 0)
est = 0;
do {
if (vfc->oc->flags & OC_F_ABANDON) {
/*
* A pass object and delivery was terminated
* We don't fail the fetch, in order for hit-for-pass
* objects to be created.
*/
AN(vfc->oc->flags & OC_F_PASS);
VSLb(wrk->vsl, SLT_FetchError,
"Pass delivery abandoned");
bo->htc->doclose = SC_RX_BODY;
break;
}
AZ(vfc->failed);
l = est;
assert(l >= 0);
if (VFP_GetStorage(vfc, &l, &ptr) != VFP_OK) {
bo->htc->doclose = SC_RX_BODY;
break;
}
AZ(vfc->failed);
vfps = VFP_Suck(vfc, ptr, &l);
if (l > 0 && vfps != VFP_ERROR) {
bo->acct.beresp_bodybytes += l;
VFP_Extend(vfc, l);
if (est >= l)
est -= l;
else
est = 0;
}
} while (vfps == VFP_OK);
if (vfc->failed) {
(void)VFP_Error(vfc, "Fetch pipeline failed to process");
bo->htc->doclose = SC_RX_BODY;
VFP_Close(vfc);
VDI_Finish(wrk, bo);
if (!bo->do_stream) {
assert(bo->fetch_objcore->boc->state < BOS_STREAM);
// XXX: doclose = ?
return (F_STP_ERROR);
} else {
wrk->stats->fetch_failed++;
return (F_STP_FAIL);
}
}
ObjTrimStore(wrk, vfc->oc);
return (F_STP_FETCHEND);
} | 0 | [
"CWE-119",
"CWE-787"
] | varnish-cache | 176f8a075a963ffbfa56f1c460c15f6a1a6af5a7 | 20,247,466,771,755,824,000,000,000,000,000,000,000 | 69 | Avoid buffer read overflow on vcl_error and -sfile
The file stevedore may return a buffer larger than asked for when
requesting storage. Due to lack of check for this condition, the code
to copy the synthetic error memory buffer from vcl_error would overrun
the buffer.
Patch by @shamger
Fixes: #2429 |
static int ms_pull_ctl_enable_lqfp48(struct rtsx_ucr *ucr)
{
rtsx_usb_init_cmd(ucr);
rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL1, 0xFF, 0x55);
rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL2, 0xFF, 0x55);
rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL3, 0xFF, 0x95);
rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL4, 0xFF, 0x55);
rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL5, 0xFF, 0x55);
rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL6, 0xFF, 0xA5);
return rtsx_usb_send_cmd(ucr, MODE_C, 100);
} | 0 | [
"CWE-416"
] | linux | 42933c8aa14be1caa9eda41f65cde8a3a95d3e39 | 211,193,892,281,656,820,000,000,000,000,000,000,000 | 13 | memstick: rtsx_usb_ms: fix UAF
This patch fixes the following issues:
1. memstick_free_host() will free the host, so the use of ms_dev(host) after
it will be a problem. To fix this, move memstick_free_host() after when we
are done with ms_dev(host).
2. In rtsx_usb_ms_drv_remove(), pm need to be disabled before we remove
and free host otherwise memstick_check will be called and UAF will
happen.
[ 11.351173] BUG: KASAN: use-after-free in rtsx_usb_ms_drv_remove+0x94/0x140 [rtsx_usb_ms]
[ 11.357077] rtsx_usb_ms_drv_remove+0x94/0x140 [rtsx_usb_ms]
[ 11.357376] platform_remove+0x2a/0x50
[ 11.367531] Freed by task 298:
[ 11.368537] kfree+0xa4/0x2a0
[ 11.368711] device_release+0x51/0xe0
[ 11.368905] kobject_put+0xa2/0x120
[ 11.369090] rtsx_usb_ms_drv_remove+0x8c/0x140 [rtsx_usb_ms]
[ 11.369386] platform_remove+0x2a/0x50
[ 12.038408] BUG: KASAN: use-after-free in __mutex_lock.isra.0+0x3ec/0x7c0
[ 12.045432] mutex_lock+0xc9/0xd0
[ 12.046080] memstick_check+0x6a/0x578 [memstick]
[ 12.046509] process_one_work+0x46d/0x750
[ 12.052107] Freed by task 297:
[ 12.053115] kfree+0xa4/0x2a0
[ 12.053272] device_release+0x51/0xe0
[ 12.053463] kobject_put+0xa2/0x120
[ 12.053647] rtsx_usb_ms_drv_remove+0xc4/0x140 [rtsx_usb_ms]
[ 12.053939] platform_remove+0x2a/0x50
Signed-off-by: Tong Zhang <[email protected]>
Co-developed-by: Ulf Hansson <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Ulf Hansson <[email protected]> |
static NTSTATUS pdb_samba_dsdb_del_trusted_domain(struct pdb_methods *methods,
const char *domain)
{
struct pdb_samba_dsdb_state *state = talloc_get_type_abort(
methods->private_data, struct pdb_samba_dsdb_state);
TALLOC_CTX *tmp_ctx = talloc_stackframe();
struct pdb_trusted_domain *td = NULL;
struct ldb_dn *tdo_dn = NULL;
bool in_txn = false;
NTSTATUS status;
int ret;
bool ok;
status = pdb_samba_dsdb_get_trusted_domain(methods,
tmp_ctx,
domain,
&td);
if (!NT_STATUS_IS_OK(status)) {
if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
DBG_ERR("Searching TDO for %s returned %s\n",
domain, nt_errstr(status));
return status;
}
DBG_NOTICE("No TDO object for %s\n", domain);
return NT_STATUS_OK;
}
tdo_dn = ldb_dn_copy(tmp_ctx, ldb_get_default_basedn(state->ldb));
if (tdo_dn == NULL) {
status = NT_STATUS_NO_MEMORY;
goto out;
}
ok = ldb_dn_add_child_fmt(tdo_dn, "cn=%s,cn=System", domain);
if (!ok) {
TALLOC_FREE(tmp_ctx);
status = NT_STATUS_NO_MEMORY;
goto out;
}
ret = ldb_transaction_start(state->ldb);
if (ret != LDB_SUCCESS) {
status = NT_STATUS_INTERNAL_DB_CORRUPTION;
goto out;
}
in_txn = true;
ret = ldb_delete(state->ldb, tdo_dn);
if (ret != LDB_SUCCESS) {
status = NT_STATUS_INVALID_HANDLE;
goto out;
}
if (td->trust_direction == LSA_TRUST_DIRECTION_INBOUND) {
status = delete_trust_user(tmp_ctx, state, domain);
if (!NT_STATUS_IS_OK(status)) {
goto out;
}
}
ret = ldb_transaction_commit(state->ldb);
if (ret != LDB_SUCCESS) {
status = NT_STATUS_INTERNAL_DB_CORRUPTION;
goto out;
}
in_txn = false;
status = NT_STATUS_OK;
out:
if (in_txn) {
ldb_transaction_cancel(state->ldb);
}
TALLOC_FREE(tmp_ctx);
return status;
} | 0 | [
"CWE-200"
] | samba | 0a3aa5f908e351201dc9c4d4807b09ed9eedff77 | 4,695,212,413,250,115,000,000,000,000,000,000,000 | 77 | CVE-2022-32746 ldb: Make use of functions for appending to an ldb_message
This aims to minimise usage of the error-prone pattern of searching for
a just-added message element in order to make modifications to it (and
potentially finding the wrong element).
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15009
Signed-off-by: Joseph Sutton <[email protected]> |
static int stbi__parse_zlib_header(stbi__zbuf *a)
{
int cmf = stbi__zget8(a);
int cm = cmf & 15;
/* int cinfo = cmf >> 4; */
int flg = stbi__zget8(a);
if (stbi__zeof(a)) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec
if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec
if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png
if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png
// window = 1 << (8 + cinfo)... but who cares, we fully buffer output
return 1;
} | 0 | [
"CWE-787"
] | stb | 5ba0baaa269b3fd681828e0e3b3ac0f1472eaf40 | 154,768,727,025,373,690,000,000,000,000,000,000,000 | 13 | stb_image: Reject fractional JPEG component subsampling ratios
The component resamplers are not written to support this and I've
never seen it happen in a real (non-crafted) JPEG file so I'm
fine rejecting this as outright corrupt.
Fixes issue #1178. |
process_prime_response(struct module_qstate* qstate, struct val_qstate* vq,
int id, int rcode, struct dns_msg* msg, struct sock_list* origin)
{
struct val_env* ve = (struct val_env*)qstate->env->modinfo[id];
struct ub_packed_rrset_key* dnskey_rrset = NULL;
struct trust_anchor* ta = anchor_find(qstate->env->anchors,
vq->trust_anchor_name, vq->trust_anchor_labs,
vq->trust_anchor_len, vq->qchase.qclass);
if(!ta) {
/* trust anchor revoked, restart with less anchors */
vq->state = VAL_INIT_STATE;
if(!vq->trust_anchor_name)
vq->state = VAL_VALIDATE_STATE; /* break a loop */
vq->trust_anchor_name = NULL;
return;
}
/* Fetch and validate the keyEntry that corresponds to the
* current trust anchor. */
if(rcode == LDNS_RCODE_NOERROR) {
dnskey_rrset = reply_find_rrset_section_an(msg->rep,
ta->name, ta->namelen, LDNS_RR_TYPE_DNSKEY,
ta->dclass);
}
if(ta->autr) {
if(!autr_process_prime(qstate->env, ve, ta, dnskey_rrset,
qstate)) {
/* trust anchor revoked, restart with less anchors */
vq->state = VAL_INIT_STATE;
vq->trust_anchor_name = NULL;
return;
}
}
vq->key_entry = primeResponseToKE(dnskey_rrset, ta, qstate, id);
lock_basic_unlock(&ta->lock);
if(vq->key_entry) {
if(key_entry_isbad(vq->key_entry)
&& vq->restart_count < ve->max_restart) {
val_blacklist(&vq->chain_blacklist, qstate->region,
origin, 1);
qstate->errinf = NULL;
vq->restart_count++;
vq->key_entry = NULL;
vq->state = VAL_INIT_STATE;
return;
}
vq->chain_blacklist = NULL;
errinf_origin(qstate, origin);
errinf_dname(qstate, "for trust anchor", ta->name);
/* store the freshly primed entry in the cache */
key_cache_insert(ve->kcache, vq->key_entry, qstate);
}
/* If the result of the prime is a null key, skip the FINDKEY state.*/
if(!vq->key_entry || key_entry_isnull(vq->key_entry) ||
key_entry_isbad(vq->key_entry)) {
vq->state = VAL_VALIDATE_STATE;
}
/* the qstate will be reactivated after inform_super is done */
} | 0 | [
"CWE-613",
"CWE-703"
] | unbound | f6753a0f1018133df552347a199e0362fc1dac68 | 80,304,553,090,856,820,000,000,000,000,000,000,000 | 60 | - Fix the novel ghost domain issues CVE-2022-30698 and CVE-2022-30699. |
check_const_name_sym(mrb_state *mrb, mrb_sym id)
{
check_const_name_str(mrb, mrb_sym2str(mrb, id));
} | 0 | [
"CWE-476",
"CWE-415"
] | mruby | faa4eaf6803bd11669bc324b4c34e7162286bfa3 | 313,359,468,354,590,300,000,000,000,000,000,000,000 | 4 | `mrb_class_real()` did not work for `BasicObject`; fix #4037 |
zcvx(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
ref *aop;
uint opidx;
check_op(1);
/*
* If the object is an internal operator, we can't allow it to
* exist in executable form anywhere outside the e-stack.
*/
if (r_has_type(op, t_operator) &&
((opidx = op_index(op)) == 0 ||
op_def_is_internal(op_index_def(opidx)))
)
return_error(gs_error_rangecheck);
aop = ACCESS_REF(op);
r_set_attrs(aop, a_executable);
return 0;
} | 0 | [] | ghostpdl | 0edd3d6c634a577db261615a9dc2719bca7f6e01 | 143,393,386,647,770,590,000,000,000,000,000,000,000 | 20 | Bug 699659: Don't just assume an object is a t_(a)struct |
static bool ieee80211_get_dtim(const struct cfg80211_bss_ies *ies,
u8 *dtim_count, u8 *dtim_period)
{
const u8 *tim_ie = cfg80211_find_ie(WLAN_EID_TIM, ies->data, ies->len);
const u8 *idx_ie = cfg80211_find_ie(WLAN_EID_MULTI_BSSID_IDX, ies->data,
ies->len);
const struct ieee80211_tim_ie *tim = NULL;
const struct ieee80211_bssid_index *idx;
bool valid = tim_ie && tim_ie[1] >= 2;
if (valid)
tim = (void *)(tim_ie + 2);
if (dtim_count)
*dtim_count = valid ? tim->dtim_count : 0;
if (dtim_period)
*dtim_period = valid ? tim->dtim_period : 0;
/* Check if value is overridden by non-transmitted profile */
if (!idx_ie || idx_ie[1] < 3)
return valid;
idx = (void *)(idx_ie + 2);
if (dtim_count)
*dtim_count = idx->dtim_count;
if (dtim_period)
*dtim_period = idx->dtim_period;
return true;
} | 0 | [] | linux | 79c92ca42b5a3e0ea172ea2ce8df8e125af237da | 295,498,386,131,883,850,000,000,000,000,000,000,000 | 33 | mac80211: handle deauthentication/disassociation from TDLS peer
When receiving a deauthentication/disassociation frame from a TDLS
peer, a station should not disconnect the current AP, but only
disable the current TDLS link if it's enabled.
Without this change, a TDLS issue can be reproduced by following the
steps as below:
1. STA-1 and STA-2 are connected to AP, bidirection traffic is running
between STA-1 and STA-2.
2. Set up TDLS link between STA-1 and STA-2, stay for a while, then
teardown TDLS link.
3. Repeat step #2 and monitor the connection between STA and AP.
During the test, one STA may send a deauthentication/disassociation
frame to another, after TDLS teardown, with reason code 6/7, which
means: Class 2/3 frame received from nonassociated STA.
On receive this frame, the receiver STA will disconnect the current
AP and then reconnect. It's not a expected behavior, purpose of this
frame should be disabling the TDLS link, not the link with AP.
Cc: [email protected]
Signed-off-by: Yu Wang <[email protected]>
Signed-off-by: Johannes Berg <[email protected]> |
static void nf_tables_gen_notify(struct net *net, struct sk_buff *skb,
int event)
{
struct nlmsghdr *nlh = nlmsg_hdr(skb);
struct sk_buff *skb2;
int err;
if (!nlmsg_report(nlh) &&
!nfnetlink_has_listeners(net, NFNLGRP_NFTABLES))
return;
skb2 = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
if (skb2 == NULL)
goto err;
err = nf_tables_fill_gen_info(skb2, net, NETLINK_CB(skb).portid,
nlh->nlmsg_seq);
if (err < 0) {
kfree_skb(skb2);
goto err;
}
nfnetlink_send(skb2, net, NETLINK_CB(skb).portid, NFNLGRP_NFTABLES,
nlmsg_report(nlh), GFP_KERNEL);
return;
err:
nfnetlink_set_err(net, NETLINK_CB(skb).portid, NFNLGRP_NFTABLES,
-ENOBUFS);
} | 0 | [
"CWE-665"
] | linux | ad9f151e560b016b6ad3280b48e42fa11e1a5440 | 62,306,352,050,234,410,000,000,000,000,000,000,000 | 29 | netfilter: nf_tables: initialize set before expression setup
nft_set_elem_expr_alloc() needs an initialized set if expression sets on
the NFT_EXPR_GC flag. Move set fields initialization before expression
setup.
[4512935.019450] ==================================================================
[4512935.019456] BUG: KASAN: null-ptr-deref in nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019487] Read of size 8 at addr 0000000000000070 by task nft/23532
[4512935.019494] CPU: 1 PID: 23532 Comm: nft Not tainted 5.12.0-rc4+ #48
[...]
[4512935.019502] Call Trace:
[4512935.019505] dump_stack+0x89/0xb4
[4512935.019512] ? nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019536] ? nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019560] kasan_report.cold.12+0x5f/0xd8
[4512935.019566] ? nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019590] nft_set_elem_expr_alloc+0x84/0xd0 [nf_tables]
[4512935.019615] nf_tables_newset+0xc7f/0x1460 [nf_tables]
Reported-by: [email protected]
Fixes: 65038428b2c6 ("netfilter: nf_tables: allow to specify stateful expression in set definition")
Signed-off-by: Pablo Neira Ayuso <[email protected]> |
void Field_decimal::overflow(bool negative)
{
uint len=field_length;
uchar *to=ptr, filler= '9';
set_warning(ER_WARN_DATA_OUT_OF_RANGE, 1);
if (negative)
{
if (!unsigned_flag)
{
/* Put - sign as a first digit so we'll have -999..999 or 999..999 */
*to++ = '-';
len--;
}
else
{
filler= '0'; // Fill up with 0
if (!zerofill)
{
/*
Handle unsigned integer without zerofill, in which case
the number should be of format ' 0' or ' 0.000'
*/
uint whole_part=field_length- (dec ? dec+2 : 1);
// Fill with spaces up to the first digit
bfill(to, whole_part, ' ');
to+= whole_part;
len-= whole_part;
// The main code will also handle the 0 before the decimal point
}
}
}
bfill(to, len, filler);
if (dec)
ptr[field_length-dec-1]='.';
return;
} | 0 | [
"CWE-416",
"CWE-703"
] | server | 08c7ab404f69d9c4ca6ca7a9cf7eec74c804f917 | 113,168,965,771,945,480,000,000,000,000,000,000,000 | 37 | MDEV-24176 Server crashes after insert in the table with virtual
column generated using date_format() and if()
vcol_info->expr is allocated on expr_arena at parsing stage. Since
expr item is allocated on expr_arena all its containee items must be
allocated on expr_arena too. Otherwise fix_session_expr() will
encounter prematurely freed item.
When table is reopened from cache vcol_info contains stale
expression. We refresh expression via TABLE::vcol_fix_exprs() but
first we must prepare a proper context (Vcol_expr_context) which meets
some requirements:
1. As noted above expr update must be done on expr_arena as there may
be new items created. It was a bug in fix_session_expr_for_read() and
was just not reproduced because of no second refix. Now refix is done
for more cases so it does reproduce. Tests affected: vcol.binlog
2. Also name resolution context must be narrowed to the single table.
Tested by: vcol.update main.default vcol.vcol_syntax gcol.gcol_bugfixes
3. sql_mode must be clean and not fail expr update.
sql_mode such as MODE_NO_BACKSLASH_ESCAPES, MODE_NO_ZERO_IN_DATE, etc
must not affect vcol expression update. If the table was created
successfully any further evaluation must not fail. Tests affected:
main.func_like
Reviewed by: Sergei Golubchik <[email protected]> |
ecryptfs_filldir(struct dir_context *ctx, const char *lower_name,
int lower_namelen, loff_t offset, u64 ino, unsigned int d_type)
{
struct ecryptfs_getdents_callback *buf =
container_of(ctx, struct ecryptfs_getdents_callback, ctx);
size_t name_size;
char *name;
int rc;
buf->filldir_called++;
rc = ecryptfs_decode_and_decrypt_filename(&name, &name_size,
buf->sb, lower_name,
lower_namelen);
if (rc) {
printk(KERN_ERR "%s: Error attempting to decode and decrypt "
"filename [%s]; rc = [%d]\n", __func__, lower_name,
rc);
goto out;
}
buf->caller->pos = buf->ctx.pos;
rc = !dir_emit(buf->caller, name, name_size, ino, d_type);
kfree(name);
if (!rc)
buf->entries_written++;
out:
return rc;
} | 0 | [
"CWE-119",
"CWE-787"
] | linux | f0fe970df3838c202ef6c07a4c2b36838ef0a88b | 127,539,072,687,998,530,000,000,000,000,000,000,000 | 27 | ecryptfs: don't allow mmap when the lower fs doesn't support it
There are legitimate reasons to disallow mmap on certain files, notably
in sysfs or procfs. We shouldn't emulate mmap support on file systems
that don't offer support natively.
CVE-2016-1583
Signed-off-by: Jeff Mahoney <[email protected]>
Cc: [email protected]
[tyhicks: clean up f_op check by using ecryptfs_file_to_lower()]
Signed-off-by: Tyler Hicks <[email protected]> |
static apr_byte_t oidc_oauth_validate_access_token(request_rec *r, oidc_cfg *c,
const char *token, const char **response) {
/* assemble parameters to call the token endpoint for validation */
apr_table_t *params = apr_table_make(r->pool, 4);
/* add any configured extra static parameters to the introspection endpoint */
oidc_util_table_add_query_encoded_params(r->pool, params,
c->oauth.introspection_endpoint_params);
/* add the access_token itself */
apr_table_addn(params, c->oauth.introspection_token_param_name, token);
/* see if we want to do basic auth or post-param-based auth */
const char *basic_auth = NULL;
if ((c->oauth.client_id != NULL) && (c->oauth.client_secret != NULL)) {
if ((c->oauth.introspection_endpoint_auth != NULL)
&& (apr_strnatcmp(c->oauth.introspection_endpoint_auth,
"client_secret_post") == 0)) {
apr_table_addn(params, "client_id", c->oauth.client_id);
apr_table_addn(params, "client_secret", c->oauth.client_secret);
} else {
basic_auth = apr_psprintf(r->pool, "%s:%s", c->oauth.client_id,
c->oauth.client_secret);
}
}
/* call the endpoint with the constructed parameter set and return the resulting response */
return apr_strnatcmp(c->oauth.introspection_endpoint_method, OIDC_INTROSPECTION_METHOD_GET) == 0 ?
oidc_util_http_get(r, c->oauth.introspection_endpoint_url, params,
basic_auth, NULL, c->oauth.ssl_validate_server, response,
c->http_timeout_long, c->outgoing_proxy,
oidc_dir_cfg_pass_cookies(r), c->oauth.introspection_endpoint_tls_client_cert, c->oauth.introspection_endpoint_tls_client_key):
oidc_util_http_post_form(r, c->oauth.introspection_endpoint_url,
params, basic_auth, NULL, c->oauth.ssl_validate_server,
response, c->http_timeout_long, c->outgoing_proxy,
oidc_dir_cfg_pass_cookies(r), c->oauth.introspection_endpoint_tls_client_cert, c->oauth.introspection_endpoint_tls_client_key);
} | 0 | [
"CWE-287"
] | mod_auth_openidc | 21e3728a825c41ab41efa75e664108051bb9665e | 124,360,548,452,134,250,000,000,000,000,000,000,000 | 38 | release 2.1.6 : security fix: scrub headers for "AuthType oauth20"
Signed-off-by: Hans Zandbelt <[email protected]> |
static int tcp_should_expand_sndbuf(const struct sock *sk)
{
const struct tcp_sock *tp = tcp_sk(sk);
/* If the user specified a specific send buffer setting, do
* not modify it.
*/
if (sk->sk_userlocks & SOCK_SNDBUF_LOCK)
return 0;
/* If we are under global TCP memory pressure, do not expand. */
if (tcp_memory_pressure)
return 0;
/* If we are under soft global TCP memory pressure, do not expand. */
if (atomic_long_read(&tcp_memory_allocated) >= sysctl_tcp_mem[0])
return 0;
/* If we filled the congestion window, do not expand. */
if (tp->packets_out >= tp->snd_cwnd)
return 0;
return 1;
} | 0 | [] | net-next | fdf5af0daf8019cec2396cdef8fb042d80fe71fa | 328,883,797,433,948,860,000,000,000,000,000,000,000 | 24 | tcp: drop SYN+FIN messages
Denys Fedoryshchenko reported that SYN+FIN attacks were bringing his
linux machines to their limits.
Dont call conn_request() if the TCP flags includes SYN flag
Reported-by: Denys Fedoryshchenko <[email protected]>
Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
{
Idx num = REG_MISSING;
unsigned char c;
while (1)
{
fetch_token (token, input, syntax);
c = token->opr.c;
if (BE (token->type == END_OF_RE, 0))
return REG_ERROR;
if (token->type == OP_CLOSE_DUP_NUM || c == ',')
break;
num = ((token->type != CHARACTER || c < '0' || '9' < c
|| num == REG_ERROR)
? REG_ERROR
: num == REG_MISSING
? c - '0'
: MIN (RE_DUP_MAX + 1, num * 10 + c - '0'));
}
return num;
} | 0 | [
"CWE-19"
] | gnulib | 5513b40999149090987a0341c018d05d3eea1272 | 320,138,445,640,765,800,000,000,000,000,000,000,000 | 21 | Diagnose ERE '()|\1'
Problem reported by Hanno Böck in: http://bugs.gnu.org/21513
* lib/regcomp.c (parse_reg_exp): While parsing alternatives, keep
track of the set of previously-completed subexpressions available
before the first alternative, and restore this set just before
parsing each subsequent alternative. This lets us diagnose the
invalid back-reference in the ERE '()|\1'. |
xsltFormatNumberConversion(xsltDecimalFormatPtr self,
xmlChar *format,
double number,
xmlChar **result)
{
xmlXPathError status = XPATH_EXPRESSION_OK;
xmlBufferPtr buffer;
xmlChar *the_format, *prefix = NULL, *suffix = NULL;
xmlChar *nprefix, *nsuffix = NULL;
xmlChar pchar;
int prefix_length, suffix_length = 0, nprefix_length, nsuffix_length;
double scale;
int j, len;
int self_grouping_len;
xsltFormatNumberInfo format_info;
/*
* delayed_multiplier allows a 'trailing' percent or
* permille to be treated as suffix
*/
int delayed_multiplier = 0;
/* flag to show no -ve format present for -ve number */
char default_sign = 0;
/* flag to show error found, should use default format */
char found_error = 0;
if (xmlStrlen(format) <= 0) {
xsltTransformError(NULL, NULL, NULL,
"xsltFormatNumberConversion : "
"Invalid format (0-length)\n");
}
*result = NULL;
switch (xmlXPathIsInf(number)) {
case -1:
if (self->minusSign == NULL)
*result = xmlStrdup(BAD_CAST "-");
else
*result = xmlStrdup(self->minusSign);
/* no-break on purpose */
case 1:
if ((self == NULL) || (self->infinity == NULL))
*result = xmlStrcat(*result, BAD_CAST "Infinity");
else
*result = xmlStrcat(*result, self->infinity);
return(status);
default:
if (xmlXPathIsNaN(number)) {
if ((self == NULL) || (self->noNumber == NULL))
*result = xmlStrdup(BAD_CAST "NaN");
else
*result = xmlStrdup(self->noNumber);
return(status);
}
}
buffer = xmlBufferCreate();
if (buffer == NULL) {
return XPATH_MEMORY_ERROR;
}
format_info.integer_hash = 0;
format_info.integer_digits = 0;
format_info.frac_digits = 0;
format_info.frac_hash = 0;
format_info.group = -1;
format_info.multiplier = 1;
format_info.add_decimal = FALSE;
format_info.is_multiplier_set = FALSE;
format_info.is_negative_pattern = FALSE;
the_format = format;
/*
* First we process the +ve pattern to get percent / permille,
* as well as main format
*/
prefix = the_format;
prefix_length = xsltFormatNumberPreSuffix(self, &the_format, &format_info);
if (prefix_length < 0) {
found_error = 1;
goto OUTPUT_NUMBER;
}
/*
* Here we process the "number" part of the format. It gets
* a little messy because of the percent/per-mille - if that
* appears at the end, it may be part of the suffix instead
* of part of the number, so the variable delayed_multiplier
* is used to handle it
*/
self_grouping_len = xmlStrlen(self->grouping);
while ((*the_format != 0) &&
(xsltUTF8Charcmp(the_format, self->decimalPoint) != 0) &&
(xsltUTF8Charcmp(the_format, self->patternSeparator) != 0)) {
if (delayed_multiplier != 0) {
format_info.multiplier = delayed_multiplier;
format_info.is_multiplier_set = TRUE;
delayed_multiplier = 0;
}
if (xsltUTF8Charcmp(the_format, self->digit) == 0) {
if (format_info.integer_digits > 0) {
found_error = 1;
goto OUTPUT_NUMBER;
}
format_info.integer_hash++;
if (format_info.group >= 0)
format_info.group++;
} else if (xsltUTF8Charcmp(the_format, self->zeroDigit) == 0) {
format_info.integer_digits++;
if (format_info.group >= 0)
format_info.group++;
} else if ((self_grouping_len > 0) &&
(!xmlStrncmp(the_format, self->grouping, self_grouping_len))) {
/* Reset group count */
format_info.group = 0;
the_format += self_grouping_len;
continue;
} else if (xsltUTF8Charcmp(the_format, self->percent) == 0) {
if (format_info.is_multiplier_set) {
found_error = 1;
goto OUTPUT_NUMBER;
}
delayed_multiplier = 100;
} else if (xsltUTF8Charcmp(the_format, self->permille) == 0) {
if (format_info.is_multiplier_set) {
found_error = 1;
goto OUTPUT_NUMBER;
}
delayed_multiplier = 1000;
} else
break; /* while */
if ((len=xsltUTF8Size(the_format)) < 1) {
found_error = 1;
goto OUTPUT_NUMBER;
}
the_format += len;
}
/* We have finished the integer part, now work on fraction */
if ( (*the_format != 0) &&
(xsltUTF8Charcmp(the_format, self->decimalPoint) == 0) ) {
format_info.add_decimal = TRUE;
the_format += xsltUTF8Size(the_format); /* Skip over the decimal */
}
while (*the_format != 0) {
if (xsltUTF8Charcmp(the_format, self->zeroDigit) == 0) {
if (format_info.frac_hash != 0) {
found_error = 1;
goto OUTPUT_NUMBER;
}
format_info.frac_digits++;
} else if (xsltUTF8Charcmp(the_format, self->digit) == 0) {
format_info.frac_hash++;
} else if (xsltUTF8Charcmp(the_format, self->percent) == 0) {
if (format_info.is_multiplier_set) {
found_error = 1;
goto OUTPUT_NUMBER;
}
delayed_multiplier = 100;
if ((len = xsltUTF8Size(the_format)) < 1) {
found_error = 1;
goto OUTPUT_NUMBER;
}
the_format += len;
continue; /* while */
} else if (xsltUTF8Charcmp(the_format, self->permille) == 0) {
if (format_info.is_multiplier_set) {
found_error = 1;
goto OUTPUT_NUMBER;
}
delayed_multiplier = 1000;
if ((len = xsltUTF8Size(the_format)) < 1) {
found_error = 1;
goto OUTPUT_NUMBER;
}
the_format += len;
continue; /* while */
} else if (xsltUTF8Charcmp(the_format, self->grouping) != 0) {
break; /* while */
}
if ((len = xsltUTF8Size(the_format)) < 1) {
found_error = 1;
goto OUTPUT_NUMBER;
}
the_format += len;
if (delayed_multiplier != 0) {
format_info.multiplier = delayed_multiplier;
delayed_multiplier = 0;
format_info.is_multiplier_set = TRUE;
}
}
/*
* If delayed_multiplier is set after processing the
* "number" part, should be in suffix
*/
if (delayed_multiplier != 0) {
the_format -= len;
delayed_multiplier = 0;
}
suffix = the_format;
suffix_length = xsltFormatNumberPreSuffix(self, &the_format, &format_info);
if ( (suffix_length < 0) ||
((*the_format != 0) &&
(xsltUTF8Charcmp(the_format, self->patternSeparator) != 0)) ) {
found_error = 1;
goto OUTPUT_NUMBER;
}
/*
* We have processed the +ve prefix, number part and +ve suffix.
* If the number is -ve, we must substitute the -ve prefix / suffix
*/
if (number < 0) {
/*
* Note that j is the number of UTF8 chars before the separator,
* not the number of bytes! (bug 151975)
*/
j = xmlUTF8Strloc(format, self->patternSeparator);
if (j < 0) {
/* No -ve pattern present, so use default signing */
default_sign = 1;
}
else {
/* Skip over pattern separator (accounting for UTF8) */
the_format = (xmlChar *)xmlUTF8Strpos(format, j + 1);
/*
* Flag changes interpretation of percent/permille
* in -ve pattern
*/
format_info.is_negative_pattern = TRUE;
format_info.is_multiplier_set = FALSE;
/* First do the -ve prefix */
nprefix = the_format;
nprefix_length = xsltFormatNumberPreSuffix(self,
&the_format, &format_info);
if (nprefix_length<0) {
found_error = 1;
goto OUTPUT_NUMBER;
}
while (*the_format != 0) {
if ( (xsltUTF8Charcmp(the_format, (self)->percent) == 0) ||
(xsltUTF8Charcmp(the_format, (self)->permille)== 0) ) {
if (format_info.is_multiplier_set) {
found_error = 1;
goto OUTPUT_NUMBER;
}
format_info.is_multiplier_set = TRUE;
delayed_multiplier = 1;
}
else if (IS_SPECIAL(self, the_format))
delayed_multiplier = 0;
else
break; /* while */
if ((len = xsltUTF8Size(the_format)) < 1) {
found_error = 1;
goto OUTPUT_NUMBER;
}
the_format += len;
}
if (delayed_multiplier != 0) {
format_info.is_multiplier_set = FALSE;
the_format -= len;
}
/* Finally do the -ve suffix */
if (*the_format != 0) {
nsuffix = the_format;
nsuffix_length = xsltFormatNumberPreSuffix(self,
&the_format, &format_info);
if (nsuffix_length < 0) {
found_error = 1;
goto OUTPUT_NUMBER;
}
}
else
nsuffix_length = 0;
if (*the_format != 0) {
found_error = 1;
goto OUTPUT_NUMBER;
}
/*
* Here's another Java peculiarity:
* if -ve prefix/suffix == +ve ones, discard & use default
*/
if ((nprefix_length != prefix_length) ||
(nsuffix_length != suffix_length) ||
((nprefix_length > 0) &&
(xmlStrncmp(nprefix, prefix, prefix_length) !=0 )) ||
((nsuffix_length > 0) &&
(xmlStrncmp(nsuffix, suffix, suffix_length) !=0 ))) {
prefix = nprefix;
prefix_length = nprefix_length;
suffix = nsuffix;
suffix_length = nsuffix_length;
} /* else {
default_sign = 1;
}
*/
}
}
OUTPUT_NUMBER:
if (found_error != 0) {
xsltTransformError(NULL, NULL, NULL,
"xsltFormatNumberConversion : "
"error in format string '%s', using default\n", format);
default_sign = (number < 0.0) ? 1 : 0;
prefix_length = suffix_length = 0;
format_info.integer_hash = 0;
format_info.integer_digits = 1;
format_info.frac_digits = 1;
format_info.frac_hash = 4;
format_info.group = -1;
format_info.multiplier = 1;
format_info.add_decimal = TRUE;
}
/* Ready to output our number. First see if "default sign" is required */
if (default_sign != 0)
xmlBufferAdd(buffer, self->minusSign, xsltUTF8Size(self->minusSign));
/* Put the prefix into the buffer */
for (j = 0; j < prefix_length; j++) {
if ((pchar = *prefix++) == SYMBOL_QUOTE) {
len = xsltUTF8Size(prefix);
xmlBufferAdd(buffer, prefix, len);
prefix += len;
j += len - 1; /* length of symbol less length of quote */
} else
xmlBufferAdd(buffer, &pchar, 1);
}
/* Next do the integer part of the number */
number = fabs(number) * (double)format_info.multiplier;
scale = pow(10.0, (double)(format_info.frac_digits + format_info.frac_hash));
number = floor((scale * number + 0.5)) / scale;
if ((self->grouping != NULL) &&
(self->grouping[0] != 0)) {
len = xmlStrlen(self->grouping);
pchar = xsltGetUTF8Char(self->grouping, &len);
xsltNumberFormatDecimal(buffer, floor(number), self->zeroDigit[0],
format_info.integer_digits,
format_info.group,
pchar, len);
} else
xsltNumberFormatDecimal(buffer, floor(number), self->zeroDigit[0],
format_info.integer_digits,
format_info.group,
',', 1);
/* Special case: java treats '.#' like '.0', '.##' like '.0#', etc. */
if ((format_info.integer_digits + format_info.integer_hash +
format_info.frac_digits == 0) && (format_info.frac_hash > 0)) {
++format_info.frac_digits;
--format_info.frac_hash;
}
/* Add leading zero, if required */
if ((floor(number) == 0) &&
(format_info.integer_digits + format_info.frac_digits == 0)) {
xmlBufferAdd(buffer, self->zeroDigit, xsltUTF8Size(self->zeroDigit));
}
/* Next the fractional part, if required */
if (format_info.frac_digits + format_info.frac_hash == 0) {
if (format_info.add_decimal)
xmlBufferAdd(buffer, self->decimalPoint,
xsltUTF8Size(self->decimalPoint));
}
else {
number -= floor(number);
if ((number != 0) || (format_info.frac_digits != 0)) {
xmlBufferAdd(buffer, self->decimalPoint,
xsltUTF8Size(self->decimalPoint));
number = floor(scale * number + 0.5);
for (j = format_info.frac_hash; j > 0; j--) {
if (fmod(number, 10.0) >= 1.0)
break; /* for */
number /= 10.0;
}
xsltNumberFormatDecimal(buffer, floor(number), self->zeroDigit[0],
format_info.frac_digits + j,
0, 0, 0);
}
}
/* Put the suffix into the buffer */
for (j = 0; j < suffix_length; j++) {
if ((pchar = *suffix++) == SYMBOL_QUOTE) {
len = xsltUTF8Size(suffix);
xmlBufferAdd(buffer, suffix, len);
suffix += len;
j += len - 1; /* length of symbol less length of escape */
} else
xmlBufferAdd(buffer, &pchar, 1);
}
*result = xmlStrdup(xmlBufferContent(buffer));
xmlBufferFree(buffer);
return status;
} | 0 | [
"CWE-119"
] | libxslt | eb1030de31165b68487f288308f9d1810fed6880 | 30,629,326,073,960,680,000,000,000,000,000,000,000 | 409 | Fix heap overread in xsltFormatNumberConversion
An empty decimal-separator could cause a heap overread. This can be
exploited to leak a couple of bytes after the buffer that holds the
pattern string.
Found with afl-fuzz and ASan. |
static inline dma_addr_t desc_to_dma(struct netdev_desc *desc)
{
return le64_to_cpu(desc->fraginfo) & DMA_BIT_MASK(48);
} | 0 | [
"CWE-284",
"CWE-264"
] | linux | 1bb57e940e1958e40d51f2078f50c3a96a9b2d75 | 165,273,734,956,198,600,000,000,000,000,000,000,000 | 4 | dl2k: Clean up rio_ioctl
The dl2k driver's rio_ioctl call has a few issues:
- No permissions checking
- Implements SIOCGMIIREG and SIOCGMIIREG using the SIOCDEVPRIVATE numbers
- Has a few ioctls that may have been used for debugging at one point
but have no place in the kernel proper.
This patch removes all but the MII ioctls, renumbers them to use the
standard ones, and adds the proper permission check for SIOCSMIIREG.
We can also get rid of the dl2k-specific struct mii_data in favor of
the generic struct mii_ioctl_data.
Since we have the phyid on hand, we can add the SIOCGMIIPHY ioctl too.
Most of the MII code for the driver could probably be converted to use
the generic MII library but I don't have a device to test the results.
Reported-by: Stephan Mueller <[email protected]>
Signed-off-by: Jeff Mahoney <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
_cimg_math_parser():
code(_code),p_code_end(0),p_break((CImg<ulongT>*)0 - 2),
imgin(CImg<T>::const_empty()),listin(CImgList<T>::const_empty()),
imgout(CImg<T>::empty()),listout(CImgList<T>::empty()),
img_stats(_img_stats),list_stats(_list_stats),list_median(_list_median),debug_indent(0),
result_dim(0),break_type(0),constcache_size(0),is_parallelizable(true),is_fill(false),need_input_copy(false),
calling_function(0) {
mem.assign(1 + _cimg_mp_slot_c,1,1,1,0); // Allow to skip 'is_empty?' test in operator()()
result = mem._data; | 0 | [
"CWE-125"
] | CImg | 10af1e8c1ad2a58a0a3342a856bae63e8f257abb | 239,281,172,868,751,900,000,000,000,000,000,000,000 | 10 | Fix other issues in 'CImg<T>::load_bmp()'. |
tty_resize(struct tty *tty)
{
struct client *c = tty->client;
struct winsize ws;
u_int sx, sy;
if (ioctl(tty->fd, TIOCGWINSZ, &ws) != -1) {
sx = ws.ws_col;
if (sx == 0)
sx = 80;
sy = ws.ws_row;
if (sy == 0)
sy = 24;
} else {
sx = 80;
sy = 24;
}
log_debug("%s: %s now %ux%u", __func__, c->name, sx, sy);
tty_set_size(tty, sx, sy);
tty_invalidate(tty);
} | 0 | [] | src | b32e1d34e10a0da806823f57f02a4ae6e93d756e | 141,481,273,631,814,000,000,000,000,000,000,000,000 | 21 | evbuffer_new and bufferevent_new can both fail (when malloc fails) and
return NULL. GitHub issue 1547. |
MagickExport MagickStatusType ParseGeometry(const char *geometry,
GeometryInfo *geometry_info)
{
char
*p,
pedantic_geometry[MagickPathExtent],
*q;
double
value;
GeometryInfo
coordinate;
int
c;
MagickStatusType
flags;
/*
Remove whitespaces meta characters from geometry specification.
*/
assert(geometry_info != (GeometryInfo *) NULL);
(void) memset(geometry_info,0,sizeof(*geometry_info));
flags=NoValue;
if ((geometry == (char *) NULL) || (*geometry == '\0'))
return(flags);
if (strlen(geometry) >= (MagickPathExtent-1))
return(flags);
c=sscanf(geometry,"%lf%*[ ,]%lf%*[ ,]%lf%*[ ,]%lf",&coordinate.rho,
&coordinate.sigma,&coordinate.xi,&coordinate.psi);
if (c == 4)
{
/*
Special case: coordinate (e.g. 0,0 255,255).
*/
geometry_info->rho=coordinate.rho;
geometry_info->sigma=coordinate.sigma;
geometry_info->xi=coordinate.xi;
geometry_info->psi=coordinate.psi;
flags|=RhoValue | SigmaValue | XiValue | PsiValue;
return(flags);
}
(void) CopyMagickString(pedantic_geometry,geometry,MagickPathExtent);
for (p=pedantic_geometry; *p != '\0'; )
{
c=(int) ((unsigned char) *p);
if (isspace(c) != 0)
{
(void) CopyMagickString(p,p+1,MagickPathExtent);
continue;
}
switch (c)
{
case '%':
{
flags|=PercentValue;
(void) CopyMagickString(p,p+1,MagickPathExtent);
break;
}
case '!':
{
flags|=AspectValue;
(void) CopyMagickString(p,p+1,MagickPathExtent);
break;
}
case '<':
{
flags|=LessValue;
(void) CopyMagickString(p,p+1,MagickPathExtent);
break;
}
case '>':
{
flags|=GreaterValue;
(void) CopyMagickString(p,p+1,MagickPathExtent);
break;
}
case '^':
{
flags|=MinimumValue;
(void) CopyMagickString(p,p+1,MagickPathExtent);
break;
}
case '@':
{
flags|=AreaValue;
(void) CopyMagickString(p,p+1,MagickPathExtent);
break;
}
case '(':
case ')':
{
(void) CopyMagickString(p,p+1,MagickPathExtent);
break;
}
case 'x':
case 'X':
{
flags|=SeparatorValue;
p++;
break;
}
case '-':
case '+':
case ',':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '/':
case 215:
case 'e':
case 'E':
{
p++;
break;
}
case '.':
{
p++;
flags|=DecimalValue;
break;
}
case ':':
{
p++;
flags|=AspectRatioValue;
break;
}
default:
return(NoValue);
}
}
/*
Parse rho, sigma, xi, psi, and optionally chi.
*/
p=pedantic_geometry;
if (*p == '\0')
return(flags);
q=p;
value=StringToDouble(p,&q);
if (LocaleNCompare(p,"0x",2) == 0)
(void) strtol(p,&q,10);
c=(int) ((unsigned char) *q);
if ((c == 215) || (*q == 'x') || (*q == 'X') || (*q == ':') ||
(*q == ',') || (*q == '/') || (*q =='\0'))
{
/*
Parse rho.
*/
q=p;
if (LocaleNCompare(p,"0x",2) == 0)
value=(double) strtol(p,&p,10);
else
value=StringToDouble(p,&p);
if (p != q)
{
flags|=RhoValue;
geometry_info->rho=value;
}
}
q=p;
c=(int) ((unsigned char) *p);
if ((c == 215) || (*p == 'x') || (*p == 'X') || (*p == ':') || (*p == ',') ||
(*p == '/'))
{
/*
Parse sigma.
*/
p++;
while (isspace((int) ((unsigned char) *p)) != 0)
p++;
c=(int) ((unsigned char) *q);
if (((c != 215) && (*q != 'x') && (*q != 'X') && (*q != ':')) ||
((*p != '+') && (*p != '-')))
{
q=p;
value=StringToDouble(p,&p);
if (p != q)
{
flags|=SigmaValue;
geometry_info->sigma=value;
}
}
}
while (isspace((int) ((unsigned char) *p)) != 0)
p++;
if ((*p == '+') || (*p == '-') || (*p == ',') || (*p == '/') || (*p == ':'))
{
/*
Parse xi value.
*/
if ((*p == ',') || (*p == '/') || (*p == ':') )
p++;
while ((*p == '+') || (*p == '-'))
{
if (*p == '-')
flags^=XiNegative; /* negate sign */
p++;
}
q=p;
value=StringToDouble(p,&p);
if (p != q)
{
flags|=XiValue;
if ((flags & XiNegative) != 0)
value=(-value);
geometry_info->xi=value;
}
while (isspace((int) ((unsigned char) *p)) != 0)
p++;
if ((*p == '+') || (*p == '-') || (*p == ',') || (*p == '/') ||
(*p == ':'))
{
/*
Parse psi value.
*/
if ((*p == ',') || (*p == '/') || (*p == ':'))
p++;
while ((*p == '+') || (*p == '-'))
{
if (*p == '-')
flags^=PsiNegative; /* negate sign */
p++;
}
q=p;
value=StringToDouble(p,&p);
if (p != q)
{
flags|=PsiValue;
if ((flags & PsiNegative) != 0)
value=(-value);
geometry_info->psi=value;
}
}
while (isspace((int) ((unsigned char) *p)) != 0)
p++;
if ((*p == '+') || (*p == '-') || (*p == ',') || (*p == '/') ||
(*p == ':'))
{
/*
Parse chi value.
*/
if ((*p == ',') || (*p == '/') || (*p == ':'))
p++;
while ((*p == '+') || (*p == '-'))
{
if (*p == '-')
flags^=ChiNegative; /* negate sign */
p++;
}
q=p;
value=StringToDouble(p,&p);
if (p != q)
{
flags|=ChiValue;
if ((flags & ChiNegative) != 0)
value=(-value);
geometry_info->chi=value;
}
}
}
if (strchr(pedantic_geometry,':') != (char *) NULL)
{
/*
Normalize sampling factor (e.g. 4:2:2 => 2x1).
*/
if ((flags & SigmaValue) != 0)
geometry_info->rho*=PerceptibleReciprocal(geometry_info->sigma);
geometry_info->sigma=1.0;
if (((flags & XiValue) != 0) && (geometry_info->xi == 0.0))
geometry_info->sigma=2.0;
}
if (((flags & RhoValue) != 0) && ((flags & SigmaValue) == 0) &&
((flags & XiValue) != 0) && ((flags & XiNegative) != 0))
{
if ((flags & PsiValue) == 0)
{
/*
Support negative height values (e.g. 30x-20).
*/
geometry_info->sigma=geometry_info->xi;
geometry_info->xi=0.0;
flags|=SigmaValue;
flags&=(~XiValue);
}
else
if ((flags & ChiValue) == 0)
{
/*
Support negative height values (e.g. 30x-20+10).
*/
geometry_info->sigma=geometry_info->xi;
geometry_info->xi=geometry_info->psi;
flags|=SigmaValue;
flags|=XiValue;
flags&=(~PsiValue);
}
else
{
/*
Support negative height values (e.g. 30x-20+10+10).
*/
geometry_info->sigma=geometry_info->xi;
geometry_info->xi=geometry_info->psi;
geometry_info->psi=geometry_info->chi;
flags|=SigmaValue;
flags|=XiValue;
flags|=PsiValue;
flags&=(~ChiValue);
}
}
if ((flags & PercentValue) != 0)
{
if (((flags & SeparatorValue) == 0) && ((flags & SigmaValue) == 0))
geometry_info->sigma=geometry_info->rho;
if (((flags & SeparatorValue) != 0) && ((flags & RhoValue) == 0))
geometry_info->rho=geometry_info->sigma;
}
#if 0
/* Debugging Geometry */
(void) fprintf(stderr,"ParseGeometry...\n");
(void) fprintf(stderr,"Flags: %c %c %s %s %s\n",
(flags & RhoValue) ? 'W' : ' ',(flags & SigmaValue) ? 'H' : ' ',
(flags & XiValue) ? ((flags & XiNegative) ? "-X" : "+X") : " ",
(flags & PsiValue) ? ((flags & PsiNegative) ? "-Y" : "+Y") : " ",
(flags & ChiValue) ? ((flags & ChiNegative) ? "-Z" : "+Z") : " ");
(void) fprintf(stderr,"Geometry: %lg,%lg,%lg,%lg,%lg\n",geometry_info->rho,
geometry_info->sigma,geometry_info->xi,geometry_info->psi,
geometry_info->chi);
#endif
return(flags);
} | 0 | [
"CWE-369"
] | ImageMagick | f35eca82b0c294ff9d0ccad104a881c3ae2ba913 | 26,401,056,184,215,123,000,000,000,000,000,000,000 | 341 | https://github.com/ImageMagick/ImageMagick/issues/1725 |
inline Http2Stream* Http2Session::SubmitRequest(
nghttp2_priority_spec* prispec,
nghttp2_nv* nva,
size_t len,
int32_t* ret,
int options) {
DEBUG_HTTP2SESSION(this, "submitting request");
Http2Scope h2scope(this);
Http2Stream* stream = nullptr;
Http2Stream::Provider::Stream prov(options);
*ret = nghttp2_submit_request(session_, prispec, nva, len, *prov, nullptr);
CHECK_NE(*ret, NGHTTP2_ERR_NOMEM);
if (*ret > 0)
stream = new Http2Stream(this, *ret, NGHTTP2_HCAT_HEADERS, options);
return stream;
} | 0 | [] | node | ce22d6f9178507c7a41b04ac4097b9ea902049e3 | 46,168,999,626,339,740,000,000,000,000,000,000,000 | 16 | http2: add altsvc support
Add support for sending and receiving ALTSVC frames.
PR-URL: https://github.com/nodejs/node/pull/17917
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Matteo Collina <[email protected]> |
WriteToRFBServer(rfbClient* client, char *buf, int n)
{
fd_set fds;
int i = 0;
int j;
const char *obuf = buf;
#ifdef LIBVNCSERVER_HAVE_SASL
const char *output;
unsigned int outputlen;
int err;
#endif /* LIBVNCSERVER_HAVE_SASL */
if (client->serverPort==-1)
return TRUE; /* vncrec playing */
if (client->tlsSession) {
/* WriteToTLS() will guarantee either everything is written, or error/eof returns */
i = WriteToTLS(client, buf, n);
if (i <= 0) return FALSE;
return TRUE;
}
#ifdef LIBVNCSERVER_HAVE_SASL
if (client->saslconn) {
err = sasl_encode(client->saslconn,
buf, n,
&output, &outputlen);
if (err != SASL_OK) {
rfbClientLog("Failed to encode SASL data %s",
sasl_errstring(err, NULL, NULL));
return FALSE;
}
obuf = output;
n = outputlen;
}
#endif /* LIBVNCSERVER_HAVE_SASL */
while (i < n) {
j = write(client->sock, obuf + i, (n - i));
if (j <= 0) {
if (j < 0) {
#ifdef WIN32
errno=WSAGetLastError();
#endif
if (errno == EWOULDBLOCK ||
#ifdef LIBVNCSERVER_ENOENT_WORKAROUND
errno == ENOENT ||
#endif
errno == EAGAIN) {
FD_ZERO(&fds);
FD_SET(client->sock,&fds);
if (select(client->sock+1, NULL, &fds, NULL, NULL) <= 0) {
rfbClientErr("select\n");
return FALSE;
}
j = 0;
} else {
rfbClientErr("write\n");
return FALSE;
}
} else {
rfbClientLog("write failed\n");
return FALSE;
}
}
i += j;
}
return TRUE;
} | 0 | [
"CWE-120",
"CWE-787"
] | libvncserver | 3fd03977c9b35800d73a865f167338cb4d05b0c1 | 107,179,681,424,719,220,000,000,000,000,000,000,000 | 70 | libvncclient: bail out if unix socket name would overflow
Closes #291 |
parameter_brace_expand_error (name, value)
char *name, *value;
{
WORD_LIST *l;
char *temp;
last_command_exit_value = EXECUTION_FAILURE; /* ensure it's non-zero */
if (value && *value)
{
l = expand_string (value, 0);
temp = string_list (l);
report_error ("%s: %s", name, temp ? temp : ""); /* XXX was value not "" */
FREE (temp);
dispose_words (l);
}
else
report_error (_("%s: parameter null or not set"), name);
/* Free the data we have allocated during this expansion, since we
are about to longjmp out. */
free (name);
FREE (value);
} | 0 | [] | bash | 955543877583837c85470f7fb8a97b7aa8d45e6c | 186,425,431,205,114,280,000,000,000,000,000,000,000 | 23 | bash-4.4-rc2 release |
_gd2CreateFromFile (gdIOCtxPtr in, int *sx, int *sy,
int *cs, int *vers, int *fmt,
int *ncx, int *ncy, t_chunk_info ** cidx)
{
gdImagePtr im;
if (_gd2GetHeader (in, sx, sy, cs, vers, fmt, ncx, ncy, cidx) != 1) {
GD2_DBG (printf ("Bad GD2 header\n"));
goto fail1;
}
if (gd2_truecolor (*fmt)) {
im = gdImageCreateTrueColor (*sx, *sy);
} else {
im = gdImageCreate (*sx, *sy);
}
if (im == NULL) {
GD2_DBG (printf ("Could not create gdImage\n"));
goto fail2;
};
if (!_gdGetColors (in, im, (*vers) == 2)) {
GD2_DBG (printf ("Could not read color palette\n"));
goto fail3;
}
GD2_DBG (printf ("Image palette completed: %d colours\n", im->colorsTotal));
return im;
fail3:
gdImageDestroy (im);
fail2:
gdFree(*cidx);
fail1:
return 0;
} | 0 | [
"CWE-703",
"CWE-189",
"CWE-681"
] | libgd | 2bb97f407c1145c850416a3bfbcc8cf124e68a19 | 93,732,125,771,830,400,000,000,000,000,000,000,000 | 36 | gd2: handle corrupt images better (CVE-2016-3074)
Make sure we do some range checking on corrupted chunks.
Thanks to Hans Jerry Illikainen <[email protected]> for indepth report
and reproducer information. Made for easy test case writing :). |
static int netlbl_cipsov4_list(struct sk_buff *skb, struct genl_info *info)
{
int ret_val;
struct sk_buff *ans_skb = NULL;
u32 nlsze_mult = 1;
void *data;
u32 doi;
struct nlattr *nla_a;
struct nlattr *nla_b;
struct cipso_v4_doi *doi_def;
u32 iter;
if (!info->attrs[NLBL_CIPSOV4_A_DOI]) {
ret_val = -EINVAL;
goto list_failure;
}
list_start:
ans_skb = nlmsg_new(NLMSG_DEFAULT_SIZE * nlsze_mult, GFP_KERNEL);
if (ans_skb == NULL) {
ret_val = -ENOMEM;
goto list_failure;
}
data = genlmsg_put_reply(ans_skb, info, &netlbl_cipsov4_gnl_family,
0, NLBL_CIPSOV4_C_LIST);
if (data == NULL) {
ret_val = -ENOMEM;
goto list_failure;
}
doi = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_DOI]);
rcu_read_lock();
doi_def = cipso_v4_doi_getdef(doi);
if (doi_def == NULL) {
ret_val = -EINVAL;
goto list_failure_lock;
}
ret_val = nla_put_u32(ans_skb, NLBL_CIPSOV4_A_MTYPE, doi_def->type);
if (ret_val != 0)
goto list_failure_lock;
nla_a = nla_nest_start_noflag(ans_skb, NLBL_CIPSOV4_A_TAGLST);
if (nla_a == NULL) {
ret_val = -ENOMEM;
goto list_failure_lock;
}
for (iter = 0;
iter < CIPSO_V4_TAG_MAXCNT &&
doi_def->tags[iter] != CIPSO_V4_TAG_INVALID;
iter++) {
ret_val = nla_put_u8(ans_skb,
NLBL_CIPSOV4_A_TAG,
doi_def->tags[iter]);
if (ret_val != 0)
goto list_failure_lock;
}
nla_nest_end(ans_skb, nla_a);
switch (doi_def->type) {
case CIPSO_V4_MAP_TRANS:
nla_a = nla_nest_start_noflag(ans_skb,
NLBL_CIPSOV4_A_MLSLVLLST);
if (nla_a == NULL) {
ret_val = -ENOMEM;
goto list_failure_lock;
}
for (iter = 0;
iter < doi_def->map.std->lvl.local_size;
iter++) {
if (doi_def->map.std->lvl.local[iter] ==
CIPSO_V4_INV_LVL)
continue;
nla_b = nla_nest_start_noflag(ans_skb,
NLBL_CIPSOV4_A_MLSLVL);
if (nla_b == NULL) {
ret_val = -ENOMEM;
goto list_retry;
}
ret_val = nla_put_u32(ans_skb,
NLBL_CIPSOV4_A_MLSLVLLOC,
iter);
if (ret_val != 0)
goto list_retry;
ret_val = nla_put_u32(ans_skb,
NLBL_CIPSOV4_A_MLSLVLREM,
doi_def->map.std->lvl.local[iter]);
if (ret_val != 0)
goto list_retry;
nla_nest_end(ans_skb, nla_b);
}
nla_nest_end(ans_skb, nla_a);
nla_a = nla_nest_start_noflag(ans_skb,
NLBL_CIPSOV4_A_MLSCATLST);
if (nla_a == NULL) {
ret_val = -ENOMEM;
goto list_retry;
}
for (iter = 0;
iter < doi_def->map.std->cat.local_size;
iter++) {
if (doi_def->map.std->cat.local[iter] ==
CIPSO_V4_INV_CAT)
continue;
nla_b = nla_nest_start_noflag(ans_skb,
NLBL_CIPSOV4_A_MLSCAT);
if (nla_b == NULL) {
ret_val = -ENOMEM;
goto list_retry;
}
ret_val = nla_put_u32(ans_skb,
NLBL_CIPSOV4_A_MLSCATLOC,
iter);
if (ret_val != 0)
goto list_retry;
ret_val = nla_put_u32(ans_skb,
NLBL_CIPSOV4_A_MLSCATREM,
doi_def->map.std->cat.local[iter]);
if (ret_val != 0)
goto list_retry;
nla_nest_end(ans_skb, nla_b);
}
nla_nest_end(ans_skb, nla_a);
break;
}
rcu_read_unlock();
genlmsg_end(ans_skb, data);
return genlmsg_reply(ans_skb, info);
list_retry:
/* XXX - this limit is a guesstimate */
if (nlsze_mult < 4) {
rcu_read_unlock();
kfree_skb(ans_skb);
nlsze_mult *= 2;
goto list_start;
}
list_failure_lock:
rcu_read_unlock();
list_failure:
kfree_skb(ans_skb);
return ret_val;
} | 1 | [
"CWE-416"
] | linux | ad5d07f4a9cd671233ae20983848874731102c08 | 111,594,179,274,178,100,000,000,000,000,000,000,000 | 149 | cipso,calipso: resolve a number of problems with the DOI refcounts
The current CIPSO and CALIPSO refcounting scheme for the DOI
definitions is a bit flawed in that we:
1. Don't correctly match gets/puts in netlbl_cipsov4_list().
2. Decrement the refcount on each attempt to remove the DOI from the
DOI list, only removing it from the list once the refcount drops
to zero.
This patch fixes these problems by adding the missing "puts" to
netlbl_cipsov4_list() and introduces a more conventional, i.e.
not-buggy, refcounting mechanism to the DOI definitions. Upon the
addition of a DOI to the DOI list, it is initialized with a refcount
of one, removing a DOI from the list removes it from the list and
drops the refcount by one; "gets" and "puts" behave as expected with
respect to refcounts, increasing and decreasing the DOI's refcount by
one.
Fixes: b1edeb102397 ("netlabel: Replace protocol/NetLabel linking with refrerence counts")
Fixes: d7cce01504a0 ("netlabel: Add support for removing a CALIPSO DOI.")
Reported-by: [email protected]
Signed-off-by: Paul Moore <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
void make_field(THD *thd, Send_field *)
{
illegal_method_call((const char*)"make_field");
}; | 0 | [
"CWE-617"
] | server | 2e7891080667c59ac80f788eef4d59d447595772 | 205,939,033,868,220,760,000,000,000,000,000,000,000 | 4 | MDEV-25635 Assertion failure when pushing from HAVING into WHERE of view
This bug could manifest itself after pushing a where condition over a
mergeable derived table / view / CTE DT into a grouping view / derived
table / CTE V whose item list contained set functions with constant
arguments such as MIN(2), SUM(1) etc. In such cases the field references
used in the condition pushed into the view V that correspond set functions
are wrapped into Item_direct_view_ref wrappers. Due to a wrong implementation
of the virtual method const_item() for the class Item_direct_view_ref the
wrapped set functions with constant arguments could be erroneously taken
for constant items. This could lead to a wrong result set returned by the
main select query in 10.2. In 10.4 where a possibility of pushing condition
from HAVING into WHERE had been added this could cause a crash.
Approved by Sergey Petrunya <[email protected]> |
UnicodeString __fastcall TSCPFileSystem::AbsolutePath(UnicodeString Path, bool /*Local*/)
{
return ::AbsolutePath(CurrentDirectory, Path);
}
| 0 | [
"CWE-20"
] | winscp | 49d876f2c5fc00bcedaa986a7cf6dedd6bf16f54 | 127,566,316,214,225,560,000,000,000,000,000,000,000 | 4 | Bug 1675: Prevent SCP server sending files that were not requested
https://winscp.net/tracker/1675
Source commit: 4aa587620973bf793fb6e783052277c0f7be4b55 |
get_default_language_name (GdmSession *self)
{
const char *default_language;
if (self->priv->saved_language != NULL) {
return self->priv->saved_language;
}
default_language = g_hash_table_lookup (self->priv->environment,
"LANG");
if (default_language != NULL) {
return default_language;
}
return setlocale (LC_MESSAGES, NULL);
} | 0 | [] | gdm | 5ac224602f1d603aac5eaa72e1760d3e33a26f0a | 24,449,074,988,604,074,000,000,000,000,000,000,000 | 17 | session: disconnect signals from worker proxy when conversation is freed
We don't want an outstanding reference on the worker proxy to lead to
signal handlers getting dispatched after the conversation is freed.
https://bugzilla.gnome.org/show_bug.cgi?id=758032 |
xsltRegisterAllElement(xsltTransformContextPtr ctxt)
{
xsltRegisterExtElement(ctxt, (const xmlChar *) "apply-templates",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltApplyTemplates);
xsltRegisterExtElement(ctxt, (const xmlChar *) "apply-imports",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltApplyImports);
xsltRegisterExtElement(ctxt, (const xmlChar *) "call-template",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltCallTemplate);
xsltRegisterExtElement(ctxt, (const xmlChar *) "element",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltElement);
xsltRegisterExtElement(ctxt, (const xmlChar *) "attribute",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltAttribute);
xsltRegisterExtElement(ctxt, (const xmlChar *) "text",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltText);
xsltRegisterExtElement(ctxt, (const xmlChar *) "processing-instruction",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltProcessingInstruction);
xsltRegisterExtElement(ctxt, (const xmlChar *) "comment",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltComment);
xsltRegisterExtElement(ctxt, (const xmlChar *) "copy",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltCopy);
xsltRegisterExtElement(ctxt, (const xmlChar *) "value-of",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltValueOf);
xsltRegisterExtElement(ctxt, (const xmlChar *) "number",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltNumber);
xsltRegisterExtElement(ctxt, (const xmlChar *) "for-each",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltForEach);
xsltRegisterExtElement(ctxt, (const xmlChar *) "if",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltIf);
xsltRegisterExtElement(ctxt, (const xmlChar *) "choose",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltChoose);
xsltRegisterExtElement(ctxt, (const xmlChar *) "sort",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltSort);
xsltRegisterExtElement(ctxt, (const xmlChar *) "copy-of",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltCopyOf);
xsltRegisterExtElement(ctxt, (const xmlChar *) "message",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltMessage);
/*
* Those don't have callable entry points but are registered anyway
*/
xsltRegisterExtElement(ctxt, (const xmlChar *) "variable",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltDebug);
xsltRegisterExtElement(ctxt, (const xmlChar *) "param",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltDebug);
xsltRegisterExtElement(ctxt, (const xmlChar *) "with-param",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltDebug);
xsltRegisterExtElement(ctxt, (const xmlChar *) "decimal-format",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltDebug);
xsltRegisterExtElement(ctxt, (const xmlChar *) "when",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltDebug);
xsltRegisterExtElement(ctxt, (const xmlChar *) "otherwise",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltDebug);
xsltRegisterExtElement(ctxt, (const xmlChar *) "fallback",
XSLT_NAMESPACE,
(xsltTransformFunction) xsltDebug);
} | 0 | [] | libxslt | 937ba2a3eb42d288f53c8adc211bd1122869f0bf | 149,527,321,150,792,350,000,000,000,000,000,000,000 | 80 | Fix default template processing on namespace nodes |
Subsets and Splits