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
|
---|---|---|---|---|---|---|---|
lexer_check_numbers (parser_context_t *context_p, /**< context */
const uint8_t **source_p, /**< source_pointer */
const uint8_t *source_end_p, /**< end of the source */
const ecma_char_t digit_max, /**< maximum of the number range */
const bool is_legacy) /**< is legacy octal number */
{
#if !JERRY_ESNEXT
JERRY_UNUSED (context_p);
JERRY_UNUSED (is_legacy);
#endif /* !JERRY_ESNEXT */
while (true)
{
while (*source_p < source_end_p && *source_p[0] >= LIT_CHAR_0 && *source_p[0] <= digit_max)
{
*source_p += 1;
}
#if JERRY_ESNEXT
if (*source_p != source_end_p && *source_p[0] == LIT_CHAR_UNDERSCORE)
{
*source_p += 1;
if (is_legacy || *source_p == source_end_p || *source_p[0] == LIT_CHAR_UNDERSCORE || *source_p[0] > digit_max
|| *source_p[0] < LIT_CHAR_0)
{
parser_raise_error (context_p, PARSER_ERR_INVALID_UNDERSCORE_IN_NUMBER);
}
continue;
}
#endif /* JERRY_ESNEXT */
break;
}
} /* lexer_check_numbers */ | 0 | [
"CWE-288"
] | jerryscript | f3a420b672927037beb4508d7bdd68fb25d2caf6 | 105,765,617,340,794,300,000,000,000,000,000,000,000 | 32 | Fix class static block opening brace parsing (#4942)
The next character should not be consumed after finding the static block opening brace.
This patch fixes #4916.
JerryScript-DCO-1.0-Signed-off-by: Martin Negyokru [email protected] |
static int add_slave_statements(void)
{
if (opt_comments)
fprintf(md_result_file,
"\n--\n-- start slave statement to make a recovery dump)\n--\n\n");
fprintf(md_result_file, "START SLAVE;\n");
return(0);
} | 0 | [
"CWE-284",
"CWE-295"
] | mysql-server | 3bd5589e1a5a93f9c224badf983cd65c45215390 | 64,963,171,461,099,740,000,000,000,000,000,000,000 | 8 | 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 |
copy_file (char const *from, char const *to, struct stat *tost,
int to_flags, mode_t mode, bool to_dir_known_to_exist)
{
int tofd;
if (debug & 4)
say ("Copying %s %s to %s\n",
S_ISLNK (mode) ? "symbolic link" : "file",
quotearg_n (0, from), quotearg_n (1, to));
if (S_ISLNK (mode))
{
char *buffer = xmalloc (PATH_MAX);
if (readlink (from, buffer, PATH_MAX) < 0)
pfatal ("Can't read %s %s", "symbolic link", from);
if (symlink (buffer, to) != 0)
pfatal ("Can't create %s %s", "symbolic link", to);
if (tost && lstat (to, tost) != 0)
pfatal ("Can't get file attributes of %s %s", "symbolic link", to);
free (buffer);
}
else
{
assert (S_ISREG (mode));
tofd = create_file (to, O_WRONLY | O_BINARY | to_flags, mode,
to_dir_known_to_exist);
copy_to_fd (from, tofd);
if (tost && fstat (tofd, tost) != 0)
pfatal ("Can't get file attributes of %s %s", "file", to);
if (close (tofd) != 0)
write_fatal ();
}
} | 0 | [
"CWE-22"
] | patch | 685a78b6052f4df6eac6d625a545cfb54a6ac0e1 | 122,829,723,549,693,500,000,000,000,000,000,000,000 | 34 | Do not let a malicious patch create files above current directory
This addresses CVE-2010-4651, reported by Jakub Wilk.
https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2010-4651
* src/util.c (strip_leading_slashes): Reject absolute file names
and file names containing a component of "..".
* tests/bad-filenames: New file. Test for this.
* tests/Makefile.am (TESTS): Add it.
Improvements by Andreas Gruenbacher. |
static Bool lsr_init_smil_times(GF_LASeRCodec *lsr, SVG_Element *anim, GF_List *times, SVG_Element *parent)
{
u32 i, count;
count = gf_list_count(times);
for (i=0; i<count; i++) {
SMIL_Time *t = (SMIL_Time *)gf_list_get(times, i);
if (t->type==GF_SMIL_TIME_EVENT) {
if (t->element_id) {
if (t->element_id[0]=='N') {
t->element = gf_sg_find_node(lsr->sg, atoi(t->element_id+1) + 1);
} else {
t->element = gf_sg_find_node_by_name(lsr->sg, t->element_id);
}
if (!t->element) return GF_FALSE;
gf_free(t->element_id);
t->element_id = NULL;
}
else if (!t->element) {
if (t->event.parameter && (t->event.type==GF_EVENT_KEYDOWN) ) {
t->element = lsr->sg->RootNode ? lsr->sg->RootNode : lsr->current_root;
} else {
t->element = (GF_Node*)parent;
}
}
}
}
return GF_TRUE;
} | 0 | [
"CWE-190"
] | gpac | faa75edde3dfeba1e2cf6ffa48e45a50f1042096 | 207,858,504,363,749,000,000,000,000,000,000,000 | 28 | fixed #2213 |
int sigprocmask(int how, sigset_t *set, sigset_t *oldset)
{
int error;
spin_lock_irq(¤t->sighand->siglock);
if (oldset)
*oldset = current->blocked;
error = 0;
switch (how) {
case SIG_BLOCK:
sigorsets(¤t->blocked, ¤t->blocked, set);
break;
case SIG_UNBLOCK:
signandsets(¤t->blocked, ¤t->blocked, set);
break;
case SIG_SETMASK:
current->blocked = *set;
break;
default:
error = -EINVAL;
}
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
return error;
} | 0 | [] | linux-2.6 | 0083fc2c50e6c5127c2802ad323adf8143ab7856 | 29,982,944,635,305,010,000,000,000,000,000,000,000 | 27 | do_sigaltstack: avoid copying 'stack_t' as a structure to user space
Ulrich Drepper correctly points out that there is generally padding in
the structure on 64-bit hosts, and that copying the structure from
kernel to user space can leak information from the kernel stack in those
padding bytes.
Avoid the whole issue by just copying the three members one by one
instead, which also means that the function also can avoid the need for
a stack frame. This also happens to match how we copy the new structure
from user space, so it all even makes sense.
[ The obvious solution of adding a memset() generates horrid code, gcc
does really stupid things. ]
Reported-by: Ulrich Drepper <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
HeaderLocationSpec(const Http::LowerCaseString& header, const std::string& value_prefix)
: header_(header), value_prefix_(value_prefix) {} | 0 | [] | envoy | 2c60632d41555ec8b3d9ef5246242be637a2db0f | 103,946,800,005,093,570,000,000,000,000,000,000,000 | 2 | http: header map security fixes for duplicate headers (#197)
Previously header matching did not match on all headers for
non-inline headers. This patch changes the default behavior to
always logically match on all headers. Multiple individual
headers will be logically concatenated with ',' similar to what
is done with inline headers. This makes the behavior effectively
consistent. This behavior can be temporary reverted by setting
the runtime value "envoy.reloadable_features.header_match_on_all_headers"
to "false".
Targeted fixes have been additionally performed on the following
extensions which make them consider all duplicate headers by default as
a comma concatenated list:
1) Any extension using CEL matching on headers.
2) The header to metadata filter.
3) The JWT filter.
4) The Lua filter.
Like primary header matching used in routing, RBAC, etc. this behavior
can be disabled by setting the runtime value
"envoy.reloadable_features.header_match_on_all_headers" to false.
Finally, the setCopy() header map API previously only set the first
header in the case of duplicate non-inline headers. setCopy() now
behaves similiarly to the other set*() APIs and replaces all found
headers with a single value. This may have had security implications
in the extauth filter which uses this API. This behavior can be disabled
by setting the runtime value
"envoy.reloadable_features.http_set_copy_replace_all_headers" to false.
Fixes https://github.com/envoyproxy/envoy-setec/issues/188
Signed-off-by: Matt Klein <[email protected]> |
str_toupper(const char *buff, size_t nbytes, Oid collid)
{
char *result;
if (!buff)
return NULL;
/* C/POSIX collations use this path regardless of database encoding */
if (lc_ctype_is_c(collid))
{
result = asc_toupper(buff, nbytes);
}
#ifdef USE_WIDE_UPPER_LOWER
else if (pg_database_encoding_max_length() > 1)
{
pg_locale_t mylocale = 0;
wchar_t *workspace;
size_t curr_char;
size_t result_size;
if (collid != DEFAULT_COLLATION_OID)
{
if (!OidIsValid(collid))
{
/*
* This typically means that the parser could not resolve a
* conflict of implicit collations, so report it that way.
*/
ereport(ERROR,
(errcode(ERRCODE_INDETERMINATE_COLLATION),
errmsg("could not determine which collation to use for upper() function"),
errhint("Use the COLLATE clause to set the collation explicitly.")));
}
mylocale = pg_newlocale_from_collation(collid);
}
/* Overflow paranoia */
if ((nbytes + 1) > (INT_MAX / sizeof(wchar_t)))
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
/* Output workspace cannot have more codes than input bytes */
workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t));
char2wchar(workspace, nbytes + 1, buff, nbytes, mylocale);
for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
{
#ifdef HAVE_LOCALE_T
if (mylocale)
workspace[curr_char] = towupper_l(workspace[curr_char], mylocale);
else
#endif
workspace[curr_char] = towupper(workspace[curr_char]);
}
/* Make result large enough; case change might change number of bytes */
result_size = curr_char * pg_database_encoding_max_length() + 1;
result = palloc(result_size);
wchar2char(result, workspace, result_size, mylocale);
pfree(workspace);
}
#endif /* USE_WIDE_UPPER_LOWER */
else
{
#ifdef HAVE_LOCALE_T
pg_locale_t mylocale = 0;
#endif
char *p;
if (collid != DEFAULT_COLLATION_OID)
{
if (!OidIsValid(collid))
{
/*
* This typically means that the parser could not resolve a
* conflict of implicit collations, so report it that way.
*/
ereport(ERROR,
(errcode(ERRCODE_INDETERMINATE_COLLATION),
errmsg("could not determine which collation to use for upper() function"),
errhint("Use the COLLATE clause to set the collation explicitly.")));
}
#ifdef HAVE_LOCALE_T
mylocale = pg_newlocale_from_collation(collid);
#endif
}
result = pnstrdup(buff, nbytes);
/*
* Note: we assume that toupper_l() will not be so broken as to need
* an islower_l() guard test. When using the default collation, we
* apply the traditional Postgres behavior that forces ASCII-style
* treatment of I/i, but in non-default collations you get exactly
* what the collation says.
*/
for (p = result; *p; p++)
{
#ifdef HAVE_LOCALE_T
if (mylocale)
*p = toupper_l((unsigned char) *p, mylocale);
else
#endif
*p = pg_toupper((unsigned char) *p);
}
}
return result;
} | 0 | [
"CWE-120"
] | postgres | 0150ab567bcf5e5913e2b62a1678f84cc272441f | 286,310,371,644,707,100,000,000,000,000,000,000,000 | 112 | to_char(): prevent accesses beyond the allocated buffer
Previously very long field masks for floats could access memory
beyond the existing buffer allocated to hold the result.
Reported by Andres Freund and Peter Geoghegan. Backpatch to all
supported versions.
Security: CVE-2015-0241 |
match_suffix(char_u *fname)
{
int fnamelen, setsuflen;
char_u *setsuf;
#define MAXSUFLEN 30 // maximum length of a file suffix
char_u suf_buf[MAXSUFLEN];
fnamelen = (int)STRLEN(fname);
setsuflen = 0;
for (setsuf = p_su; *setsuf; )
{
setsuflen = copy_option_part(&setsuf, suf_buf, MAXSUFLEN, ".,");
if (setsuflen == 0)
{
char_u *tail = gettail(fname);
// empty entry: match name without a '.'
if (vim_strchr(tail, '.') == NULL)
{
setsuflen = 1;
break;
}
}
else
{
if (fnamelen >= setsuflen
&& fnamencmp(suf_buf, fname + fnamelen - setsuflen,
(size_t)setsuflen) == 0)
break;
setsuflen = 0;
}
}
return (setsuflen != 0);
} | 0 | [
"CWE-823",
"CWE-703"
] | vim | 5921aeb5741fc6e84c870d68c7c35b93ad0c9f87 | 292,884,775,796,208,440,000,000,000,000,000,000,000 | 34 | patch 8.2.4418: crash when using special multi-byte character
Problem: Crash when using special multi-byte character.
Solution: Don't use isalpha() for an arbitrary character. |
FormatSpec(
unsigned width = 0, char type = 0, wchar_t fill = ' ')
: AlignSpec(width, fill), flags_(0), precision_(-1), type_(type) {} | 0 | [
"CWE-134",
"CWE-119",
"CWE-787"
] | fmt | 8cf30aa2be256eba07bb1cefb998c52326e846e7 | 203,799,790,099,687,700,000,000,000,000,000,000,000 | 3 | Fix segfault on complex pointer formatting (#642) |
static BOOL wf_cliprdr_add_to_file_arrays(wfClipboard* clipboard, WCHAR* full_file_name,
size_t pathLen)
{
if (!wf_cliprdr_array_ensure_capacity(clipboard))
return FALSE;
/* add to name array */
clipboard->file_names[clipboard->nFiles] = (LPWSTR)malloc(MAX_PATH * 2);
if (!clipboard->file_names[clipboard->nFiles])
return FALSE;
wcscpy_s(clipboard->file_names[clipboard->nFiles], MAX_PATH, full_file_name);
/* add to descriptor array */
clipboard->fileDescriptor[clipboard->nFiles] =
wf_cliprdr_get_file_descriptor(full_file_name, pathLen);
if (!clipboard->fileDescriptor[clipboard->nFiles])
{
free(clipboard->file_names[clipboard->nFiles]);
return FALSE;
}
clipboard->nFiles++;
return TRUE;
} | 0 | [
"CWE-20"
] | FreeRDP | 0d79670a28c0ab049af08613621aa0c267f977e9 | 151,139,380,880,636,470,000,000,000,000,000,000,000 | 26 | Fixed missing input checks for file contents request
reported by Valentino Ricotta (Thalium) |
gsicc_smask_finalize(const gs_memory_t *memory, void * vptr)
{
gsicc_smask_t *iccsmask = (gsicc_smask_t *)vptr;
rc_decrement(iccsmask->smask_gray,
"gsicc_smask_finalize");
rc_decrement(iccsmask->smask_rgb,
"gsicc_smask_finalize");
rc_decrement(iccsmask->smask_cmyk,
"gsicc_smask_finalize");
} | 0 | [] | ghostpdl | 6d444c273da5499a4cd72f21cb6d4c9a5256807d | 280,197,122,596,824,700,000,000,000,000,000,000,000 | 11 | 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. |
static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVQcowState *s = bs->opaque;
unsigned int len, i;
int ret = 0;
QCowHeader header;
QemuOpts *opts;
Error *local_err = NULL;
uint64_t ext_end;
uint64_t l1_vm_state_index;
const char *opt_overlap_check;
int overlap_check_template = 0;
ret = bdrv_pread(bs->file, 0, &header, sizeof(header));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read qcow2 header");
goto fail;
}
be32_to_cpus(&header.magic);
be32_to_cpus(&header.version);
be64_to_cpus(&header.backing_file_offset);
be32_to_cpus(&header.backing_file_size);
be64_to_cpus(&header.size);
be32_to_cpus(&header.cluster_bits);
be32_to_cpus(&header.crypt_method);
be64_to_cpus(&header.l1_table_offset);
be32_to_cpus(&header.l1_size);
be64_to_cpus(&header.refcount_table_offset);
be32_to_cpus(&header.refcount_table_clusters);
be64_to_cpus(&header.snapshots_offset);
be32_to_cpus(&header.nb_snapshots);
if (header.magic != QCOW_MAGIC) {
error_setg(errp, "Image is not in qcow2 format");
ret = -EINVAL;
goto fail;
}
if (header.version < 2 || header.version > 3) {
report_unsupported(bs, errp, "QCOW version %d", header.version);
ret = -ENOTSUP;
goto fail;
}
s->qcow_version = header.version;
/* Initialise cluster size */
if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) {
error_setg(errp, "Unsupported cluster size: 2^%i", header.cluster_bits);
ret = -EINVAL;
goto fail;
}
s->cluster_bits = header.cluster_bits;
s->cluster_size = 1 << s->cluster_bits;
s->cluster_sectors = 1 << (s->cluster_bits - 9);
/* Initialise version 3 header fields */
if (header.version == 2) {
header.incompatible_features = 0;
header.compatible_features = 0;
header.autoclear_features = 0;
header.refcount_order = 4;
header.header_length = 72;
} else {
be64_to_cpus(&header.incompatible_features);
be64_to_cpus(&header.compatible_features);
be64_to_cpus(&header.autoclear_features);
be32_to_cpus(&header.refcount_order);
be32_to_cpus(&header.header_length);
if (header.header_length < 104) {
error_setg(errp, "qcow2 header too short");
ret = -EINVAL;
goto fail;
}
}
if (header.header_length > s->cluster_size) {
error_setg(errp, "qcow2 header exceeds cluster size");
ret = -EINVAL;
goto fail;
}
if (header.header_length > sizeof(header)) {
s->unknown_header_fields_size = header.header_length - sizeof(header);
s->unknown_header_fields = g_malloc(s->unknown_header_fields_size);
ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields,
s->unknown_header_fields_size);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read unknown qcow2 header "
"fields");
goto fail;
}
}
if (header.backing_file_offset > s->cluster_size) {
error_setg(errp, "Invalid backing file offset");
ret = -EINVAL;
goto fail;
}
if (header.backing_file_offset) {
ext_end = header.backing_file_offset;
} else {
ext_end = 1 << header.cluster_bits;
}
/* Handle feature bits */
s->incompatible_features = header.incompatible_features;
s->compatible_features = header.compatible_features;
s->autoclear_features = header.autoclear_features;
if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) {
void *feature_table = NULL;
qcow2_read_extensions(bs, header.header_length, ext_end,
&feature_table, NULL);
report_unsupported_feature(bs, errp, feature_table,
s->incompatible_features &
~QCOW2_INCOMPAT_MASK);
ret = -ENOTSUP;
g_free(feature_table);
goto fail;
}
if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {
/* Corrupt images may not be written to unless they are being repaired
*/
if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) {
error_setg(errp, "qcow2: Image is corrupt; cannot be opened "
"read/write");
ret = -EACCES;
goto fail;
}
}
/* Check support for various header values */
if (header.refcount_order != 4) {
report_unsupported(bs, errp, "%d bit reference counts",
1 << header.refcount_order);
ret = -ENOTSUP;
goto fail;
}
s->refcount_order = header.refcount_order;
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(errp, "Unsupported encryption method: %i",
header.crypt_method);
ret = -EINVAL;
goto fail;
}
s->crypt_method_header = header.crypt_method;
if (s->crypt_method_header) {
bs->encrypted = 1;
}
s->l2_bits = s->cluster_bits - 3; /* L2 is always one cluster */
s->l2_size = 1 << s->l2_bits;
bs->total_sectors = header.size / 512;
s->csize_shift = (62 - (s->cluster_bits - 8));
s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
s->refcount_table_offset = header.refcount_table_offset;
s->refcount_table_size =
header.refcount_table_clusters << (s->cluster_bits - 3);
if (header.refcount_table_clusters > qcow2_max_refcount_clusters(s)) {
error_setg(errp, "Reference count table too large");
ret = -EINVAL;
goto fail;
}
ret = validate_table_offset(bs, s->refcount_table_offset,
s->refcount_table_size, sizeof(uint64_t));
if (ret < 0) {
error_setg(errp, "Invalid reference count table offset");
goto fail;
}
/* Snapshot table offset/length */
if (header.nb_snapshots > QCOW_MAX_SNAPSHOTS) {
error_setg(errp, "Too many snapshots");
ret = -EINVAL;
goto fail;
}
ret = validate_table_offset(bs, header.snapshots_offset,
header.nb_snapshots,
sizeof(QCowSnapshotHeader));
if (ret < 0) {
error_setg(errp, "Invalid snapshot table offset");
goto fail;
}
/* read the level 1 table */
if (header.l1_size > 0x2000000) {
/* 32 MB L1 table is enough for 2 PB images at 64k cluster size
* (128 GB for 512 byte clusters, 2 EB for 2 MB clusters) */
error_setg(errp, "Active L1 table too large");
ret = -EFBIG;
goto fail;
}
s->l1_size = header.l1_size;
l1_vm_state_index = size_to_l1(s, header.size);
if (l1_vm_state_index > INT_MAX) {
error_setg(errp, "Image is too big");
ret = -EFBIG;
goto fail;
}
s->l1_vm_state_index = l1_vm_state_index;
/* the L1 table must contain at least enough entries to put
header.size bytes */
if (s->l1_size < s->l1_vm_state_index) {
error_setg(errp, "L1 table is too small");
ret = -EINVAL;
goto fail;
}
ret = validate_table_offset(bs, header.l1_table_offset,
header.l1_size, sizeof(uint64_t));
if (ret < 0) {
error_setg(errp, "Invalid L1 table offset");
goto fail;
}
s->l1_table_offset = header.l1_table_offset;
if (s->l1_size > 0) {
s->l1_table = g_malloc0(
align_offset(s->l1_size * sizeof(uint64_t), 512));
ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table,
s->l1_size * sizeof(uint64_t));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read L1 table");
goto fail;
}
for(i = 0;i < s->l1_size; i++) {
be64_to_cpus(&s->l1_table[i]);
}
}
/* alloc L2 table/refcount block cache */
s->l2_table_cache = qcow2_cache_create(bs, L2_CACHE_SIZE);
s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE);
s->cluster_cache = g_malloc(s->cluster_size);
/* one more sector for decompressed data alignment */
s->cluster_data = qemu_blockalign(bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size
+ 512);
s->cluster_cache_offset = -1;
s->flags = flags;
ret = qcow2_refcount_init(bs);
if (ret != 0) {
error_setg_errno(errp, -ret, "Could not initialize refcount handling");
goto fail;
}
QLIST_INIT(&s->cluster_allocs);
QTAILQ_INIT(&s->discards);
/* read qcow2 extensions */
if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL,
&local_err)) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
/* read the backing file name */
if (header.backing_file_offset != 0) {
len = header.backing_file_size;
if (len > MIN(1023, s->cluster_size - header.backing_file_offset)) {
error_setg(errp, "Backing file name too long");
ret = -EINVAL;
goto fail;
}
ret = bdrv_pread(bs->file, header.backing_file_offset,
bs->backing_file, len);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read backing file name");
goto fail;
}
bs->backing_file[len] = '\0';
}
/* Internal snapshots */
s->snapshots_offset = header.snapshots_offset;
s->nb_snapshots = header.nb_snapshots;
ret = qcow2_read_snapshots(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not read snapshots");
goto fail;
}
/* Clear unknown autoclear feature bits */
if (!bs->read_only && !(flags & BDRV_O_INCOMING) && s->autoclear_features) {
s->autoclear_features = 0;
ret = qcow2_update_header(bs);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not update qcow2 header");
goto fail;
}
}
/* Initialise locks */
qemu_co_mutex_init(&s->lock);
/* Repair image if dirty */
if (!(flags & (BDRV_O_CHECK | BDRV_O_INCOMING)) && !bs->read_only &&
(s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) {
BdrvCheckResult result = {0};
ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not repair dirty image");
goto fail;
}
}
/* Enable lazy_refcounts according to image and command line options */
opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto fail;
}
s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS,
(s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS));
s->discard_passthrough[QCOW2_DISCARD_NEVER] = false;
s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true;
s->discard_passthrough[QCOW2_DISCARD_REQUEST] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST,
flags & BDRV_O_UNMAP);
s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true);
s->discard_passthrough[QCOW2_DISCARD_OTHER] =
qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false);
opt_overlap_check = qemu_opt_get(opts, "overlap-check") ?: "cached";
if (!strcmp(opt_overlap_check, "none")) {
overlap_check_template = 0;
} else if (!strcmp(opt_overlap_check, "constant")) {
overlap_check_template = QCOW2_OL_CONSTANT;
} else if (!strcmp(opt_overlap_check, "cached")) {
overlap_check_template = QCOW2_OL_CACHED;
} else if (!strcmp(opt_overlap_check, "all")) {
overlap_check_template = QCOW2_OL_ALL;
} else {
error_setg(errp, "Unsupported value '%s' for qcow2 option "
"'overlap-check'. Allowed are either of the following: "
"none, constant, cached, all", opt_overlap_check);
qemu_opts_del(opts);
ret = -EINVAL;
goto fail;
}
s->overlap_check = 0;
for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) {
/* overlap-check defines a template bitmask, but every flag may be
* overwritten through the associated boolean option */
s->overlap_check |=
qemu_opt_get_bool(opts, overlap_bool_option_names[i],
overlap_check_template & (1 << i)) << i;
}
qemu_opts_del(opts);
if (s->use_lazy_refcounts && s->qcow_version < 3) {
error_setg(errp, "Lazy refcounts require a qcow2 image with at least "
"qemu 1.1 compatibility level");
ret = -EINVAL;
goto fail;
}
#ifdef DEBUG_ALLOC
{
BdrvCheckResult result = {0};
qcow2_check_refcounts(bs, &result, 0);
}
#endif
return ret;
fail:
g_free(s->unknown_header_fields);
cleanup_unknown_header_ext(bs);
qcow2_free_snapshots(bs);
qcow2_refcount_close(bs);
g_free(s->l1_table);
/* else pre-write overlap checks in cache_destroy may crash */
s->l1_table = NULL;
if (s->l2_table_cache) {
qcow2_cache_destroy(bs, s->l2_table_cache);
}
if (s->refcount_block_cache) {
qcow2_cache_destroy(bs, s->refcount_block_cache);
}
g_free(s->cluster_cache);
qemu_vfree(s->cluster_data);
return ret;
} | 1 | [
"CWE-190"
] | qemu | 6a83f8b5bec6f59e56cc49bd49e4c3f8f805d56f | 241,096,042,149,752,900,000,000,000,000,000,000,000 | 409 | qcow2: Check maximum L1 size in qcow2_snapshot_load_tmp() (CVE-2014-0143)
This avoids an unbounded allocation.
Signed-off-by: Kevin Wolf <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]> |
void t_cpp_generator::generate_serialize_container(ofstream& out, t_type* ttype, string prefix) {
scope_up(out);
if (ttype->is_map()) {
indent(out) << "xfer += oprot->writeMapBegin(" << type_to_enum(((t_map*)ttype)->get_key_type())
<< ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", "
<< "static_cast<uint32_t>(" << prefix << ".size()));" << endl;
} else if (ttype->is_set()) {
indent(out) << "xfer += oprot->writeSetBegin(" << type_to_enum(((t_set*)ttype)->get_elem_type())
<< ", "
<< "static_cast<uint32_t>(" << prefix << ".size()));" << endl;
} else if (ttype->is_list()) {
indent(out) << "xfer += oprot->writeListBegin("
<< type_to_enum(((t_list*)ttype)->get_elem_type()) << ", "
<< "static_cast<uint32_t>(" << prefix << ".size()));" << endl;
}
string iter = tmp("_iter");
out << indent() << type_name(ttype) << "::const_iterator " << iter << ";" << endl << indent()
<< "for (" << iter << " = " << prefix << ".begin(); " << iter << " != " << prefix
<< ".end(); ++" << iter << ")" << endl;
scope_up(out);
if (ttype->is_map()) {
generate_serialize_map_element(out, (t_map*)ttype, iter);
} else if (ttype->is_set()) {
generate_serialize_set_element(out, (t_set*)ttype, iter);
} else if (ttype->is_list()) {
generate_serialize_list_element(out, (t_list*)ttype, iter);
}
scope_down(out);
if (ttype->is_map()) {
indent(out) << "xfer += oprot->writeMapEnd();" << endl;
} else if (ttype->is_set()) {
indent(out) << "xfer += oprot->writeSetEnd();" << endl;
} else if (ttype->is_list()) {
indent(out) << "xfer += oprot->writeListEnd();" << endl;
}
scope_down(out);
} | 0 | [
"CWE-20"
] | thrift | cfaadcc4adcfde2a8232c62ec89870b73ef40df1 | 313,585,999,025,324,900,000,000,000,000,000,000,000 | 41 | THRIFT-3231 CPP: Limit recursion depth to 64
Client: cpp
Patch: Ben Craig <[email protected]> |
static int opvmclear(RAsm *a, ut8 *data, const Opcode *op) {
int l = 0;
switch (op->operands_count) {
case 1:
if ( op->operands[0].type & OT_MEMORY &&
op->operands[0].type & OT_QWORD
) {
data[l++] = 0x66;
data[l++] = 0x0f;
data[l++] = 0xc7;
data[l++] = 0x30 | op->operands[0].regs[0];
} else {
return -1;
}
break;
default:
return -1;
}
return l;
} | 0 | [
"CWE-119",
"CWE-125",
"CWE-787"
] | radare2 | 9b46d38dd3c4de6048a488b655c7319f845af185 | 17,819,359,114,789,285,000,000,000,000,000,000,000 | 20 | Fix #12372 and #12373 - Crash in x86 assembler (#12380)
0 ,0,[bP-bL-bP-bL-bL-r-bL-bP-bL-bL-
mov ,0,[ax+Bx-ax+Bx-ax+ax+Bx-ax+Bx--
leA ,0,[bP-bL-bL-bP-bL-bP-bL-60@bL-
leA ,0,[bP-bL-r-bP-bL-bP-bL-60@bL-
mov ,0,[ax+Bx-ax+Bx-ax+ax+Bx-ax+Bx-- |
static inline int ip6_rt_check(const struct rt6key *rt_key,
const struct in6_addr *fl_addr,
const struct in6_addr *addr_cache)
{
return (rt_key->plen != 128 || !ipv6_addr_equal(fl_addr, &rt_key->addr)) &&
(!addr_cache || !ipv6_addr_equal(fl_addr, addr_cache));
} | 0 | [
"CWE-125"
] | linux | 2423496af35d94a87156b063ea5cedffc10a70a1 | 206,640,202,681,626,570,000,000,000,000,000,000,000 | 7 | ipv6: Prevent overrun when parsing v6 header options
The KASAN warning repoted below was discovered with a syzkaller
program. The reproducer is basically:
int s = socket(AF_INET6, SOCK_RAW, NEXTHDR_HOP);
send(s, &one_byte_of_data, 1, MSG_MORE);
send(s, &more_than_mtu_bytes_data, 2000, 0);
The socket() call sets the nexthdr field of the v6 header to
NEXTHDR_HOP, the first send call primes the payload with a non zero
byte of data, and the second send call triggers the fragmentation path.
The fragmentation code tries to parse the header options in order
to figure out where to insert the fragment option. Since nexthdr points
to an invalid option, the calculation of the size of the network header
can made to be much larger than the linear section of the skb and data
is read outside of it.
This fix makes ip6_find_1stfrag return an error if it detects
running out-of-bounds.
[ 42.361487] ==================================================================
[ 42.364412] BUG: KASAN: slab-out-of-bounds in ip6_fragment+0x11c8/0x3730
[ 42.365471] Read of size 840 at addr ffff88000969e798 by task ip6_fragment-oo/3789
[ 42.366469]
[ 42.366696] CPU: 1 PID: 3789 Comm: ip6_fragment-oo Not tainted 4.11.0+ #41
[ 42.367628] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-1ubuntu1 04/01/2014
[ 42.368824] Call Trace:
[ 42.369183] dump_stack+0xb3/0x10b
[ 42.369664] print_address_description+0x73/0x290
[ 42.370325] kasan_report+0x252/0x370
[ 42.370839] ? ip6_fragment+0x11c8/0x3730
[ 42.371396] check_memory_region+0x13c/0x1a0
[ 42.371978] memcpy+0x23/0x50
[ 42.372395] ip6_fragment+0x11c8/0x3730
[ 42.372920] ? nf_ct_expect_unregister_notifier+0x110/0x110
[ 42.373681] ? ip6_copy_metadata+0x7f0/0x7f0
[ 42.374263] ? ip6_forward+0x2e30/0x2e30
[ 42.374803] ip6_finish_output+0x584/0x990
[ 42.375350] ip6_output+0x1b7/0x690
[ 42.375836] ? ip6_finish_output+0x990/0x990
[ 42.376411] ? ip6_fragment+0x3730/0x3730
[ 42.376968] ip6_local_out+0x95/0x160
[ 42.377471] ip6_send_skb+0xa1/0x330
[ 42.377969] ip6_push_pending_frames+0xb3/0xe0
[ 42.378589] rawv6_sendmsg+0x2051/0x2db0
[ 42.379129] ? rawv6_bind+0x8b0/0x8b0
[ 42.379633] ? _copy_from_user+0x84/0xe0
[ 42.380193] ? debug_check_no_locks_freed+0x290/0x290
[ 42.380878] ? ___sys_sendmsg+0x162/0x930
[ 42.381427] ? rcu_read_lock_sched_held+0xa3/0x120
[ 42.382074] ? sock_has_perm+0x1f6/0x290
[ 42.382614] ? ___sys_sendmsg+0x167/0x930
[ 42.383173] ? lock_downgrade+0x660/0x660
[ 42.383727] inet_sendmsg+0x123/0x500
[ 42.384226] ? inet_sendmsg+0x123/0x500
[ 42.384748] ? inet_recvmsg+0x540/0x540
[ 42.385263] sock_sendmsg+0xca/0x110
[ 42.385758] SYSC_sendto+0x217/0x380
[ 42.386249] ? SYSC_connect+0x310/0x310
[ 42.386783] ? __might_fault+0x110/0x1d0
[ 42.387324] ? lock_downgrade+0x660/0x660
[ 42.387880] ? __fget_light+0xa1/0x1f0
[ 42.388403] ? __fdget+0x18/0x20
[ 42.388851] ? sock_common_setsockopt+0x95/0xd0
[ 42.389472] ? SyS_setsockopt+0x17f/0x260
[ 42.390021] ? entry_SYSCALL_64_fastpath+0x5/0xbe
[ 42.390650] SyS_sendto+0x40/0x50
[ 42.391103] entry_SYSCALL_64_fastpath+0x1f/0xbe
[ 42.391731] RIP: 0033:0x7fbbb711e383
[ 42.392217] RSP: 002b:00007ffff4d34f28 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
[ 42.393235] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fbbb711e383
[ 42.394195] RDX: 0000000000001000 RSI: 00007ffff4d34f60 RDI: 0000000000000003
[ 42.395145] RBP: 0000000000000046 R08: 00007ffff4d34f40 R09: 0000000000000018
[ 42.396056] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000400aad
[ 42.396598] R13: 0000000000000066 R14: 00007ffff4d34ee0 R15: 00007fbbb717af00
[ 42.397257]
[ 42.397411] Allocated by task 3789:
[ 42.397702] save_stack_trace+0x16/0x20
[ 42.398005] save_stack+0x46/0xd0
[ 42.398267] kasan_kmalloc+0xad/0xe0
[ 42.398548] kasan_slab_alloc+0x12/0x20
[ 42.398848] __kmalloc_node_track_caller+0xcb/0x380
[ 42.399224] __kmalloc_reserve.isra.32+0x41/0xe0
[ 42.399654] __alloc_skb+0xf8/0x580
[ 42.400003] sock_wmalloc+0xab/0xf0
[ 42.400346] __ip6_append_data.isra.41+0x2472/0x33d0
[ 42.400813] ip6_append_data+0x1a8/0x2f0
[ 42.401122] rawv6_sendmsg+0x11ee/0x2db0
[ 42.401505] inet_sendmsg+0x123/0x500
[ 42.401860] sock_sendmsg+0xca/0x110
[ 42.402209] ___sys_sendmsg+0x7cb/0x930
[ 42.402582] __sys_sendmsg+0xd9/0x190
[ 42.402941] SyS_sendmsg+0x2d/0x50
[ 42.403273] entry_SYSCALL_64_fastpath+0x1f/0xbe
[ 42.403718]
[ 42.403871] Freed by task 1794:
[ 42.404146] save_stack_trace+0x16/0x20
[ 42.404515] save_stack+0x46/0xd0
[ 42.404827] kasan_slab_free+0x72/0xc0
[ 42.405167] kfree+0xe8/0x2b0
[ 42.405462] skb_free_head+0x74/0xb0
[ 42.405806] skb_release_data+0x30e/0x3a0
[ 42.406198] skb_release_all+0x4a/0x60
[ 42.406563] consume_skb+0x113/0x2e0
[ 42.406910] skb_free_datagram+0x1a/0xe0
[ 42.407288] netlink_recvmsg+0x60d/0xe40
[ 42.407667] sock_recvmsg+0xd7/0x110
[ 42.408022] ___sys_recvmsg+0x25c/0x580
[ 42.408395] __sys_recvmsg+0xd6/0x190
[ 42.408753] SyS_recvmsg+0x2d/0x50
[ 42.409086] entry_SYSCALL_64_fastpath+0x1f/0xbe
[ 42.409513]
[ 42.409665] The buggy address belongs to the object at ffff88000969e780
[ 42.409665] which belongs to the cache kmalloc-512 of size 512
[ 42.410846] The buggy address is located 24 bytes inside of
[ 42.410846] 512-byte region [ffff88000969e780, ffff88000969e980)
[ 42.411941] The buggy address belongs to the page:
[ 42.412405] page:ffffea000025a780 count:1 mapcount:0 mapping: (null) index:0x0 compound_mapcount: 0
[ 42.413298] flags: 0x100000000008100(slab|head)
[ 42.413729] raw: 0100000000008100 0000000000000000 0000000000000000 00000001800c000c
[ 42.414387] raw: ffffea00002a9500 0000000900000007 ffff88000c401280 0000000000000000
[ 42.415074] page dumped because: kasan: bad access detected
[ 42.415604]
[ 42.415757] Memory state around the buggy address:
[ 42.416222] ffff88000969e880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[ 42.416904] ffff88000969e900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[ 42.417591] >ffff88000969e980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 42.418273] ^
[ 42.418588] ffff88000969ea00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[ 42.419273] ffff88000969ea80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[ 42.419882] ==================================================================
Reported-by: Andrey Konovalov <[email protected]>
Signed-off-by: Craig Gallek <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
static void fill_block16_c(uint8_t *block, uint8_t value, int line_size, int h)
{
int i;
for (i = 0; i < h; i++) {
memset(block, value, 16);
block += line_size;
}
} | 0 | [
"CWE-703",
"CWE-189"
] | FFmpeg | 454a11a1c9c686c78aa97954306fb63453299760 | 256,043,922,250,067,160,000,000,000,000,000,000,000 | 9 | avcodec/dsputil: fix signedness in sizeof() comparissions
Signed-off-by: Michael Niedermayer <[email protected]> |
shorten_utf8_string (const char *base,
int reduce_by_num_bytes)
{
int len;
char *ret;
const char *p;
len = strlen (base);
len -= reduce_by_num_bytes;
if (len <= 0)
{
return NULL;
}
ret = g_new (char, len + 1);
p = base;
while (len)
{
char *next;
next = g_utf8_next_char (p);
if (next - p > len || *next == '\0')
{
break;
}
len -= next - p;
p = next;
}
if (p - base == 0)
{
g_free (ret);
return NULL;
}
else
{
memcpy (ret, base, p - base);
ret[p - base] = '\0';
return ret;
}
} | 0 | [
"CWE-20"
] | nautilus | 1630f53481f445ada0a455e9979236d31a8d3bb0 | 262,366,214,807,589,960,000,000,000,000,000,000,000 | 43 | mime-actions: use file metadata for trusting desktop files
Currently we only trust desktop files that have the executable bit
set, and don't replace the displayed icon or the displayed name until
it's trusted, which prevents for running random programs by a malicious
desktop file.
However, the executable permission is preserved if the desktop file
comes from a compressed file.
To prevent this, add a metadata::trusted metadata to the file once the
user acknowledges the file as trusted. This adds metadata to the file,
which cannot be added unless it has access to the computer.
Also remove the SHEBANG "trusted" content we were putting inside the
desktop file, since that doesn't add more security since it can come
with the file itself.
https://bugzilla.gnome.org/show_bug.cgi?id=777991 |
int wc_ecc_get_curve_size_from_id(int curve_id)
{
int curve_idx = wc_ecc_get_curve_idx(curve_id);
if (curve_idx == ECC_CURVE_INVALID)
return ECC_BAD_ARG_E;
return ecc_sets[curve_idx].size;
} | 0 | [
"CWE-326",
"CWE-203"
] | wolfssl | 1de07da61f0c8e9926dcbd68119f73230dae283f | 283,382,494,661,565,300,000,000,000,000,000,000,000 | 7 | Constant time EC map to affine for private operations
For fast math, use a constant time modular inverse when mapping to
affine when operation involves a private key - key gen, calc shared
secret, sign. |
char* GetAppendBufferVariable(size_t minSize,
size_t desiredSizeHint,
char* scratch,
size_t scratchSize,
size_t* allocatedSize) {
if (desiredSizeHint > _cursor.length() || minSize > _cursor.length()) {
_scratch.resize(desiredSizeHint);
*allocatedSize = _scratch.size();
return _scratch.data();
}
*allocatedSize = _cursor.length();
return const_cast<char*>(_cursor.data());
} | 0 | [] | mongo | 5ad69b851801edadbfde8fdf271f4ba7c21170b5 | 61,965,608,712,101,570,000,000,000,000,000,000,000 | 14 | SERVER-31273 Use Source/Sink version of snappy functions
(cherry picked from commit 59ead734faa8aa51f0c53bf2bd39d0a0247ddf99) |
void mbedtls_x509_crt_free( mbedtls_x509_crt *crt )
{
mbedtls_x509_crt *cert_cur = crt;
mbedtls_x509_crt *cert_prv;
mbedtls_x509_name *name_cur;
mbedtls_x509_name *name_prv;
mbedtls_x509_sequence *seq_cur;
mbedtls_x509_sequence *seq_prv;
if( crt == NULL )
return;
do
{
mbedtls_pk_free( &cert_cur->pk );
#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT)
mbedtls_free( cert_cur->sig_opts );
#endif
name_cur = cert_cur->issuer.next;
while( name_cur != NULL )
{
name_prv = name_cur;
name_cur = name_cur->next;
mbedtls_zeroize( name_prv, sizeof( mbedtls_x509_name ) );
mbedtls_free( name_prv );
}
name_cur = cert_cur->subject.next;
while( name_cur != NULL )
{
name_prv = name_cur;
name_cur = name_cur->next;
mbedtls_zeroize( name_prv, sizeof( mbedtls_x509_name ) );
mbedtls_free( name_prv );
}
seq_cur = cert_cur->ext_key_usage.next;
while( seq_cur != NULL )
{
seq_prv = seq_cur;
seq_cur = seq_cur->next;
mbedtls_zeroize( seq_prv, sizeof( mbedtls_x509_sequence ) );
mbedtls_free( seq_prv );
}
seq_cur = cert_cur->subject_alt_names.next;
while( seq_cur != NULL )
{
seq_prv = seq_cur;
seq_cur = seq_cur->next;
mbedtls_zeroize( seq_prv, sizeof( mbedtls_x509_sequence ) );
mbedtls_free( seq_prv );
}
if( cert_cur->raw.p != NULL )
{
mbedtls_zeroize( cert_cur->raw.p, cert_cur->raw.len );
mbedtls_free( cert_cur->raw.p );
}
cert_cur = cert_cur->next;
}
while( cert_cur != NULL );
cert_cur = crt;
do
{
cert_prv = cert_cur;
cert_cur = cert_cur->next;
mbedtls_zeroize( cert_prv, sizeof( mbedtls_x509_crt ) );
if( cert_prv != crt )
mbedtls_free( cert_prv );
}
while( cert_cur != NULL );
} | 0 | [
"CWE-287",
"CWE-284"
] | mbedtls | d15795acd5074e0b44e71f7ede8bdfe1b48591fc | 209,292,239,485,488,270,000,000,000,000,000,000,000 | 78 | Improve behaviour on fatal errors
If we didn't walk the whole chain, then there may be any kind of errors in the
part of the chain we didn't check, so setting all flags looks like the safe
thing to do. |
symgraphlink_new (graphid id, symgraphlink *next)
{
symgraphlink *res = xmalloc (sizeof *res);
res->id = id;
res->next = next;
return res;
} | 0 | [] | bison | b7aab2dbad43aaf14eebe78d54aafa245a000988 | 58,070,810,608,686,960,000,000,000,000,000,000,000 | 7 | fix: crash when redefining the EOF token
Reported by Agency for Defense Development.
https://lists.gnu.org/r/bug-bison/2020-08/msg00008.html
On an empty such as
%token FOO
BAR
FOO 0
%%
input: %empty
we crash because when we find FOO 0, we decrement ntokens (since FOO
was discovered to be EOF, which is already known to be a token, so we
increment ntokens for it, and need to cancel this). This "works well"
when EOF is properly defined in one go, but here it is first defined
and later only assign token code 0. In the meanwhile BAR was given
the token number that we just decremented.
To fix this, assign symbol numbers after parsing, not during parsing,
so that we also saw all the explicit token codes. To maintain the
current numbers (I'd like to keep no difference in the output, not
just equivalence), we need to make sure the symbols are numbered in
the same order: that of appearance in the source file. So we need the
locations to be correct, which was almost the case, except for nterms
that appeared several times as LHS (i.e., several times as "foo:
..."). Fixing the use of location_of_lhs sufficed (it appears it was
intended for this use, but its implementation was unfinished: it was
always set to "false" only).
* src/symtab.c (symbol_location_as_lhs_set): Update location_of_lhs.
(symbol_code_set): Remove broken hack that decremented ntokens.
(symbol_class_set, dummy_symbol_get): Don't set number, ntokens and
nnterms.
(symbol_check_defined): Do it.
(symbols): Don't count nsyms here.
Actually, don't count nsyms at all: let it be done in...
* src/reader.c (check_and_convert_grammar): here. Define nsyms from
ntokens and nnterms after parsing.
* tests/input.at (EOF redeclared): New.
* examples/c/bistromathic/bistromathic.test: Adjust the traces: in
"%nterm <double> exp %% input: ...", exp used to be numbered before
input. |
int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info)
{
struct nlattr *attrs[TIPC_NLA_MON_MAX + 1];
struct net *net = sock_net(skb->sk);
int err;
if (!info->attrs[TIPC_NLA_MON])
return -EINVAL;
err = nla_parse_nested_deprecated(attrs, TIPC_NLA_MON_MAX,
info->attrs[TIPC_NLA_MON],
tipc_nl_monitor_policy,
info->extack);
if (err)
return err;
if (attrs[TIPC_NLA_MON_ACTIVATION_THRESHOLD]) {
u32 val;
val = nla_get_u32(attrs[TIPC_NLA_MON_ACTIVATION_THRESHOLD]);
err = tipc_nl_monitor_set_threshold(net, val);
if (err)
return err;
}
return 0;
} | 0 | [] | linux | 0217ed2848e8538bcf9172d97ed2eeb4a26041bb | 298,002,093,445,040,300,000,000,000,000,000,000,000 | 27 | tipc: better validate user input in tipc_nl_retrieve_key()
Before calling tipc_aead_key_size(ptr), we need to ensure
we have enough data to dereference ptr->keylen.
We probably also want to make sure tipc_aead_key_size()
wont overflow with malicious ptr->keylen values.
Syzbot reported:
BUG: KMSAN: uninit-value in __tipc_nl_node_set_key net/tipc/node.c:2971 [inline]
BUG: KMSAN: uninit-value in tipc_nl_node_set_key+0x9bf/0x13b0 net/tipc/node.c:3023
CPU: 0 PID: 21060 Comm: syz-executor.5 Not tainted 5.11.0-rc7-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:79 [inline]
dump_stack+0x21c/0x280 lib/dump_stack.c:120
kmsan_report+0xfb/0x1e0 mm/kmsan/kmsan_report.c:118
__msan_warning+0x5f/0xa0 mm/kmsan/kmsan_instr.c:197
__tipc_nl_node_set_key net/tipc/node.c:2971 [inline]
tipc_nl_node_set_key+0x9bf/0x13b0 net/tipc/node.c:3023
genl_family_rcv_msg_doit net/netlink/genetlink.c:739 [inline]
genl_family_rcv_msg net/netlink/genetlink.c:783 [inline]
genl_rcv_msg+0x1319/0x1610 net/netlink/genetlink.c:800
netlink_rcv_skb+0x6fa/0x810 net/netlink/af_netlink.c:2494
genl_rcv+0x63/0x80 net/netlink/genetlink.c:811
netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
netlink_unicast+0x11d6/0x14a0 net/netlink/af_netlink.c:1330
netlink_sendmsg+0x1740/0x1840 net/netlink/af_netlink.c:1919
sock_sendmsg_nosec net/socket.c:652 [inline]
sock_sendmsg net/socket.c:672 [inline]
____sys_sendmsg+0xcfc/0x12f0 net/socket.c:2345
___sys_sendmsg net/socket.c:2399 [inline]
__sys_sendmsg+0x714/0x830 net/socket.c:2432
__compat_sys_sendmsg net/compat.c:347 [inline]
__do_compat_sys_sendmsg net/compat.c:354 [inline]
__se_compat_sys_sendmsg+0xa7/0xc0 net/compat.c:351
__ia32_compat_sys_sendmsg+0x4a/0x70 net/compat.c:351
do_syscall_32_irqs_on arch/x86/entry/common.c:79 [inline]
__do_fast_syscall_32+0x102/0x160 arch/x86/entry/common.c:141
do_fast_syscall_32+0x6a/0xc0 arch/x86/entry/common.c:166
do_SYSENTER_32+0x73/0x90 arch/x86/entry/common.c:209
entry_SYSENTER_compat_after_hwframe+0x4d/0x5c
RIP: 0023:0xf7f60549
Code: 03 74 c0 01 10 05 03 74 b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d b4 26 00 00 00 00 8d b4 26 00 00 00 00
RSP: 002b:00000000f555a5fc EFLAGS: 00000296 ORIG_RAX: 0000000000000172
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000020000200
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
Uninit was created at:
kmsan_save_stack_with_flags mm/kmsan/kmsan.c:121 [inline]
kmsan_internal_poison_shadow+0x5c/0xf0 mm/kmsan/kmsan.c:104
kmsan_slab_alloc+0x8d/0xe0 mm/kmsan/kmsan_hooks.c:76
slab_alloc_node mm/slub.c:2907 [inline]
__kmalloc_node_track_caller+0xa37/0x1430 mm/slub.c:4527
__kmalloc_reserve net/core/skbuff.c:142 [inline]
__alloc_skb+0x2f8/0xb30 net/core/skbuff.c:210
alloc_skb include/linux/skbuff.h:1099 [inline]
netlink_alloc_large_skb net/netlink/af_netlink.c:1176 [inline]
netlink_sendmsg+0xdbc/0x1840 net/netlink/af_netlink.c:1894
sock_sendmsg_nosec net/socket.c:652 [inline]
sock_sendmsg net/socket.c:672 [inline]
____sys_sendmsg+0xcfc/0x12f0 net/socket.c:2345
___sys_sendmsg net/socket.c:2399 [inline]
__sys_sendmsg+0x714/0x830 net/socket.c:2432
__compat_sys_sendmsg net/compat.c:347 [inline]
__do_compat_sys_sendmsg net/compat.c:354 [inline]
__se_compat_sys_sendmsg+0xa7/0xc0 net/compat.c:351
__ia32_compat_sys_sendmsg+0x4a/0x70 net/compat.c:351
do_syscall_32_irqs_on arch/x86/entry/common.c:79 [inline]
__do_fast_syscall_32+0x102/0x160 arch/x86/entry/common.c:141
do_fast_syscall_32+0x6a/0xc0 arch/x86/entry/common.c:166
do_SYSENTER_32+0x73/0x90 arch/x86/entry/common.c:209
entry_SYSENTER_compat_after_hwframe+0x4d/0x5c
Fixes: e1f32190cf7d ("tipc: add support for AEAD key setting via netlink")
Signed-off-by: Eric Dumazet <[email protected]>
Cc: Tuong Lien <[email protected]>
Cc: Jon Maloy <[email protected]>
Cc: Ying Xue <[email protected]>
Reported-by: syzbot <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
bool RGWBulkUploadOp::handle_file_verify_permission(RGWBucketInfo& binfo,
const rgw_obj& obj,
std::map<std::string, ceph::bufferlist>& battrs,
ACLOwner& bucket_owner /* out */)
{
RGWAccessControlPolicy bacl(store->ctx());
op_ret = read_bucket_policy(store, s, binfo, battrs, &bacl, binfo.bucket);
if (op_ret < 0) {
ldout(s->cct, 20) << "bulk upload: cannot read_policy() for bucket"
<< dendl;
return false;
}
auto policy = get_iam_policy_from_attr(s->cct, store, battrs, binfo.bucket.tenant);
bucket_owner = bacl.get_owner();
if (policy) {
auto e = policy->eval(s->env, *s->auth.identity,
rgw::IAM::s3PutObject, obj);
if (e == Effect::Allow) {
return true;
} else if (e == Effect::Deny) {
return false;
}
}
return verify_bucket_permission_no_policy(s, s->user_acl.get(),
&bacl, RGW_PERM_WRITE);
} | 0 | [
"CWE-770"
] | ceph | ab29bed2fc9f961fe895de1086a8208e21ddaddc | 248,554,145,416,549,520,000,000,000,000,000,000,000 | 29 | 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 |
void PngImg::InitStorage_() {
rowPtrs_.resize(info_.height, nullptr);
// Extend height and rowbytes from uint32_t to size_t to avoid multiplication overflow when size_t is larger
size_t h = info_.height;
size_t rb = info_.rowbytes;
// We need to make sure that info_.height * info_.rowbytes will not overflow size_t
// Unfotunately, there's no simple and portable way to do this in C++
// For integer division of positive numbers a * b > c <==> a > c / b holds
if (h > std::numeric_limits<size_t>::max() / rb) {
// TODO Propagate this exception to JS, and test it
throw std::runtime_error("Image is too large to allocate single buffer");
}
data_ = new png_byte[h * rb];
for(size_t i = 0; i < info_.height; ++i) {
rowPtrs_[i] = data_ + i * rb;
}
} | 0 | [
"CWE-190",
"CWE-787"
] | png-img | 14ac462a32ca4b3b78f56502ac976d5b0222ce3d | 291,712,469,890,126,750,000,000,000,000,000,000,000 | 18 | Handle image size overflow |
qtdemux_parse_uuid (GstQTDemux * qtdemux, const guint8 * buffer, gint length)
{
static const guint8 xmp_uuid[] = { 0xBE, 0x7A, 0xCF, 0xCB,
0x97, 0xA9, 0x42, 0xE8,
0x9C, 0x71, 0x99, 0x94,
0x91, 0xE3, 0xAF, 0xAC
};
static const guint8 playready_uuid[] = {
0xd0, 0x8a, 0x4f, 0x18, 0x10, 0xf3, 0x4a, 0x82,
0xb6, 0xc8, 0x32, 0xd8, 0xab, 0xa1, 0x83, 0xd3
};
static const guint8 piff_sample_encryption_uuid[] = {
0xa2, 0x39, 0x4f, 0x52, 0x5a, 0x9b, 0x4f, 0x14,
0xa2, 0x44, 0x6c, 0x42, 0x7c, 0x64, 0x8d, 0xf4
};
guint offset;
/* counts as header data */
qtdemux->header_size += length;
offset = (QT_UINT32 (buffer) == 0) ? 16 : 8;
if (length <= offset + 16) {
GST_DEBUG_OBJECT (qtdemux, "uuid atom is too short, skipping");
return;
}
if (memcmp (buffer + offset, xmp_uuid, 16) == 0) {
GstBuffer *buf;
GstTagList *taglist;
buf = _gst_buffer_new_wrapped ((guint8 *) buffer + offset + 16,
length - offset - 16, NULL);
taglist = gst_tag_list_from_xmp_buffer (buf);
gst_buffer_unref (buf);
qtdemux_handle_xmp_taglist (qtdemux, qtdemux->tag_list, taglist);
} else if (memcmp (buffer + offset, playready_uuid, 16) == 0) {
int len;
const gunichar2 *s_utf16;
char *contents;
len = GST_READ_UINT16_LE (buffer + offset + 0x30);
s_utf16 = (const gunichar2 *) (buffer + offset + 0x32);
contents = g_utf16_to_utf8 (s_utf16, len / 2, NULL, NULL, NULL);
GST_ERROR_OBJECT (qtdemux, "contents: %s", contents);
g_free (contents);
GST_ELEMENT_ERROR (qtdemux, STREAM, DECRYPT,
(_("Cannot play stream because it is encrypted with PlayReady DRM.")),
(NULL));
} else if (memcmp (buffer + offset, piff_sample_encryption_uuid, 16) == 0) {
qtdemux_parse_piff (qtdemux, buffer, length, offset);
} else {
GST_DEBUG_OBJECT (qtdemux, "Ignoring unknown uuid: %08x-%08x-%08x-%08x",
GST_READ_UINT32_LE (buffer + offset),
GST_READ_UINT32_LE (buffer + offset + 4),
GST_READ_UINT32_LE (buffer + offset + 8),
GST_READ_UINT32_LE (buffer + offset + 12));
}
} | 0 | [
"CWE-125"
] | gst-plugins-good | d0949baf3dadea6021d54abef6802fed5a06af75 | 258,960,445,345,763,300,000,000,000,000,000,000,000 | 65 | qtdemux: Fix out of bounds read in tag parsing code
We can't simply assume that the length of the tag value as given
inside the stream is correct but should also check against the amount of
data we have actually available.
https://bugzilla.gnome.org/show_bug.cgi?id=775451 |
int mailimf_fws_word_parse(const char * message, size_t length,
size_t * indx, char ** result, int * p_missing_closing_quote)
{
size_t cur_token;
char * word;
int r;
int missing_closing_quote;
cur_token = * indx;
missing_closing_quote = 0;
r = mailimf_fws_atom_for_word_parse(message, length, &cur_token, &word, &missing_closing_quote);
if (r == MAILIMF_ERROR_PARSE)
r = mailimf_fws_quoted_string_parse(message, length, &cur_token, &word);
if (r != MAILIMF_NO_ERROR)
return r;
* result = word;
* indx = cur_token;
* p_missing_closing_quote = missing_closing_quote;
return MAILIMF_NO_ERROR;
} | 0 | [
"CWE-476"
] | libetpan | 1fe8fbc032ccda1db9af66d93016b49c16c1f22d | 8,738,288,083,128,990,000,000,000,000,000,000,000 | 25 | Fixed crash #274 |
_gnutls_rsa_pms_set_version(gnutls_session_t session,
unsigned char major, unsigned char minor)
{
session->internals.rsa_pms_version[0] = major;
session->internals.rsa_pms_version[1] = minor;
} | 0 | [
"CWE-400"
] | gnutls | 1ffb827e45721ef56982d0ffd5c5de52376c428e | 60,873,026,291,866,440,000,000,000,000,000,000,000 | 6 | handshake: set a maximum number of warning messages that can be received per handshake
That is to avoid DoS due to the assymetry of cost of sending an alert vs the cost
of processing. |
static int sctp_getsockopt_enable_strreset(struct sock *sk, int len,
char __user *optval,
int __user *optlen)
{
struct sctp_assoc_value params;
struct sctp_association *asoc;
int retval = -EFAULT;
if (len < sizeof(params)) {
retval = -EINVAL;
goto out;
}
len = sizeof(params);
if (copy_from_user(¶ms, optval, len))
goto out;
asoc = sctp_id2assoc(sk, params.assoc_id);
if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
sctp_style(sk, UDP)) {
retval = -EINVAL;
goto out;
}
params.assoc_value = asoc ? asoc->strreset_enable
: sctp_sk(sk)->ep->strreset_enable;
if (put_user(len, optlen))
goto out;
if (copy_to_user(optval, ¶ms, len))
goto out;
retval = 0;
out:
return retval;
} | 0 | [
"CWE-362"
] | linux | b166a20b07382b8bc1dcee2a448715c9c2c81b5b | 310,857,882,155,496,480,000,000,000,000,000,000,000 | 38 | net/sctp: fix race condition in sctp_destroy_sock
If sctp_destroy_sock is called without sock_net(sk)->sctp.addr_wq_lock
held and sp->do_auto_asconf is true, then an element is removed
from the auto_asconf_splist without any proper locking.
This can happen in the following functions:
1. In sctp_accept, if sctp_sock_migrate fails.
2. In inet_create or inet6_create, if there is a bpf program
attached to BPF_CGROUP_INET_SOCK_CREATE which denies
creation of the sctp socket.
The bug is fixed by acquiring addr_wq_lock in sctp_destroy_sock
instead of sctp_close.
This addresses CVE-2021-23133.
Reported-by: Or Cohen <[email protected]>
Reviewed-by: Xin Long <[email protected]>
Fixes: 610236587600 ("bpf: Add new cgroup attach type to enable sock modifications")
Signed-off-by: Or Cohen <[email protected]>
Acked-by: Marcelo Ricardo Leitner <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
svcxdr_dupstr(struct nfsd4_compoundargs *argp, void *buf, u32 len)
{
char *p = svcxdr_tmpalloc(argp, len + 1);
if (!p)
return NULL;
memcpy(p, buf, len);
p[len] = '\0';
return p;
} | 0 | [
"CWE-20",
"CWE-129"
] | linux | f961e3f2acae94b727380c0b74e2d3954d0edf79 | 218,102,096,694,954,980,000,000,000,000,000,000,000 | 10 | nfsd: encoders mustn't use unitialized values in error cases
In error cases, lgp->lg_layout_type may be out of bounds; so we
shouldn't be using it until after the check of nfserr.
This was seen to crash nfsd threads when the server receives a LAYOUTGET
request with a large layout type.
GETDEVICEINFO has the same problem.
Reported-by: Ari Kauppi <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Cc: [email protected]
Signed-off-by: J. Bruce Fields <[email protected]> |
static void unpin_rcv_pages(struct hfi1_filedata *fd,
struct tid_user_buf *tidbuf,
struct tid_rb_node *node,
unsigned int idx,
unsigned int npages,
bool mapped)
{
struct page **pages;
struct hfi1_devdata *dd = fd->uctxt->dd;
struct mm_struct *mm;
if (mapped) {
pci_unmap_single(dd->pcidev, node->dma_addr,
node->npages * PAGE_SIZE, PCI_DMA_FROMDEVICE);
pages = &node->pages[idx];
mm = mm_from_tid_node(node);
} else {
pages = &tidbuf->pages[idx];
mm = current->mm;
}
hfi1_release_user_pages(mm, pages, npages, mapped);
fd->tid_n_pinned -= npages;
} | 0 | [
"CWE-416"
] | linux | 3d2a9d642512c21a12d19b9250e7a835dcb41a79 | 159,790,374,965,578,000,000,000,000,000,000,000,000 | 23 | IB/hfi1: Ensure correct mm is used at all times
Two earlier bug fixes have created a security problem in the hfi1
driver. One fix aimed to solve an issue where current->mm was not valid
when closing the hfi1 cdev. It attempted to do this by saving a cached
value of the current->mm pointer at file open time. This is a problem if
another process with access to the FD calls in via write() or ioctl() to
pin pages via the hfi driver. The other fix tried to solve a use after
free by taking a reference on the mm.
To fix this correctly we use the existing cached value of the mm in the
mmu notifier. Now we can check in the insert, evict, etc. routines that
current->mm matched what the notifier was registered for. If not, then
don't allow access. The register of the mmu notifier will save the mm
pointer.
Since in do_exit() the exit_mm() is called before exit_files(), which
would call our close routine a reference is needed on the mm. We rely on
the mmgrab done by the registration of the notifier, whereas before it was
explicit. The mmu notifier deregistration happens when the user context is
torn down, the creation of which triggered the registration.
Also of note is we do not do any explicit work to protect the interval
tree notifier. It doesn't seem that this is going to be needed since we
aren't actually doing anything with current->mm. The interval tree
notifier stuff still has a FIXME noted from a previous commit that will be
addressed in a follow on patch.
Cc: <[email protected]>
Fixes: e0cf75deab81 ("IB/hfi1: Fix mm_struct use after free")
Fixes: 3faa3d9a308e ("IB/hfi1: Make use of mm consistent")
Link: https://lore.kernel.org/r/[email protected]
Suggested-by: Jann Horn <[email protected]>
Reported-by: Jason Gunthorpe <[email protected]>
Reviewed-by: Ira Weiny <[email protected]>
Reviewed-by: Mike Marciniszyn <[email protected]>
Signed-off-by: Dennis Dalessandro <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]> |
AirPDcapGetSaAddress(
const AIRPDCAP_MAC_FRAME_ADDR4 *frame,
AIRPDCAP_SEC_ASSOCIATION_ID *id)
{
#ifdef _DEBUG
#define MSGBUF_LEN 255
CHAR msgbuf[MSGBUF_LEN];
#endif
if ((AIRPDCAP_TYPE(frame->fc[0])==AIRPDCAP_TYPE_DATA) &&
(AIRPDCAP_DS_BITS(frame->fc[1]) == 0) &&
(memcmp(frame->addr2, frame->addr3, AIRPDCAP_MAC_LEN) != 0) &&
(memcmp(frame->addr1, frame->addr3, AIRPDCAP_MAC_LEN) != 0)) {
/* DATA frame with fromDS=0 ToDS=0 and neither RA or SA is BSSID
=> TDLS traffic. Use highest MAC address for bssid */
if (memcmp(frame->addr1, frame->addr2, AIRPDCAP_MAC_LEN) < 0) {
memcpy(id->sta, frame->addr1, AIRPDCAP_MAC_LEN);
memcpy(id->bssid, frame->addr2, AIRPDCAP_MAC_LEN);
} else {
memcpy(id->sta, frame->addr2, AIRPDCAP_MAC_LEN);
memcpy(id->bssid, frame->addr1, AIRPDCAP_MAC_LEN);
}
} else {
const UCHAR *addr;
/* Normal Case: SA between STA and AP */
if ((addr = AirPDcapGetBssidAddress(frame)) != NULL) {
memcpy(id->bssid, addr, AIRPDCAP_MAC_LEN);
} else {
return AIRPDCAP_RET_UNSUCCESS;
}
if ((addr = AirPDcapGetStaAddress(frame)) != NULL) {
memcpy(id->sta, addr, AIRPDCAP_MAC_LEN);
} else {
return AIRPDCAP_RET_UNSUCCESS;
}
}
#ifdef _DEBUG
g_snprintf(msgbuf, MSGBUF_LEN, "BSSID_MAC: %02X.%02X.%02X.%02X.%02X.%02X\t",
id->bssid[0],id->bssid[1],id->bssid[2],id->bssid[3],id->bssid[4],id->bssid[5]);
AIRPDCAP_DEBUG_PRINT_LINE("AirPDcapGetSaAddress", msgbuf, AIRPDCAP_DEBUG_LEVEL_3);
g_snprintf(msgbuf, MSGBUF_LEN, "STA_MAC: %02X.%02X.%02X.%02X.%02X.%02X\t",
id->sta[0],id->sta[1],id->sta[2],id->sta[3],id->sta[4],id->sta[5]);
AIRPDCAP_DEBUG_PRINT_LINE("AirPDcapGetSaAddress", msgbuf, AIRPDCAP_DEBUG_LEVEL_3);
#endif
return AIRPDCAP_RET_SUCCESS;
} | 0 | [
"CWE-20"
] | wireshark | 9b0b20b8d5f8c9f7839d58ff6c5900f7e19283b4 | 73,554,943,821,290,760,000,000,000,000,000,000,000 | 50 | Make sure EAPOL body is big enough for a EAPOL_RSN_KEY.
A pointer to a EAPOL_RSN_KEY is set on the packet presuming the
whole EAPOL_RSN_KEY is there. That's not always the case for
fuzzed/malicious captures.
Bug: 11585
Change-Id: Ib94b8aceef444c7820e43b969596efdb8dbecccd
Reviewed-on: https://code.wireshark.org/review/15540
Reviewed-by: Michael Mann <[email protected]>
Petri-Dish: Michael Mann <[email protected]>
Tested-by: Petri Dish Buildbot <[email protected]>
Reviewed-by: Anders Broman <[email protected]> |
int ha_rollback_trans(THD *thd, bool all)
{
int error=0;
THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt;
Ha_trx_info *ha_info= trans->ha_list, *ha_info_next;
/*
"real" is a nick name for a transaction for which a commit will
make persistent changes. E.g. a 'stmt' transaction inside a 'all'
transaction is not 'real': even though it's possible to commit it,
the changes are not durable as they might be rolled back if the
enclosing 'all' transaction is rolled back.
We establish the value of 'is_real_trans' by checking
if it's an explicit COMMIT or BEGIN statement, or implicit
commit issued by DDL (in these cases all == TRUE),
or if we're running in autocommit mode (it's only in the autocommit mode
ha_commit_one_phase() is called with an empty
transaction.all.ha_list, see why in trans_register_ha()).
*/
bool is_real_trans=all || thd->transaction.all.ha_list == 0;
DBUG_ENTER("ha_rollback_trans");
/*
We must not rollback the normal transaction if a statement
transaction is pending.
*/
DBUG_ASSERT(thd->transaction.stmt.ha_list == NULL ||
trans == &thd->transaction.stmt);
#ifdef HAVE_REPLICATION
if (is_real_trans)
{
/*
In parallel replication, if we need to rollback during commit, we must
first inform following transactions that we are going to abort our commit
attempt. Otherwise those following transactions can run too early, and
possibly cause replication to fail. See comments in retry_event_group().
There were several bugs with this in the past that were very hard to
track down (MDEV-7458, MDEV-8302). So we add here an assertion for
rollback without signalling following transactions. And in release
builds, we explicitly do the signalling before rolling back.
*/
DBUG_ASSERT(!(thd->rgi_slave && thd->rgi_slave->did_mark_start_commit));
if (thd->rgi_slave && thd->rgi_slave->did_mark_start_commit)
thd->rgi_slave->unmark_start_commit();
}
#endif
if (thd->in_sub_stmt)
{
DBUG_ASSERT(0);
/*
If we are inside stored function or trigger we should not commit or
rollback current statement transaction. See comment in ha_commit_trans()
call for more information.
*/
if (!all)
DBUG_RETURN(0);
my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0));
DBUG_RETURN(1);
}
#ifdef WITH_WSREP
(void) wsrep_before_rollback(thd, all);
#endif /* WITH_WSREP */
if (ha_info)
{
/* Close all cursors that can not survive ROLLBACK */
if (is_real_trans) /* not a statement commit */
thd->stmt_map.close_transient_cursors();
for (; ha_info; ha_info= ha_info_next)
{
int err;
handlerton *ht= ha_info->ht();
if ((err= ht->rollback(ht, thd, all)))
{ // cannot happen
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err);
error=1;
#ifdef WITH_WSREP
WSREP_WARN("handlerton rollback failed, thd %lld %lld conf %d SQL %s",
thd->thread_id, thd->query_id, thd->wsrep_trx().state(),
thd->query());
#endif /* WITH_WSREP */
}
status_var_increment(thd->status_var.ha_rollback_count);
ha_info_next= ha_info->next();
ha_info->reset(); /* keep it conveniently zero-filled */
}
trans->ha_list= 0;
trans->no_2pc=0;
}
#ifdef WITH_WSREP
if (thd->is_error())
{
WSREP_DEBUG("ha_rollback_trans(%lld, %s) rolled back: %s: %s; is_real %d",
thd->thread_id, all?"TRUE":"FALSE", wsrep_thd_query(thd),
thd->get_stmt_da()->message(), is_real_trans);
}
(void) wsrep_after_rollback(thd, all);
#endif /* WITH_WSREP */
/* Always cleanup. Even if nht==0. There may be savepoints. */
if (is_real_trans)
{
/*
Thanks to possibility of MDL deadlock rollback request can come even if
transaction hasn't been started in any transactional storage engine.
*/
if (thd->transaction_rollback_request &&
thd->transaction.xid_state.is_explicit_XA())
thd->transaction.xid_state.set_error(thd->get_stmt_da()->sql_errno());
thd->has_waiter= false;
thd->transaction.cleanup();
}
if (all)
thd->transaction_rollback_request= FALSE;
/*
If a non-transactional table was updated, warn; don't warn if this is a
slave thread (because when a slave thread executes a ROLLBACK, it has
been read from the binary log, so it's 100% sure and normal to produce
error ER_WARNING_NOT_COMPLETE_ROLLBACK. If we sent the warning to the
slave SQL thread, it would not stop the thread but just be printed in
the error log; but we don't want users to wonder why they have this
message in the error log, so we don't send it.
We don't have to test for thd->killed == KILL_SYSTEM_THREAD as
it doesn't matter if a warning is pushed to a system thread or not:
No one will see it...
*/
if (is_real_trans && thd->transaction.all.modified_non_trans_table &&
!thd->slave_thread && thd->killed < KILL_CONNECTION)
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARNING_NOT_COMPLETE_ROLLBACK,
ER_THD(thd, ER_WARNING_NOT_COMPLETE_ROLLBACK));
#ifdef HAVE_REPLICATION
repl_semisync_master.wait_after_rollback(thd, all);
#endif
DBUG_RETURN(error);
} | 0 | [
"CWE-416"
] | server | af810407f78b7f792a9bb8c47c8c532eb3b3a758 | 312,033,971,408,576,630,000,000,000,000,000,000,000 | 142 | MDEV-28098 incorrect key in "dup value" error after long unique
reset errkey after using it, so that it wouldn't affect
the next error message in the next statement |
static void parse_error(struct filter_parse_error *pe, int err, int pos)
{
pe->lasterr = err;
pe->lasterr_pos = pos;
} | 0 | [
"CWE-787"
] | linux | 70303420b5721c38998cf987e6b7d30cc62d4ff1 | 58,097,404,720,073,760,000,000,000,000,000,000,000 | 5 | tracing: Check for no filter when processing event filters
The syzkaller detected a out-of-bounds issue with the events filter code,
specifically here:
prog[N].pred = NULL; /* #13 */
prog[N].target = 1; /* TRUE */
prog[N+1].pred = NULL;
prog[N+1].target = 0; /* FALSE */
-> prog[N-1].target = N;
prog[N-1].when_to_branch = false;
As that's the first reference to a "N-1" index, it appears that the code got
here with N = 0, which means the filter parser found no filter to parse
(which shouldn't ever happen, but apparently it did).
Add a new error to the parsing code that will check to make sure that N is
not zero before going into this part of the code. If N = 0, then -EINVAL is
returned, and a error message is added to the filter.
Cc: [email protected]
Fixes: 80765597bc587 ("tracing: Rewrite filter logic to be simpler and faster")
Reported-by: air icy <[email protected]>
bugzilla url: https://bugzilla.kernel.org/show_bug.cgi?id=200019
Signed-off-by: Steven Rostedt (VMware) <[email protected]> |
PERL_STATIC_INLINE UV*
S__invlist_array_init(SV* const invlist, const bool will_have_0)
{
/* Returns a pointer to the first element in the inversion list's array.
* This is called upon initialization of an inversion list. Where the
* array begins depends on whether the list has the code point U+0000 in it
* or not. The other parameter tells it whether the code that follows this
* call is about to put a 0 in the inversion list or not. The first
* element is either the element reserved for 0, if TRUE, or the element
* after it, if FALSE */
bool* offset = get_invlist_offset_addr(invlist);
UV* zero_addr = (UV *) SvPVX(invlist);
PERL_ARGS_ASSERT__INVLIST_ARRAY_INIT;
/* Must be empty */
assert(! _invlist_len(invlist));
*zero_addr = 0;
/* 1^1 = 0; 1^0 = 1 */
*offset = 1 ^ will_have_0;
return zero_addr + *offset; | 0 | [
"CWE-190",
"CWE-787"
] | perl5 | 897d1f7fd515b828e4b198d8b8bef76c6faf03ed | 54,965,858,520,085,930,000,000,000,000,000,000,000 | 24 | regcomp.c: Prevent integer overflow from nested regex quantifiers.
(CVE-2020-10543) On 32bit systems the size calculations for nested regular
expression quantifiers could overflow causing heap memory corruption.
Fixes: Perl/perl5-security#125
(cherry picked from commit bfd31397db5dc1a5c5d3e0a1f753a4f89a736e71) |
__be32 nfsd4_check_resp_size(struct nfsd4_compoundres *resp, u32 respsize)
{
struct xdr_buf *buf = &resp->rqstp->rq_res;
struct nfsd4_slot *slot = resp->cstate.slot;
if (buf->len + respsize <= buf->buflen)
return nfs_ok;
if (!nfsd4_has_session(&resp->cstate))
return nfserr_resource;
if (slot->sl_flags & NFSD4_SLOT_CACHETHIS) {
WARN_ON_ONCE(1);
return nfserr_rep_too_big_to_cache;
}
return nfserr_rep_too_big;
} | 0 | [
"CWE-20",
"CWE-129"
] | linux | f961e3f2acae94b727380c0b74e2d3954d0edf79 | 133,553,775,557,785,260,000,000,000,000,000,000,000 | 15 | nfsd: encoders mustn't use unitialized values in error cases
In error cases, lgp->lg_layout_type may be out of bounds; so we
shouldn't be using it until after the check of nfserr.
This was seen to crash nfsd threads when the server receives a LAYOUTGET
request with a large layout type.
GETDEVICEINFO has the same problem.
Reported-by: Ari Kauppi <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Cc: [email protected]
Signed-off-by: J. Bruce Fields <[email protected]> |
static int snd_pcm_oss_reset(struct snd_pcm_oss_file *pcm_oss_file)
{
struct snd_pcm_substream *substream;
struct snd_pcm_runtime *runtime;
int i;
for (i = 0; i < 2; i++) {
substream = pcm_oss_file->streams[i];
if (!substream)
continue;
runtime = substream->runtime;
snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
mutex_lock(&runtime->oss.params_lock);
runtime->oss.prepare = 1;
runtime->oss.buffer_used = 0;
runtime->oss.prev_hw_ptr_period = 0;
runtime->oss.period_ptr = 0;
mutex_unlock(&runtime->oss.params_lock);
}
return 0;
} | 0 | [
"CWE-362"
] | linux | 8423f0b6d513b259fdab9c9bf4aaa6188d054c2d | 145,227,769,766,833,160,000,000,000,000,000,000,000 | 21 | ALSA: pcm: oss: Fix race at SNDCTL_DSP_SYNC
There is a small race window at snd_pcm_oss_sync() that is called from
OSS PCM SNDCTL_DSP_SYNC ioctl; namely the function calls
snd_pcm_oss_make_ready() at first, then takes the params_lock mutex
for the rest. When the stream is set up again by another thread
between them, it leads to inconsistency, and may result in unexpected
results such as NULL dereference of OSS buffer as a fuzzer spotted
recently.
The fix is simply to cover snd_pcm_oss_make_ready() call into the same
params_lock mutex with snd_pcm_oss_make_ready_locked() variant.
Reported-and-tested-by: butt3rflyh4ck <[email protected]>
Reviewed-by: Jaroslav Kysela <[email protected]>
Cc: <[email protected]>
Link: https://lore.kernel.org/r/CAFcO6XN7JDM4xSXGhtusQfS2mSBcx50VJKwQpCq=WeLt57aaZA@mail.gmail.com
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]> |
static void test_strings()
{
char* str = "---- abc ---- xyz";
uint8_t blob[] = "---- a\0b\0c\0 -\0-\0-\0-\0x\0y\0z\0";
assert_true_rule(
"rule test { strings: $a = \"a\" condition: $a }",
str);
assert_true_rule(
"rule test { strings: $a = \"ab\" condition: $a }",
str);
assert_true_rule(
"rule test { strings: $a = \"abc\" condition: $a }",
str);
assert_true_rule(
"rule test { strings: $a = \"xyz\" condition: $a }",
str);
assert_true_rule(
"rule test { strings: $a = \"abc\" nocase fullword condition: $a }",
str);
assert_true_rule(
"rule test { strings: $a = \"aBc\" nocase condition: $a }",
str);
assert_true_rule(
"rule test { strings: $a = \"abc\" fullword condition: $a }",
str);
assert_false_rule(
"rule test { strings: $a = \"a\" fullword condition: $a }",
str);
assert_false_rule(
"rule test { strings: $a = \"ab\" fullword condition: $a }",
str);
assert_false_rule(
"rule test { strings: $a = \"abc\" wide fullword condition: $a }",
str);
assert_true_rule_blob(
"rule test { strings: $a = \"a\" wide condition: $a }",
blob);
assert_true_rule_blob(
"rule test { strings: $a = \"a\" wide ascii condition: $a }",
blob);
assert_true_rule_blob(
"rule test { strings: $a = \"ab\" wide condition: $a }",
blob);
assert_true_rule_blob(
"rule test { strings: $a = \"ab\" wide ascii condition: $a }",
blob);
assert_true_rule_blob(
"rule test { strings: $a = \"abc\" wide condition: $a }",
blob);
assert_true_rule_blob(
"rule test { strings: $a = \"abc\" wide nocase fullword condition: $a }",
blob);
assert_true_rule_blob(
"rule test { strings: $a = \"aBc\" wide nocase condition: $a }",
blob);
assert_true_rule_blob(
"rule test { strings: $a = \"aBc\" wide ascii nocase condition: $a }",
blob);
assert_true_rule_blob(
"rule test { strings: $a = \"---xyz\" wide nocase condition: $a }",
blob);
assert_true_rule(
"rule test { strings: $a = \"abc\" fullword condition: $a }",
"abc");
assert_false_rule(
"rule test { strings: $a = \"abc\" fullword condition: $a }",
"xabcx");
assert_false_rule(
"rule test { strings: $a = \"abc\" fullword condition: $a }",
"xabc");
assert_false_rule(
"rule test { strings: $a = \"abc\" fullword condition: $a }",
"abcx");
assert_false_rule(
"rule test { strings: $a = \"abc\" ascii wide fullword condition: $a }",
"abcx");
assert_true_rule_blob(
"rule test { strings: $a = \"abc\" ascii wide fullword condition: $a }",
"a\0abc");
assert_true_rule_blob(
"rule test { strings: $a = \"abc\" wide fullword condition: $a }",
"a\0b\0c\0");
assert_false_rule_blob(
"rule test { strings: $a = \"abc\" wide fullword condition: $a }",
"x\0a\0b\0c\0x\0");
assert_false_rule_blob(
"rule test { strings: $a = \"ab\" wide fullword condition: $a }",
"x\0a\0b\0");
assert_false_rule_blob(
"rule test { strings: $a = \"abc\" wide fullword condition: $a }",
"x\0a\0b\0c\0");
assert_true_rule_blob(
"rule test { strings: $a = \"abc\" wide fullword condition: $a }",
"x\001a\0b\0c\0");
assert_true_rule(
"rule test {\n\
strings:\n\
$a = \"abcdef\"\n\
$b = \"cdef\"\n\
$c = \"ef\"\n\
condition:\n\
all of them\n\
}", "abcdef");
} | 0 | [
"CWE-476",
"CWE-703",
"CWE-125"
] | yara | 3119b232c9c453c98d8fa8b6ae4e37ba18117cd4 | 326,106,697,596,578,980,000,000,000,000,000,000,000 | 135 | re_lexer: Make reading escape sequences more robust (#586)
* Add test for issue #503
* re_lexer: Make reading escape sequences more robust
This commit fixes parsing incomplete escape sequences at the end of a
regular expression and parsing things like \xxy (invalid hex digits)
which before were silently turned into (char)255.
Close #503
* Update re_lexer.c |
struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *vma)
{
struct anon_vma *anon_vma;
struct vm_area_struct *near;
near = vma->vm_next;
if (!near)
goto try_prev;
anon_vma = reusable_anon_vma(near, vma, near);
if (anon_vma)
return anon_vma;
try_prev:
near = vma->vm_prev;
if (!near)
goto none;
anon_vma = reusable_anon_vma(near, near, vma);
if (anon_vma)
return anon_vma;
none:
/*
* There's no absolute need to look only at touching neighbours:
* we could search further afield for "compatible" anon_vmas.
* But it would probably just be a waste of time searching,
* or lead to too many vmas hanging off the same anon_vma.
* We're trying to allow mprotect remerging later on,
* not trying to minimize memory used for anon_vmas.
*/
return NULL;
} | 0 | [
"CWE-119"
] | linux | 1be7107fbe18eed3e319a6c3e83c78254b693acb | 119,622,447,415,865,770,000,000,000,000,000,000,000 | 31 | mm: larger stack guard gap, between vmas
Stack guard page is a useful feature to reduce a risk of stack smashing
into a different mapping. We have been using a single page gap which
is sufficient to prevent having stack adjacent to a different mapping.
But this seems to be insufficient in the light of the stack usage in
userspace. E.g. glibc uses as large as 64kB alloca() in many commonly
used functions. Others use constructs liks gid_t buffer[NGROUPS_MAX]
which is 256kB or stack strings with MAX_ARG_STRLEN.
This will become especially dangerous for suid binaries and the default
no limit for the stack size limit because those applications can be
tricked to consume a large portion of the stack and a single glibc call
could jump over the guard page. These attacks are not theoretical,
unfortunatelly.
Make those attacks less probable by increasing the stack guard gap
to 1MB (on systems with 4k pages; but make it depend on the page size
because systems with larger base pages might cap stack allocations in
the PAGE_SIZE units) which should cover larger alloca() and VLA stack
allocations. It is obviously not a full fix because the problem is
somehow inherent, but it should reduce attack space a lot.
One could argue that the gap size should be configurable from userspace,
but that can be done later when somebody finds that the new 1MB is wrong
for some special case applications. For now, add a kernel command line
option (stack_guard_gap) to specify the stack gap size (in page units).
Implementation wise, first delete all the old code for stack guard page:
because although we could get away with accounting one extra page in a
stack vma, accounting a larger gap can break userspace - case in point,
a program run with "ulimit -S -v 20000" failed when the 1MB gap was
counted for RLIMIT_AS; similar problems could come with RLIMIT_MLOCK
and strict non-overcommit mode.
Instead of keeping gap inside the stack vma, maintain the stack guard
gap as a gap between vmas: using vm_start_gap() in place of vm_start
(or vm_end_gap() in place of vm_end if VM_GROWSUP) in just those few
places which need to respect the gap - mainly arch_get_unmapped_area(),
and and the vma tree's subtree_gap support for that.
Original-patch-by: Oleg Nesterov <[email protected]>
Original-patch-by: Michal Hocko <[email protected]>
Signed-off-by: Hugh Dickins <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Tested-by: Helge Deller <[email protected]> # parisc
Signed-off-by: Linus Torvalds <[email protected]> |
comics_document_init (ComicsDocument *comics_document)
{
comics_document->archive = NULL;
comics_document->page_names = NULL;
comics_document->extract_command = NULL;
} | 0 | [] | atril | f4291fd62f7dfe6460d2406a979ccfac0c68dd59 | 271,662,584,993,166,420,000,000,000,000,000,000,000 | 6 | comics: make the files containing "--checkpoint-action=" unsupported
Fixes #257 |
bool input_device_exists(const bdaddr_t *src, const bdaddr_t *dst)
{
if (find_device(src, dst))
return true;
return false;
} | 0 | [] | bluez | 3cccdbab2324086588df4ccf5f892fb3ce1f1787 | 215,182,980,606,259,800,000,000,000,000,000,000,000 | 7 | HID accepts bonded device connections only.
This change adds a configuration for platforms to choose a more secure
posture for the HID profile. While some older mice are known to not
support pairing or encryption, some platform may choose a more secure
posture by requiring the device to be bonded and require the
connection to be encrypted when bonding is required.
Reference:
https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00352.html |
static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2, const int16_t *v3, int order, int mul)
{
int res = 0;
while (order--) {
res += *v1 * *v2++;
*v1++ += mul * *v3++;
}
return res;
} | 0 | [
"CWE-703",
"CWE-189"
] | FFmpeg | 454a11a1c9c686c78aa97954306fb63453299760 | 270,484,479,688,928,400,000,000,000,000,000,000,000 | 9 | avcodec/dsputil: fix signedness in sizeof() comparissions
Signed-off-by: Michael Niedermayer <[email protected]> |
MOBI_RET mobi_build_opf_guide(OPF *opf, const MOBIRawml *rawml) {
/* parse guide data */
if (rawml == NULL || rawml->guide == NULL) {
debug_print("%s\n", "Initialization failed");
return MOBI_INIT_FAILED;
}
size_t i = 0;
size_t j = 0;
MOBI_RET ret;
size_t count = rawml->guide->entries_count;
if (count == 0) {
return MOBI_SUCCESS;
}
opf->guide = malloc(sizeof(OPFguide));
if (opf->guide == NULL) {
debug_print("%s\n", "Memory allocation failed");
return MOBI_MALLOC_FAILED;
}
OPFreference **reference = malloc((count + 1) * sizeof(OPFreference*));
if (reference == NULL) {
free(opf->guide);
opf->guide = NULL;
debug_print("%s\n", "Memory allocation failed");
return MOBI_MALLOC_FAILED;
}
if (rawml->guide->cncx_record == NULL) {
free(reference);
free(opf->guide);
opf->guide = NULL;
debug_print("%s\n", "Missing cncx record");
return MOBI_DATA_CORRUPT;
}
while (i < count) {
const MOBIIndexEntry *guide_entry = &rawml->guide->entries[i];
const char *type = guide_entry->label;
uint32_t cncx_offset;
ret = mobi_get_indxentry_tagvalue(&cncx_offset, guide_entry, INDX_TAG_GUIDE_TITLE_CNCX);
if (ret != MOBI_SUCCESS) {
free(reference);
free(opf->guide);
opf->guide = NULL;
return ret;
}
const MOBIPdbRecord *cncx_record = rawml->guide->cncx_record;
char *ref_title = mobi_get_cncx_string_utf8(cncx_record, cncx_offset, rawml->guide->encoding);
if (ref_title == NULL) {
free(reference);
free(opf->guide);
opf->guide = NULL;
debug_print("%s\n", "Memory allocation failed");
return MOBI_MALLOC_FAILED;
}
uint32_t frag_number = MOBI_NOTSET;
ret = mobi_get_indxentry_tagvalue(&frag_number, guide_entry, INDX_TAG_FRAG_POSITION);
if (ret != MOBI_SUCCESS) {
debug_print("INDX_TAG_FRAG_POSITION not found (%i)\n", ret);
free(ref_title);
i++;
continue;
/* FIXME: I need some examples which use other tags */
//mobi_get_indxentry_tagvalue(&frag_number, guide_entry, INDX_TAG_FRAG_FILE_NR);
}
if (frag_number >= rawml->frag->entries_count) {
debug_print("Wrong frag entry index (%i)\n", frag_number);
free(ref_title);
i++;
continue;
}
const MOBIIndexEntry *frag_entry = &rawml->frag->entries[frag_number];
uint32_t file_number;
ret = mobi_get_indxentry_tagvalue(&file_number, frag_entry, INDX_TAG_FRAG_FILE_NR);
if (ret != MOBI_SUCCESS) {
free(reference);
free(opf->guide);
free(ref_title);
opf->guide = NULL;
return ret;
}
/* check if valid guide type */
char *ref_type;
size_t type_size = strlen(type);
if (!mobi_is_guide_type(type)) {
/* prepend "other." prefix */
type_size += 6;
ref_type = malloc(type_size + 1);
if (ref_type == NULL) {
free(reference);
free(opf->guide);
opf->guide = NULL;
free(ref_title);
debug_print("%s\n", "Memory allocation failed");
return MOBI_MALLOC_FAILED;
}
snprintf(ref_type, type_size + 1, "other.%s", type);
} else {
ref_type = malloc(type_size + 1);
if (ref_type == NULL) {
free(reference);
free(opf->guide);
opf->guide = NULL;
free(ref_title);
debug_print("%s\n", "Memory allocation failed");
return MOBI_MALLOC_FAILED;
}
memcpy(ref_type, type, type_size);
ref_type[type_size] = '\0';
}
debug_print("<reference type=\"%s\" title=\"%s\" href=\"part%05u.html\" />", ref_type, ref_title, file_number);
char href[FILENAME_MAX + 1];
snprintf(href, sizeof(href), "part%05u.html", file_number);
char *ref_href = strdup(href);
reference[j] = calloc(1, sizeof(OPFreference));
*reference[j] = (OPFreference) { ref_type, ref_title, ref_href };
i++;
j++;
}
/* terminate array with NULL */
reference[j] = NULL;
opf->guide->reference = reference;
return MOBI_SUCCESS;
} | 0 | [
"CWE-476"
] | libmobi | c0699c8693c47f14a2e57dec7292e862ac7adf9c | 84,501,395,373,428,050,000,000,000,000,000,000,000 | 121 | Fix undefined behavior when passing null to strdup |
GF_Err pmax_dump(GF_Box *a, FILE * trace)
{
GF_PMAXBox *p;
p = (GF_PMAXBox *)a;
gf_isom_box_dump_start(a, "MaxPacketSizeBox", trace);
fprintf(trace, "MaximumSize=\"%d\">\n", p->maxSize);
gf_isom_box_dump_done("MaxPacketSizeBox", a, trace);
return GF_OK;
} | 0 | [
"CWE-125"
] | gpac | bceb03fd2be95097a7b409ea59914f332fb6bc86 | 72,641,623,963,508,930,000,000,000,000,000,000,000 | 9 | fixed 2 possible heap overflows (inc. #1088) |
static void cmdloop(void)
{
int c, r = 0, mode;
static struct buf cmd, arg1, arg2, arg3, arg4;
char *p, *result, buf[1024];
const char *err;
uint32_t uid, last;
struct backend *be;
char curgroup[MAX_MAILBOX_BUFFER] = "";
allowanonymous = config_getswitch(IMAPOPT_ALLOWANONYMOUSLOGIN);
for (;;) {
/* Flush any buffered output */
prot_flush(nntp_out);
if (backend_current) prot_flush(backend_current->out);
/* Check for shutdown file */
if (shutdown_file(buf, sizeof(buf)) ||
(nntp_userid &&
userdeny(nntp_userid, config_ident, buf, sizeof(buf)))) {
prot_printf(nntp_out, "400 %s\r\n", buf);
shut_down(0);
}
signals_poll();
if (!proxy_check_input(protin, nntp_in, nntp_out,
backend_current ? backend_current->in : NULL,
NULL, 0)) {
/* No input from client */
continue;
}
if (group_state &&
config_getswitch(IMAPOPT_DISCONNECT_ON_VANISHED_MAILBOX)) {
if (group_state->mailbox->i.options & OPT_MAILBOX_DELETED) {
/* Mailbox has been (re)moved */
syslog(LOG_WARNING,
"Newsgroup %s has been (re)moved out from under client",
group_state->mailbox->name);
prot_printf(nntp_out,
"400 Newsgroup has been (re)moved\r\n");
shut_down(0);
}
}
/* Parse command name */
c = getword(nntp_in, &cmd);
if (c == EOF) {
if ((err = prot_error(nntp_in)) != NULL
&& strcmp(err, PROT_EOF_STRING)) {
syslog(LOG_WARNING, "%s, closing connection", err);
prot_printf(nntp_out, "400 %s\r\n", err);
}
return;
}
if (!cmd.s[0]) {
prot_printf(nntp_out, "501 Empty command\r\n");
eatline(nntp_in, c);
continue;
}
if (Uislower(cmd.s[0]))
cmd.s[0] = toupper((unsigned char) cmd.s[0]);
for (p = &cmd.s[1]; *p; p++) {
if (Uisupper(*p)) *p = tolower((unsigned char) *p);
}
/* Ihave/Takethis only allowed for feeders */
if (!(nntp_capa & MODE_FEED) &&
strchr("IT", cmd.s[0])) goto noperm;
/* Body/Date/Group/Newgroups/Newnews/Next/Over/Post/Xhdr/Xover/Xpat
only allowed for readers */
if (!(nntp_capa & MODE_READ) &&
strchr("BDGNOPX", cmd.s[0])) goto noperm;
/* Only Authinfo/Capabilities/Check/Head/Help/Ihave/List Active/
Mode/Quit/Starttls/Stat/Takethis allowed when not logged in */
if (!nntp_userid && !allowanonymous &&
!strchr("ACHILMQST", cmd.s[0])) goto nologin;
/* In case a [LIST]GROUP fails or
a retrieval by msgid makes us switch groups */
strcpy(curgroup, group_state ? group_state->mailbox->name : "");
switch (cmd.s[0]) {
case 'A':
if (!strcmp(cmd.s, "Authinfo")) {
if (c != ' ') goto missingargs;
c = getword(nntp_in, &arg1); /* subcommand */
if (c == EOF) goto missingargs;
lcase(arg1.s);
if (!strcmp(arg1.s, "user") || !strcmp(arg1.s, "pass")) {
if (c != ' ') goto missingargs;
c = getuserpass(nntp_in, &arg2); /* user/pass */
if (c == EOF) goto missingargs;
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
if (arg1.s[0] == 'u')
cmd_authinfo_user(arg2.s);
else
cmd_authinfo_pass(arg2.s);
}
else if (!strcmp(arg1.s, "sasl") || !strcmp(arg1.s, "generic")) {
arg2.len = arg3.len = 0;
/* mech name required for SASL but not GENERIC */
if ((arg1.s[0] == 's') && (c != ' ')) goto missingargs;
if (c == ' ') {
c = getword(nntp_in, &arg2); /* mech name */
if (c == EOF) goto missingargs;
if (c == ' ') {
c = getword(nntp_in, &arg3); /* init response */
if (c == EOF) goto missingargs;
}
}
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
cmd_authinfo_sasl(arg1.s, arg2.len ? arg2.s : NULL,
arg3.len ? arg3.s : NULL);
}
else
prot_printf(nntp_out,
"501 Unrecognized AUTHINFO command\r\n");
}
else if (!(nntp_capa & MODE_READ)) goto noperm;
else if (!nntp_userid && !allowanonymous) goto nologin;
else if (!strcmp(cmd.s, "Article")) {
char *msgid;
mode = ARTICLE_ALL;
article:
if (arg1.s) *arg1.s = 0;
if (c == ' ') {
c = getword(nntp_in, &arg1); /* number/msgid (optional) */
if (c == EOF) goto missingargs;
}
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
if (parserange(arg1.s, &uid, NULL, &msgid, &be) != -1) {
if (be) {
if (arg1.s && *arg1.s)
prot_printf(be->out, "%s %s\r\n", cmd.s, arg1.s);
else
prot_printf(be->out, "%s\r\n", cmd.s);
if (be != backend_current) {
r = read_response(be, 0, &result);
if (r) goto noopengroup;
prot_printf(nntp_out, "%s", result);
if (!strncmp(result, "22", 2) &&
mode != ARTICLE_STAT) {
pipe_to_end_of_response(be, 0);
}
}
}
else
cmd_article(mode, msgid, uid);
}
if (msgid) goto prevgroup;
}
else goto badcmd;
break;
case 'B':
if (!strcmp(cmd.s, "Body")) {
mode = ARTICLE_BODY;
goto article;
}
else goto badcmd;
break;
case 'C':
if (!strcmp(cmd.s, "Capabilities")) {
arg1.len = 0;
if (c == ' ') {
c = getword(nntp_in, &arg1); /* keyword (optional) */
if (c == EOF) goto missingargs;
}
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
cmd_capabilities(arg1.s);
}
else if (!(nntp_capa & MODE_FEED)) goto noperm;
else if (!strcmp(cmd.s, "Check")) {
mode = POST_CHECK;
goto ihave;
}
else goto badcmd;
break;
case 'D':
if (!strcmp(cmd.s, "Date")) {
time_t now = time(NULL);
struct tm *my_tm = gmtime(&now);
char buf[15];
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
strftime(buf, sizeof(buf), "%Y%m%d%H%M%S", my_tm);
prot_printf(nntp_out, "111 %s\r\n", buf);
}
else goto badcmd;
break;
case 'G':
if (!strcmp(cmd.s, "Group")) {
arg2.len = 0; /* GROUP command (no range) */
group:
#define LISTGROUP (arg2.len)
if (!LISTGROUP && c != ' ') goto missingargs;
if (c == ' ') {
c = getword(nntp_in, &arg1); /* group */
if (c == EOF) goto missingargs;
}
if (LISTGROUP && c == ' ') {
c = getword(nntp_in, &arg2); /* range (optional) */
if (c == EOF) goto missingargs;
}
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
be = backend_current;
if (arg1.len &&
(!is_newsgroup(arg1.s) ||
(r = open_group(arg1.s, 1, &be, NULL)))) goto nogroup;
else if (be) {
prot_printf(be->out, "%s", cmd.s);
if (arg1.len) {
prot_printf(be->out, " %s", arg1.s);
if (LISTGROUP) prot_printf(be->out, " %s", arg2.s);
}
prot_printf(be->out, "\r\n");
r = read_response(be, 0, &result);
if (r) goto nogroup;
prot_printf(nntp_out, "%s", result);
if (!strncmp(result, "211", 3)) {
if (LISTGROUP) pipe_to_end_of_response(be, 0);
if (backend_current && backend_current != be) {
/* remove backend_current from the protgroup */
protgroup_delete(protin, backend_current->in);
}
backend_current = be;
/* add backend_current to the protgroup */
protgroup_insert(protin, backend_current->in);
}
}
else if (!group_state) goto noopengroup;
else if (LISTGROUP &&
parserange(arg2.s, &uid, &last, NULL, NULL) != 0) {
/* parserange() will handle error code -- do nothing */
}
else {
if (backend_current) {
/* remove backend_current from the protgroup */
protgroup_delete(protin, backend_current->in);
}
backend_current = NULL;
nntp_exists = group_state->exists;
nntp_current = nntp_exists > 0;
prot_printf(nntp_out, "211 %u %lu %lu %s\r\n",
nntp_exists,
nntp_exists ? index_getuid(group_state, 1) :
group_state->last_uid+1,
nntp_exists ? index_getuid(group_state, nntp_exists) :
group_state->last_uid,
group_state->mailbox->name + strlen(newsprefix));
if (LISTGROUP) {
int msgno, last_msgno;
msgno = index_finduid(group_state, uid);
if (!msgno || index_getuid(group_state, msgno) != uid) {
msgno++;
}
last_msgno = index_finduid(group_state, last);
for (; msgno <= last_msgno; msgno++) {
prot_printf(nntp_out, "%u\r\n",
index_getuid(group_state, msgno));
}
prot_printf(nntp_out, ".\r\n");
}
}
#undef LISTGROUP
}
else goto badcmd;
break;
case 'H':
if (!strcmp(cmd.s, "Head")) {
mode = ARTICLE_HEAD;
goto article;
}
else if (!strcmp(cmd.s, "Help")) {
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
cmd_help();
}
else if (!(nntp_capa & MODE_READ)) goto noperm;
else if (!nntp_userid && !allowanonymous) goto nologin;
else if (!strcmp(cmd.s, "Hdr")) {
char *msgid;
hdr:
if (arg2.s) *arg2.s = 0;
if (c != ' ') goto missingargs;
c = getword(nntp_in, &arg1); /* header */
if (c == EOF) goto missingargs;
if (c == ' ') {
c = getword(nntp_in, &arg2); /* range (optional) */
if (c == EOF) goto missingargs;
}
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
if (parserange(arg2.s, &uid, &last, &msgid, &be) != -1) {
if (be) {
if (arg2.s && *arg2.s)
prot_printf(be->out, "%s %s %s\r\n",
cmd.s, arg1.s, arg2.s);
else
prot_printf(be->out, "%s %s\r\n", cmd.s, arg1.s);
if (be != backend_current) {
r = read_response(be, 0, &result);
if (r) goto noopengroup;
prot_printf(nntp_out, "%s", result);
if (!strncmp(result, "22", 2)) { /* 221 or 225 */
pipe_to_end_of_response(be, 0);
}
}
}
else
cmd_hdr(cmd.s, arg1.s, NULL, msgid, uid, last);
}
if (msgid) goto prevgroup;
}
else goto badcmd;
break;
case 'I':
if (!strcmp(cmd.s, "Ihave")) {
mode = POST_IHAVE;
ihave:
if (c != ' ') goto missingargs;
c = getword(nntp_in, &arg1); /* msgid */
if (c == EOF) goto missingargs;
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
cmd_post(arg1.s, mode);
}
else goto badcmd;
break;
case 'L':
if (!strcmp(cmd.s, "List")) {
arg1.len = arg2.len = 0;
if (c == ' ') {
c = getword(nntp_in, &arg1); /* subcommand (optional) */
if (c == EOF) goto missingargs;
if (c == ' ') {
c = getword(nntp_in, &arg2); /* argument (optional) */
if (c == EOF) goto missingargs;
}
}
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
cmd_list(arg1.len ? arg1.s : NULL, arg2.len ? arg2.s : NULL);
goto prevgroup; /* In case we did LIST [ACTIVE] */
}
else if (!(nntp_capa & MODE_READ)) goto noperm;
else if (!nntp_userid && !allowanonymous) goto nologin;
else if (!strcmp(cmd.s, "Last")) {
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
if (backend_current) {
prot_printf(backend_current->out, "LAST\r\n");
}
else if (!group_state) goto noopengroup;
else if (!nntp_current) goto nocurrent;
else if (nntp_current == 1) {
prot_printf(nntp_out,
"422 No previous article in this group\r\n");
}
else {
char *msgid = index_get_msgid(group_state, --nntp_current);
prot_printf(nntp_out, "223 %u %s\r\n",
index_getuid(group_state, nntp_current),
msgid ? msgid : "<0>");
if (msgid) free(msgid);
}
}
else if (!strcmp(cmd.s, "Listgroup")) {
arg1.len = 0; /* group is optional */
buf_setcstr(&arg2, "1-"); /* default range is all */
buf_cstring(&arg2); /* appends a '\0' */
goto group;
}
else goto badcmd;
break;
case 'M':
if (!strcmp(cmd.s, "Mode")) {
if (c != ' ') goto missingargs;
c = getword(nntp_in, &arg1); /* mode */
if (c == EOF) goto missingargs;
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
cmd_mode(arg1.s);
}
else goto badcmd;
break;
case 'N':
if (!strcmp(cmd.s, "Newgroups")) {
time_t tstamp;
arg3.len = 0;
if (c != ' ') goto missingargs;
c = getword(nntp_in, &arg1); /* date */
if (c != ' ') goto missingargs;
c = getword(nntp_in, &arg2); /* time */
if (c == EOF) goto missingargs;
if (c == ' ') {
c = getword(nntp_in, &arg3); /* "GMT" (optional) */
if (c == EOF) goto missingargs;
}
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
if ((tstamp = parse_datetime(arg1.s, arg2.s,
arg3.len ? arg3.s : NULL)) < 0)
goto baddatetime;
cmd_newgroups(tstamp);
}
else if (!strcmp(cmd.s, "Newnews")) {
time_t tstamp;
if (!config_getswitch(IMAPOPT_ALLOWNEWNEWS))
goto cmddisabled;
arg4.len = 0;
if (c != ' ') goto missingargs;
c = getword(nntp_in, &arg1); /* wildmat */
if (c != ' ') goto missingargs;
c = getword(nntp_in, &arg2); /* date */
if (c != ' ') goto missingargs;
c = getword(nntp_in, &arg3); /* time */
if (c == EOF) goto missingargs;
if (c == ' ') {
c = getword(nntp_in, &arg4); /* "GMT" (optional) */
if (c == EOF) goto missingargs;
}
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
if ((tstamp = parse_datetime(arg2.s, arg3.s,
arg4.len ? arg4.s : NULL)) < 0)
goto baddatetime;
cmd_newnews(arg1.s, tstamp);
}
else if (!strcmp(cmd.s, "Next")) {
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
if (backend_current) {
prot_printf(backend_current->out, "NEXT\r\n");
}
else if (!group_state) goto noopengroup;
else if (!nntp_current) goto nocurrent;
else if (nntp_current == nntp_exists) {
prot_printf(nntp_out,
"421 No next article in this group\r\n");
}
else {
char *msgid = index_get_msgid(group_state, ++nntp_current);
prot_printf(nntp_out, "223 %u %s\r\n",
index_getuid(group_state, nntp_current),
msgid ? msgid : "<0>");
if (msgid) free(msgid);
}
}
else goto badcmd;
break;
case 'O':
if (!strcmp(cmd.s, "Over")) {
char *msgid;
over:
if (arg1.s) *arg1.s = 0;
if (c == ' ') {
c = getword(nntp_in, &arg1); /* range/msgid (optional) */
if (c == EOF) goto missingargs;
}
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
msgid = NULL;
if (parserange(arg1.s, &uid, &last,
/* XOVER doesn't accept message-id */
(cmd.s[0] == 'X' ? NULL : &msgid), &be) != -1) {
if (be) {
if (arg1.s && *arg1.s)
prot_printf(be->out, "%s %s\r\n", cmd.s, arg1.s);
else
prot_printf(be->out, "%s\r\n", cmd.s);
if (be != backend_current) {
r = read_response(be, 0, &result);
if (r) goto noopengroup;
prot_printf(nntp_out, "%s", result);
if (!strncmp(result, "224", 3)) {
pipe_to_end_of_response(be, 0);
}
}
}
else
cmd_over(msgid, uid, last);
}
if (msgid) goto prevgroup;
}
else goto badcmd;
break;
case 'P':
if (!strcmp(cmd.s, "Post")) {
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
cmd_post(NULL, POST_POST);
}
else goto badcmd;
break;
case 'Q':
if (!strcmp(cmd.s, "Quit")) {
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
prot_printf(nntp_out, "205 Connection closing\r\n");
return;
}
else goto badcmd;
break;
case 'S':
if (!strcmp(cmd.s, "Starttls") && tls_enabled()) {
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
/* XXX discard any input pipelined after STARTTLS */
prot_flush(nntp_in);
cmd_starttls(0);
}
else if (!strcmp(cmd.s, "Stat")) {
mode = ARTICLE_STAT;
goto article;
}
else if (!nntp_userid && !allowanonymous) goto nologin;
else if (!strcmp(cmd.s, "Slave")) {
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
prot_printf(nntp_out, "202 Slave status noted\r\n");
}
else goto badcmd;
break;
case 'T':
if (!strcmp(cmd.s, "Takethis")) {
mode = POST_TAKETHIS;
goto ihave;
}
else goto badcmd;
break;
case 'X':
if (!strcmp(cmd.s, "Xhdr")) {
goto hdr;
}
else if (!strcmp(cmd.s, "Xover")) {
goto over;
}
else if (!strcmp(cmd.s, "Xpat")) {
char *msgid;
if (c != ' ') goto missingargs;
c = getword(nntp_in, &arg1); /* header */
if (c != ' ') goto missingargs;
/* gobble extra whitespace (hack for Mozilla) */
while ((c = prot_getc(nntp_in)) == ' ');
prot_ungetc(c, nntp_in);
c = getword(nntp_in, &arg2); /* range */
if (c != ' ') goto missingargs;
c = getword(nntp_in, &arg3); /* wildmat */
if (c == EOF) goto missingargs;
/* XXX per RFC 2980, we can have multiple patterns */
if (c == '\r') c = prot_getc(nntp_in);
if (c != '\n') goto extraargs;
if (parserange(arg2.s, &uid, &last, &msgid, &be) != -1) {
if (be) {
prot_printf(be->out, "%s %s %s %s\r\n",
cmd.s, arg1.s, arg2.s, arg3.s);
if (be != backend_current) {
r = read_response(be, 0, &result);
if (r) goto noopengroup;
prot_printf(nntp_out, "%s", result);
if (!strncmp(result, "221", 3)) {
pipe_to_end_of_response(be, 0);
}
}
}
else
cmd_hdr(cmd.s, arg1.s, arg3.s, msgid, uid, last);
}
if (msgid) goto prevgroup;
}
else goto badcmd;
break;
default:
badcmd:
prot_printf(nntp_out, "500 Unrecognized command\r\n");
eatline(nntp_in, c);
}
continue;
noperm:
prot_printf(nntp_out, "502 Permission denied\r\n");
eatline(nntp_in, c);
continue;
nologin:
prot_printf(nntp_out, "480 Authentication required\r\n");
eatline(nntp_in, c);
continue;
cmddisabled:
prot_printf(nntp_out, "503 \"%s\" disabled\r\n", cmd.s);
eatline(nntp_in, c);
continue;
extraargs:
prot_printf(nntp_out, "501 Unexpected extra argument\r\n");
eatline(nntp_in, c);
continue;
missingargs:
prot_printf(nntp_out, "501 Missing argument\r\n");
eatline(nntp_in, c);
continue;
baddatetime:
prot_printf(nntp_out, "501 Bad date/time\r\n");
continue;
nogroup:
prot_printf(nntp_out, "411 No such newsgroup (%s)\r\n",
error_message(r));
prevgroup:
/* Return to previously selected group */
if (*curgroup &&
(!group_state || strcmp(curgroup, group_state->mailbox->name))) {
open_group(curgroup, 1, NULL, NULL);
}
continue;
noopengroup:
prot_printf(nntp_out, "412 No newsgroup selected\r\n");
continue;
nocurrent:
prot_printf(nntp_out, "420 Current article number is invalid\r\n");
continue;
}
} | 1 | [
"CWE-287"
] | cyrus-imapd | 77903669e04c9788460561dd0560b9c916519594 | 36,227,003,234,558,720,000,000,000,000,000,000,000 | 735 | Secunia SA46093 - make sure nntp authentication completes
Discovered by Stefan Cornelius, Secunia Research
The vulnerability is caused due to the access restriction for certain
commands only checking whether or not variable "nntp_userid" is non-NULL,
without performing additional checks to verify that a complete, successful
authentication actually took place. The variable "nntp_userid" can be set to
point to a string holding the username (changing it to a non-NULL, thus
allowing attackers to bypass the checks) by sending an "AUTHINFO USER"
command. The variable is not reset to NULL until e.g. a wrong "AUTHINFO
PASS" command is received. This can be exploited to bypass the
authentication mechanism and allows access to e.g. the "NEWNEWS" or the
"LIST NEWSGROUPS" commands by sending an "AUTHINFO USER" command without a
following "AUTHINFO PASS" command. |
bool Item_param::convert_str_value(THD *thd)
{
bool rc= FALSE;
if (state == STRING_VALUE || state == LONG_DATA_VALUE)
{
/*
Check is so simple because all charsets were set up properly
in setup_one_conversion_function, where typecode of
placeholder was also taken into account: the variables are different
here only if conversion is really necessary.
*/
if (value.cs_info.final_character_set_of_str_value !=
value.cs_info.character_set_of_placeholder)
{
rc= thd->convert_string(&str_value,
value.cs_info.character_set_of_placeholder,
value.cs_info.final_character_set_of_str_value);
}
else
str_value.set_charset(value.cs_info.final_character_set_of_str_value);
/* Here str_value is guaranteed to be in final_character_set_of_str_value */
max_length= str_value.numchars() * str_value.charset()->mbmaxlen;
/* For the strings converted to numeric form within some functions */
decimals= NOT_FIXED_DEC;
/*
str_value_ptr is returned from val_str(). It must be not alloced
to prevent it's modification by val_str() invoker.
*/
str_value_ptr.set(str_value.ptr(), str_value.length(),
str_value.charset());
/* Synchronize item charset with value charset */
collation.set(str_value.charset(), DERIVATION_COERCIBLE);
}
return rc;
} | 0 | [] | server | b000e169562697aa072600695d4f0c0412f94f4f | 109,141,766,591,082,420,000,000,000,000,000,000,000 | 37 | Bug#26361149 MYSQL SERVER CRASHES AT: COL IN(IFNULL(CONST, COL), NAME_CONST('NAME', NULL))
based on:
commit f7316aa0c9a
Author: Ajo Robert <[email protected]>
Date: Thu Aug 24 17:03:21 2017 +0530
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. |
void Field_longlong::sql_type(String &res) const
{
CHARSET_INFO *cs=res.charset();
res.length(cs->cset->snprintf(cs,(char*) res.ptr(),res.alloced_length(),
"bigint(%d)",(int) field_length));
add_zerofill_and_unsigned(res);
} | 0 | [
"CWE-416",
"CWE-703"
] | server | 08c7ab404f69d9c4ca6ca7a9cf7eec74c804f917 | 21,180,134,072,493,868,000,000,000,000,000,000,000 | 7 | 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]> |
static VALUE cState_array_nl(VALUE self)
{
GET_STATE(self);
return state->array_nl ? rb_str_new(state->array_nl, state->array_nl_len) : rb_str_new2("");
} | 0 | [
"CWE-119",
"CWE-787"
] | json | 8f782fd8e181d9cfe9387ded43a5ca9692266b85 | 225,457,827,303,288,080,000,000,000,000,000,000,000 | 5 | Fix arbitrary heap exposure problem |
int do_attack_deauth( void )
{
int i, n;
int aacks, sacks, caplen;
struct timeval tv;
fd_set rfds;
if(getnet(NULL, 0, 1) != 0)
return 1;
if( memcmp( opt.r_dmac, NULL_MAC, 6 ) == 0 )
printf( "NB: this attack is more effective when targeting\n"
"a connected wireless client (-c <client's mac>).\n" );
n = 0;
while( 1 )
{
if( opt.a_count > 0 && ++n > opt.a_count )
break;
usleep( 180000 );
if( memcmp( opt.r_dmac, NULL_MAC, 6 ) != 0 )
{
/* deauthenticate the target */
memcpy( h80211, DEAUTH_REQ, 26 );
memcpy( h80211 + 16, opt.r_bssid, 6 );
aacks = 0;
sacks = 0;
for( i = 0; i < 64; i++ )
{
if(i == 0)
{
PCT; printf( "Sending 64 directed DeAuth. STMAC:"
" [%02X:%02X:%02X:%02X:%02X:%02X] [%2d|%2d ACKs]\r",
opt.r_dmac[0], opt.r_dmac[1],
opt.r_dmac[2], opt.r_dmac[3],
opt.r_dmac[4], opt.r_dmac[5],
sacks, aacks );
}
memcpy( h80211 + 4, opt.r_dmac, 6 );
memcpy( h80211 + 10, opt.r_bssid, 6 );
if( send_packet( h80211, 26 ) < 0 )
return( 1 );
usleep( 2000 );
memcpy( h80211 + 4, opt.r_bssid, 6 );
memcpy( h80211 + 10, opt.r_dmac, 6 );
if( send_packet( h80211, 26 ) < 0 )
return( 1 );
usleep( 2000 );
while( 1 )
{
FD_ZERO( &rfds );
FD_SET( dev.fd_in, &rfds );
tv.tv_sec = 0;
tv.tv_usec = 1000;
if( select( dev.fd_in + 1, &rfds, NULL, NULL, &tv ) < 0 )
{
if( errno == EINTR ) continue;
perror( "select failed" );
return( 1 );
}
if( ! FD_ISSET( dev.fd_in, &rfds ) )
break;
caplen = read_packet( tmpbuf, sizeof( tmpbuf ), NULL );
if(caplen <= 0 ) break;
if(caplen != 10) continue;
if( tmpbuf[0] == 0xD4)
{
if( memcmp(tmpbuf+4, opt.r_dmac, 6) == 0 )
{
aacks++;
}
if( memcmp(tmpbuf+4, opt.r_bssid, 6) == 0 )
{
sacks++;
}
PCT; printf( "Sending 64 directed DeAuth. STMAC:"
" [%02X:%02X:%02X:%02X:%02X:%02X] [%2d|%2d ACKs]\r",
opt.r_dmac[0], opt.r_dmac[1],
opt.r_dmac[2], opt.r_dmac[3],
opt.r_dmac[4], opt.r_dmac[5],
sacks, aacks );
}
}
}
printf("\n");
}
else
{
/* deauthenticate all stations */
PCT; printf( "Sending DeAuth to broadcast -- BSSID:"
" [%02X:%02X:%02X:%02X:%02X:%02X]\n",
opt.r_bssid[0], opt.r_bssid[1],
opt.r_bssid[2], opt.r_bssid[3],
opt.r_bssid[4], opt.r_bssid[5] );
memcpy( h80211, DEAUTH_REQ, 26 );
memcpy( h80211 + 4, BROADCAST, 6 );
memcpy( h80211 + 10, opt.r_bssid, 6 );
memcpy( h80211 + 16, opt.r_bssid, 6 );
for( i = 0; i < 128; i++ )
{
if( send_packet( h80211, 26 ) < 0 )
return( 1 );
usleep( 2000 );
}
}
}
return( 0 );
} | 0 | [
"CWE-787"
] | aircrack-ng | 091b153f294b9b695b0b2831e65936438b550d7b | 82,018,471,324,912,970,000,000,000,000,000,000,000 | 131 | Aireplay-ng: Fixed tcp_test stack overflow (Closes #14 on GitHub).
git-svn-id: http://svn.aircrack-ng.org/trunk@2417 28c6078b-6c39-48e3-add9-af49d547ecab |
static unsigned int pkt_type_offset(void)
{
struct sk_buff skb_probe = { .pkt_type = ~0, };
u8 *ct = (u8 *) &skb_probe;
unsigned int off;
for (off = 0; off < sizeof(struct sk_buff); off++) {
if (ct[off] == PKT_TYPE_MAX)
return off;
}
pr_err_once("Please fix %s, as pkt_type couldn't be found!\n", __func__);
return -1;
} | 0 | [
"CWE-416",
"CWE-125",
"CWE-189"
] | linux | 05ab8f2647e4221cbdb3856dd7d32bd5407316b3 | 142,259,486,230,768,750,000,000,000,000,000,000,000 | 14 | filter: prevent nla extensions to peek beyond the end of the message
The BPF_S_ANC_NLATTR and BPF_S_ANC_NLATTR_NEST extensions fail to check
for a minimal message length before testing the supplied offset to be
within the bounds of the message. This allows the subtraction of the nla
header to underflow and therefore -- as the data type is unsigned --
allowing far to big offset and length values for the search of the
netlink attribute.
The remainder calculation for the BPF_S_ANC_NLATTR_NEST extension is
also wrong. It has the minuend and subtrahend mixed up, therefore
calculates a huge length value, allowing to overrun the end of the
message while looking for the netlink attribute.
The following three BPF snippets will trigger the bugs when attached to
a UNIX datagram socket and parsing a message with length 1, 2 or 3.
,-[ PoC for missing size check in BPF_S_ANC_NLATTR ]--
| ld #0x87654321
| ldx #42
| ld #nla
| ret a
`---
,-[ PoC for the same bug in BPF_S_ANC_NLATTR_NEST ]--
| ld #0x87654321
| ldx #42
| ld #nlan
| ret a
`---
,-[ PoC for wrong remainder calculation in BPF_S_ANC_NLATTR_NEST ]--
| ; (needs a fake netlink header at offset 0)
| ld #0
| ldx #42
| ld #nlan
| ret a
`---
Fix the first issue by ensuring the message length fulfills the minimal
size constrains of a nla header. Fix the second bug by getting the math
for the remainder calculation right.
Fixes: 4738c1db15 ("[SKFILTER]: Add SKF_ADF_NLATTR instruction")
Fixes: d214c7537b ("filter: add SKF_AD_NLATTR_NEST to look for nested..")
Cc: Patrick McHardy <[email protected]>
Cc: Pablo Neira Ayuso <[email protected]>
Signed-off-by: Mathias Krause <[email protected]>
Acked-by: Daniel Borkmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
static void process_fd_request(void)
{
cont = &rw_cont;
schedule_bh(redo_fd_request);
} | 0 | [
"CWE-264",
"CWE-754"
] | linux | ef87dbe7614341c2e7bfe8d32fcb7028cc97442c | 251,457,527,146,488,040,000,000,000,000,000,000,000 | 5 | floppy: ignore kernel-only members in FDRAWCMD ioctl input
Always clear out these floppy_raw_cmd struct members after copying the
entire structure from userspace so that the in-kernel version is always
valid and never left in an interdeterminate state.
Signed-off-by: Matthew Daley <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
{
__sk_dst_set(sk, dst);
sk->sk_route_caps = dst->dev->features;
if (sk->sk_route_caps & NETIF_F_GSO)
sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE;
sk->sk_route_caps &= ~sk->sk_route_nocaps;
if (sk_can_gso(sk)) {
if (dst->header_len) {
sk->sk_route_caps &= ~NETIF_F_GSO_MASK;
} else {
sk->sk_route_caps |= NETIF_F_SG | NETIF_F_HW_CSUM;
sk->sk_gso_max_size = dst->dev->gso_max_size;
sk->sk_gso_max_segs = dst->dev->gso_max_segs;
}
}
} | 0 | [] | linux | 7bced397510ab569d31de4c70b39e13355046387 | 72,740,872,455,630,490,000,000,000,000,000,000,000 | 17 | net_dma: simple removal
Per commit "77873803363c net_dma: mark broken" net_dma is no longer used
and there is no plan to fix it.
This is the mechanical removal of bits in CONFIG_NET_DMA ifdef guards.
Reverting the remainder of the net_dma induced changes is deferred to
subsequent patches.
Marked for stable due to Roman's report of a memory leak in
dma_pin_iovec_pages():
https://lkml.org/lkml/2014/9/3/177
Cc: Dave Jiang <[email protected]>
Cc: Vinod Koul <[email protected]>
Cc: David Whipple <[email protected]>
Cc: Alexander Duyck <[email protected]>
Cc: <[email protected]>
Reported-by: Roman Gushchin <[email protected]>
Acked-by: David S. Miller <[email protected]>
Signed-off-by: Dan Williams <[email protected]> |
int vhost_add_used(struct vhost_virtqueue *vq, unsigned int head, int len)
{
struct vring_used_elem __user *used;
/* The virtqueue contains a ring of used buffers. Get a pointer to the
* next entry in that used ring. */
used = &vq->used->ring[vq->last_used_idx % vq->num];
if (__put_user(head, &used->id)) {
vq_err(vq, "Failed to write used id");
return -EFAULT;
}
if (__put_user(len, &used->len)) {
vq_err(vq, "Failed to write used len");
return -EFAULT;
}
/* Make sure buffer is written before we update index. */
smp_wmb();
if (__put_user(vq->last_used_idx + 1, &vq->used->idx)) {
vq_err(vq, "Failed to increment used idx");
return -EFAULT;
}
if (unlikely(vq->log_used)) {
/* Make sure data is seen before log. */
smp_wmb();
/* Log used ring entry write. */
log_write(vq->log_base,
vq->log_addr +
((void __user *)used - (void __user *)vq->used),
sizeof *used);
/* Log used index update. */
log_write(vq->log_base,
vq->log_addr + offsetof(struct vring_used, idx),
sizeof vq->used->idx);
if (vq->log_ctx)
eventfd_signal(vq->log_ctx, 1);
}
vq->last_used_idx++;
/* If the driver never bothers to signal in a very long while,
* used index might wrap around. If that happens, invalidate
* signalled_used index we stored. TODO: make sure driver
* signals at least once in 2^16 and remove this. */
if (unlikely(vq->last_used_idx == vq->signalled_used))
vq->signalled_used_valid = false;
return 0;
} | 0 | [] | linux-2.6 | bd97120fc3d1a11f3124c7c9ba1d91f51829eb85 | 141,732,557,956,845,320,000,000,000,000,000,000,000 | 45 | vhost: fix length for cross region descriptor
If a single descriptor crosses a region, the
second chunk length should be decremented
by size translated so far, instead it includes
the full descriptor length.
Signed-off-by: Michael S. Tsirkin <[email protected]>
Acked-by: Jason Wang <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
Word httpCallHandler(void* raw_context, Word uri_ptr, Word uri_size, Word header_pairs_ptr,
Word header_pairs_size, Word body_ptr, Word body_size, Word trailer_pairs_ptr,
Word trailer_pairs_size, Word timeout_milliseconds) {
auto context = WASM_CONTEXT(raw_context)->root_context();
auto uri = context->wasmVm()->getMemory(uri_ptr.u64_, uri_size.u64_);
auto body = context->wasmVm()->getMemory(body_ptr.u64_, body_size.u64_);
auto header_pairs = context->wasmVm()->getMemory(header_pairs_ptr.u64_, header_pairs_size.u64_);
auto trailer_pairs =
context->wasmVm()->getMemory(trailer_pairs_ptr.u64_, trailer_pairs_size.u64_);
if (!uri || !body || !header_pairs || !trailer_pairs) {
return wasmResultToWord(WasmResult::InvalidMemoryAccess);
}
auto headers = toPairs(header_pairs.value());
auto trailers = toPairs(trailer_pairs.value());
return context->httpCall(uri.value(), headers, body.value(), trailers, timeout_milliseconds.u64_);
} | 0 | [
"CWE-476"
] | envoy | 8788a3cf255b647fd14e6b5e2585abaaedb28153 | 214,404,243,343,930,300,000,000,000,000,000,000,000 | 16 | 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]> |
jwe_t * r_jwe_copy(jwe_t * jwe) {
jwe_t * jwe_copy = NULL;
if (jwe != NULL) {
if (r_jwe_init(&jwe_copy) == RHN_OK) {
jwe_copy->alg = jwe->alg;
jwe_copy->enc = jwe->enc;
jwe_copy->token_mode = jwe->token_mode;
if (r_jwe_set_payload(jwe_copy, jwe->payload, jwe->payload_len) == RHN_OK &&
r_jwe_set_iv(jwe_copy, jwe->iv, jwe->iv_len) == RHN_OK &&
r_jwe_set_aad(jwe_copy, jwe->aad, jwe->aad_len) == RHN_OK &&
r_jwe_set_cypher_key(jwe_copy, jwe->key, jwe->key_len) == RHN_OK &&
r_jwe_set_alg(jwe_copy, r_jwe_get_alg(jwe)) == RHN_OK) {
jwe_copy->header_b64url = (unsigned char *)o_strdup((const char *)jwe->header_b64url);
jwe_copy->encrypted_key_b64url = (unsigned char *)o_strdup((const char *)jwe->encrypted_key_b64url);
jwe_copy->ciphertext_b64url = (unsigned char *)o_strdup((const char *)jwe->ciphertext_b64url);
jwe_copy->auth_tag_b64url = (unsigned char *)o_strdup((const char *)jwe->auth_tag_b64url);
r_jwks_free(jwe_copy->jwks_privkey);
jwe_copy->jwks_privkey = r_jwks_copy(jwe->jwks_privkey);
r_jwks_free(jwe_copy->jwks_pubkey);
jwe_copy->jwks_pubkey = r_jwks_copy(jwe->jwks_pubkey);
json_decref(jwe_copy->j_header);
jwe_copy->j_header = json_deep_copy(jwe->j_header);
jwe_copy->j_unprotected_header = json_deep_copy(jwe->j_unprotected_header);
jwe_copy->j_json_serialization = json_deep_copy(jwe->j_json_serialization);
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "r_jwe_copy - Error setting values");
r_jwe_free(jwe_copy);
jwe_copy = NULL;
}
}
}
return jwe_copy;
} | 0 | [
"CWE-787"
] | rhonabwy | b4c2923a1ba4fabf9b55a89244127e153a3e549b | 40,585,674,517,070,993,000,000,000,000,000,000,000 | 34 | Fix buffer overflow on r_jwe_aesgcm_key_unwrap |
static void update_discovery_counters(handlerton *hton, int val)
{
if (hton->discover_table_existence == full_discover_for_existence)
need_full_discover_for_existence+= val;
if (hton->discover_table_names && hton->tablefile_extensions[0])
engines_with_discover_file_names+= val;
if (hton->discover_table)
engines_with_discover+= val;
} | 0 | [
"CWE-416"
] | server | af810407f78b7f792a9bb8c47c8c532eb3b3a758 | 19,132,244,980,528,902,000,000,000,000,000,000,000 | 11 | MDEV-28098 incorrect key in "dup value" error after long unique
reset errkey after using it, so that it wouldn't affect
the next error message in the next statement |
static struct dce_hwseq *dce80_hwseq_create(
struct dc_context *ctx)
{
struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
if (hws) {
hws->ctx = ctx;
hws->regs = &hwseq_reg;
hws->shifts = &hwseq_shift;
hws->masks = &hwseq_mask;
}
return hws;
} | 0 | [
"CWE-400",
"CWE-703",
"CWE-401"
] | linux | 055e547478a11a6360c7ce05e2afc3e366968a12 | 203,304,533,555,053,100,000,000,000,000,000,000,000 | 13 | drm/amd/display: memory leak
In dcn*_clock_source_create when dcn20_clk_src_construct fails allocated
clk_src needs release.
Signed-off-by: Navid Emamdoost <[email protected]>
Signed-off-by: Alex Deucher <[email protected]> |
void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
unsigned long address, bool freeze, struct page *page)
{
spinlock_t *ptl;
struct mm_struct *mm = vma->vm_mm;
unsigned long haddr = address & HPAGE_PMD_MASK;
mmu_notifier_invalidate_range_start(mm, haddr, haddr + HPAGE_PMD_SIZE);
ptl = pmd_lock(mm, pmd);
/*
* If caller asks to setup a migration entries, we need a page to check
* pmd against. Otherwise we can end up replacing wrong page.
*/
VM_BUG_ON(freeze && !page);
if (page && page != pmd_page(*pmd))
goto out;
if (pmd_trans_huge(*pmd)) {
page = pmd_page(*pmd);
if (PageMlocked(page))
clear_page_mlock(page);
} else if (!(pmd_devmap(*pmd) || is_pmd_migration_entry(*pmd)))
goto out;
__split_huge_pmd_locked(vma, pmd, haddr, freeze);
out:
spin_unlock(ptl);
/*
* No need to double call mmu_notifier->invalidate_range() callback.
* They are 3 cases to consider inside __split_huge_pmd_locked():
* 1) pmdp_huge_clear_flush_notify() call invalidate_range() obvious
* 2) __split_huge_zero_page_pmd() read only zero page and any write
* fault will trigger a flush_notify before pointing to a new page
* (it is fine if the secondary mmu keeps pointing to the old zero
* page in the meantime)
* 3) Split a huge pmd into pte pointing to the same page. No need
* to invalidate secondary tlb entry they are all still valid.
* any further changes to individual pte will notify. So no need
* to call mmu_notifier->invalidate_range()
*/
mmu_notifier_invalidate_range_only_end(mm, haddr, haddr +
HPAGE_PMD_SIZE);
} | 0 | [
"CWE-362"
] | linux | a8f97366452ed491d13cf1e44241bc0b5740b1f0 | 207,370,676,513,898,880,000,000,000,000,000,000,000 | 43 | mm, thp: Do not make page table dirty unconditionally in touch_p[mu]d()
Currently, we unconditionally make page table dirty in touch_pmd().
It may result in false-positive can_follow_write_pmd().
We may avoid the situation, if we would only make the page table entry
dirty if caller asks for write access -- FOLL_WRITE.
The patch also changes touch_pud() in the same way.
Signed-off-by: Kirill A. Shutemov <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Hugh Dickins <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
String *Item_cache_int::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
if (!has_value())
return NULL;
str->set_int(value, unsigned_flag, default_charset());
return str;
} | 0 | [] | server | b000e169562697aa072600695d4f0c0412f94f4f | 187,949,184,366,799,140,000,000,000,000,000,000,000 | 8 | Bug#26361149 MYSQL SERVER CRASHES AT: COL IN(IFNULL(CONST, COL), NAME_CONST('NAME', NULL))
based on:
commit f7316aa0c9a
Author: Ajo Robert <[email protected]>
Date: Thu Aug 24 17:03:21 2017 +0530
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. |
xcmalloc (size_t nmemb, size_t size)
{
/* Check for overflow. */
if (nmemb >= ~(size_t) 0 / size)
{
fprintf (stderr,
_("Attempt to allocate an array with an excessive number of elements: 0x%lx\n"),
(long) nmemb);
xexit (1);
}
return xmalloc (nmemb * size);
} | 0 | [
"CWE-703"
] | binutils-gdb | 695c6dfe7e85006b98c8b746f3fd5f913c94ebff | 97,947,292,868,413,730,000,000,000,000,000,000,000 | 13 | PR29370, infinite loop in display_debug_abbrev
The PR29370 testcase is a fuzzed object file with multiple
.trace_abbrev sections. Multiple .trace_abbrev or .debug_abbrev
sections are not a violation of the DWARF standard. The DWARF5
standard even gives an example of multiple .debug_abbrev sections
contained in groups. Caching and lookup of processed abbrevs thus
needs to be done by section and offset rather than base and offset.
(Why base anyway?) Or, since section contents are kept, by a pointer
into the contents.
PR 29370
* dwarf.c (struct abbrev_list): Replace abbrev_base and
abbrev_offset with raw field.
(find_abbrev_list_by_abbrev_offset): Delete.
(find_abbrev_list_by_raw_abbrev): New function.
(process_abbrev_set): Set list->raw and list->next.
(find_and_process_abbrev_set): Replace abbrev list lookup with
new function. Don't set list abbrev_base, abbrev_offset or next. |
static bool nfs41_match_stateid(const nfs4_stateid *s1,
const nfs4_stateid *s2)
{
if (s1->type != s2->type)
return false;
if (memcmp(s1->other, s2->other, sizeof(s1->other)) != 0)
return false;
if (s1->seqid == s2->seqid)
return true;
return s1->seqid == 0 || s2->seqid == 0;
} | 0 | [
"CWE-787"
] | linux | b4487b93545214a9db8cbf32e86411677b0cca21 | 199,418,693,976,561,270,000,000,000,000,000,000,000 | 14 | nfs: Fix getxattr kernel panic and memory overflow
Move the buffer size check to decode_attr_security_label() before memcpy()
Only call memcpy() if the buffer is large enough
Fixes: aa9c2669626c ("NFS: Client implementation of Labeled-NFS")
Signed-off-by: Jeffrey Mitchell <[email protected]>
[Trond: clean up duplicate test of label->len != 0]
Signed-off-by: Trond Myklebust <[email protected]> |
static int ssl_rsa_public_encrypt(SESS_CERT *sc, int len, unsigned char *from,
unsigned char *to, int padding)
{
EVP_PKEY *pkey=NULL;
int i= -1;
if ((sc == NULL) || (sc->peer_key->x509 == NULL) ||
((pkey=X509_get_pubkey(sc->peer_key->x509)) == NULL))
{
SSLerr(SSL_F_SSL_RSA_PUBLIC_ENCRYPT,SSL_R_NO_PUBLICKEY);
return(-1);
}
if (pkey->type != EVP_PKEY_RSA)
{
SSLerr(SSL_F_SSL_RSA_PUBLIC_ENCRYPT,SSL_R_PUBLIC_KEY_IS_NOT_RSA);
goto end;
}
/* we have the public key */
i=RSA_public_encrypt(len,from,to,pkey->pkey.rsa,padding);
if (i < 0)
SSLerr(SSL_F_SSL_RSA_PUBLIC_ENCRYPT,ERR_R_RSA_LIB);
end:
EVP_PKEY_free(pkey);
return(i);
} | 0 | [
"CWE-310"
] | openssl | 270881316664396326c461ec7a124aec2c6cc081 | 124,465,752,052,388,300,000,000,000,000,000,000,000 | 26 | Add and use a constant-time memcmp.
This change adds CRYPTO_memcmp, which compares two vectors of bytes in
an amount of time that's independent of their contents. It also changes
several MAC compares in the code to use this over the standard memcmp,
which may leak information about the size of a matching prefix.
(cherry picked from commit 2ee798880a246d648ecddadc5b91367bee4a5d98)
Conflicts:
crypto/crypto.h
ssl/t1_lib.c
(cherry picked from commit dc406b59f3169fe191e58906df08dce97edb727c)
Conflicts:
crypto/crypto.h
ssl/d1_pkt.c
ssl/s3_pkt.c |
static void tty_serial_init(int fd, int speed,
int parity, int data_bits, int stop_bits)
{
struct termios tty;
speed_t spd;
#if 0
printf("tty_serial_init: speed=%d parity=%c data=%d stop=%d\n",
speed, parity, data_bits, stop_bits);
#endif
tcgetattr (fd, &tty);
#define check_speed(val) if (speed <= val) { spd = B##val; break; }
speed = speed * 10 / 11;
do {
check_speed(50);
check_speed(75);
check_speed(110);
check_speed(134);
check_speed(150);
check_speed(200);
check_speed(300);
check_speed(600);
check_speed(1200);
check_speed(1800);
check_speed(2400);
check_speed(4800);
check_speed(9600);
check_speed(19200);
check_speed(38400);
/* Non-Posix values follow. They may be unsupported on some systems. */
check_speed(57600);
check_speed(115200);
#ifdef B230400
check_speed(230400);
#endif
#ifdef B460800
check_speed(460800);
#endif
#ifdef B500000
check_speed(500000);
#endif
#ifdef B576000
check_speed(576000);
#endif
#ifdef B921600
check_speed(921600);
#endif
#ifdef B1000000
check_speed(1000000);
#endif
#ifdef B1152000
check_speed(1152000);
#endif
#ifdef B1500000
check_speed(1500000);
#endif
#ifdef B2000000
check_speed(2000000);
#endif
#ifdef B2500000
check_speed(2500000);
#endif
#ifdef B3000000
check_speed(3000000);
#endif
#ifdef B3500000
check_speed(3500000);
#endif
#ifdef B4000000
check_speed(4000000);
#endif
spd = B115200;
} while (0);
cfsetispeed(&tty, spd);
cfsetospeed(&tty, spd);
tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
|INLCR|IGNCR|ICRNL|IXON);
tty.c_oflag |= OPOST;
tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN|ISIG);
tty.c_cflag &= ~(CSIZE|PARENB|PARODD|CRTSCTS|CSTOPB);
switch(data_bits) {
default:
case 8:
tty.c_cflag |= CS8;
break;
case 7:
tty.c_cflag |= CS7;
break;
case 6:
tty.c_cflag |= CS6;
break;
case 5:
tty.c_cflag |= CS5;
break;
}
switch(parity) {
default:
case 'N':
break;
case 'E':
tty.c_cflag |= PARENB;
break;
case 'O':
tty.c_cflag |= PARENB | PARODD;
break;
}
if (stop_bits == 2)
tty.c_cflag |= CSTOPB;
tcsetattr (fd, TCSANOW, &tty);
} | 0 | [
"CWE-416"
] | qemu | a4afa548fc6dd9842ed86639b4d37d4d1c4ad480 | 163,227,886,725,523,380,000,000,000,000,000,000,000 | 114 | char: move front end handlers in CharBackend
Since the hanlders are associated with a CharBackend, rather than the
CharDriverState, it is more appropriate to store in CharBackend. This
avoids the handler copy dance in qemu_chr_fe_set_handlers() then
mux_chr_update_read_handler(), by storing the CharBackend pointer
directly.
Also a mux CharDriver should go through mux->backends[focused], since
chr->be will stay NULL. Before that, it was possible to call
chr->handler by mistake with surprising results, for ex through
qemu_chr_be_can_write(), which would result in calling the last set
handler front end, not the one with focus.
Signed-off-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]> |
static void test_bug14169()
{
MYSQL_STMT *stmt;
const char *stmt_text;
MYSQL_RES *res;
MYSQL_FIELD *field;
int rc;
myheader("test_bug14169");
rc= mysql_query(mysql, "drop table if exists t1");
myquery(rc);
rc= mysql_query(mysql, "set session group_concat_max_len=1024");
myquery(rc);
rc= mysql_query(mysql, "create table t1 (f1 int unsigned, f2 varchar(255))");
myquery(rc);
rc= mysql_query(mysql, "insert into t1 values (1,repeat('a',255)),"
"(2,repeat('b',255))");
myquery(rc);
stmt= mysql_stmt_init(mysql);
stmt_text= "select f2,group_concat(f1) from t1 group by f2";
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
myquery(rc);
res= mysql_stmt_result_metadata(stmt);
field= mysql_fetch_fields(res);
if (!opt_silent)
printf("GROUP_CONCAT() result type %i", field[1].type);
DIE_UNLESS(field[1].type == MYSQL_TYPE_BLOB);
mysql_free_result(res);
mysql_stmt_free_result(stmt);
mysql_stmt_close(stmt);
rc= mysql_query(mysql, "drop table t1");
myquery(rc);
} | 0 | [
"CWE-284",
"CWE-295"
] | mysql-server | 3bd5589e1a5a93f9c224badf983cd65c45215390 | 32,082,515,705,230,200,000,000,000,000,000,000,000 | 35 | 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 |
static void php_libxml_exports_dtor(zval *zv)
{
free(Z_PTR_P(zv));
} | 0 | [] | php-src | f15f8fc573eb38c3c73e23e0930063a6f6409ed4 | 185,039,526,740,907,250,000,000,000,000,000,000,000 | 4 | Fix #79971: special character is breaking the path in xml function
The libxml based XML functions accepting a filename actually accept
URIs with possibly percent-encoded characters. Percent-encoded NUL
bytes lead to truncation, like non-encoded NUL bytes would. We catch
those, and let the functions fail with a respective warning. |
swproc(gs_main_instance * minst, const char *arg, arg_list * pal)
{
char sw = arg[1];
ref vtrue;
int code = 0;
#undef initial_enter_name
#define initial_enter_name(nstr, pvalue)\
i_initial_enter_name(minst->i_ctx_p, nstr, pvalue)
make_true(&vtrue);
arg += 2; /* skip - and letter */
switch (sw) {
default:
return 1;
case 0: /* read stdin as a file char-by-char */
/* This is a ******HACK****** for Ghostview. */
minst->heap->gs_lib_ctx->stdin_is_interactive = true;
goto run_stdin;
case '_': /* read stdin with normal buffering */
minst->heap->gs_lib_ctx->stdin_is_interactive = false;
run_stdin:
minst->run_start = false; /* don't run 'start' */
/* Set NOPAUSE so showpage won't try to read from stdin. */
code = swproc(minst, "-dNOPAUSE", pal);
if (code)
return code;
code = gs_main_init2(minst); /* Finish initialization */
if (code < 0)
return code;
code = run_string(minst, ".runstdin", runFlush);
if (code < 0)
return code;
break;
case '-': /* run with command line args */
if (strncmp(arg, "debug=", 6) == 0) {
code = gs_debug_flags_parse(minst->heap, arg+6);
if (code < 0)
return code;
break;
}
/* FALLTHROUGH */
case '+':
pal->expand_ats = false;
/* FALLTHROUGH */
case '@': /* ditto with @-expansion */
{
const char *psarg = arg_next(pal, &code, minst->heap);
if (code < 0)
return e_Fatal;
if (psarg == 0) {
outprintf(minst->heap, "Usage: gs ... -%c file.ps arg1 ... argn\n", sw);
arg_finit(pal);
return e_Fatal;
}
psarg = arg_copy(psarg, minst->heap);
if (psarg == NULL)
code = e_Fatal;
else
code = gs_main_init2(minst);
if (code >= 0)
code = run_string(minst, "userdict/ARGUMENTS[", 0);
if (code >= 0)
while ((arg = arg_next(pal, &code, minst->heap)) != 0) {
code = runarg(minst, "", arg, "", runInit);
if (code < 0)
break;
}
if (code >= 0)
code = runarg(minst, "]put", psarg, ".runfile", runInit | runFlush);
arg_free((char *)psarg, minst->heap);
if (code >= 0)
code = e_Quit;
return code;
}
case 'A': /* trace allocator */
switch (*arg) {
case 0:
gs_alloc_debug = 1;
break;
case '-':
gs_alloc_debug = 0;
break;
default:
puts(minst->heap, "-A may only be followed by -");
return e_Fatal;
}
break;
case 'B': /* set run_string buffer size */
if (*arg == '-')
minst->run_buffer_size = 0;
else {
uint bsize;
if (sscanf((const char *)arg, "%u", &bsize) != 1 ||
bsize <= 0 || bsize > MAX_BUFFERED_SIZE
) {
outprintf(minst->heap,
"-B must be followed by - or size between 1 and %u\n",
MAX_BUFFERED_SIZE);
return e_Fatal;
}
minst->run_buffer_size = bsize;
}
break;
case 'c': /* code follows */
{
bool ats = pal->expand_ats;
code = gs_main_init2(minst);
if (code < 0)
return code;
pal->expand_ats = false;
while ((arg = arg_next(pal, &code, minst->heap)) != 0) {
if (arg[0] == '@' ||
(arg[0] == '-' && !isdigit((unsigned char)arg[1]))
)
break;
code = runarg(minst, "", arg, ".runstring", runBuffer);
if (code < 0)
return code;
}
if (code < 0)
return e_Fatal;
if (arg != 0) {
char *p = arg_copy(arg, minst->heap);
if (p == NULL)
return e_Fatal;
arg_push_string(pal, p, true);
}
pal->expand_ats = ats;
break;
}
case 'E': /* log errors */
switch (*arg) {
case 0:
gs_log_errors = 1;
break;
case '-':
gs_log_errors = 0;
break;
default:
puts(minst->heap, "-E may only be followed by -");
return e_Fatal;
}
break;
case 'f': /* run file of arbitrary name */
if (*arg != 0) {
code = argproc(minst, arg);
if (code < 0)
return code;
}
break;
case 'F': /* run file with buffer_size = 1 */
if (!*arg) {
puts(minst->heap, "-F requires a file name");
return e_Fatal;
} {
uint bsize = minst->run_buffer_size;
minst->run_buffer_size = 1;
code = argproc(minst, arg);
minst->run_buffer_size = bsize;
if (code < 0)
return code;
}
break;
case 'g': /* define device geometry */
{
long width, height;
ref value;
if ((code = gs_main_init1(minst)) < 0)
return code;
if (sscanf((const char *)arg, "%ldx%ld", &width, &height) != 2) {
puts(minst->heap, "-g must be followed by <width>x<height>");
return e_Fatal;
}
make_int(&value, width);
initial_enter_name("DEVICEWIDTH", &value);
make_int(&value, height);
initial_enter_name("DEVICEHEIGHT", &value);
initial_enter_name("FIXEDMEDIA", &vtrue);
break;
}
case 'h': /* print help */
case '?': /* ditto */
print_help(minst);
return e_Info; /* show usage info on exit */
case 'I': /* specify search path */
{
const char *path;
if (arg[0] == 0) {
path = arg_next(pal, &code, minst->heap);
if (code < 0)
return code;
} else
path = arg;
if (path == NULL)
return e_Fatal;
path = arg_copy(path, minst->heap);
if (path == NULL)
return e_Fatal;
gs_main_add_lib_path(minst, path);
}
break;
case 'K': /* set malloc limit */
{
long msize = 0;
gs_malloc_memory_t *rawheap = gs_malloc_wrapped_contents(minst->heap);
sscanf((const char *)arg, "%ld", &msize);
if (msize <= 0 || msize > max_long >> 10) {
outprintf(minst->heap, "-K<numK> must have 1 <= numK <= %ld\n",
max_long >> 10);
return e_Fatal;
}
rawheap->limit = msize << 10;
}
break;
case 'M': /* set memory allocation increment */
{
unsigned msize = 0;
sscanf((const char *)arg, "%u", &msize);
#if ARCH_INTS_ARE_SHORT
if (msize <= 0 || msize >= 64) {
puts(minst->heap, "-M must be between 1 and 63");
return e_Fatal;
}
#endif
minst->memory_chunk_size = msize << 10;
}
break;
case 'N': /* set size of name table */
{
unsigned nsize = 0;
sscanf((const char *)arg, "%d", &nsize);
#if ARCH_INTS_ARE_SHORT
if (nsize < 2 || nsize > 64) {
puts(minst->heap, "-N must be between 2 and 64");
return e_Fatal;
}
#endif
minst->name_table_size = (ulong) nsize << 10;
}
break;
case 'o': /* set output file name and batch mode */
{
const char *adef;
char *str;
ref value;
int len;
if (arg[0] == 0) {
adef = arg_next(pal, &code, minst->heap);
if (code < 0)
return code;
} else
adef = arg;
if ((code = gs_main_init1(minst)) < 0)
return code;
len = strlen(adef);
str = (char *)gs_alloc_bytes(minst->heap, (uint)len, "-o");
if (str == NULL)
return e_VMerror;
memcpy(str, adef, len);
make_const_string(&value, a_readonly | avm_foreign,
len, (const byte *)str);
initial_enter_name("OutputFile", &value);
initial_enter_name("NOPAUSE", &vtrue);
initial_enter_name("BATCH", &vtrue);
}
break;
case 'P': /* choose whether search '.' first */
if (!strcmp(arg, ""))
minst->search_here_first = true;
else if (!strcmp(arg, "-"))
minst->search_here_first = false;
else {
puts(minst->heap, "Only -P or -P- is allowed.");
return e_Fatal;
}
break;
case 'q': /* quiet startup */
if ((code = gs_main_init1(minst)) < 0)
return code;
initial_enter_name("QUIET", &vtrue);
break;
case 'r': /* define device resolution */
{
float xres, yres;
ref value;
if ((code = gs_main_init1(minst)) < 0)
return code;
switch (sscanf((const char *)arg, "%fx%f", &xres, &yres)) {
default:
puts(minst->heap, "-r must be followed by <res> or <xres>x<yres>");
return e_Fatal;
case 1: /* -r<res> */
yres = xres;
case 2: /* -r<xres>x<yres> */
make_real(&value, xres);
initial_enter_name("DEVICEXRESOLUTION", &value);
make_real(&value, yres);
initial_enter_name("DEVICEYRESOLUTION", &value);
initial_enter_name("FIXEDRESOLUTION", &vtrue);
}
break;
}
case 'D': /* define name */
case 'd':
case 'S': /* define name as string */
case 's':
{
char *adef = arg_copy(arg, minst->heap);
char *eqp;
bool isd = (sw == 'D' || sw == 'd');
ref value;
if (adef == NULL)
return e_Fatal;
eqp = strchr(adef, '=');
if (eqp == NULL)
eqp = strchr(adef, '#');
/* Initialize the object memory, scanner, and */
/* name table now if needed. */
if ((code = gs_main_init1(minst)) < 0)
return code;
if (eqp == adef) {
puts(minst->heap, "Usage: -dNAME, -dNAME=TOKEN, -sNAME=STRING");
return e_Fatal;
}
if (eqp == NULL) {
if (isd)
make_true(&value);
else
make_empty_string(&value, a_readonly);
} else {
int code;
i_ctx_t *i_ctx_p = minst->i_ctx_p;
uint space = icurrent_space;
*eqp++ = 0;
ialloc_set_space(idmemory, avm_system);
if (isd) {
int num, i;
/* Check for numbers so we can provide for suffix scalers */
/* Note the check for '#' is for PS "radix" numbers such as 16#ff */
/* and check for '.' and 'e' or 'E' which are 'real' numbers */
if ((strchr(eqp, '#') == NULL) && (strchr(eqp, '.') == NULL) &&
(strchr(eqp, 'e') == NULL) && (strchr(eqp, 'E') == NULL) &&
((i = sscanf((const char *)eqp, "%d", &num)) == 1)) {
char suffix = eqp[strlen(eqp) - 1];
switch (suffix) {
case 'k':
case 'K':
num *= 1024;
break;
case 'm':
case 'M':
num *= 1024 * 1024;
break;
case 'g':
case 'G':
/* caveat emptor: more than 2g will overflow */
/* and really should produce a 'real', so don't do this */
num *= 1024 * 1024 * 1024;
break;
default:
break; /* not a valid suffix or last char was digit */
}
make_int(&value, num);
} else {
/* use the PS scanner to capture other valid token types */
stream astream;
scanner_state state;
s_init(&astream, NULL);
sread_string(&astream,
(const byte *)eqp, strlen(eqp));
gs_scanner_init_stream(&state, &astream);
code = gs_scan_token(minst->i_ctx_p, &value, &state);
if (code) {
outprintf(minst->heap, "Invalid value for option -d%s, -dNAME= must be followed by a valid token\n", arg);
return e_Fatal;
}
if (r_has_type_attrs(&value, t_name,
a_executable)) {
ref nsref;
name_string_ref(minst->heap, &value, &nsref);
#undef string_is
#define string_is(nsref, str, len)\
(r_size(&(nsref)) == (len) &&\
!strncmp((const char *)(nsref).value.const_bytes, str, (len)))
if (string_is(nsref, "null", 4))
make_null(&value);
else if (string_is(nsref, "true", 4))
make_true(&value);
else if (string_is(nsref, "false", 5))
make_false(&value);
else {
outprintf(minst->heap, "Invalid value for option -d%s, use -sNAME= to define string constants\n", arg);
return e_Fatal;
}
}
}
} else {
int len = strlen(eqp);
char *str =
(char *)gs_alloc_bytes(minst->heap,
(uint) len, "-s");
if (str == 0) {
lprintf("Out of memory!\n");
return e_Fatal;
}
memcpy(str, eqp, len);
make_const_string(&value,
a_readonly | avm_foreign,
len, (const byte *)str);
if ((code = try_stdout_redirect(minst, adef, eqp)) < 0)
return code;
}
ialloc_set_space(idmemory, space);
}
/* Enter the name in systemdict. */
initial_enter_name(adef, &value);
break;
}
case 'T':
set_debug_flags(arg, vd_flags);
break;
case 'u': /* undefine name */
if (!*arg) {
puts(minst->heap, "-u requires a name to undefine.");
return e_Fatal;
}
if ((code = gs_main_init1(minst)) < 0)
return code;
i_initial_remove_name(minst->i_ctx_p, arg);
break;
case 'v': /* print revision */
print_revision(minst);
return e_Info;
/*#ifdef DEBUG */
/*
* Here we provide a place for inserting debugging code that can be
* run in place of the normal interpreter code.
*/
case 'X':
code = gs_main_init2(minst);
if (code < 0)
return code;
{
int xec; /* exit_code */
ref xeo; /* error_object */
#define start_x()\
gs_main_run_string_begin(minst, 1, &xec, &xeo)
#define run_x(str)\
gs_main_run_string_continue(minst, str, strlen(str), 1, &xec, &xeo)
#define stop_x()\
gs_main_run_string_end(minst, 1, &xec, &xeo)
start_x();
run_x("\216\003abc");
run_x("== flush\n");
stop_x();
}
return e_Quit;
/*#endif */
case 'Z':
set_debug_flags(arg, gs_debug);
break;
}
return 0;
} | 0 | [] | ghostpdl | 407cc61e87b0fd9d44d72ca740af7d3c85dee78d | 319,044,761,599,692,700,000,000,000,000,000,000,000 | 486 | "starting_arg_file" should only apply once.
The "starting_arg_file == true" setting should apply to the *first* call to
lib_file_open() in the context of a given call to runarg(). Previously, it
remained set for the entire duration of the runarg() call, resulting in the
current directory being searched for any resource files required by the job.
We also want "starting_arg_file == false" when runarg() is called to execute
Postscript from a buffer, rather than a file argument.
There is a very small chance this may cause problems with some strange scripts
or utilities, but I have been unable to prompt such an issue. If one does arise,
we may have rethink this entirely.
No cluster differences. |
handle_connection_from_outside (GDBusServer *server,
GDBusConnection *connection,
GdmSession *self)
{
GCredentials *credentials;
GPid pid_of_client;
g_debug ("GdmSession: Handling new connection from outside");
self->priv->outside_connections =
g_list_prepend (self->priv->outside_connections,
g_object_ref (connection));
g_signal_connect_object (connection,
"closed",
G_CALLBACK (on_outside_connection_closed),
self,
0);
export_user_verifier_interface (self, connection);
switch (self->priv->verification_mode) {
case GDM_SESSION_VERIFICATION_MODE_LOGIN:
export_greeter_interface (self, connection);
break;
case GDM_SESSION_VERIFICATION_MODE_CHOOSER:
export_chooser_interface (self, connection);
break;
default:
break;
}
if (!self->priv->display_is_local) {
export_remote_greeter_interface (self, connection);
}
credentials = g_dbus_connection_get_peer_credentials (connection);
pid_of_client = g_credentials_get_unix_pid (credentials, NULL);
g_signal_emit (G_OBJECT (self),
signals [CLIENT_CONNECTED],
0,
credentials,
(guint)
pid_of_client);
return TRUE;
} | 0 | [] | gdm | 5ac224602f1d603aac5eaa72e1760d3e33a26f0a | 116,367,953,384,790,740,000,000,000,000,000,000,000 | 50 | 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 |
static int nfs4_proc_rmdir(struct inode *dir, const struct qstr *name)
{
struct nfs4_exception exception = {
.interruptible = true,
};
int err;
do {
err = _nfs4_proc_remove(dir, name, NF4DIR);
trace_nfs4_remove(dir, name, err);
err = nfs4_handle_exception(NFS_SERVER(dir), err,
&exception);
} while (exception.retry);
return err;
} | 0 | [
"CWE-787"
] | linux | b4487b93545214a9db8cbf32e86411677b0cca21 | 116,847,468,100,457,370,000,000,000,000,000,000,000 | 15 | nfs: Fix getxattr kernel panic and memory overflow
Move the buffer size check to decode_attr_security_label() before memcpy()
Only call memcpy() if the buffer is large enough
Fixes: aa9c2669626c ("NFS: Client implementation of Labeled-NFS")
Signed-off-by: Jeffrey Mitchell <[email protected]>
[Trond: clean up duplicate test of label->len != 0]
Signed-off-by: Trond Myklebust <[email protected]> |
ssize_t local_removexattr_nofollow(FsContext *ctx, const char *path,
const char *name)
{
char *dirpath = g_path_get_dirname(path);
char *filename = g_path_get_basename(path);
int dirfd;
ssize_t ret = -1;
dirfd = local_opendir_nofollow(ctx, dirpath);
if (dirfd == -1) {
goto out;
}
ret = fremovexattrat_nofollow(dirfd, filename, name);
close_preserve_errno(dirfd);
out:
g_free(dirpath);
g_free(filename);
return ret;
} | 0 | [
"CWE-772"
] | qemu | 4ffcdef4277a91af15a3c09f7d16af072c29f3f2 | 74,712,164,944,598,170,000,000,000,000,000,000,000 | 20 | 9pfs: xattr: fix memory leak in v9fs_list_xattr
Free 'orig_value' in error path.
Signed-off-by: Li Qiang <[email protected]>
Signed-off-by: Greg Kurz <[email protected]> |
static int start_client(int argc, char *argv[])
{
char *p, *shell_machine = NULL, *shell_user = NULL;
char **remote_argv;
int remote_argc, env_port = rsync_port;
int f_in, f_out;
int ret;
pid_t pid;
/* Don't clobber argv[] so that ps(1) can still show the right
* command line. */
dup_argv(argv);
if (!read_batch) { /* for read_batch, NO source is specified */
char *path = check_for_hostspec(argv[0], &shell_machine, &rsync_port);
if (path) { /* source is remote */
char *dummy_host;
int dummy_port = 0;
*argv = path;
remote_argv = argv;
remote_argc = argc;
argv += argc - 1;
if (argc == 1 || **argv == ':')
argc = 0; /* no dest arg */
else if (check_for_hostspec(*argv, &dummy_host, &dummy_port)) {
rprintf(FERROR,
"The source and destination cannot both be remote.\n");
exit_cleanup(RERR_SYNTAX);
} else {
remote_argc--; /* don't count dest */
argc = 1;
}
if (filesfrom_host && *filesfrom_host && strcmp(filesfrom_host, shell_machine) != 0) {
rprintf(FERROR,
"--files-from hostname is not the same as the transfer hostname\n");
exit_cleanup(RERR_SYNTAX);
}
am_sender = 0;
if (rsync_port)
daemon_connection = shell_cmd ? 1 : -1;
} else { /* source is local, check dest arg */
am_sender = 1;
if (argc > 1) {
p = argv[--argc];
remote_argv = argv + argc;
} else {
static char *dotarg[1] = { "." };
p = dotarg[0];
remote_argv = dotarg;
}
remote_argc = 1;
path = check_for_hostspec(p, &shell_machine, &rsync_port);
if (path && filesfrom_host && *filesfrom_host && strcmp(filesfrom_host, shell_machine) != 0) {
rprintf(FERROR,
"--files-from hostname is not the same as the transfer hostname\n");
exit_cleanup(RERR_SYNTAX);
}
if (!path) { /* no hostspec found, so src & dest are local */
local_server = 1;
if (filesfrom_host) {
rprintf(FERROR,
"--files-from cannot be remote when the transfer is local\n");
exit_cleanup(RERR_SYNTAX);
}
shell_machine = NULL;
rsync_port = 0;
} else { /* hostspec was found, so dest is remote */
argv[argc] = path;
if (rsync_port)
daemon_connection = shell_cmd ? 1 : -1;
}
}
} else { /* read_batch */
local_server = 1;
if (check_for_hostspec(argv[argc-1], &shell_machine, &rsync_port)) {
rprintf(FERROR, "remote destination is not allowed with --read-batch\n");
exit_cleanup(RERR_SYNTAX);
}
remote_argv = argv += argc - 1;
remote_argc = argc = 1;
rsync_port = 0;
}
/* A local transfer doesn't unbackslash anything, so leave the args alone. */
if (local_server)
old_style_args = 2;
if (!rsync_port && remote_argc && !**remote_argv) /* Turn an empty arg into a dot dir. */
*remote_argv = ".";
if (am_sender) {
char *dummy_host;
int dummy_port = rsync_port;
int i;
if (!argv[0][0])
goto invalid_empty;
/* For local source, extra source args must not have hostspec. */
for (i = 1; i < argc; i++) {
if (!argv[i][0]) {
invalid_empty:
rprintf(FERROR, "Empty source arg specified.\n");
exit_cleanup(RERR_SYNTAX);
}
if (check_for_hostspec(argv[i], &dummy_host, &dummy_port)) {
rprintf(FERROR, "Unexpected remote arg: %s\n", argv[i]);
exit_cleanup(RERR_SYNTAX);
}
}
} else {
char *dummy_host;
int dummy_port = rsync_port;
int i;
if (filesfrom_fd < 0)
add_implied_include(remote_argv[0]);
/* For remote source, any extra source args must have either
* the same hostname or an empty hostname. */
for (i = 1; i < remote_argc; i++) {
char *arg = check_for_hostspec(remote_argv[i], &dummy_host, &dummy_port);
if (!arg) {
rprintf(FERROR, "Unexpected local arg: %s\n", remote_argv[i]);
rprintf(FERROR, "If arg is a remote file/dir, prefix it with a colon (:).\n");
exit_cleanup(RERR_SYNTAX);
}
if (*dummy_host && strcmp(dummy_host, shell_machine) != 0) {
rprintf(FERROR, "All source args must come from the same machine.\n");
exit_cleanup(RERR_SYNTAX);
}
if (rsync_port != dummy_port) {
if (!rsync_port || !dummy_port)
rprintf(FERROR, "All source args must use the same hostspec format.\n");
else
rprintf(FERROR, "All source args must use the same port number.\n");
exit_cleanup(RERR_SYNTAX);
}
if (!rsync_port && !*arg) /* Turn an empty arg into a dot dir. */
arg = ".";
remote_argv[i] = arg;
add_implied_include(arg);
}
}
if (rsync_port < 0)
rsync_port = RSYNC_PORT;
else
env_port = rsync_port;
if (daemon_connection < 0)
return start_socket_client(shell_machine, remote_argc, remote_argv, argc, argv);
if (password_file && !daemon_connection) {
rprintf(FERROR, "The --password-file option may only be "
"used when accessing an rsync daemon.\n");
exit_cleanup(RERR_SYNTAX);
}
if (connect_timeout) {
rprintf(FERROR, "The --contimeout option may only be "
"used when connecting to an rsync daemon.\n");
exit_cleanup(RERR_SYNTAX);
}
if (shell_machine) {
p = strrchr(shell_machine,'@');
if (p) {
*p = 0;
shell_user = shell_machine;
shell_machine = p+1;
}
}
if (DEBUG_GTE(CMD, 2)) {
rprintf(FINFO,"cmd=%s machine=%s user=%s path=%s\n",
NS(shell_cmd), NS(shell_machine), NS(shell_user),
NS(remote_argv[0]));
}
#ifdef HAVE_PUTENV
if (daemon_connection)
set_env_num("RSYNC_PORT", env_port);
#else
(void)env_port;
#endif
pid = do_cmd(shell_cmd, shell_machine, shell_user, remote_argv, remote_argc, &f_in, &f_out);
/* if we're running an rsync server on the remote host over a
* remote shell command, we need to do the RSYNCD protocol first */
if (daemon_connection) {
int tmpret;
tmpret = start_inband_exchange(f_in, f_out, shell_user, remote_argc, remote_argv);
if (tmpret < 0)
return tmpret;
}
ret = client_run(f_in, f_out, pid, argc, argv);
fflush(stdout);
fflush(stderr);
return ret;
} | 0 | [] | rsync | b7231c7d02cfb65d291af74ff66e7d8c507ee871 | 43,141,383,974,593,770,000,000,000,000,000,000,000 | 203 | Some extra file-list safety checks. |
clear_cached_dir(cached_dir_t *d)
{
tor_free(d->dir);
tor_free(d->dir_z);
memset(d, 0, sizeof(cached_dir_t));
} | 0 | [
"CWE-264"
] | tor | 00fffbc1a15e2696a89c721d0c94dc333ff419ef | 336,015,423,130,132,840,000,000,000,000,000,000,000 | 6 | Don't give the Guard flag to relays without the CVE-2011-2768 fix |
sort_page_names (gconstpointer a,
gconstpointer b)
{
gchar *temp1, *temp2;
gint ret;
temp1 = g_utf8_collate_key_for_filename (* (const char **) a, -1);
temp2 = g_utf8_collate_key_for_filename (* (const char **) b, -1);
ret = strcmp (temp1, temp2);
g_free (temp1);
g_free (temp2);
return ret;
} | 0 | [] | evince | 717df38fd8509bf883b70d680c9b1b3cf36732ee | 167,833,701,754,414,300,000,000,000,000,000,000,000 | 16 | comics: Remove support for tar and tar-like commands
When handling tar files, or using a command with tar-compatible syntax,
to open comic-book archives, both the archive name (the name of the
comics file) and the filename (the name of a page within the archive)
are quoted to not be interpreted by the shell.
But the filename is completely with the attacker's control and can start
with "--" which leads to tar interpreting it as a command line flag.
This can be exploited by creating a CBT file (a tar archive with the
.cbt suffix) with an embedded file named something like this:
"--checkpoint-action=exec=bash -c 'touch ~/hacked;'.jpg"
CBT files are infinitely rare (CBZ is usually used for DRM-free
commercial releases, CBR for those from more dubious provenance), so
removing support is the easiest way to avoid the bug triggering. All
this code was rewritten in the development release for GNOME 3.26 to not
shell out to any command, closing off this particular attack vector.
This also removes the ability to use libarchive's bsdtar-compatible
binary for CBZ (ZIP), CB7 (7zip), and CBR (RAR) formats. The first two
are already supported by unzip and 7zip respectively. libarchive's RAR
support is limited, so unrar is a requirement anyway.
Discovered by Felix Wilhelm from the Google Security Team.
https://bugzilla.gnome.org/show_bug.cgi?id=784630 |
static void conn_close(conn *c) {
assert(c != NULL);
/* delete the event, the socket and the conn */
event_del(&c->event);
if (settings.verbose > 1)
fprintf(stderr, "<%d connection closed.\n", c->sfd);
MEMCACHED_CONN_RELEASE(c->sfd);
close(c->sfd);
pthread_mutex_lock(&conn_lock);
allow_new_conns = true;
pthread_mutex_unlock(&conn_lock);
conn_cleanup(c);
/* if the connection has big buffers, just free it */
if (c->rsize > READ_BUFFER_HIGHWAT || conn_add_to_freelist(c)) {
conn_free(c);
}
STATS_LOCK();
stats.curr_conns--;
STATS_UNLOCK();
return;
} | 0 | [
"CWE-189"
] | memcached | 6695ccbc525c36d693aaa3e8337b36aa0c784424 | 236,661,297,540,228,700,000,000,000,000,000,000,000 | 27 | Fix segfault on specially crafted packet. |
encode_custom_modifiers (MonoDynamicImage *assembly, MonoArray *modreq, MonoArray *modopt, SigBuffer *buf)
{
int i;
if (modreq) {
for (i = 0; i < mono_array_length (modreq); ++i) {
MonoType *mod = mono_type_array_get_and_resolve (modreq, i);
sigbuffer_add_byte (buf, MONO_TYPE_CMOD_REQD);
sigbuffer_add_value (buf, mono_image_typedef_or_ref (assembly, mod));
}
}
if (modopt) {
for (i = 0; i < mono_array_length (modopt); ++i) {
MonoType *mod = mono_type_array_get_and_resolve (modopt, i);
sigbuffer_add_byte (buf, MONO_TYPE_CMOD_OPT);
sigbuffer_add_value (buf, mono_image_typedef_or_ref (assembly, mod));
}
}
} | 0 | [
"CWE-20"
] | mono | 4905ef1130feb26c3150b28b97e4a96752e0d399 | 148,009,014,590,444,000,000,000,000,000,000,000,000 | 19 | 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 |
static int hls_nal_unit(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc.gb;
int nuh_layer_id;
if (get_bits1(gb) != 0)
return AVERROR_INVALIDDATA;
s->nal_unit_type = get_bits(gb, 6);
nuh_layer_id = get_bits(gb, 6);
s->temporal_id = get_bits(gb, 3) - 1;
if (s->temporal_id < 0)
return AVERROR_INVALIDDATA;
av_log(s->avctx, AV_LOG_DEBUG,
"nal_unit_type: %d, nuh_layer_id: %dtemporal_id: %d\n",
s->nal_unit_type, nuh_layer_id, s->temporal_id);
return nuh_layer_id == 0;
} | 0 | [
"CWE-703"
] | FFmpeg | b25e84b7399bd91605596b67d761d3464dbe8a6e | 236,341,862,307,436,170,000,000,000,000,000,000,000 | 21 | hevc: check that the VCL NAL types are the same for all slice segments of a frame
Fixes possible invalid memory access for mismatching skipped/non-skipped
slice segments.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Sample-Id: 00001533-google |
void fuse_release_common(struct file *file, bool isdir)
{
struct fuse_inode *fi = get_fuse_inode(file_inode(file));
struct fuse_file *ff = file->private_data;
struct fuse_release_args *ra = ff->release_args;
int opcode = isdir ? FUSE_RELEASEDIR : FUSE_RELEASE;
fuse_prepare_release(fi, ff, file->f_flags, opcode);
if (ff->flock) {
ra->inarg.release_flags |= FUSE_RELEASE_FLOCK_UNLOCK;
ra->inarg.lock_owner = fuse_lock_owner_id(ff->fm->fc,
(fl_owner_t) file);
}
/* Hold inode until release is finished */
ra->inode = igrab(file_inode(file));
/*
* Normally this will send the RELEASE request, however if
* some asynchronous READ or WRITE requests are outstanding,
* the sending will be delayed.
*
* Make the release synchronous if this is a fuseblk mount,
* synchronous RELEASE is allowed (and desirable) in this case
* because the server can be trusted not to screw up.
*/
fuse_file_put(ff, ff->fm->fc->destroy, isdir);
} | 0 | [
"CWE-459"
] | linux | 5d069dbe8aaf2a197142558b6fb2978189ba3454 | 102,341,718,946,475,220,000,000,000,000,000,000,000 | 28 | fuse: fix bad inode
Jan Kara's analysis of the syzbot report (edited):
The reproducer opens a directory on FUSE filesystem, it then attaches
dnotify mark to the open directory. After that a fuse_do_getattr() call
finds that attributes returned by the server are inconsistent, and calls
make_bad_inode() which, among other things does:
inode->i_mode = S_IFREG;
This then confuses dnotify which doesn't tear down its structures
properly and eventually crashes.
Avoid calling make_bad_inode() on a live inode: switch to a private flag on
the fuse inode. Also add the test to ops which the bad_inode_ops would
have caught.
This bug goes back to the initial merge of fuse in 2.6.14...
Reported-by: [email protected]
Signed-off-by: Miklos Szeredi <[email protected]>
Tested-by: Jan Kara <[email protected]>
Cc: <[email protected]> |
bool WireFormat::ReadPackedEnumPreserveUnknowns(io::CodedInputStream* input,
uint32_t field_number,
bool (*is_valid)(int),
UnknownFieldSet* unknown_fields,
RepeatedField<int>* values) {
uint32_t length;
if (!input->ReadVarint32(&length)) return false;
io::CodedInputStream::Limit limit = input->PushLimit(length);
while (input->BytesUntilLimit() > 0) {
int value;
if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(
input, &value)) {
return false;
}
if (is_valid == NULL || is_valid(value)) {
values->Add(value);
} else {
unknown_fields->AddVarint(field_number, value);
}
}
input->PopLimit(limit);
return true;
} | 0 | [
"CWE-703"
] | protobuf | d1635e1496f51e0d5653d856211e8821bc47adc4 | 336,093,429,909,663,350,000,000,000,000,000,000,000 | 23 | Apply patch |
NM nm_merge(NM dst, NM src) {
/* both lists are ordered and non-overlapping. Knit them into a
* single ordered, non-overlapping list. */
NM tmp;
NM *pos = &dst; /* double indirect pointer simplifies list insertion
logic. */
while(src) {
if(*pos == NULL) {
/* remains of src go to tail of dst */
tmp = src;
src = *pos;
*pos = tmp;
} else if(subset_of(src, *pos)) {
status("found %016llx %016llx/%d a subset of %016llx %016llx/%d", src->neta.h, src->neta.l, cidr(src->mask), (*pos)->neta.h, (*pos)->neta.l, cidr((*pos)->mask));
/* drop src elt on the floor */
if(src->domain != AF_INET) /* may need to promote domain */
(*pos)->domain = src->domain;
tmp = src;
src = src->next;
free(tmp);
} else if(subset_of(*pos, src)) {
/* src seems larger, merge the other direction instead */
tmp = src;
src = *pos;
*pos = tmp;
} else if(joinable_pair(src, *pos)) {
status("joinable %016llx %016llx/%d and %016llx %016llx/%d", src->neta.h, src->neta.l, cidr(src->mask), (*pos)->neta.h, (*pos)->neta.l, cidr((*pos)->mask));
/* pull the dst elt */
tmp = *pos;
*pos = (*pos)->next;
if(src->domain == AF_INET)
src->domain = tmp->domain;
free(tmp);
/* widen the src elt */
src->mask = u128_lsh(src->mask, 1);
src->neta = u128_and(src->neta, src->mask);
/* and merge it back into the src tail */
tmp = src->next;
src->next = NULL;
src = nm_merge(src, tmp);
/* now the dst scan needs to start over to find preceding
* join candidates. */
pos = &dst;
/* TODO: there should be a cheaper way to do this than an
* effective double recursion, but the possibility of joins
* cascading backwards makes this difficult */
} else if(u128_cmp(src->neta, (*pos)->neta) < 0) {
/* src elt goes here in dst list. if top src elt were
* spliced into dst, it may duplicate later elts in dst.
* swap tails instead because src is well formed. */
tmp = src;
src = *pos;
*pos = tmp;
} else {
/* move down the dst list */
pos = &(*pos)->next;
}
}
return dst;
} | 0 | [] | netmask | 29a9c239bd1008363f5b34ffd6c2cef906f3660c | 221,185,384,941,745,500,000,000,000,000,000,000,000 | 60 | bump version to 2.4.4
* remove checks for negative unsigned ints, fixes #2
* harden error logging functions, fixes #3 |
static int ZEND_FASTCALL ZEND_INIT_ARRAY_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zend_op *opline = EX(opline);
array_init(&EX_T(opline->result.u.var).tmp_var);
if (IS_CONST == IS_UNUSED) {
ZEND_VM_NEXT_OPCODE();
#if 0 || IS_CONST != IS_UNUSED
} else {
return ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);
#endif
}
} | 0 | [] | php-src | ce96fd6b0761d98353761bf78d5bfb55291179fd | 273,415,374,675,301,600,000,000,000,000,000,000,000 | 13 | - 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 |
rsvg_filter_primitive_specular_lighting_render (RsvgFilterPrimitive * self, RsvgFilterContext * ctx)
{
gint x, y;
gdouble z, surfaceScale;
gint rowstride, height, width;
gdouble factor, max, base;
vector3 lightcolour, colour;
vector3 L;
gdouble iaffine[6];
RsvgIRect boundarys;
RsvgNodeLightSource *source = NULL;
guchar *in_pixels;
guchar *output_pixels;
RsvgFilterPrimitiveSpecularLighting *upself;
GdkPixbuf *output;
GdkPixbuf *in;
unsigned int i;
for (i = 0; i < self->super.children->len; i++) {
RsvgNode *temp;
temp = g_ptr_array_index (self->super.children, i);
if (RSVG_NODE_TYPE (temp) == RSVG_NODE_TYPE_LIGHT_SOURCE) {
source = (RsvgNodeLightSource *) temp;
}
}
if (source == NULL)
return;
upself = (RsvgFilterPrimitiveSpecularLighting *) self;
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
in = rsvg_filter_get_in (self->in, ctx);
in_pixels = gdk_pixbuf_get_pixels (in);
height = gdk_pixbuf_get_height (in);
width = gdk_pixbuf_get_width (in);
rowstride = gdk_pixbuf_get_rowstride (in);
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, width, height);
output_pixels = gdk_pixbuf_get_pixels (output);
colour.x = ((guchar *) (&upself->lightingcolour))[2] / 255.0;
colour.y = ((guchar *) (&upself->lightingcolour))[1] / 255.0;
colour.z = ((guchar *) (&upself->lightingcolour))[0] / 255.0;
surfaceScale = upself->surfaceScale / 255.0;
_rsvg_affine_invert (iaffine, ctx->paffine);
for (y = boundarys.y0; y < boundarys.y1; y++)
for (x = boundarys.x0; x < boundarys.x1; x++) {
z = in_pixels[y * rowstride + x * 4 + 3] * surfaceScale;
L = get_light_direction (source, x, y, z, iaffine, ctx->ctx);
L.z += 1;
L = normalise (L);
lightcolour = get_light_colour (source, colour, x, y, z, iaffine, ctx->ctx);
base = dotproduct (get_surface_normal (in_pixels, boundarys, x, y,
1, 1, 1.0 / ctx->paffine[0],
1.0 / ctx->paffine[3], upself->surfaceScale,
rowstride, ctx->channelmap[3]), L);
factor = upself->specularConstant * pow (base, upself->specularExponent) * 255;
max = 0;
if (max < lightcolour.x)
max = lightcolour.x;
if (max < lightcolour.y)
max = lightcolour.y;
if (max < lightcolour.z)
max = lightcolour.z;
max *= factor;
if (max > 255)
max = 255;
if (max < 0)
max = 0;
output_pixels[y * rowstride + x * 4 + ctx->channelmap[0]] = lightcolour.x * max;
output_pixels[y * rowstride + x * 4 + ctx->channelmap[1]] = lightcolour.y * max;
output_pixels[y * rowstride + x * 4 + ctx->channelmap[2]] = lightcolour.z * max;
output_pixels[y * rowstride + x * 4 + ctx->channelmap[3]] = max;
}
rsvg_filter_store_result (self->result, output, ctx);
g_object_unref (in);
g_object_unref (output);
} | 0 | [] | librsvg | 34c95743ca692ea0e44778e41a7c0a129363de84 | 195,243,799,329,942,720,000,000,000,000,000,000,000 | 96 | Store node type separately in RsvgNode
The node name (formerly RsvgNode:type) cannot be used to infer
the sub-type of RsvgNode that we're dealing with, since for unknown
elements we put type = node-name. This lead to a (potentially exploitable)
crash e.g. when the element name started with "fe" which tricked
the old code into considering it as a RsvgFilterPrimitive.
CVE-2011-3146
https://bugzilla.gnome.org/show_bug.cgi?id=658014 |
com_shell(String *buffer __attribute__((unused)),
char *line __attribute__((unused)))
{
char *shell_cmd;
/* Skip space from line begin */
while (my_isspace(charset_info, *line))
line++;
if (!(shell_cmd = strchr(line, ' ')))
{
put_info("Usage: \\! shell-command", INFO_ERROR);
return -1;
}
/*
The output of the shell command does not
get directed to the pager or the outfile
*/
if (system(shell_cmd) == -1)
{
put_info(strerror(errno), INFO_ERROR, errno);
return -1;
}
return 0;
} | 0 | [
"CWE-284",
"CWE-295"
] | mysql-server | 3bd5589e1a5a93f9c224badf983cd65c45215390 | 97,039,378,307,059,240,000,000,000,000,000,000,000 | 24 | 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 |
static MonoMethod*
mono_reflection_method_get_handle (MonoObject *method)
{
MonoClass *class = mono_object_class (method);
if (is_sr_mono_method (class) || is_sr_mono_generic_method (class)) {
MonoReflectionMethod *sr_method = (MonoReflectionMethod*)method;
return sr_method->method;
}
if (is_sre_method_builder (class)) {
MonoReflectionMethodBuilder *mb = (MonoReflectionMethodBuilder*)method;
return mb->mhandle;
}
if (is_sre_method_on_tb_inst (class)) {
MonoReflectionMethodOnTypeBuilderInst *m = (MonoReflectionMethodOnTypeBuilderInst*)method;
MonoMethod *result;
/*FIXME move this to a proper method and unify with resolve_object*/
if (m->method_args) {
result = mono_reflection_method_on_tb_inst_get_handle (m);
} else {
MonoType *type = mono_reflection_type_get_handle ((MonoReflectionType*)m->inst);
MonoClass *inflated_klass = mono_class_from_mono_type (type);
MonoMethod *mono_method;
if (is_sre_method_builder (mono_object_class (m->mb)))
mono_method = ((MonoReflectionMethodBuilder *)m->mb)->mhandle;
else if (is_sr_mono_method (mono_object_class (m->mb)))
mono_method = ((MonoReflectionMethod *)m->mb)->method;
else
g_error ("resolve_object:: can't handle a MTBI with base_method of type %s", mono_type_get_full_name (mono_object_class (m->mb)));
result = inflate_mono_method (inflated_klass, mono_method, (MonoObject*)m->mb);
}
return result;
}
g_error ("Can't handle methods of type %s:%s", class->name_space, class->name);
return NULL; | 0 | [
"CWE-20"
] | mono | 4905ef1130feb26c3150b28b97e4a96752e0d399 | 121,418,923,088,499,160,000,000,000,000,000,000,000 | 37 | 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 |
WRITE_JSON_ELEMENT(ArrEnd) {
ctx->depth--; //decrease depth
ctx->commaNeeded[ctx->depth] = true;
return writeChar(ctx, ']');
} | 0 | [
"CWE-703",
"CWE-787"
] | open62541 | c800e2987b10bb3af6ef644b515b5d6392f8861d | 171,755,977,356,549,340,000,000,000,000,000,000,000 | 5 | fix(json): Check max recursion depth in more places |
static int fat_dir_ioctl(struct inode * inode, struct file * filp,
unsigned int cmd, unsigned long arg)
{
struct fat_ioctl_filldir_callback buf;
struct dirent __user *d1;
int ret, short_only, both;
switch (cmd) {
case VFAT_IOCTL_READDIR_SHORT:
short_only = 1;
both = 0;
break;
case VFAT_IOCTL_READDIR_BOTH:
short_only = 0;
both = 1;
break;
default:
return fat_generic_ioctl(inode, filp, cmd, arg);
}
d1 = (struct dirent __user *)arg;
if (!access_ok(VERIFY_WRITE, d1, sizeof(struct dirent[2])))
return -EFAULT;
/*
* Yes, we don't need this put_user() absolutely. However old
* code didn't return the right value. So, app use this value,
* in order to check whether it is EOF.
*/
if (put_user(0, &d1->d_reclen))
return -EFAULT;
buf.dirent = d1;
buf.result = 0;
mutex_lock(&inode->i_mutex);
ret = -ENOENT;
if (!IS_DEADDIR(inode)) {
ret = __fat_readdir(inode, filp, &buf, fat_ioctl_filldir,
short_only, both);
}
mutex_unlock(&inode->i_mutex);
if (ret >= 0)
ret = buf.result;
return ret;
} | 1 | [] | linux-2.6 | c483bab099cb89e92b7cad94a52fcdaf37e56657 | 113,627,596,617,655,060,000,000,000,000,000,000,000 | 44 | fat: fix VFAT compat ioctls on 64-bit systems
If you compile and run the below test case in an msdos or vfat directory on
an x86-64 system with -m32 you'll get garbage in the kernel_dirent struct
followed by a SIGSEGV.
The patch fixes this.
Reported and initial fix by Bart Oldeman
#include <sys/types.h>
#include <sys/ioctl.h>
#include <dirent.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
struct kernel_dirent {
long d_ino;
long d_off;
unsigned short d_reclen;
char d_name[256]; /* We must not include limits.h! */
};
#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct kernel_dirent [2])
#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct kernel_dirent [2])
int main(void)
{
int fd = open(".", O_RDONLY);
struct kernel_dirent de[2];
while (1) {
int i = ioctl(fd, VFAT_IOCTL_READDIR_BOTH, (long)de);
if (i == -1) break;
if (de[0].d_reclen == 0) break;
printf("SFN: reclen=%2d off=%d ino=%d, %-12s",
de[0].d_reclen, de[0].d_off, de[0].d_ino, de[0].d_name);
if (de[1].d_reclen)
printf("\tLFN: reclen=%2d off=%d ino=%d, %s",
de[1].d_reclen, de[1].d_off, de[1].d_ino, de[1].d_name);
printf("\n");
}
return 0;
}
Signed-off-by: Bart Oldeman <[email protected]>
Signed-off-by: OGAWA Hirofumi <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
R_API char *r_socket_http_post (const char *url, const char *data, int *code, int *rlen) {
RSocket *s;
bool ssl = r_str_startswith (url, "https://");
char *uri = strdup (url);
if (!uri) {
return NULL;
}
char *host = strstr (uri, "://");
if (!host) {
free (uri);
printf ("Invalid URI");
return NULL;
}
host += 3;
char *port = strchr (host, ':');
if (!port) {
port = (ssl)? "443": "80";
} else {
*port++ = 0;
}
char *path = strchr (host, '/');
if (!path) {
path = "";
} else {
*path++ = 0;
}
s = r_socket_new (ssl);
if (!s) {
printf ("Cannot create socket\n");
free (uri);
return NULL;
}
if (!r_socket_connect_tcp (s, host, port, 0)) {
eprintf ("Cannot connect to %s:%s\n", host, port);
free (uri);
return NULL;
}
/* Send */
r_socket_printf (s,
"POST /%s HTTP/1.0\r\n"
"User-Agent: radare2 "R2_VERSION"\r\n"
"Accept: */*\r\n"
"Host: %s\r\n"
"Content-Length: %i\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"\r\n", path, host, (int)strlen (data));
free (uri);
r_socket_write (s, (void *)data, strlen (data));
return r_socket_http_answer (s, code, rlen);
} | 1 | [
"CWE-78"
] | radare2 | 04edfa82c1f3fa2bc3621ccdad2f93bdbf00e4f9 | 268,458,739,334,982,870,000,000,000,000,000,000,000 | 51 | Fix command injection on PDB download (#16966)
* Fix r_sys_mkdirp with absolute path on Windows
* Fix build with --with-openssl
* Use RBuffer in r_socket_http_answer()
* r_socket_http_answer: Fix read for big responses
* Implement r_str_escape_sh()
* Cleanup r_socket_connect() on Windows
* Fix socket being created without a protocol
* Fix socket connect with SSL ##socket
* Use select() in r_socket_ready()
* Fix read failing if received only protocol answer
* Fix double-free
* r_socket_http_get: Fail if req. SSL with no support
* Follow redirects in r_socket_http_answer()
* Fix r_socket_http_get result length with R2_CURL=1
* Also follow redirects
* Avoid using curl for downloading PDBs
* Use r_socket_http_get() on UNIXs
* Use WinINet API on Windows for r_socket_http_get()
* Fix command injection
* Fix r_sys_cmd_str_full output for binary data
* Validate GUID on PDB download
* Pass depth to socket_http_get_recursive()
* Remove 'r_' and '__' from static function names
* Fix is_valid_guid
* Fix for comments |
static int __init ipv6_offload_init(void)
{
if (tcpv6_offload_init() < 0)
pr_crit("%s: Cannot add TCP protocol offload\n", __func__);
if (ipv6_exthdrs_offload_init() < 0)
pr_crit("%s: Cannot add EXTHDRS protocol offload\n", __func__);
dev_add_offload(&ipv6_packet_offload);
inet_add_offload(&sit_offload, IPPROTO_IPV6);
inet6_add_offload(&ip6ip6_offload, IPPROTO_IPV6);
inet6_add_offload(&ip4ip6_offload, IPPROTO_IPIP);
return 0;
} | 0 | [
"CWE-125"
] | linux | 2423496af35d94a87156b063ea5cedffc10a70a1 | 246,715,287,168,791,170,000,000,000,000,000,000,000 | 16 | ipv6: Prevent overrun when parsing v6 header options
The KASAN warning repoted below was discovered with a syzkaller
program. The reproducer is basically:
int s = socket(AF_INET6, SOCK_RAW, NEXTHDR_HOP);
send(s, &one_byte_of_data, 1, MSG_MORE);
send(s, &more_than_mtu_bytes_data, 2000, 0);
The socket() call sets the nexthdr field of the v6 header to
NEXTHDR_HOP, the first send call primes the payload with a non zero
byte of data, and the second send call triggers the fragmentation path.
The fragmentation code tries to parse the header options in order
to figure out where to insert the fragment option. Since nexthdr points
to an invalid option, the calculation of the size of the network header
can made to be much larger than the linear section of the skb and data
is read outside of it.
This fix makes ip6_find_1stfrag return an error if it detects
running out-of-bounds.
[ 42.361487] ==================================================================
[ 42.364412] BUG: KASAN: slab-out-of-bounds in ip6_fragment+0x11c8/0x3730
[ 42.365471] Read of size 840 at addr ffff88000969e798 by task ip6_fragment-oo/3789
[ 42.366469]
[ 42.366696] CPU: 1 PID: 3789 Comm: ip6_fragment-oo Not tainted 4.11.0+ #41
[ 42.367628] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-1ubuntu1 04/01/2014
[ 42.368824] Call Trace:
[ 42.369183] dump_stack+0xb3/0x10b
[ 42.369664] print_address_description+0x73/0x290
[ 42.370325] kasan_report+0x252/0x370
[ 42.370839] ? ip6_fragment+0x11c8/0x3730
[ 42.371396] check_memory_region+0x13c/0x1a0
[ 42.371978] memcpy+0x23/0x50
[ 42.372395] ip6_fragment+0x11c8/0x3730
[ 42.372920] ? nf_ct_expect_unregister_notifier+0x110/0x110
[ 42.373681] ? ip6_copy_metadata+0x7f0/0x7f0
[ 42.374263] ? ip6_forward+0x2e30/0x2e30
[ 42.374803] ip6_finish_output+0x584/0x990
[ 42.375350] ip6_output+0x1b7/0x690
[ 42.375836] ? ip6_finish_output+0x990/0x990
[ 42.376411] ? ip6_fragment+0x3730/0x3730
[ 42.376968] ip6_local_out+0x95/0x160
[ 42.377471] ip6_send_skb+0xa1/0x330
[ 42.377969] ip6_push_pending_frames+0xb3/0xe0
[ 42.378589] rawv6_sendmsg+0x2051/0x2db0
[ 42.379129] ? rawv6_bind+0x8b0/0x8b0
[ 42.379633] ? _copy_from_user+0x84/0xe0
[ 42.380193] ? debug_check_no_locks_freed+0x290/0x290
[ 42.380878] ? ___sys_sendmsg+0x162/0x930
[ 42.381427] ? rcu_read_lock_sched_held+0xa3/0x120
[ 42.382074] ? sock_has_perm+0x1f6/0x290
[ 42.382614] ? ___sys_sendmsg+0x167/0x930
[ 42.383173] ? lock_downgrade+0x660/0x660
[ 42.383727] inet_sendmsg+0x123/0x500
[ 42.384226] ? inet_sendmsg+0x123/0x500
[ 42.384748] ? inet_recvmsg+0x540/0x540
[ 42.385263] sock_sendmsg+0xca/0x110
[ 42.385758] SYSC_sendto+0x217/0x380
[ 42.386249] ? SYSC_connect+0x310/0x310
[ 42.386783] ? __might_fault+0x110/0x1d0
[ 42.387324] ? lock_downgrade+0x660/0x660
[ 42.387880] ? __fget_light+0xa1/0x1f0
[ 42.388403] ? __fdget+0x18/0x20
[ 42.388851] ? sock_common_setsockopt+0x95/0xd0
[ 42.389472] ? SyS_setsockopt+0x17f/0x260
[ 42.390021] ? entry_SYSCALL_64_fastpath+0x5/0xbe
[ 42.390650] SyS_sendto+0x40/0x50
[ 42.391103] entry_SYSCALL_64_fastpath+0x1f/0xbe
[ 42.391731] RIP: 0033:0x7fbbb711e383
[ 42.392217] RSP: 002b:00007ffff4d34f28 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
[ 42.393235] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fbbb711e383
[ 42.394195] RDX: 0000000000001000 RSI: 00007ffff4d34f60 RDI: 0000000000000003
[ 42.395145] RBP: 0000000000000046 R08: 00007ffff4d34f40 R09: 0000000000000018
[ 42.396056] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000400aad
[ 42.396598] R13: 0000000000000066 R14: 00007ffff4d34ee0 R15: 00007fbbb717af00
[ 42.397257]
[ 42.397411] Allocated by task 3789:
[ 42.397702] save_stack_trace+0x16/0x20
[ 42.398005] save_stack+0x46/0xd0
[ 42.398267] kasan_kmalloc+0xad/0xe0
[ 42.398548] kasan_slab_alloc+0x12/0x20
[ 42.398848] __kmalloc_node_track_caller+0xcb/0x380
[ 42.399224] __kmalloc_reserve.isra.32+0x41/0xe0
[ 42.399654] __alloc_skb+0xf8/0x580
[ 42.400003] sock_wmalloc+0xab/0xf0
[ 42.400346] __ip6_append_data.isra.41+0x2472/0x33d0
[ 42.400813] ip6_append_data+0x1a8/0x2f0
[ 42.401122] rawv6_sendmsg+0x11ee/0x2db0
[ 42.401505] inet_sendmsg+0x123/0x500
[ 42.401860] sock_sendmsg+0xca/0x110
[ 42.402209] ___sys_sendmsg+0x7cb/0x930
[ 42.402582] __sys_sendmsg+0xd9/0x190
[ 42.402941] SyS_sendmsg+0x2d/0x50
[ 42.403273] entry_SYSCALL_64_fastpath+0x1f/0xbe
[ 42.403718]
[ 42.403871] Freed by task 1794:
[ 42.404146] save_stack_trace+0x16/0x20
[ 42.404515] save_stack+0x46/0xd0
[ 42.404827] kasan_slab_free+0x72/0xc0
[ 42.405167] kfree+0xe8/0x2b0
[ 42.405462] skb_free_head+0x74/0xb0
[ 42.405806] skb_release_data+0x30e/0x3a0
[ 42.406198] skb_release_all+0x4a/0x60
[ 42.406563] consume_skb+0x113/0x2e0
[ 42.406910] skb_free_datagram+0x1a/0xe0
[ 42.407288] netlink_recvmsg+0x60d/0xe40
[ 42.407667] sock_recvmsg+0xd7/0x110
[ 42.408022] ___sys_recvmsg+0x25c/0x580
[ 42.408395] __sys_recvmsg+0xd6/0x190
[ 42.408753] SyS_recvmsg+0x2d/0x50
[ 42.409086] entry_SYSCALL_64_fastpath+0x1f/0xbe
[ 42.409513]
[ 42.409665] The buggy address belongs to the object at ffff88000969e780
[ 42.409665] which belongs to the cache kmalloc-512 of size 512
[ 42.410846] The buggy address is located 24 bytes inside of
[ 42.410846] 512-byte region [ffff88000969e780, ffff88000969e980)
[ 42.411941] The buggy address belongs to the page:
[ 42.412405] page:ffffea000025a780 count:1 mapcount:0 mapping: (null) index:0x0 compound_mapcount: 0
[ 42.413298] flags: 0x100000000008100(slab|head)
[ 42.413729] raw: 0100000000008100 0000000000000000 0000000000000000 00000001800c000c
[ 42.414387] raw: ffffea00002a9500 0000000900000007 ffff88000c401280 0000000000000000
[ 42.415074] page dumped because: kasan: bad access detected
[ 42.415604]
[ 42.415757] Memory state around the buggy address:
[ 42.416222] ffff88000969e880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[ 42.416904] ffff88000969e900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[ 42.417591] >ffff88000969e980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 42.418273] ^
[ 42.418588] ffff88000969ea00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[ 42.419273] ffff88000969ea80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[ 42.419882] ==================================================================
Reported-by: Andrey Konovalov <[email protected]>
Signed-off-by: Craig Gallek <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
TfLiteStatus EvalImpl(TfLiteContext* context, const TfLiteTensor* input,
TfLiteNode* node) {
auto* params = reinterpret_cast<TfLiteUniqueParams*>(node->builtin_data);
if (params == nullptr) {
context->ReportError(context, "Null params passed");
return kTfLiteError;
}
switch (params->index_out_type) {
case kTfLiteInt32:
return EvalImpl<T, int32_t>(context, input, node);
case kTfLiteInt64:
return EvalImpl<T, int64_t>(context, input, node);
default:
context->ReportError(
context,
"Unique index output array can only be Int32 or In64, requested: %s",
TfLiteTypeGetName(params->index_out_type));
}
return kTfLiteError;
} | 1 | [
"CWE-125",
"CWE-787"
] | tensorflow | 1970c2158b1ffa416d159d03c3370b9a462aee35 | 190,949,436,845,689,970,000,000,000,000,000,000,000 | 20 | [tflite]: Insert `nullptr` checks when obtaining tensors.
As part of ongoing refactoring, `tflite::GetInput`, `tflite::GetOutput`, `tflite::GetTemporary` and `tflite::GetIntermediates` will return `nullptr` in some cases. Hence, we insert the `nullptr` checks on all usages.
We also insert `nullptr` checks on usages of `tflite::GetVariableInput` and `tflite::GetOptionalInputTensor` but only in the cases where there is no obvious check that `nullptr` is acceptable (that is, we only insert the check for the output of these two functions if the tensor is accessed as if it is always not `nullptr`).
PiperOrigin-RevId: 332521299
Change-Id: I29af455bcb48d0b92e58132d951a3badbd772d56 |
gdImageColorDeallocate (gdImagePtr im, int color)
{
if (im->trueColor)
{
return;
}
/* Mark it open. */
im->open[color] = 1;
} | 0 | [
"CWE-119"
] | php-src | feba44546c27b0158f9ac20e72040a224b918c75 | 205,467,891,045,423,830,000,000,000,000,000,000,000 | 9 | Fixed bug #22965 (Crash in gd lib's ImageFillToBorder()). |
static bool tcp_try_undo_recovery(struct sock *sk)
{
struct tcp_sock *tp = tcp_sk(sk);
if (tcp_may_undo(tp)) {
int mib_idx;
/* Happy end! We did not retransmit anything
* or our original transmission succeeded.
*/
DBGUNDO(sk, inet_csk(sk)->icsk_ca_state == TCP_CA_Loss ? "loss" : "retrans");
tcp_undo_cwnd_reduction(sk, false);
if (inet_csk(sk)->icsk_ca_state == TCP_CA_Loss)
mib_idx = LINUX_MIB_TCPLOSSUNDO;
else
mib_idx = LINUX_MIB_TCPFULLUNDO;
NET_INC_STATS(sock_net(sk), mib_idx);
}
if (tp->snd_una == tp->high_seq && tcp_is_reno(tp)) {
/* Hold old state until something *above* high_seq
* is ACKed. For Reno it is MUST to prevent false
* fast retransmits (RFC2582). SACK TCP is safe. */
if (!tcp_any_retrans_done(sk))
tp->retrans_stamp = 0;
return true;
}
tcp_set_ca_state(sk, TCP_CA_Open);
return false;
} | 0 | [
"CWE-200"
] | net | 75ff39ccc1bd5d3c455b6822ab09e533c551f758 | 56,180,505,719,223,040,000,000,000,000,000,000,000 | 30 | tcp: make challenge acks less predictable
Yue Cao claims that current host rate limiting of challenge ACKS
(RFC 5961) could leak enough information to allow a patient attacker
to hijack TCP sessions. He will soon provide details in an academic
paper.
This patch increases the default limit from 100 to 1000, and adds
some randomization so that the attacker can no longer hijack
sessions without spending a considerable amount of probes.
Based on initial analysis and patch from Linus.
Note that we also have per socket rate limiting, so it is tempting
to remove the host limit in the future.
v2: randomize the count of challenge acks per second, not the period.
Fixes: 282f23c6ee34 ("tcp: implement RFC 5961 3.2")
Reported-by: Yue Cao <[email protected]>
Signed-off-by: Eric Dumazet <[email protected]>
Suggested-by: Linus Torvalds <[email protected]>
Cc: Yuchung Cheng <[email protected]>
Cc: Neal Cardwell <[email protected]>
Acked-by: Neal Cardwell <[email protected]>
Acked-by: Yuchung Cheng <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
void stralgoLCS(client *c) {
uint32_t i, j;
long long minmatchlen = 0;
sds a = NULL, b = NULL;
int getlen = 0, getidx = 0, withmatchlen = 0;
robj *obja = NULL, *objb = NULL;
for (j = 2; j < (uint32_t)c->argc; j++) {
char *opt = c->argv[j]->ptr;
int moreargs = (c->argc-1) - j;
if (!strcasecmp(opt,"IDX")) {
getidx = 1;
} else if (!strcasecmp(opt,"LEN")) {
getlen = 1;
} else if (!strcasecmp(opt,"WITHMATCHLEN")) {
withmatchlen = 1;
} else if (!strcasecmp(opt,"MINMATCHLEN") && moreargs) {
if (getLongLongFromObjectOrReply(c,c->argv[j+1],&minmatchlen,NULL)
!= C_OK) goto cleanup;
if (minmatchlen < 0) minmatchlen = 0;
j++;
} else if (!strcasecmp(opt,"STRINGS") && moreargs > 1) {
if (a != NULL) {
addReplyError(c,"Either use STRINGS or KEYS");
goto cleanup;
}
a = c->argv[j+1]->ptr;
b = c->argv[j+2]->ptr;
j += 2;
} else if (!strcasecmp(opt,"KEYS") && moreargs > 1) {
if (a != NULL) {
addReplyError(c,"Either use STRINGS or KEYS");
goto cleanup;
}
obja = lookupKeyRead(c->db,c->argv[j+1]);
objb = lookupKeyRead(c->db,c->argv[j+2]);
if ((obja && obja->type != OBJ_STRING) ||
(objb && objb->type != OBJ_STRING))
{
addReplyError(c,
"The specified keys must contain string values");
/* Don't cleanup the objects, we need to do that
* only after calling getDecodedObject(). */
obja = NULL;
objb = NULL;
goto cleanup;
}
obja = obja ? getDecodedObject(obja) : createStringObject("",0);
objb = objb ? getDecodedObject(objb) : createStringObject("",0);
a = obja->ptr;
b = objb->ptr;
j += 2;
} else {
addReplyErrorObject(c,shared.syntaxerr);
goto cleanup;
}
}
/* Complain if the user passed ambiguous parameters. */
if (a == NULL) {
addReplyError(c,"Please specify two strings: "
"STRINGS or KEYS options are mandatory");
goto cleanup;
} else if (getlen && getidx) {
addReplyError(c,
"If you want both the length and indexes, please "
"just use IDX.");
goto cleanup;
}
/* Compute the LCS using the vanilla dynamic programming technique of
* building a table of LCS(x,y) substrings. */
uint32_t alen = sdslen(a);
uint32_t blen = sdslen(b);
/* Setup an uint32_t array to store at LCS[i,j] the length of the
* LCS A0..i-1, B0..j-1. Note that we have a linear array here, so
* we index it as LCS[j+(blen+1)*j] */
uint32_t *lcs = zmalloc((alen+1)*(blen+1)*sizeof(uint32_t));
#define LCS(A,B) lcs[(B)+((A)*(blen+1))]
/* Start building the LCS table. */
for (uint32_t i = 0; i <= alen; i++) {
for (uint32_t j = 0; j <= blen; j++) {
if (i == 0 || j == 0) {
/* If one substring has length of zero, the
* LCS length is zero. */
LCS(i,j) = 0;
} else if (a[i-1] == b[j-1]) {
/* The len LCS (and the LCS itself) of two
* sequences with the same final character, is the
* LCS of the two sequences without the last char
* plus that last char. */
LCS(i,j) = LCS(i-1,j-1)+1;
} else {
/* If the last character is different, take the longest
* between the LCS of the first string and the second
* minus the last char, and the reverse. */
uint32_t lcs1 = LCS(i-1,j);
uint32_t lcs2 = LCS(i,j-1);
LCS(i,j) = lcs1 > lcs2 ? lcs1 : lcs2;
}
}
}
/* Store the actual LCS string in "result" if needed. We create
* it backward, but the length is already known, we store it into idx. */
uint32_t idx = LCS(alen,blen);
sds result = NULL; /* Resulting LCS string. */
void *arraylenptr = NULL; /* Deffered length of the array for IDX. */
uint32_t arange_start = alen, /* alen signals that values are not set. */
arange_end = 0,
brange_start = 0,
brange_end = 0;
/* Do we need to compute the actual LCS string? Allocate it in that case. */
int computelcs = getidx || !getlen;
if (computelcs) result = sdsnewlen(SDS_NOINIT,idx);
/* Start with a deferred array if we have to emit the ranges. */
uint32_t arraylen = 0; /* Number of ranges emitted in the array. */
if (getidx) {
addReplyMapLen(c,2);
addReplyBulkCString(c,"matches");
arraylenptr = addReplyDeferredLen(c);
}
i = alen, j = blen;
while (computelcs && i > 0 && j > 0) {
int emit_range = 0;
if (a[i-1] == b[j-1]) {
/* If there is a match, store the character and reduce
* the indexes to look for a new match. */
result[idx-1] = a[i-1];
/* Track the current range. */
if (arange_start == alen) {
arange_start = i-1;
arange_end = i-1;
brange_start = j-1;
brange_end = j-1;
} else {
/* Let's see if we can extend the range backward since
* it is contiguous. */
if (arange_start == i && brange_start == j) {
arange_start--;
brange_start--;
} else {
emit_range = 1;
}
}
/* Emit the range if we matched with the first byte of
* one of the two strings. We'll exit the loop ASAP. */
if (arange_start == 0 || brange_start == 0) emit_range = 1;
idx--; i--; j--;
} else {
/* Otherwise reduce i and j depending on the largest
* LCS between, to understand what direction we need to go. */
uint32_t lcs1 = LCS(i-1,j);
uint32_t lcs2 = LCS(i,j-1);
if (lcs1 > lcs2)
i--;
else
j--;
if (arange_start != alen) emit_range = 1;
}
/* Emit the current range if needed. */
uint32_t match_len = arange_end - arange_start + 1;
if (emit_range) {
if (minmatchlen == 0 || match_len >= minmatchlen) {
if (arraylenptr) {
addReplyArrayLen(c,2+withmatchlen);
addReplyArrayLen(c,2);
addReplyLongLong(c,arange_start);
addReplyLongLong(c,arange_end);
addReplyArrayLen(c,2);
addReplyLongLong(c,brange_start);
addReplyLongLong(c,brange_end);
if (withmatchlen) addReplyLongLong(c,match_len);
arraylen++;
}
}
arange_start = alen; /* Restart at the next match. */
}
}
/* Signal modified key, increment dirty, ... */
/* Reply depending on the given options. */
if (arraylenptr) {
addReplyBulkCString(c,"len");
addReplyLongLong(c,LCS(alen,blen));
setDeferredArrayLen(c,arraylenptr,arraylen);
} else if (getlen) {
addReplyLongLong(c,LCS(alen,blen));
} else {
addReplyBulkSds(c,result);
result = NULL;
}
/* Cleanup. */
sdsfree(result);
zfree(lcs);
cleanup:
if (obja) decrRefCount(obja);
if (objb) decrRefCount(objb);
return;
} | 1 | [
"CWE-190"
] | redis | 92e3b1802f72ca0c5b0bde97f01d9b57a758d85c | 176,537,741,763,154,450,000,000,000,000,000,000,000 | 211 | Fix integer overflow in STRALGO LCS (CVE-2021-29477)
An integer overflow bug in Redis version 6.0 or newer could be exploited using
the STRALGO LCS command to corrupt the heap and potentially result with remote
code execution.
(cherry picked from commit f0c5f920d0f88bd8aa376a2c05af4902789d1ef9) |
static void Compute(OpKernelContext* context, const CPUDevice& device,
typename TTypes<T, 3>::ConstTensor& input,
typename TTypes<T>::Tensor& output,
const Eigen::Index lower_diag_index,
const Eigen::Index upper_diag_index,
const Eigen::Index max_diag_len, const T padding_value,
const bool left_align_superdiagonal,
const bool left_align_subdiagonal) {
// 10 in cost_per_batch is from existing heuristic.
// TODO(penporn): Tune for the best constant in cost_per_batch.
const Eigen::Index num_diags = upper_diag_index - lower_diag_index + 1;
const Eigen::Index output_elements_in_batch = num_diags * max_diag_len;
const Eigen::Index cost_per_batch = 10 * output_elements_in_batch;
const Eigen::Index num_batches = input.dimension(0);
const Eigen::Index num_rows = input.dimension(1);
const Eigen::Index num_cols = input.dimension(2);
auto compute_shard = [&output, &input, &num_rows, &num_cols,
&upper_diag_index, &max_diag_len, &num_diags,
&output_elements_in_batch, &padding_value,
&left_align_superdiagonal, &left_align_subdiagonal](
Eigen::Index begin, Eigen::Index end) {
Eigen::Index output_base_index = begin * output_elements_in_batch;
for (Eigen::Index batch = begin; batch < end; ++batch) {
for (Eigen::Index m = 0; m < num_diags; ++m) {
const Eigen::Index diag_index = upper_diag_index - m;
Eigen::Index y_offset = std::max<Eigen::Index>(0, -diag_index);
Eigen::Index x_offset = std::max<Eigen::Index>(0, diag_index);
int diag_len, content_offset;
std::tie(diag_len, content_offset) = ComputeDiagLenAndContentOffset(
diag_index, max_diag_len, num_rows, num_cols,
left_align_superdiagonal, left_align_subdiagonal);
// Fills the diagonal.
for (Eigen::Index n = 0; n < diag_len; ++n) {
output(output_base_index + content_offset + n) =
input(batch, n + y_offset, n + x_offset);
}
// Padding.
const bool left_align = (content_offset == 0);
const Eigen::Index padding_start = (left_align) ? diag_len : 0;
const Eigen::Index padding_end =
(left_align) ? max_diag_len : content_offset;
for (Eigen::Index n = padding_start; n < padding_end; ++n) {
output(output_base_index + n) = padding_value;
}
output_base_index += max_diag_len;
}
}
};
auto thread_pool =
context->device()->tensorflow_cpu_worker_threads()->workers;
thread_pool->ParallelFor(num_batches, cost_per_batch,
std::move(compute_shard));
} | 0 | [
"CWE-476",
"CWE-125"
] | tensorflow | 482da92095c4d48f8784b1f00dda4f81c28d2988 | 223,638,036,830,396,870,000,000,000,000,000,000,000 | 56 | Ensure non-empty padding_value input to tf.raw_ops.MatrixDiagPartV2, if a padding_value is input
PiperOrigin-RevId: 388314614
Change-Id: If0b51ad58d5d8543a6be6ce8f42ae4755c80d55f |
psutil_win32_QueryDosDevice(PyObject *self, PyObject *args) {
LPCTSTR lpDevicePath;
TCHAR d = TEXT('A');
TCHAR szBuff[5];
if (!PyArg_ParseTuple(args, "s", &lpDevicePath))
return NULL;
while (d <= TEXT('Z')) {
TCHAR szDeviceName[3] = {d, TEXT(':'), TEXT('\0')};
TCHAR szTarget[512] = {0};
if (QueryDosDevice(szDeviceName, szTarget, 511) != 0) {
if (_tcscmp(lpDevicePath, szTarget) == 0) {
_stprintf_s(szBuff, _countof(szBuff), TEXT("%c:"), d);
return Py_BuildValue("s", szBuff);
}
}
d++;
}
return Py_BuildValue("s", "");
} | 0 | [
"CWE-415"
] | psutil | 7d512c8e4442a896d56505be3e78f1156f443465 | 73,669,574,038,440,790,000,000,000,000,000,000,000 | 21 | Use Py_CLEAR instead of Py_DECREF to also set the variable to NULL (#1616)
These files contain loops that convert system data into python objects
and during the process they create objects and dereference their
refcounts after they have been added to the resulting list.
However, in case of errors during the creation of those python objects,
the refcount to previously allocated objects is dropped again with
Py_XDECREF, which should be a no-op in case the paramater is NULL. Even
so, in most of these loops the variables pointing to the objects are
never set to NULL, even after Py_DECREF is called at the end of the loop
iteration. This means, after the first iteration, if an error occurs
those python objects will get their refcount dropped two times,
resulting in a possible double-free. |
usm_add_user(struct usmUser *user)
{
struct usmUser *uptr;
uptr = usm_add_user_to_list(user, userList);
if (uptr != NULL)
userList = uptr;
return uptr;
} | 0 | [
"CWE-415"
] | net-snmp | 5f881d3bf24599b90d67a45cae7a3eb099cd71c9 | 231,993,013,645,554,600,000,000,000,000,000,000,000 | 8 | libsnmp, USM: Introduce a reference count in struct usmStateReference
This patch fixes https://sourceforge.net/p/net-snmp/bugs/2956/. |
TEST_P(Http2CodecImplTest, ManyRequestHeadersAccepted) {
max_request_headers_count_ = 150;
initialize();
TestRequestHeaderMapImpl request_headers;
HttpTestUtility::addDefaultHeaders(request_headers);
for (int i = 0; i < 145; i++) {
request_headers.addCopy(std::to_string(i), "");
}
EXPECT_CALL(request_decoder_, decodeHeaders_(_, _));
EXPECT_CALL(server_stream_callbacks_, onResetStream(_, _)).Times(0);
request_encoder_->encodeHeaders(request_headers, false);
} | 0 | [
"CWE-400"
] | envoy | 0e49a495826ea9e29134c1bd54fdeb31a034f40c | 60,375,413,966,151,890,000,000,000,000,000,000,000 | 13 | http/2: add stats and stream flush timeout (#139)
This commit adds a new stream flush timeout to guard against a
remote server that does not open window once an entire stream has
been buffered for flushing. Additional stats have also been added
to better understand the codecs view of active streams as well as
amount of data buffered.
Signed-off-by: Matt Klein <[email protected]> |
static char *write_metadata (WavpackMetadata *wpmd, char *outdata)
{
unsigned char id = wpmd->id, wordlen [3];
wordlen [0] = (wpmd->byte_length + 1) >> 1;
wordlen [1] = (wpmd->byte_length + 1) >> 9;
wordlen [2] = (wpmd->byte_length + 1) >> 17;
if (wpmd->byte_length & 1)
id |= ID_ODD_SIZE;
if (wordlen [1] || wordlen [2])
id |= ID_LARGE;
*outdata++ = id;
*outdata++ = wordlen [0];
if (id & ID_LARGE) {
*outdata++ = wordlen [1];
*outdata++ = wordlen [2];
}
if (wpmd->data && wpmd->byte_length) {
memcpy (outdata, wpmd->data, wpmd->byte_length);
outdata += wpmd->byte_length;
if (wpmd->byte_length & 1)
*outdata++ = 0;
}
return outdata;
} | 0 | [
"CWE-703",
"CWE-835"
] | WavPack | 070ef6f138956d9ea9612e69586152339dbefe51 | 200,908,234,786,361,700,000,000,000,000,000,000,000 | 32 | issue #53: error out on zero sample rate |
TEST_F(QueryPlannerTest, ShardFilterNestedProjCovered) {
params.options = QueryPlannerParams::INCLUDE_SHARD_FILTER;
params.shardKey = BSON("a" << 1 << "b.c" << 1);
addIndex(BSON("a" << 1 << "b.c" << 1));
runQuerySortProj(fromjson("{a: 1}"), BSONObj(), fromjson("{_id: 0, a: 1, 'b.c': 1}"));
assertNumSolutions(1U);
assertSolutionExists(
"{proj: {spec: {_id: 0, a: 1, 'b.c': 1 }, type: 'default', node: "
"{sharding_filter: {node: "
"{ixscan: {filter: null, pattern: {a: 1, 'b.c': 1}}}}}}}");
} | 0 | [] | mongo | ee97c0699fd55b498310996ee002328e533681a3 | 17,018,540,278,954,353,000,000,000,000,000,000,000 | 13 | SERVER-36993 Fix crash due to incorrect $or pushdown for indexed $expr. |
TEST_F(EncryptionUtilTest, aes_test_basic) {
std::string source_1 = "hello, doris";
do_aes_test(source_1, _aes_key);
std::string source_2 = "doris test";
do_aes_test(source_2, _aes_key);
} | 0 | [
"CWE-200"
] | incubator-doris | 246ac4e37aa4da6836b7850cb990f02d1c3725a3 | 322,725,663,766,573,100,000,000,000,000,000,000,000 | 6 | [fix] fix a bug of encryption function with iv may return wrong result (#8277) |
xml_data(void *userData, const char *s, int len)
{
struct archive_read *a;
struct xar *xar;
a = (struct archive_read *)userData;
xar = (struct xar *)(a->format->data);
#if DEBUG
{
char buff[1024];
if (len > (int)(sizeof(buff)-1))
len = (int)(sizeof(buff)-1);
strncpy(buff, s, len);
buff[len] = 0;
fprintf(stderr, "\tlen=%d:\"%s\"\n", len, buff);
}
#endif
switch (xar->xmlsts) {
case TOC_CHECKSUM_OFFSET:
xar->toc_chksum_offset = atol10(s, len);
break;
case TOC_CHECKSUM_SIZE:
xar->toc_chksum_size = atol10(s, len);
break;
default:
break;
}
if (xar->file == NULL)
return;
switch (xar->xmlsts) {
case FILE_NAME:
if (xar->file->parent != NULL) {
archive_string_concat(&(xar->file->pathname),
&(xar->file->parent->pathname));
archive_strappend_char(&(xar->file->pathname), '/');
}
xar->file->has |= HAS_PATHNAME;
if (xar->base64text) {
strappend_base64(xar,
&(xar->file->pathname), s, len);
} else
archive_strncat(&(xar->file->pathname), s, len);
break;
case FILE_LINK:
xar->file->has |= HAS_SYMLINK;
archive_strncpy(&(xar->file->symlink), s, len);
break;
case FILE_TYPE:
if (strncmp("file", s, len) == 0 ||
strncmp("hardlink", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFREG;
if (strncmp("directory", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFDIR;
if (strncmp("symlink", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFLNK;
if (strncmp("character special", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFCHR;
if (strncmp("block special", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFBLK;
if (strncmp("socket", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFSOCK;
if (strncmp("fifo", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFIFO;
xar->file->has |= HAS_TYPE;
break;
case FILE_INODE:
xar->file->has |= HAS_INO;
xar->file->ino64 = atol10(s, len);
break;
case FILE_DEVICE_MAJOR:
xar->file->has |= HAS_DEVMAJOR;
xar->file->devmajor = (dev_t)atol10(s, len);
break;
case FILE_DEVICE_MINOR:
xar->file->has |= HAS_DEVMINOR;
xar->file->devminor = (dev_t)atol10(s, len);
break;
case FILE_DEVICENO:
xar->file->has |= HAS_DEV;
xar->file->dev = (dev_t)atol10(s, len);
break;
case FILE_MODE:
xar->file->has |= HAS_MODE;
xar->file->mode =
(xar->file->mode & AE_IFMT) |
((mode_t)(atol8(s, len)) & ~AE_IFMT);
break;
case FILE_GROUP:
xar->file->has |= HAS_GID;
archive_strncpy(&(xar->file->gname), s, len);
break;
case FILE_GID:
xar->file->has |= HAS_GID;
xar->file->gid = atol10(s, len);
break;
case FILE_USER:
xar->file->has |= HAS_UID;
archive_strncpy(&(xar->file->uname), s, len);
break;
case FILE_UID:
xar->file->has |= HAS_UID;
xar->file->uid = atol10(s, len);
break;
case FILE_CTIME:
xar->file->has |= HAS_TIME;
xar->file->ctime = parse_time(s, len);
break;
case FILE_MTIME:
xar->file->has |= HAS_TIME;
xar->file->mtime = parse_time(s, len);
break;
case FILE_ATIME:
xar->file->has |= HAS_TIME;
xar->file->atime = parse_time(s, len);
break;
case FILE_DATA_LENGTH:
xar->file->has |= HAS_DATA;
xar->file->length = atol10(s, len);
break;
case FILE_DATA_OFFSET:
xar->file->has |= HAS_DATA;
xar->file->offset = atol10(s, len);
break;
case FILE_DATA_SIZE:
xar->file->has |= HAS_DATA;
xar->file->size = atol10(s, len);
break;
case FILE_DATA_A_CHECKSUM:
xar->file->a_sum.len = atohex(xar->file->a_sum.val,
sizeof(xar->file->a_sum.val), s, len);
break;
case FILE_DATA_E_CHECKSUM:
xar->file->e_sum.len = atohex(xar->file->e_sum.val,
sizeof(xar->file->e_sum.val), s, len);
break;
case FILE_EA_LENGTH:
xar->file->has |= HAS_XATTR;
xar->xattr->length = atol10(s, len);
break;
case FILE_EA_OFFSET:
xar->file->has |= HAS_XATTR;
xar->xattr->offset = atol10(s, len);
break;
case FILE_EA_SIZE:
xar->file->has |= HAS_XATTR;
xar->xattr->size = atol10(s, len);
break;
case FILE_EA_A_CHECKSUM:
xar->file->has |= HAS_XATTR;
xar->xattr->a_sum.len = atohex(xar->xattr->a_sum.val,
sizeof(xar->xattr->a_sum.val), s, len);
break;
case FILE_EA_E_CHECKSUM:
xar->file->has |= HAS_XATTR;
xar->xattr->e_sum.len = atohex(xar->xattr->e_sum.val,
sizeof(xar->xattr->e_sum.val), s, len);
break;
case FILE_EA_NAME:
xar->file->has |= HAS_XATTR;
archive_strncpy(&(xar->xattr->name), s, len);
break;
case FILE_EA_FSTYPE:
xar->file->has |= HAS_XATTR;
archive_strncpy(&(xar->xattr->fstype), s, len);
break;
break;
case FILE_ACL_DEFAULT:
case FILE_ACL_ACCESS:
case FILE_ACL_APPLEEXTENDED:
xar->file->has |= HAS_ACL;
/* TODO */
break;
case INIT:
case XAR:
case TOC:
case TOC_CREATION_TIME:
case TOC_CHECKSUM:
case TOC_CHECKSUM_OFFSET:
case TOC_CHECKSUM_SIZE:
case TOC_FILE:
case FILE_DATA:
case FILE_DATA_ENCODING:
case FILE_DATA_CONTENT:
case FILE_DEVICE:
case FILE_EA:
case FILE_EA_ENCODING:
case FILE_ACL:
case FILE_FLAGS:
case FILE_FLAGS_USER_NODUMP:
case FILE_FLAGS_USER_IMMUTABLE:
case FILE_FLAGS_USER_APPEND:
case FILE_FLAGS_USER_OPAQUE:
case FILE_FLAGS_USER_NOUNLINK:
case FILE_FLAGS_SYS_ARCHIVED:
case FILE_FLAGS_SYS_IMMUTABLE:
case FILE_FLAGS_SYS_APPEND:
case FILE_FLAGS_SYS_NOUNLINK:
case FILE_FLAGS_SYS_SNAPSHOT:
case FILE_EXT2:
case FILE_EXT2_SecureDeletion:
case FILE_EXT2_Undelete:
case FILE_EXT2_Compress:
case FILE_EXT2_Synchronous:
case FILE_EXT2_Immutable:
case FILE_EXT2_AppendOnly:
case FILE_EXT2_NoDump:
case FILE_EXT2_NoAtime:
case FILE_EXT2_CompDirty:
case FILE_EXT2_CompBlock:
case FILE_EXT2_NoCompBlock:
case FILE_EXT2_CompError:
case FILE_EXT2_BTree:
case FILE_EXT2_HashIndexed:
case FILE_EXT2_iMagic:
case FILE_EXT2_Journaled:
case FILE_EXT2_NoTail:
case FILE_EXT2_DirSync:
case FILE_EXT2_TopDir:
case FILE_EXT2_Reserved:
case UNKNOWN:
break;
}
} | 0 | [
"CWE-125"
] | libarchive | fa7438a0ff4033e4741c807394a9af6207940d71 | 73,406,347,275,341,870,000,000,000,000,000,000,000 | 232 | Do something sensible for empty strings to make fuzzers happy. |
RGWOpType get_type() { return RGW_OP_DELETE_OBJ_TAGGING;} | 0 | [
"CWE-770"
] | ceph | ab29bed2fc9f961fe895de1086a8208e21ddaddc | 280,251,901,703,501,630,000,000,000,000,000,000,000 | 1 | rgw: fix issues with 'enforce bounds' patch
The patch to enforce bounds on max-keys/max-uploads/max-parts had a few
issues that would prevent us from compiling it. Instead of changing the
code provided by the submitter, we're addressing them in a separate
commit to maintain the DCO.
Signed-off-by: Joao Eduardo Luis <[email protected]>
Signed-off-by: Abhishek Lekshmanan <[email protected]>
(cherry picked from commit 29bc434a6a81a2e5c5b8cfc4c8d5c82ca5bf538a)
mimic specific fixes:
As the largeish change from master g_conf() isn't in mimic yet, use the g_conf
global structure, also make rgw_op use the value from req_info ceph context as
we do for all the requests |
PHP_MINIT_FUNCTION(soap)
{
zend_class_entry ce;
/* TODO: add ini entry for always use soap errors */
php_soap_prepare_globals();
ZEND_INIT_MODULE_GLOBALS(soap, php_soap_init_globals, NULL);
REGISTER_INI_ENTRIES();
/* Register SoapClient class */
/* BIG NOTE : THIS EMITS AN COMPILATION WARNING UNDER ZE2 - handle_function_call deprecated.
soap_call_function_handler should be of type struct _zend_function, not (*handle_function_call).
*/
{
zend_internal_function fe;
fe.type = ZEND_INTERNAL_FUNCTION;
fe.handler = ZEND_MN(SoapClient___call);
fe.function_name = NULL;
fe.scope = NULL;
fe.fn_flags = 0;
fe.prototype = NULL;
fe.num_args = 2;
fe.arg_info = NULL;
INIT_OVERLOADED_CLASS_ENTRY(ce, PHP_SOAP_CLIENT_CLASSNAME, soap_client_functions,
(zend_function *)&fe, NULL, NULL);
soap_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
}
/* Register SoapVar class */
INIT_CLASS_ENTRY(ce, PHP_SOAP_VAR_CLASSNAME, soap_var_functions);
soap_var_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
/* Register SoapServer class */
INIT_CLASS_ENTRY(ce, PHP_SOAP_SERVER_CLASSNAME, soap_server_functions);
soap_server_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
/* Register SoapFault class */
INIT_CLASS_ENTRY(ce, PHP_SOAP_FAULT_CLASSNAME, soap_fault_functions);
soap_fault_class_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);
/* Register SoapParam class */
INIT_CLASS_ENTRY(ce, PHP_SOAP_PARAM_CLASSNAME, soap_param_functions);
soap_param_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
INIT_CLASS_ENTRY(ce, PHP_SOAP_HEADER_CLASSNAME, soap_header_functions);
soap_header_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
le_sdl = register_list_destructors(delete_sdl, NULL);
le_url = register_list_destructors(delete_url, NULL);
le_service = register_list_destructors(delete_service, NULL);
le_typemap = register_list_destructors(delete_hashtable, NULL);
REGISTER_LONG_CONSTANT("SOAP_1_1", SOAP_1_1, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_1_2", SOAP_1_2, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_PERSISTENCE_SESSION", SOAP_PERSISTENCE_SESSION, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_PERSISTENCE_REQUEST", SOAP_PERSISTENCE_REQUEST, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_FUNCTIONS_ALL", SOAP_FUNCTIONS_ALL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_ENCODED", SOAP_ENCODED, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_LITERAL", SOAP_LITERAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_RPC", SOAP_RPC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_DOCUMENT", SOAP_DOCUMENT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_ACTOR_NEXT", SOAP_ACTOR_NEXT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_ACTOR_NONE", SOAP_ACTOR_NONE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_ACTOR_UNLIMATERECEIVER", SOAP_ACTOR_UNLIMATERECEIVER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_COMPRESSION_ACCEPT", SOAP_COMPRESSION_ACCEPT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_COMPRESSION_GZIP", SOAP_COMPRESSION_GZIP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_COMPRESSION_DEFLATE", SOAP_COMPRESSION_DEFLATE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_AUTHENTICATION_BASIC", SOAP_AUTHENTICATION_BASIC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_AUTHENTICATION_DIGEST", SOAP_AUTHENTICATION_DIGEST, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UNKNOWN_TYPE", UNKNOWN_TYPE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_STRING", XSD_STRING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_BOOLEAN", XSD_BOOLEAN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_DECIMAL", XSD_DECIMAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_FLOAT", XSD_FLOAT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_DOUBLE", XSD_DOUBLE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_DURATION", XSD_DURATION, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_DATETIME", XSD_DATETIME, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_TIME", XSD_TIME, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_DATE", XSD_DATE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_GYEARMONTH", XSD_GYEARMONTH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_GYEAR", XSD_GYEAR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_GMONTHDAY", XSD_GMONTHDAY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_GDAY", XSD_GDAY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_GMONTH", XSD_GMONTH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_HEXBINARY", XSD_HEXBINARY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_BASE64BINARY", XSD_BASE64BINARY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_ANYURI", XSD_ANYURI, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_QNAME", XSD_QNAME, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NOTATION", XSD_NOTATION, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NORMALIZEDSTRING", XSD_NORMALIZEDSTRING, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_TOKEN", XSD_TOKEN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_LANGUAGE", XSD_LANGUAGE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NMTOKEN", XSD_NMTOKEN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NAME", XSD_NAME, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NCNAME", XSD_NCNAME, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_ID", XSD_ID, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_IDREF", XSD_IDREF, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_IDREFS", XSD_IDREFS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_ENTITY", XSD_ENTITY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_ENTITIES", XSD_ENTITIES, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_INTEGER", XSD_INTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NONPOSITIVEINTEGER", XSD_NONPOSITIVEINTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NEGATIVEINTEGER", XSD_NEGATIVEINTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_LONG", XSD_LONG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_INT", XSD_INT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_SHORT", XSD_SHORT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_BYTE", XSD_BYTE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NONNEGATIVEINTEGER", XSD_NONNEGATIVEINTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_UNSIGNEDLONG", XSD_UNSIGNEDLONG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_UNSIGNEDINT", XSD_UNSIGNEDINT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_UNSIGNEDSHORT", XSD_UNSIGNEDSHORT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_UNSIGNEDBYTE", XSD_UNSIGNEDBYTE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_POSITIVEINTEGER", XSD_POSITIVEINTEGER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_NMTOKENS", XSD_NMTOKENS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_ANYTYPE", XSD_ANYTYPE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_ANYXML", XSD_ANYXML, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("APACHE_MAP", APACHE_MAP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_ENC_OBJECT", SOAP_ENC_OBJECT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_ENC_ARRAY", SOAP_ENC_ARRAY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XSD_1999_TIMEINSTANT", XSD_1999_TIMEINSTANT, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("XSD_NAMESPACE", XSD_NAMESPACE, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("XSD_1999_NAMESPACE", XSD_1999_NAMESPACE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_SINGLE_ELEMENT_ARRAYS", SOAP_SINGLE_ELEMENT_ARRAYS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_WAIT_ONE_WAY_CALLS", SOAP_WAIT_ONE_WAY_CALLS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SOAP_USE_XSI_ARRAY_TYPE", SOAP_USE_XSI_ARRAY_TYPE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("WSDL_CACHE_NONE", WSDL_CACHE_NONE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("WSDL_CACHE_DISK", WSDL_CACHE_DISK, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("WSDL_CACHE_MEMORY", WSDL_CACHE_MEMORY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("WSDL_CACHE_BOTH", WSDL_CACHE_BOTH, CONST_CS | CONST_PERSISTENT);
old_error_handler = zend_error_cb;
zend_error_cb = soap_error_handler;
return SUCCESS;
} | 0 | [] | php-src | 51856a76f87ecb24fe1385342be43610fb6c86e4 | 38,203,800,748,803,124,000,000,000,000,000,000,000 | 150 | Fixed bug #69152 |
Expression_Obj Parser::parse_expression()
{
NESTING_GUARD(nestings);
advanceToNextToken();
ParserState state(pstate);
// parses multiple add and subtract operations
// NOTE: make sure that identifiers starting with
// NOTE: dashes do NOT count as subtract operation
Expression_Obj lhs = parse_operators();
// if it's a singleton, return it (don't wrap it)
if (!(peek_css< exactly<'+'> >(position) ||
// condition is a bit misterious, but some combinations should not be counted as operations
(peek< no_spaces >(position) && peek< sequence< negate< unsigned_number >, exactly<'-'>, negate< space > > >(position)) ||
(peek< sequence< negate< unsigned_number >, exactly<'-'>, negate< unsigned_number > > >(position))) ||
peek< sequence < zero_plus < exactly <'-' > >, identifier > >(position))
{ return lhs; }
std::vector<Expression_Obj> operands;
std::vector<Operand> operators;
bool left_ws = peek < css_comments >() != NULL;
while (
lex_css< exactly<'+'> >() ||
(
! peek_css< sequence < zero_plus < exactly <'-' > >, identifier > >(position)
&& lex_css< sequence< negate< digit >, exactly<'-'> > >()
)
) {
bool right_ws = peek < css_comments >() != NULL;
operators.push_back({ lexed.to_string() == "+" ? Sass_OP::ADD : Sass_OP::SUB, left_ws, right_ws });
operands.push_back(parse_operators());
left_ws = peek < css_comments >() != NULL;
}
if (operands.size() == 0) return lhs;
Expression_Obj ex = fold_operands(lhs, operands, operators);
state.offset = pstate - state + pstate.offset;
ex->pstate(state);
return ex;
} | 0 | [
"CWE-125"
] | libsass | eb15533b07773c30dc03c9d742865604f47120ef | 232,883,358,268,092,250,000,000,000,000,000,000,000 | 42 | Fix memory leak in `parse_ie_keyword_arg`
`kwd_arg` would never get freed when there was a parse error in
`parse_ie_keyword_arg`.
Closes #2656 |
Subsets and Splits