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
|
---|---|---|---|---|---|---|---|
static void zmalloc_default_oom(size_t size) {
fprintf(stderr, "zmalloc: Out of memory trying to allocate %zu bytes\n",
size);
fflush(stderr);
abort();
} | 0 | [
"CWE-190"
] | redis | d32f2e9999ce003bad0bd2c3bca29f64dcce4433 | 174,911,523,117,203,820,000,000,000,000,000,000,000 | 6 | Fix integer overflow (CVE-2021-21309). (#8522)
On 32-bit systems, setting the proto-max-bulk-len config parameter to a high value may result with integer overflow and a subsequent heap overflow when parsing an input bulk (CVE-2021-21309).
This fix has two parts:
Set a reasonable limit to the config parameter.
Add additional checks to prevent the problem in other potential but unknown code paths. |
void kvm_inject_pit_timer_irqs(struct kvm_vcpu *vcpu)
{
struct kvm_pit *pit = vcpu->kvm->arch.vpit;
struct kvm *kvm = vcpu->kvm;
struct kvm_kpit_state *ps;
if (pit) {
int inject = 0;
ps = &pit->pit_state;
/* Try to inject pending interrupts when
* last one has been acked.
*/
spin_lock(&ps->inject_lock);
if (atomic_read(&ps->pit_timer.pending) && ps->irq_ack) {
ps->irq_ack = 0;
inject = 1;
}
spin_unlock(&ps->inject_lock);
if (inject)
__inject_pit_timer_intr(kvm);
}
} | 0 | [
"CWE-119",
"CWE-787"
] | linux | ee73f656a604d5aa9df86a97102e4e462dd79924 | 332,895,183,187,107,230,000,000,000,000,000,000,000 | 23 | KVM: PIT: control word is write-only
PIT control word (address 0x43) is write-only, reads are undefined.
Cc: [email protected]
Signed-off-by: Marcelo Tosatti <[email protected]> |
static uint get_table_structure(char *table, char *db, char *table_type,
char *ignore_flag)
{
my_bool init=0, delayed, write_data, complete_insert;
my_ulonglong num_fields;
char *result_table, *opt_quoted_table;
const char *insert_option;
char name_buff[NAME_LEN+3],table_buff[NAME_LEN*2+3];
char table_buff2[NAME_LEN*2+3], query_buff[QUERY_LENGTH];
const char *show_fields_stmt= "SELECT `COLUMN_NAME` AS `Field`, "
"`COLUMN_TYPE` AS `Type`, "
"`IS_NULLABLE` AS `Null`, "
"`COLUMN_KEY` AS `Key`, "
"`COLUMN_DEFAULT` AS `Default`, "
"`EXTRA` AS `Extra`, "
"`COLUMN_COMMENT` AS `Comment` "
"FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE "
"TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'";
FILE *sql_file= md_result_file;
int len;
my_bool is_log_table;
MYSQL_RES *result;
MYSQL_ROW row;
DBUG_ENTER("get_table_structure");
DBUG_PRINT("enter", ("db: %s table: %s", db, table));
*ignore_flag= check_if_ignore_table(table, table_type);
delayed= opt_delayed;
if (delayed && (*ignore_flag & IGNORE_INSERT_DELAYED))
{
delayed= 0;
verbose_msg("-- Warning: Unable to use delayed inserts for table '%s' "
"because it's of type %s\n", table, table_type);
}
complete_insert= 0;
if ((write_data= !(*ignore_flag & IGNORE_DATA)))
{
complete_insert= opt_complete_insert;
if (!insert_pat_inited)
{
insert_pat_inited= 1;
init_dynamic_string_checked(&insert_pat, "", 1024, 1024);
}
else
dynstr_set_checked(&insert_pat, "");
}
insert_option= ((delayed && opt_ignore) ? " DELAYED IGNORE " :
delayed ? " DELAYED " : opt_ignore ? " IGNORE " : "");
verbose_msg("-- Retrieving table structure for table %s...\n", table);
len= my_snprintf(query_buff, sizeof(query_buff),
"SET SQL_QUOTE_SHOW_CREATE=%d",
(opt_quoted || opt_keywords));
if (!create_options)
strmov(query_buff+len,
"/*!40102 ,SQL_MODE=concat(@@sql_mode, _utf8 ',NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS') */");
result_table= quote_name(table, table_buff, 1);
opt_quoted_table= quote_name(table, table_buff2, 0);
if (opt_order_by_primary)
order_by= primary_key_fields(result_table);
if (!opt_xml && !mysql_query_with_error_report(mysql, 0, query_buff))
{
/* using SHOW CREATE statement */
if (!opt_no_create_info)
{
/* Make an sql-file, if path was given iow. option -T was given */
char buff[20+FN_REFLEN];
MYSQL_FIELD *field;
my_snprintf(buff, sizeof(buff), "show create table %s", result_table);
if (switch_character_set_results(mysql, "binary") ||
mysql_query_with_error_report(mysql, &result, buff) ||
switch_character_set_results(mysql, default_charset))
DBUG_RETURN(0);
if (path)
{
if (!(sql_file= open_sql_file_for_table(table, O_WRONLY)))
DBUG_RETURN(0);
write_header(sql_file, db);
}
if (strcmp (table_type, "VIEW") == 0) /* view */
print_comment(sql_file, 0,
"\n--\n-- Temporary table structure for view %s\n--\n\n",
fix_identifier_with_newline(result_table));
else
print_comment(sql_file, 0,
"\n--\n-- Table structure for table %s\n--\n\n",
fix_identifier_with_newline(result_table));
if (opt_drop)
{
/*
Even if the "table" is a view, we do a DROP TABLE here. The
view-specific code below fills in the DROP VIEW.
We will skip the DROP TABLE for general_log and slow_log, since
those stmts will fail, in case we apply dump by enabling logging.
*/
if (!general_log_or_slow_log_tables(db, table))
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",
opt_quoted_table);
check_io(sql_file);
}
field= mysql_fetch_field_direct(result, 0);
if (strcmp(field->name, "View") == 0)
{
char *scv_buff= NULL;
my_ulonglong n_cols;
verbose_msg("-- It's a view, create dummy table for view\n");
/* save "show create" statement for later */
if ((row= mysql_fetch_row(result)) && (scv_buff=row[1]))
scv_buff= my_strdup(scv_buff, MYF(0));
mysql_free_result(result);
/*
Create a table with the same name as the view and with columns of
the same name in order to satisfy views that depend on this view.
The table will be removed when the actual view is created.
The properties of each column, are not preserved in this temporary
table, because they are not necessary.
This will not be necessary once we can determine dependencies
between views and can simply dump them in the appropriate order.
*/
my_snprintf(query_buff, sizeof(query_buff),
"SHOW FIELDS FROM %s", result_table);
if (switch_character_set_results(mysql, "binary") ||
mysql_query_with_error_report(mysql, &result, query_buff) ||
switch_character_set_results(mysql, default_charset))
{
/*
View references invalid or privileged table/col/fun (err 1356),
so we cannot create a stand-in table. Be defensive and dump
a comment with the view's 'show create' statement. (Bug #17371)
*/
if (mysql_errno(mysql) == ER_VIEW_INVALID)
fprintf(sql_file, "\n-- failed on view %s: %s\n\n", result_table, scv_buff ? scv_buff : "");
my_free(scv_buff);
DBUG_RETURN(0);
}
else
my_free(scv_buff);
n_cols= mysql_num_rows(result);
if (0 != n_cols)
{
/*
The actual formula is based on the column names and how the .FRM
files are stored and is too volatile to be repeated here.
Thus we simply warn the user if the columns exceed a limit we
know works most of the time.
*/
if (n_cols >= 1000)
fprintf(stderr,
"-- Warning: Creating a stand-in table for view %s may"
" fail when replaying the dump file produced because "
"of the number of columns exceeding 1000. Exercise "
"caution when replaying the produced dump file.\n",
table);
if (opt_drop)
{
/*
We have already dropped any table of the same name above, so
here we just drop the view.
*/
fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n",
opt_quoted_table);
check_io(sql_file);
}
fprintf(sql_file,
"SET @saved_cs_client = @@character_set_client;\n"
"SET character_set_client = utf8;\n"
"/*!50001 CREATE TABLE %s (\n",
result_table);
/*
Get first row, following loop will prepend comma - keeps from
having to know if the row being printed is last to determine if
there should be a _trailing_ comma.
*/
row= mysql_fetch_row(result);
/*
The actual column type doesn't matter anyway, since the table will
be dropped at run time.
We do tinyint to avoid hitting the row size limit.
*/
fprintf(sql_file, " %s tinyint NOT NULL",
quote_name(row[0], name_buff, 0));
while((row= mysql_fetch_row(result)))
{
/* col name, col type */
fprintf(sql_file, ",\n %s tinyint NOT NULL",
quote_name(row[0], name_buff, 0));
}
/*
Stand-in tables are always MyISAM tables as the default
engine might have a column-limit that's lower than the
number of columns in the view, and MyISAM support is
guaranteed to be in the server anyway.
*/
fprintf(sql_file,
"\n) ENGINE=MyISAM */;\n"
"SET character_set_client = @saved_cs_client;\n");
check_io(sql_file);
}
mysql_free_result(result);
if (path)
my_fclose(sql_file, MYF(MY_WME));
seen_views= 1;
DBUG_RETURN(0);
}
row= mysql_fetch_row(result);
is_log_table= general_log_or_slow_log_tables(db, table);
if (is_log_table)
row[1]+= 13; /* strlen("CREATE TABLE ")= 13 */
if (opt_compatible_mode & 3)
{
fprintf(sql_file,
is_log_table ? "CREATE TABLE IF NOT EXISTS %s;\n" : "%s;\n",
row[1]);
}
else
{
fprintf(sql_file,
"/*!40101 SET @saved_cs_client = @@character_set_client */;\n"
"/*!40101 SET character_set_client = utf8 */;\n"
"%s%s;\n"
"/*!40101 SET character_set_client = @saved_cs_client */;\n",
is_log_table ? "CREATE TABLE IF NOT EXISTS " : "",
row[1]);
}
check_io(sql_file);
mysql_free_result(result);
}
my_snprintf(query_buff, sizeof(query_buff), "show fields from %s",
result_table);
if (mysql_query_with_error_report(mysql, &result, query_buff))
{
if (path)
my_fclose(sql_file, MYF(MY_WME));
DBUG_RETURN(0);
}
/*
If write_data is true, then we build up insert statements for
the table's data. Note: in subsequent lines of code, this test
will have to be performed each time we are appending to
insert_pat.
*/
if (write_data)
{
if (opt_replace_into)
dynstr_append_checked(&insert_pat, "REPLACE ");
else
dynstr_append_checked(&insert_pat, "INSERT ");
dynstr_append_checked(&insert_pat, insert_option);
dynstr_append_checked(&insert_pat, "INTO ");
dynstr_append_checked(&insert_pat, opt_quoted_table);
if (complete_insert)
{
dynstr_append_checked(&insert_pat, " (");
}
else
{
dynstr_append_checked(&insert_pat, " VALUES ");
if (!extended_insert)
dynstr_append_checked(&insert_pat, "(");
}
}
while ((row= mysql_fetch_row(result)))
{
if (complete_insert)
{
if (init)
{
dynstr_append_checked(&insert_pat, ", ");
}
init=1;
dynstr_append_checked(&insert_pat,
quote_name(row[SHOW_FIELDNAME], name_buff, 0));
}
}
num_fields= mysql_num_rows(result);
mysql_free_result(result);
}
else
{
verbose_msg("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n",
my_progname, mysql_error(mysql));
my_snprintf(query_buff, sizeof(query_buff), show_fields_stmt, db, table);
if (mysql_query_with_error_report(mysql, &result, query_buff))
DBUG_RETURN(0);
/* Make an sql-file, if path was given iow. option -T was given */
if (!opt_no_create_info)
{
if (path)
{
if (!(sql_file= open_sql_file_for_table(table, O_WRONLY)))
DBUG_RETURN(0);
write_header(sql_file, db);
}
print_comment(sql_file, 0,
"\n--\n-- Table structure for table %s\n--\n\n",
fix_identifier_with_newline(result_table));
if (opt_drop)
fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", result_table);
if (!opt_xml)
fprintf(sql_file, "CREATE TABLE %s (\n", result_table);
else
print_xml_tag(sql_file, "\t", "\n", "table_structure", "name=", table,
NullS);
check_io(sql_file);
}
if (write_data)
{
if (opt_replace_into)
dynstr_append_checked(&insert_pat, "REPLACE ");
else
dynstr_append_checked(&insert_pat, "INSERT ");
dynstr_append_checked(&insert_pat, insert_option);
dynstr_append_checked(&insert_pat, "INTO ");
dynstr_append_checked(&insert_pat, result_table);
if (complete_insert)
dynstr_append_checked(&insert_pat, " (");
else
{
dynstr_append_checked(&insert_pat, " VALUES ");
if (!extended_insert)
dynstr_append_checked(&insert_pat, "(");
}
}
while ((row= mysql_fetch_row(result)))
{
ulong *lengths= mysql_fetch_lengths(result);
if (init)
{
if (!opt_xml && !opt_no_create_info)
{
fputs(",\n",sql_file);
check_io(sql_file);
}
if (complete_insert)
dynstr_append_checked(&insert_pat, ", ");
}
init=1;
if (complete_insert)
dynstr_append_checked(&insert_pat,
quote_name(row[SHOW_FIELDNAME], name_buff, 0));
if (!opt_no_create_info)
{
if (opt_xml)
{
print_xml_row(sql_file, "field", result, &row, NullS);
continue;
}
if (opt_keywords)
fprintf(sql_file, " %s.%s %s", result_table,
quote_name(row[SHOW_FIELDNAME],name_buff, 0),
row[SHOW_TYPE]);
else
fprintf(sql_file, " %s %s", quote_name(row[SHOW_FIELDNAME],
name_buff, 0),
row[SHOW_TYPE]);
if (row[SHOW_DEFAULT])
{
fputs(" DEFAULT ", sql_file);
unescape(sql_file, row[SHOW_DEFAULT], lengths[SHOW_DEFAULT]);
}
if (!row[SHOW_NULL][0])
fputs(" NOT NULL", sql_file);
if (row[SHOW_EXTRA][0])
fprintf(sql_file, " %s",row[SHOW_EXTRA]);
check_io(sql_file);
}
}
num_fields= mysql_num_rows(result);
mysql_free_result(result);
if (!opt_no_create_info)
{
/* Make an sql-file, if path was given iow. option -T was given */
char buff[20+FN_REFLEN];
uint keynr,primary_key;
my_snprintf(buff, sizeof(buff), "show keys from %s", result_table);
if (mysql_query_with_error_report(mysql, &result, buff))
{
if (mysql_errno(mysql) == ER_WRONG_OBJECT)
{
/* it is VIEW */
fputs("\t\t<options Comment=\"view\" />\n", sql_file);
goto continue_xml;
}
fprintf(stderr, "%s: Can't get keys for table %s (%s)\n",
my_progname, result_table, mysql_error(mysql));
if (path)
my_fclose(sql_file, MYF(MY_WME));
DBUG_RETURN(0);
}
/* Find first which key is primary key */
keynr=0;
primary_key=INT_MAX;
while ((row= mysql_fetch_row(result)))
{
if (atoi(row[3]) == 1)
{
keynr++;
#ifdef FORCE_PRIMARY_KEY
if (atoi(row[1]) == 0 && primary_key == INT_MAX)
primary_key=keynr;
#endif
if (!strcmp(row[2],"PRIMARY"))
{
primary_key=keynr;
break;
}
}
}
mysql_data_seek(result,0);
keynr=0;
while ((row= mysql_fetch_row(result)))
{
if (opt_xml)
{
print_xml_row(sql_file, "key", result, &row, NullS);
continue;
}
if (atoi(row[3]) == 1)
{
if (keynr++)
putc(')', sql_file);
if (atoi(row[1])) /* Test if duplicate key */
/* Duplicate allowed */
fprintf(sql_file, ",\n KEY %s (",quote_name(row[2],name_buff,0));
else if (keynr == primary_key)
fputs(",\n PRIMARY KEY (",sql_file); /* First UNIQUE is primary */
else
fprintf(sql_file, ",\n UNIQUE %s (",quote_name(row[2],name_buff,
0));
}
else
putc(',', sql_file);
fputs(quote_name(row[4], name_buff, 0), sql_file);
if (row[7])
fprintf(sql_file, " (%s)",row[7]); /* Sub key */
check_io(sql_file);
}
mysql_free_result(result);
if (!opt_xml)
{
if (keynr)
putc(')', sql_file);
fputs("\n)",sql_file);
check_io(sql_file);
}
/* Get MySQL specific create options */
if (create_options)
{
char show_name_buff[NAME_LEN*2+2+24];
/* Check memory for quote_for_like() */
my_snprintf(buff, sizeof(buff), "show table status like %s",
quote_for_like(table, show_name_buff));
if (mysql_query_with_error_report(mysql, &result, buff))
{
if (mysql_errno(mysql) != ER_PARSE_ERROR)
{ /* If old MySQL version */
verbose_msg("-- Warning: Couldn't get status information for " \
"table %s (%s)\n", result_table,mysql_error(mysql));
}
}
else if (!(row= mysql_fetch_row(result)))
{
fprintf(stderr,
"Error: Couldn't read status information for table %s (%s)\n",
result_table,mysql_error(mysql));
}
else
{
if (opt_xml)
print_xml_row(sql_file, "options", result, &row, NullS);
else
{
fputs("/*!",sql_file);
print_value(sql_file,result,row,"engine=","Engine",0);
print_value(sql_file,result,row,"","Create_options",0);
print_value(sql_file,result,row,"comment=","Comment",1);
fputs(" */",sql_file);
check_io(sql_file);
}
}
mysql_free_result(result); /* Is always safe to free */
}
continue_xml:
if (!opt_xml)
fputs(";\n", sql_file);
else
fputs("\t</table_structure>\n", sql_file);
check_io(sql_file);
}
}
if (complete_insert)
{
dynstr_append_checked(&insert_pat, ") VALUES ");
if (!extended_insert)
dynstr_append_checked(&insert_pat, "(");
}
if (sql_file != md_result_file)
{
fputs("\n", sql_file);
write_footer(sql_file);
my_fclose(sql_file, MYF(MY_WME));
}
DBUG_RETURN((uint) num_fields);
} /* get_table_structure */ | 1 | [] | mysql-server | d982e717aba67227ec40761a21a4211db91aa0e2 | 103,776,134,934,436,430,000,000,000,000,000,000,000 | 557 | Bug#27510150: MYSQLDUMP FAILS FOR SPECIFIC --WHERE CLAUSES
Description: Mysqldump utility fails for specific clauses
used with the option, 'where'.
Analysis:- Method, "fix_identifier_with_newline()" that
prefixes all occurrences of newline char ('\n') in incoming
buffer does not verify the size of the buffer. The buffer in
which the incoming buffer is copied is limited to 2048 bytes
and the method does not try to allocate additional memory
for larger incoming buffers.
Fix:- Method, "fix_identifier_with_newline()" is modified
to fix this issue. |
impl_permission_manager_test (EphyPermissionManager *manager,
const char *host,
const char *type)
{
g_return_val_if_fail (type != NULL && type[0] != '\0', EPHY_PERMISSION_DEFAULT);
return (EphyPermission)0;
} | 0 | [] | epiphany | 3e0f7dea754381c5ad11a06ccc62eb153382b498 | 107,683,667,263,055,270,000,000,000,000,000,000,000 | 8 | Report broken certs through the padlock icon
This uses a new feature in libsoup that reports through a
SoupMessageFlag whether the message is talking to a server that has a
trusted server.
Bug #600663 |
g_NPP_Write(NPP instance, NPStream *stream, int32_t offset, int32_t len, void *buf)
{
if (instance == NULL)
return -1;
if (plugin_funcs.write == NULL)
return -1;
if (stream == NULL)
return -1;
D(bugiI("NPP_Write instance=%p, stream=%p, offset=%d, len=%d, buf=%p\n", instance, stream, offset, len, buf));
int32_t ret = plugin_funcs.write(instance, stream, offset, len, buf);
D(bugiD("NPP_Write return: %d\n", ret));
return ret;
} | 0 | [
"CWE-264"
] | nspluginwrapper | 7e4ab8e1189846041f955e6c83f72bc1624e7a98 | 269,875,007,106,104,050,000,000,000,000,000,000,000 | 16 | Support all the new variables added |
mem_cgroup_get_reclaim_stat_from_page(struct page *page)
{
struct page_cgroup *pc;
struct mem_cgroup_per_zone *mz;
if (mem_cgroup_disabled())
return NULL;
pc = lookup_page_cgroup(page);
if (!PageCgroupUsed(pc))
return NULL;
/* Ensure pc->mem_cgroup is visible after reading PCG_USED. */
smp_rmb();
mz = page_cgroup_zoneinfo(pc->mem_cgroup, page);
return &mz->reclaim_stat;
} | 0 | [
"CWE-264"
] | linux-2.6 | 1a5a9906d4e8d1976b701f889d8f35d54b928f25 | 139,688,894,130,493,760,000,000,000,000,000,000,000 | 16 | mm: thp: fix pmd_bad() triggering in code paths holding mmap_sem read mode
In some cases it may happen that pmd_none_or_clear_bad() is called with
the mmap_sem hold in read mode. In those cases the huge page faults can
allocate hugepmds under pmd_none_or_clear_bad() and that can trigger a
false positive from pmd_bad() that will not like to see a pmd
materializing as trans huge.
It's not khugepaged causing the problem, khugepaged holds the mmap_sem
in write mode (and all those sites must hold the mmap_sem in read mode
to prevent pagetables to go away from under them, during code review it
seems vm86 mode on 32bit kernels requires that too unless it's
restricted to 1 thread per process or UP builds). The race is only with
the huge pagefaults that can convert a pmd_none() into a
pmd_trans_huge().
Effectively all these pmd_none_or_clear_bad() sites running with
mmap_sem in read mode are somewhat speculative with the page faults, and
the result is always undefined when they run simultaneously. This is
probably why it wasn't common to run into this. For example if the
madvise(MADV_DONTNEED) runs zap_page_range() shortly before the page
fault, the hugepage will not be zapped, if the page fault runs first it
will be zapped.
Altering pmd_bad() not to error out if it finds hugepmds won't be enough
to fix this, because zap_pmd_range would then proceed to call
zap_pte_range (which would be incorrect if the pmd become a
pmd_trans_huge()).
The simplest way to fix this is to read the pmd in the local stack
(regardless of what we read, no need of actual CPU barriers, only
compiler barrier needed), and be sure it is not changing under the code
that computes its value. Even if the real pmd is changing under the
value we hold on the stack, we don't care. If we actually end up in
zap_pte_range it means the pmd was not none already and it was not huge,
and it can't become huge from under us (khugepaged locking explained
above).
All we need is to enforce that there is no way anymore that in a code
path like below, pmd_trans_huge can be false, but pmd_none_or_clear_bad
can run into a hugepmd. The overhead of a barrier() is just a compiler
tweak and should not be measurable (I only added it for THP builds). I
don't exclude different compiler versions may have prevented the race
too by caching the value of *pmd on the stack (that hasn't been
verified, but it wouldn't be impossible considering
pmd_none_or_clear_bad, pmd_bad, pmd_trans_huge, pmd_none are all inlines
and there's no external function called in between pmd_trans_huge and
pmd_none_or_clear_bad).
if (pmd_trans_huge(*pmd)) {
if (next-addr != HPAGE_PMD_SIZE) {
VM_BUG_ON(!rwsem_is_locked(&tlb->mm->mmap_sem));
split_huge_page_pmd(vma->vm_mm, pmd);
} else if (zap_huge_pmd(tlb, vma, pmd, addr))
continue;
/* fall through */
}
if (pmd_none_or_clear_bad(pmd))
Because this race condition could be exercised without special
privileges this was reported in CVE-2012-1179.
The race was identified and fully explained by Ulrich who debugged it.
I'm quoting his accurate explanation below, for reference.
====== start quote =======
mapcount 0 page_mapcount 1
kernel BUG at mm/huge_memory.c:1384!
At some point prior to the panic, a "bad pmd ..." message similar to the
following is logged on the console:
mm/memory.c:145: bad pmd ffff8800376e1f98(80000000314000e7).
The "bad pmd ..." message is logged by pmd_clear_bad() before it clears
the page's PMD table entry.
143 void pmd_clear_bad(pmd_t *pmd)
144 {
-> 145 pmd_ERROR(*pmd);
146 pmd_clear(pmd);
147 }
After the PMD table entry has been cleared, there is an inconsistency
between the actual number of PMD table entries that are mapping the page
and the page's map count (_mapcount field in struct page). When the page
is subsequently reclaimed, __split_huge_page() detects this inconsistency.
1381 if (mapcount != page_mapcount(page))
1382 printk(KERN_ERR "mapcount %d page_mapcount %d\n",
1383 mapcount, page_mapcount(page));
-> 1384 BUG_ON(mapcount != page_mapcount(page));
The root cause of the problem is a race of two threads in a multithreaded
process. Thread B incurs a page fault on a virtual address that has never
been accessed (PMD entry is zero) while Thread A is executing an madvise()
system call on a virtual address within the same 2 MB (huge page) range.
virtual address space
.---------------------.
| |
| |
.-|---------------------|
| | |
| | |<-- B(fault)
| | |
2 MB | |/////////////////////|-.
huge < |/////////////////////| > A(range)
page | |/////////////////////|-'
| | |
| | |
'-|---------------------|
| |
| |
'---------------------'
- Thread A is executing an madvise(..., MADV_DONTNEED) system call
on the virtual address range "A(range)" shown in the picture.
sys_madvise
// Acquire the semaphore in shared mode.
down_read(¤t->mm->mmap_sem)
...
madvise_vma
switch (behavior)
case MADV_DONTNEED:
madvise_dontneed
zap_page_range
unmap_vmas
unmap_page_range
zap_pud_range
zap_pmd_range
//
// Assume that this huge page has never been accessed.
// I.e. content of the PMD entry is zero (not mapped).
//
if (pmd_trans_huge(*pmd)) {
// We don't get here due to the above assumption.
}
//
// Assume that Thread B incurred a page fault and
.---------> // sneaks in here as shown below.
| //
| if (pmd_none_or_clear_bad(pmd))
| {
| if (unlikely(pmd_bad(*pmd)))
| pmd_clear_bad
| {
| pmd_ERROR
| // Log "bad pmd ..." message here.
| pmd_clear
| // Clear the page's PMD entry.
| // Thread B incremented the map count
| // in page_add_new_anon_rmap(), but
| // now the page is no longer mapped
| // by a PMD entry (-> inconsistency).
| }
| }
|
v
- Thread B is handling a page fault on virtual address "B(fault)" shown
in the picture.
...
do_page_fault
__do_page_fault
// Acquire the semaphore in shared mode.
down_read_trylock(&mm->mmap_sem)
...
handle_mm_fault
if (pmd_none(*pmd) && transparent_hugepage_enabled(vma))
// We get here due to the above assumption (PMD entry is zero).
do_huge_pmd_anonymous_page
alloc_hugepage_vma
// Allocate a new transparent huge page here.
...
__do_huge_pmd_anonymous_page
...
spin_lock(&mm->page_table_lock)
...
page_add_new_anon_rmap
// Here we increment the page's map count (starts at -1).
atomic_set(&page->_mapcount, 0)
set_pmd_at
// Here we set the page's PMD entry which will be cleared
// when Thread A calls pmd_clear_bad().
...
spin_unlock(&mm->page_table_lock)
The mmap_sem does not prevent the race because both threads are acquiring
it in shared mode (down_read). Thread B holds the page_table_lock while
the page's map count and PMD table entry are updated. However, Thread A
does not synchronize on that lock.
====== end quote =======
[[email protected]: checkpatch fixes]
Reported-by: Ulrich Obergfell <[email protected]>
Signed-off-by: Andrea Arcangeli <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Dave Jones <[email protected]>
Acked-by: Larry Woodman <[email protected]>
Acked-by: Rik van Riel <[email protected]>
Cc: <[email protected]> [2.6.38+]
Cc: Mark Salter <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
static int hidinput_query_battery_capacity(struct hid_device *dev)
{
u8 *buf;
int ret;
buf = kmalloc(4, GFP_KERNEL);
if (!buf)
return -ENOMEM;
ret = hid_hw_raw_request(dev, dev->battery_report_id, buf, 4,
dev->battery_report_type, HID_REQ_GET_REPORT);
if (ret < 2) {
kfree(buf);
return -ENODATA;
}
ret = hidinput_scale_battery_capacity(dev, buf[1]);
kfree(buf);
return ret;
} | 0 | [
"CWE-787"
] | linux | 35556bed836f8dc07ac55f69c8d17dce3e7f0e25 | 83,596,453,438,055,910,000,000,000,000,000,000,000 | 20 | HID: core: Sanitize event code and type when mapping input
When calling into hid_map_usage(), the passed event code is
blindly stored as is, even if it doesn't fit in the associated bitmap.
This event code can come from a variety of sources, including devices
masquerading as input devices, only a bit more "programmable".
Instead of taking the event code at face value, check that it actually
fits the corresponding bitmap, and if it doesn't:
- spit out a warning so that we know which device is acting up
- NULLify the bitmap pointer so that we catch unexpected uses
Code paths that can make use of untrusted inputs can now check
that the mapping was indeed correct and bail out if not.
Cc: [email protected]
Signed-off-by: Marc Zyngier <[email protected]>
Signed-off-by: Benjamin Tissoires <[email protected]> |
static inline bool __meminit early_page_uninitialised(unsigned long pfn)
{
int nid = early_pfn_to_nid(pfn);
if (node_online(nid) && pfn >= NODE_DATA(nid)->first_deferred_pfn)
return true;
return false;
} | 0 | [] | linux | 400e22499dd92613821374c8c6c88c7225359980 | 155,523,940,680,914,970,000,000,000,000,000,000,000 | 9 | mm: don't warn about allocations which stall for too long
Commit 63f53dea0c98 ("mm: warn about allocations which stall for too
long") was a great step for reducing possibility of silent hang up
problem caused by memory allocation stalls. But this commit reverts it,
for it is possible to trigger OOM lockup and/or soft lockups when many
threads concurrently called warn_alloc() (in order to warn about memory
allocation stalls) due to current implementation of printk(), and it is
difficult to obtain useful information due to limitation of synchronous
warning approach.
Current printk() implementation flushes all pending logs using the
context of a thread which called console_unlock(). printk() should be
able to flush all pending logs eventually unless somebody continues
appending to printk() buffer.
Since warn_alloc() started appending to printk() buffer while waiting
for oom_kill_process() to make forward progress when oom_kill_process()
is processing pending logs, it became possible for warn_alloc() to force
oom_kill_process() loop inside printk(). As a result, warn_alloc()
significantly increased possibility of preventing oom_kill_process()
from making forward progress.
---------- Pseudo code start ----------
Before warn_alloc() was introduced:
retry:
if (mutex_trylock(&oom_lock)) {
while (atomic_read(&printk_pending_logs) > 0) {
atomic_dec(&printk_pending_logs);
print_one_log();
}
// Send SIGKILL here.
mutex_unlock(&oom_lock)
}
goto retry;
After warn_alloc() was introduced:
retry:
if (mutex_trylock(&oom_lock)) {
while (atomic_read(&printk_pending_logs) > 0) {
atomic_dec(&printk_pending_logs);
print_one_log();
}
// Send SIGKILL here.
mutex_unlock(&oom_lock)
} else if (waited_for_10seconds()) {
atomic_inc(&printk_pending_logs);
}
goto retry;
---------- Pseudo code end ----------
Although waited_for_10seconds() becomes true once per 10 seconds,
unbounded number of threads can call waited_for_10seconds() at the same
time. Also, since threads doing waited_for_10seconds() keep doing
almost busy loop, the thread doing print_one_log() can use little CPU
resource. Therefore, this situation can be simplified like
---------- Pseudo code start ----------
retry:
if (mutex_trylock(&oom_lock)) {
while (atomic_read(&printk_pending_logs) > 0) {
atomic_dec(&printk_pending_logs);
print_one_log();
}
// Send SIGKILL here.
mutex_unlock(&oom_lock)
} else {
atomic_inc(&printk_pending_logs);
}
goto retry;
---------- Pseudo code end ----------
when printk() is called faster than print_one_log() can process a log.
One of possible mitigation would be to introduce a new lock in order to
make sure that no other series of printk() (either oom_kill_process() or
warn_alloc()) can append to printk() buffer when one series of printk()
(either oom_kill_process() or warn_alloc()) is already in progress.
Such serialization will also help obtaining kernel messages in readable
form.
---------- Pseudo code start ----------
retry:
if (mutex_trylock(&oom_lock)) {
mutex_lock(&oom_printk_lock);
while (atomic_read(&printk_pending_logs) > 0) {
atomic_dec(&printk_pending_logs);
print_one_log();
}
// Send SIGKILL here.
mutex_unlock(&oom_printk_lock);
mutex_unlock(&oom_lock)
} else {
if (mutex_trylock(&oom_printk_lock)) {
atomic_inc(&printk_pending_logs);
mutex_unlock(&oom_printk_lock);
}
}
goto retry;
---------- Pseudo code end ----------
But this commit does not go that direction, for we don't want to
introduce a new lock dependency, and we unlikely be able to obtain
useful information even if we serialized oom_kill_process() and
warn_alloc().
Synchronous approach is prone to unexpected results (e.g. too late [1],
too frequent [2], overlooked [3]). As far as I know, warn_alloc() never
helped with providing information other than "something is going wrong".
I want to consider asynchronous approach which can obtain information
during stalls with possibly relevant threads (e.g. the owner of
oom_lock and kswapd-like threads) and serve as a trigger for actions
(e.g. turn on/off tracepoints, ask libvirt daemon to take a memory dump
of stalling KVM guest for diagnostic purpose).
This commit temporarily loses ability to report e.g. OOM lockup due to
unable to invoke the OOM killer due to !__GFP_FS allocation request.
But asynchronous approach will be able to detect such situation and emit
warning. Thus, let's remove warn_alloc().
[1] https://bugzilla.kernel.org/show_bug.cgi?id=192981
[2] http://lkml.kernel.org/r/CAM_iQpWuPVGc2ky8M-9yukECtS+zKjiDasNymX7rMcBjBFyM_A@mail.gmail.com
[3] commit db73ee0d46379922 ("mm, vmscan: do not loop on too_many_isolated for ever"))
Link: http://lkml.kernel.org/r/1509017339-4802-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp
Signed-off-by: Tetsuo Handa <[email protected]>
Reported-by: Cong Wang <[email protected]>
Reported-by: yuwang.yuwang <[email protected]>
Reported-by: Johannes Weiner <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Sergey Senozhatsky <[email protected]>
Cc: Petr Mladek <[email protected]>
Cc: Steven Rostedt <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
static inline unsigned char get_pixel_color(int n, size_t row)
{
return (n & (1 << (nstripes - 1 - row))) ? '\xc0' : '\x40';
} | 1 | [
"CWE-787"
] | qpdf | d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e | 259,344,529,268,765,200,000,000,000,000,000,000,000 | 4 | Fix sign and conversion warnings (major)
This makes all integer type conversions that have potential data loss
explicit with calls that do range checks and raise an exception. After
this commit, qpdf builds with no warnings when -Wsign-conversion
-Wconversion is used with gcc or clang or when -W3 -Wd4800 is used
with MSVC. This significantly reduces the likelihood of potential
crashes from bogus integer values.
There are some parts of the code that take int when they should take
size_t or an offset. Such places would make qpdf not support files
with more than 2^31 of something that usually wouldn't be so large. In
the event that such a file shows up and is valid, at least qpdf would
raise an error in the right spot so the issue could be legitimately
addressed rather than failing in some weird way because of a silent
overflow condition. |
MagickPrivate void XFileBrowserWidget(Display *display,XWindows *windows,
const char *action,char *reply)
{
#define CancelButtonText "Cancel"
#define DirectoryText "Directory:"
#define FilenameText "File name:"
#define GrabButtonText "Grab"
#define FormatButtonText "Format"
#define HomeButtonText "Home"
#define UpButtonText "Up"
char
*directory,
**filelist,
home_directory[MagickPathExtent],
primary_selection[MagickPathExtent],
text[MagickPathExtent],
working_path[MagickPathExtent];
int
x,
y;
ssize_t
i;
static char
glob_pattern[MagickPathExtent] = "*",
format[MagickPathExtent] = "miff";
static MagickStatusType
mask = (MagickStatusType) (CWWidth | CWHeight | CWX | CWY);
Status
status;
unsigned int
anomaly,
height,
text_width,
visible_files,
width;
size_t
delay,
files,
state;
XEvent
event;
XFontStruct
*font_info;
XTextProperty
window_name;
XWidgetInfo
action_info,
cancel_info,
expose_info,
special_info,
list_info,
home_info,
north_info,
reply_info,
scroll_info,
selection_info,
slider_info,
south_info,
text_info,
up_info;
XWindowChanges
window_changes;
/*
Read filelist from current directory.
*/
assert(display != (Display *) NULL);
assert(windows != (XWindows *) NULL);
assert(action != (char *) NULL);
assert(reply != (char *) NULL);
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",action);
XSetCursorState(display,windows,MagickTrue);
XCheckRefreshWindows(display,windows);
directory=getcwd(home_directory,MagickPathExtent);
(void) directory;
(void) CopyMagickString(working_path,home_directory,MagickPathExtent);
filelist=ListFiles(working_path,glob_pattern,&files);
if (filelist == (char **) NULL)
{
/*
Directory read failed.
*/
XNoticeWidget(display,windows,"Unable to read directory:",working_path);
(void) XDialogWidget(display,windows,action,"Enter filename:",reply);
return;
}
/*
Determine File Browser widget attributes.
*/
font_info=windows->widget.font_info;
text_width=0;
for (i=0; i < (ssize_t) files; i++)
if (WidgetTextWidth(font_info,filelist[i]) > text_width)
text_width=WidgetTextWidth(font_info,filelist[i]);
width=WidgetTextWidth(font_info,(char *) action);
if (WidgetTextWidth(font_info,GrabButtonText) > width)
width=WidgetTextWidth(font_info,GrabButtonText);
if (WidgetTextWidth(font_info,FormatButtonText) > width)
width=WidgetTextWidth(font_info,FormatButtonText);
if (WidgetTextWidth(font_info,CancelButtonText) > width)
width=WidgetTextWidth(font_info,CancelButtonText);
if (WidgetTextWidth(font_info,HomeButtonText) > width)
width=WidgetTextWidth(font_info,HomeButtonText);
if (WidgetTextWidth(font_info,UpButtonText) > width)
width=WidgetTextWidth(font_info,UpButtonText);
width+=QuantumMargin;
if (WidgetTextWidth(font_info,DirectoryText) > width)
width=WidgetTextWidth(font_info,DirectoryText);
if (WidgetTextWidth(font_info,FilenameText) > width)
width=WidgetTextWidth(font_info,FilenameText);
height=(unsigned int) (font_info->ascent+font_info->descent);
/*
Position File Browser widget.
*/
windows->widget.width=width+MagickMin((int) text_width,(int) MaxTextWidth)+
6*QuantumMargin;
windows->widget.min_width=width+MinTextWidth+4*QuantumMargin;
if (windows->widget.width < windows->widget.min_width)
windows->widget.width=windows->widget.min_width;
windows->widget.height=(unsigned int)
(((81*height) >> 2)+((13*QuantumMargin) >> 1)+4);
windows->widget.min_height=(unsigned int)
(((23*height) >> 1)+((13*QuantumMargin) >> 1)+4);
if (windows->widget.height < windows->widget.min_height)
windows->widget.height=windows->widget.min_height;
XConstrainWindowPosition(display,&windows->widget);
/*
Map File Browser widget.
*/
(void) CopyMagickString(windows->widget.name,"Browse and Select a File",
MagickPathExtent);
status=XStringListToTextProperty(&windows->widget.name,1,&window_name);
if (status != False)
{
XSetWMName(display,windows->widget.id,&window_name);
XSetWMIconName(display,windows->widget.id,&window_name);
(void) XFree((void *) window_name.value);
}
window_changes.width=(int) windows->widget.width;
window_changes.height=(int) windows->widget.height;
window_changes.x=windows->widget.x;
window_changes.y=windows->widget.y;
(void) XReconfigureWMWindow(display,windows->widget.id,
windows->widget.screen,mask,&window_changes);
(void) XMapRaised(display,windows->widget.id);
windows->widget.mapped=MagickFalse;
/*
Respond to X events.
*/
XGetWidgetInfo((char *) NULL,&slider_info);
XGetWidgetInfo((char *) NULL,&north_info);
XGetWidgetInfo((char *) NULL,&south_info);
XGetWidgetInfo((char *) NULL,&expose_info);
visible_files=0;
anomaly=(LocaleCompare(action,"Composite") == 0) ||
(LocaleCompare(action,"Open") == 0) || (LocaleCompare(action,"Map") == 0);
*reply='\0';
delay=SuspendTime << 2;
state=UpdateConfigurationState;
do
{
if (state & UpdateConfigurationState)
{
int
id;
/*
Initialize button information.
*/
XGetWidgetInfo(CancelButtonText,&cancel_info);
cancel_info.width=width;
cancel_info.height=(unsigned int) ((3*height) >> 1);
cancel_info.x=(int)
(windows->widget.width-cancel_info.width-QuantumMargin-2);
cancel_info.y=(int)
(windows->widget.height-cancel_info.height-QuantumMargin);
XGetWidgetInfo(action,&action_info);
action_info.width=width;
action_info.height=(unsigned int) ((3*height) >> 1);
action_info.x=cancel_info.x-(cancel_info.width+(QuantumMargin >> 1)+
(action_info.bevel_width << 1));
action_info.y=cancel_info.y;
XGetWidgetInfo(GrabButtonText,&special_info);
special_info.width=width;
special_info.height=(unsigned int) ((3*height) >> 1);
special_info.x=action_info.x-(action_info.width+(QuantumMargin >> 1)+
(special_info.bevel_width << 1));
special_info.y=action_info.y;
if (anomaly == MagickFalse)
{
char
*p;
special_info.text=(char *) FormatButtonText;
p=reply+Extent(reply)-1;
while ((p > (reply+1)) && (*(p-1) != '.'))
p--;
if ((p > (reply+1)) && (*(p-1) == '.'))
(void) CopyMagickString(format,p,MagickPathExtent);
}
XGetWidgetInfo(UpButtonText,&up_info);
up_info.width=width;
up_info.height=(unsigned int) ((3*height) >> 1);
up_info.x=QuantumMargin;
up_info.y=((5*QuantumMargin) >> 1)+height;
XGetWidgetInfo(HomeButtonText,&home_info);
home_info.width=width;
home_info.height=(unsigned int) ((3*height) >> 1);
home_info.x=QuantumMargin;
home_info.y=up_info.y+up_info.height+QuantumMargin;
/*
Initialize reply information.
*/
XGetWidgetInfo(reply,&reply_info);
reply_info.raised=MagickFalse;
reply_info.bevel_width--;
reply_info.width=windows->widget.width-width-((6*QuantumMargin) >> 1);
reply_info.height=height << 1;
reply_info.x=(int) (width+(QuantumMargin << 1));
reply_info.y=action_info.y-reply_info.height-QuantumMargin;
/*
Initialize scroll information.
*/
XGetWidgetInfo((char *) NULL,&scroll_info);
scroll_info.bevel_width--;
scroll_info.width=height;
scroll_info.height=(unsigned int)
(reply_info.y-up_info.y-(QuantumMargin >> 1));
scroll_info.x=reply_info.x+(reply_info.width-scroll_info.width);
scroll_info.y=up_info.y-reply_info.bevel_width;
scroll_info.raised=MagickFalse;
scroll_info.trough=MagickTrue;
north_info=scroll_info;
north_info.raised=MagickTrue;
north_info.width-=(north_info.bevel_width << 1);
north_info.height=north_info.width-1;
north_info.x+=north_info.bevel_width;
north_info.y+=north_info.bevel_width;
south_info=north_info;
south_info.y=scroll_info.y+scroll_info.height-scroll_info.bevel_width-
south_info.height;
id=slider_info.id;
slider_info=north_info;
slider_info.id=id;
slider_info.width-=2;
slider_info.min_y=north_info.y+north_info.height+north_info.bevel_width+
slider_info.bevel_width+2;
slider_info.height=scroll_info.height-((slider_info.min_y-
scroll_info.y+1) << 1)+4;
visible_files=scroll_info.height/(height+(height >> 3));
if (files > visible_files)
slider_info.height=(unsigned int)
((visible_files*slider_info.height)/files);
slider_info.max_y=south_info.y-south_info.bevel_width-
slider_info.bevel_width-2;
slider_info.x=scroll_info.x+slider_info.bevel_width+1;
slider_info.y=slider_info.min_y;
expose_info=scroll_info;
expose_info.y=slider_info.y;
/*
Initialize list information.
*/
XGetWidgetInfo((char *) NULL,&list_info);
list_info.raised=MagickFalse;
list_info.bevel_width--;
list_info.width=(unsigned int)
(scroll_info.x-reply_info.x-(QuantumMargin >> 1));
list_info.height=scroll_info.height;
list_info.x=reply_info.x;
list_info.y=scroll_info.y;
if (windows->widget.mapped == MagickFalse)
state|=JumpListState;
/*
Initialize text information.
*/
*text='\0';
XGetWidgetInfo(text,&text_info);
text_info.center=MagickFalse;
text_info.width=reply_info.width;
text_info.height=height;
text_info.x=list_info.x-(QuantumMargin >> 1);
text_info.y=QuantumMargin;
/*
Initialize selection information.
*/
XGetWidgetInfo((char *) NULL,&selection_info);
selection_info.center=MagickFalse;
selection_info.width=list_info.width;
selection_info.height=(unsigned int) ((9*height) >> 3);
selection_info.x=list_info.x;
state&=(~UpdateConfigurationState);
}
if (state & RedrawWidgetState)
{
/*
Redraw File Browser window.
*/
x=QuantumMargin;
y=text_info.y+((text_info.height-height) >> 1)+font_info->ascent;
(void) XDrawString(display,windows->widget.id,
windows->widget.annotate_context,x,y,DirectoryText,
Extent(DirectoryText));
(void) CopyMagickString(text_info.text,working_path,MagickPathExtent);
(void) ConcatenateMagickString(text_info.text,DirectorySeparator,
MagickPathExtent);
(void) ConcatenateMagickString(text_info.text,glob_pattern,
MagickPathExtent);
XDrawWidgetText(display,&windows->widget,&text_info);
XDrawBeveledButton(display,&windows->widget,&up_info);
XDrawBeveledButton(display,&windows->widget,&home_info);
XDrawBeveledMatte(display,&windows->widget,&list_info);
XDrawBeveledMatte(display,&windows->widget,&scroll_info);
XDrawTriangleNorth(display,&windows->widget,&north_info);
XDrawBeveledButton(display,&windows->widget,&slider_info);
XDrawTriangleSouth(display,&windows->widget,&south_info);
x=QuantumMargin;
y=reply_info.y+((reply_info.height-height) >> 1)+font_info->ascent;
(void) XDrawString(display,windows->widget.id,
windows->widget.annotate_context,x,y,FilenameText,
Extent(FilenameText));
XDrawBeveledMatte(display,&windows->widget,&reply_info);
XDrawMatteText(display,&windows->widget,&reply_info);
XDrawBeveledButton(display,&windows->widget,&special_info);
XDrawBeveledButton(display,&windows->widget,&action_info);
XDrawBeveledButton(display,&windows->widget,&cancel_info);
XHighlightWidget(display,&windows->widget,BorderOffset,BorderOffset);
selection_info.id=(~0);
state|=RedrawListState;
state&=(~RedrawWidgetState);
}
if (state & UpdateListState)
{
char
**checklist;
size_t
number_files;
/*
Update file list.
*/
checklist=ListFiles(working_path,glob_pattern,&number_files);
if (checklist == (char **) NULL)
{
/*
Reply is a filename, exit.
*/
action_info.raised=MagickFalse;
XDrawBeveledButton(display,&windows->widget,&action_info);
break;
}
for (i=0; i < (ssize_t) files; i++)
filelist[i]=DestroyString(filelist[i]);
if (filelist != (char **) NULL)
filelist=(char **) RelinquishMagickMemory(filelist);
filelist=checklist;
files=number_files;
/*
Update file list.
*/
slider_info.height=
scroll_info.height-((slider_info.min_y-scroll_info.y+1) << 1)+1;
if (files > visible_files)
slider_info.height=(unsigned int)
((visible_files*slider_info.height)/files);
slider_info.max_y=south_info.y-south_info.bevel_width-
slider_info.bevel_width-2;
slider_info.id=0;
slider_info.y=slider_info.min_y;
expose_info.y=slider_info.y;
selection_info.id=(~0);
list_info.id=(~0);
state|=RedrawListState;
/*
Redraw directory name & reply.
*/
if (IsGlob(reply_info.text) == MagickFalse)
{
*reply_info.text='\0';
reply_info.cursor=reply_info.text;
}
(void) CopyMagickString(text_info.text,working_path,MagickPathExtent);
(void) ConcatenateMagickString(text_info.text,DirectorySeparator,
MagickPathExtent);
(void) ConcatenateMagickString(text_info.text,glob_pattern,
MagickPathExtent);
XDrawWidgetText(display,&windows->widget,&text_info);
XDrawMatteText(display,&windows->widget,&reply_info);
XDrawBeveledMatte(display,&windows->widget,&scroll_info);
XDrawTriangleNorth(display,&windows->widget,&north_info);
XDrawBeveledButton(display,&windows->widget,&slider_info);
XDrawTriangleSouth(display,&windows->widget,&south_info);
XHighlightWidget(display,&windows->widget,BorderOffset,BorderOffset);
state&=(~UpdateListState);
}
if (state & JumpListState)
{
/*
Jump scroll to match user filename.
*/
list_info.id=(~0);
for (i=0; i < (ssize_t) files; i++)
if (LocaleCompare(filelist[i],reply) >= 0)
{
list_info.id=(int)
(LocaleCompare(filelist[i],reply) == 0 ? i : ~0);
break;
}
if ((i < (ssize_t) slider_info.id) ||
(i >= (ssize_t) (slider_info.id+visible_files)))
slider_info.id=(int) i-(visible_files >> 1);
selection_info.id=(~0);
state|=RedrawListState;
state&=(~JumpListState);
}
if (state & RedrawListState)
{
/*
Determine slider id and position.
*/
if (slider_info.id >= (int) (files-visible_files))
slider_info.id=(int) (files-visible_files);
if ((slider_info.id < 0) || (files <= visible_files))
slider_info.id=0;
slider_info.y=slider_info.min_y;
if (files > 0)
slider_info.y+=((ssize_t) slider_info.id*(slider_info.max_y-
slider_info.min_y+1)/files);
if (slider_info.id != selection_info.id)
{
/*
Redraw scroll bar and file names.
*/
selection_info.id=slider_info.id;
selection_info.y=list_info.y+(height >> 3)+2;
for (i=0; i < (ssize_t) visible_files; i++)
{
selection_info.raised=(int) (slider_info.id+i) != list_info.id ?
MagickTrue : MagickFalse;
selection_info.text=(char *) NULL;
if ((slider_info.id+i) < (ssize_t) files)
selection_info.text=filelist[slider_info.id+i];
XDrawWidgetText(display,&windows->widget,&selection_info);
selection_info.y+=(int) selection_info.height;
}
/*
Update slider.
*/
if (slider_info.y > expose_info.y)
{
expose_info.height=(unsigned int) slider_info.y-expose_info.y;
expose_info.y=slider_info.y-expose_info.height-
slider_info.bevel_width-1;
}
else
{
expose_info.height=(unsigned int) expose_info.y-slider_info.y;
expose_info.y=slider_info.y+slider_info.height+
slider_info.bevel_width+1;
}
XDrawTriangleNorth(display,&windows->widget,&north_info);
XDrawMatte(display,&windows->widget,&expose_info);
XDrawBeveledButton(display,&windows->widget,&slider_info);
XDrawTriangleSouth(display,&windows->widget,&south_info);
expose_info.y=slider_info.y;
}
state&=(~RedrawListState);
}
/*
Wait for next event.
*/
if (north_info.raised && south_info.raised)
(void) XIfEvent(display,&event,XScreenEvent,(char *) windows);
else
{
/*
Brief delay before advancing scroll bar.
*/
XDelay(display,delay);
delay=SuspendTime;
(void) XCheckIfEvent(display,&event,XScreenEvent,(char *) windows);
if (north_info.raised == MagickFalse)
if (slider_info.id > 0)
{
/*
Move slider up.
*/
slider_info.id--;
state|=RedrawListState;
}
if (south_info.raised == MagickFalse)
if (slider_info.id < (int) files)
{
/*
Move slider down.
*/
slider_info.id++;
state|=RedrawListState;
}
if (event.type != ButtonRelease)
continue;
}
switch (event.type)
{
case ButtonPress:
{
if (MatteIsActive(slider_info,event.xbutton))
{
/*
Track slider.
*/
slider_info.active=MagickTrue;
break;
}
if (MatteIsActive(north_info,event.xbutton))
if (slider_info.id > 0)
{
/*
Move slider up.
*/
north_info.raised=MagickFalse;
slider_info.id--;
state|=RedrawListState;
break;
}
if (MatteIsActive(south_info,event.xbutton))
if (slider_info.id < (int) files)
{
/*
Move slider down.
*/
south_info.raised=MagickFalse;
slider_info.id++;
state|=RedrawListState;
break;
}
if (MatteIsActive(scroll_info,event.xbutton))
{
/*
Move slider.
*/
if (event.xbutton.y < slider_info.y)
slider_info.id-=(visible_files-1);
else
slider_info.id+=(visible_files-1);
state|=RedrawListState;
break;
}
if (MatteIsActive(list_info,event.xbutton))
{
int
id;
/*
User pressed file matte.
*/
id=slider_info.id+(event.xbutton.y-(list_info.y+(height >> 1))+1)/
selection_info.height;
if (id >= (int) files)
break;
(void) CopyMagickString(reply_info.text,filelist[id],MagickPathExtent);
reply_info.highlight=MagickFalse;
reply_info.marker=reply_info.text;
reply_info.cursor=reply_info.text+Extent(reply_info.text);
XDrawMatteText(display,&windows->widget,&reply_info);
if (id == list_info.id)
{
char
*p;
p=reply_info.text+strlen(reply_info.text)-1;
if (*p == *DirectorySeparator)
ChopPathComponents(reply_info.text,1);
(void) ConcatenateMagickString(working_path,DirectorySeparator,
MagickPathExtent);
(void) ConcatenateMagickString(working_path,reply_info.text,
MagickPathExtent);
*reply='\0';
state|=UpdateListState;
}
selection_info.id=(~0);
list_info.id=id;
state|=RedrawListState;
break;
}
if (MatteIsActive(up_info,event.xbutton))
{
/*
User pressed Up button.
*/
up_info.raised=MagickFalse;
XDrawBeveledButton(display,&windows->widget,&up_info);
break;
}
if (MatteIsActive(home_info,event.xbutton))
{
/*
User pressed Home button.
*/
home_info.raised=MagickFalse;
XDrawBeveledButton(display,&windows->widget,&home_info);
break;
}
if (MatteIsActive(special_info,event.xbutton))
{
/*
User pressed Special button.
*/
special_info.raised=MagickFalse;
XDrawBeveledButton(display,&windows->widget,&special_info);
break;
}
if (MatteIsActive(action_info,event.xbutton))
{
/*
User pressed action button.
*/
action_info.raised=MagickFalse;
XDrawBeveledButton(display,&windows->widget,&action_info);
break;
}
if (MatteIsActive(cancel_info,event.xbutton))
{
/*
User pressed Cancel button.
*/
cancel_info.raised=MagickFalse;
XDrawBeveledButton(display,&windows->widget,&cancel_info);
break;
}
if (MatteIsActive(reply_info,event.xbutton) == MagickFalse)
break;
if (event.xbutton.button != Button2)
{
static Time
click_time;
/*
Move text cursor to position of button press.
*/
x=event.xbutton.x-reply_info.x-(QuantumMargin >> 2);
for (i=1; i <= (ssize_t) Extent(reply_info.marker); i++)
if (XTextWidth(font_info,reply_info.marker,(int) i) > x)
break;
reply_info.cursor=reply_info.marker+i-1;
if (event.xbutton.time > (click_time+DoubleClick))
reply_info.highlight=MagickFalse;
else
{
/*
Become the XA_PRIMARY selection owner.
*/
(void) CopyMagickString(primary_selection,reply_info.text,
MagickPathExtent);
(void) XSetSelectionOwner(display,XA_PRIMARY,windows->widget.id,
event.xbutton.time);
reply_info.highlight=XGetSelectionOwner(display,XA_PRIMARY) ==
windows->widget.id ? MagickTrue : MagickFalse;
}
XDrawMatteText(display,&windows->widget,&reply_info);
click_time=event.xbutton.time;
break;
}
/*
Request primary selection.
*/
(void) XConvertSelection(display,XA_PRIMARY,XA_STRING,XA_STRING,
windows->widget.id,event.xbutton.time);
break;
}
case ButtonRelease:
{
if (windows->widget.mapped == MagickFalse)
break;
if (north_info.raised == MagickFalse)
{
/*
User released up button.
*/
delay=SuspendTime << 2;
north_info.raised=MagickTrue;
XDrawTriangleNorth(display,&windows->widget,&north_info);
}
if (south_info.raised == MagickFalse)
{
/*
User released down button.
*/
delay=SuspendTime << 2;
south_info.raised=MagickTrue;
XDrawTriangleSouth(display,&windows->widget,&south_info);
}
if (slider_info.active)
{
/*
Stop tracking slider.
*/
slider_info.active=MagickFalse;
break;
}
if (up_info.raised == MagickFalse)
{
if (event.xbutton.window == windows->widget.id)
if (MatteIsActive(up_info,event.xbutton))
{
ChopPathComponents(working_path,1);
if (*working_path == '\0')
(void) CopyMagickString(working_path,DirectorySeparator,
MagickPathExtent);
state|=UpdateListState;
}
up_info.raised=MagickTrue;
XDrawBeveledButton(display,&windows->widget,&up_info);
}
if (home_info.raised == MagickFalse)
{
if (event.xbutton.window == windows->widget.id)
if (MatteIsActive(home_info,event.xbutton))
{
(void) CopyMagickString(working_path,home_directory,
MagickPathExtent);
state|=UpdateListState;
}
home_info.raised=MagickTrue;
XDrawBeveledButton(display,&windows->widget,&home_info);
}
if (special_info.raised == MagickFalse)
{
if (anomaly == MagickFalse)
{
char
**formats;
ExceptionInfo
*exception;
size_t
number_formats;
/*
Let user select image format.
*/
exception=AcquireExceptionInfo();
formats=GetMagickList("*",&number_formats,exception);
exception=DestroyExceptionInfo(exception);
if (formats == (char **) NULL)
break;
(void) XCheckDefineCursor(display,windows->widget.id,
windows->widget.busy_cursor);
windows->popup.x=windows->widget.x+60;
windows->popup.y=windows->widget.y+60;
XListBrowserWidget(display,windows,&windows->popup,
(const char **) formats,"Select","Select image format type:",
format);
XSetCursorState(display,windows,MagickTrue);
(void) XCheckDefineCursor(display,windows->widget.id,
windows->widget.cursor);
LocaleLower(format);
AppendImageFormat(format,reply_info.text);
reply_info.cursor=reply_info.text+Extent(reply_info.text);
XDrawMatteText(display,&windows->widget,&reply_info);
special_info.raised=MagickTrue;
XDrawBeveledButton(display,&windows->widget,&special_info);
for (i=0; i < (ssize_t) number_formats; i++)
formats[i]=DestroyString(formats[i]);
formats=(char **) RelinquishMagickMemory(formats);
break;
}
if (event.xbutton.window == windows->widget.id)
if (MatteIsActive(special_info,event.xbutton))
{
(void) CopyMagickString(working_path,"x:",MagickPathExtent);
state|=ExitState;
}
special_info.raised=MagickTrue;
XDrawBeveledButton(display,&windows->widget,&special_info);
}
if (action_info.raised == MagickFalse)
{
if (event.xbutton.window == windows->widget.id)
{
if (MatteIsActive(action_info,event.xbutton))
{
if (*reply_info.text == '\0')
(void) XBell(display,0);
else
state|=ExitState;
}
}
action_info.raised=MagickTrue;
XDrawBeveledButton(display,&windows->widget,&action_info);
}
if (cancel_info.raised == MagickFalse)
{
if (event.xbutton.window == windows->widget.id)
if (MatteIsActive(cancel_info,event.xbutton))
{
*reply_info.text='\0';
*reply='\0';
state|=ExitState;
}
cancel_info.raised=MagickTrue;
XDrawBeveledButton(display,&windows->widget,&cancel_info);
}
break;
}
case ClientMessage:
{
/*
If client window delete message, exit.
*/
if (event.xclient.message_type != windows->wm_protocols)
break;
if (*event.xclient.data.l == (int) windows->wm_take_focus)
{
(void) XSetInputFocus(display,event.xclient.window,RevertToParent,
(Time) event.xclient.data.l[1]);
break;
}
if (*event.xclient.data.l != (int) windows->wm_delete_window)
break;
if (event.xclient.window == windows->widget.id)
{
*reply_info.text='\0';
state|=ExitState;
break;
}
break;
}
case ConfigureNotify:
{
/*
Update widget configuration.
*/
if (event.xconfigure.window != windows->widget.id)
break;
if ((event.xconfigure.width == (int) windows->widget.width) &&
(event.xconfigure.height == (int) windows->widget.height))
break;
windows->widget.width=(unsigned int)
MagickMax(event.xconfigure.width,(int) windows->widget.min_width);
windows->widget.height=(unsigned int)
MagickMax(event.xconfigure.height,(int) windows->widget.min_height);
state|=UpdateConfigurationState;
break;
}
case EnterNotify:
{
if (event.xcrossing.window != windows->widget.id)
break;
state&=(~InactiveWidgetState);
break;
}
case Expose:
{
if (event.xexpose.window != windows->widget.id)
break;
if (event.xexpose.count != 0)
break;
state|=RedrawWidgetState;
break;
}
case KeyPress:
{
static char
command[MagickPathExtent];
static int
length;
static KeySym
key_symbol;
/*
Respond to a user key press.
*/
if (event.xkey.window != windows->widget.id)
break;
length=XLookupString((XKeyEvent *) &event.xkey,command,
(int) sizeof(command),&key_symbol,(XComposeStatus *) NULL);
*(command+length)='\0';
if (AreaIsActive(scroll_info,event.xkey))
{
/*
Move slider.
*/
switch ((int) key_symbol)
{
case XK_Home:
case XK_KP_Home:
{
slider_info.id=0;
break;
}
case XK_Up:
case XK_KP_Up:
{
slider_info.id--;
break;
}
case XK_Down:
case XK_KP_Down:
{
slider_info.id++;
break;
}
case XK_Prior:
case XK_KP_Prior:
{
slider_info.id-=visible_files;
break;
}
case XK_Next:
case XK_KP_Next:
{
slider_info.id+=visible_files;
break;
}
case XK_End:
case XK_KP_End:
{
slider_info.id=(int) files;
break;
}
}
state|=RedrawListState;
break;
}
if ((key_symbol == XK_Return) || (key_symbol == XK_KP_Enter))
{
/*
Read new directory or glob patterm.
*/
if (*reply_info.text == '\0')
break;
if (IsGlob(reply_info.text))
(void) CopyMagickString(glob_pattern,reply_info.text,
MagickPathExtent);
else
{
(void) ConcatenateMagickString(working_path,DirectorySeparator,
MagickPathExtent);
(void) ConcatenateMagickString(working_path,reply_info.text,
MagickPathExtent);
if (*working_path == '~')
ExpandFilename(working_path);
*reply='\0';
}
state|=UpdateListState;
break;
}
if (key_symbol == XK_Control_L)
{
state|=ControlState;
break;
}
if (state & ControlState)
switch ((int) key_symbol)
{
case XK_u:
case XK_U:
{
/*
Erase the entire line of text.
*/
*reply_info.text='\0';
reply_info.cursor=reply_info.text;
reply_info.marker=reply_info.text;
reply_info.highlight=MagickFalse;
break;
}
default:
break;
}
XEditText(display,&reply_info,key_symbol,command,state);
XDrawMatteText(display,&windows->widget,&reply_info);
state|=JumpListState;
break;
}
case KeyRelease:
{
static char
command[MagickPathExtent];
static KeySym
key_symbol;
/*
Respond to a user key release.
*/
if (event.xkey.window != windows->widget.id)
break;
(void) XLookupString((XKeyEvent *) &event.xkey,command,
(int) sizeof(command),&key_symbol,(XComposeStatus *) NULL);
if (key_symbol == XK_Control_L)
state&=(~ControlState);
break;
}
case LeaveNotify:
{
if (event.xcrossing.window != windows->widget.id)
break;
state|=InactiveWidgetState;
break;
}
case MapNotify:
{
mask&=(~CWX);
mask&=(~CWY);
break;
}
case MotionNotify:
{
/*
Discard pending button motion events.
*/
while (XCheckMaskEvent(display,ButtonMotionMask,&event)) ;
if (slider_info.active)
{
/*
Move slider matte.
*/
slider_info.y=event.xmotion.y-
((slider_info.height+slider_info.bevel_width) >> 1)+1;
if (slider_info.y < slider_info.min_y)
slider_info.y=slider_info.min_y;
if (slider_info.y > slider_info.max_y)
slider_info.y=slider_info.max_y;
slider_info.id=0;
if (slider_info.y != slider_info.min_y)
slider_info.id=(int) ((files*(slider_info.y-slider_info.min_y+1))/
(slider_info.max_y-slider_info.min_y+1));
state|=RedrawListState;
break;
}
if (state & InactiveWidgetState)
break;
if (up_info.raised == MatteIsActive(up_info,event.xmotion))
{
/*
Up button status changed.
*/
up_info.raised=!up_info.raised;
XDrawBeveledButton(display,&windows->widget,&up_info);
break;
}
if (home_info.raised == MatteIsActive(home_info,event.xmotion))
{
/*
Home button status changed.
*/
home_info.raised=!home_info.raised;
XDrawBeveledButton(display,&windows->widget,&home_info);
break;
}
if (special_info.raised == MatteIsActive(special_info,event.xmotion))
{
/*
Grab button status changed.
*/
special_info.raised=!special_info.raised;
XDrawBeveledButton(display,&windows->widget,&special_info);
break;
}
if (action_info.raised == MatteIsActive(action_info,event.xmotion))
{
/*
Action button status changed.
*/
action_info.raised=action_info.raised == MagickFalse ?
MagickTrue : MagickFalse;
XDrawBeveledButton(display,&windows->widget,&action_info);
break;
}
if (cancel_info.raised == MatteIsActive(cancel_info,event.xmotion))
{
/*
Cancel button status changed.
*/
cancel_info.raised=cancel_info.raised == MagickFalse ?
MagickTrue : MagickFalse;
XDrawBeveledButton(display,&windows->widget,&cancel_info);
break;
}
break;
}
case SelectionClear:
{
reply_info.highlight=MagickFalse;
XDrawMatteText(display,&windows->widget,&reply_info);
break;
}
case SelectionNotify:
{
Atom
type;
int
format;
unsigned char
*data;
unsigned long
after,
length;
/*
Obtain response from primary selection.
*/
if (event.xselection.property == (Atom) None)
break;
status=XGetWindowProperty(display,event.xselection.requestor,
event.xselection.property,0L,2047L,MagickTrue,XA_STRING,&type,
&format,&length,&after,&data);
if ((status != Success) || (type != XA_STRING) || (format == 32) ||
(length == 0))
break;
if ((Extent(reply_info.text)+length) >= (MagickPathExtent-1))
(void) XBell(display,0);
else
{
/*
Insert primary selection in reply text.
*/
*(data+length)='\0';
XEditText(display,&reply_info,(KeySym) XK_Insert,(char *) data,
state);
XDrawMatteText(display,&windows->widget,&reply_info);
state|=JumpListState;
state|=RedrawActionState;
}
(void) XFree((void *) data);
break;
}
case SelectionRequest:
{
XSelectionEvent
notify;
XSelectionRequestEvent
*request;
if (reply_info.highlight == MagickFalse)
break;
/*
Set primary selection.
*/
request=(&(event.xselectionrequest));
(void) XChangeProperty(request->display,request->requestor,
request->property,request->target,8,PropModeReplace,
(unsigned char *) primary_selection,Extent(primary_selection));
notify.type=SelectionNotify;
notify.display=request->display;
notify.requestor=request->requestor;
notify.selection=request->selection;
notify.target=request->target;
notify.time=request->time;
if (request->property == None)
notify.property=request->target;
else
notify.property=request->property;
(void) XSendEvent(request->display,request->requestor,False,0,
(XEvent *) ¬ify);
}
default:
break;
}
} while ((state & ExitState) == 0);
XSetCursorState(display,windows,MagickFalse);
(void) XWithdrawWindow(display,windows->widget.id,windows->widget.screen);
XCheckRefreshWindows(display,windows);
/*
Free file list.
*/
for (i=0; i < (ssize_t) files; i++)
filelist[i]=DestroyString(filelist[i]);
if (filelist != (char **) NULL)
filelist=(char **) RelinquishMagickMemory(filelist);
if (*reply != '\0')
{
(void) ConcatenateMagickString(working_path,DirectorySeparator,
MagickPathExtent);
(void) ConcatenateMagickString(working_path,reply,MagickPathExtent);
}
(void) CopyMagickString(reply,working_path,MagickPathExtent);
if (*reply == '~')
ExpandFilename(reply);
} | 1 | [] | ImageMagick | 17619a5e3a2c8f1e6296a9d38a10d8da97da8fd9 | 162,977,621,883,560,550,000,000,000,000,000,000,000 | 1,202 | https://github.com/ImageMagick/ImageMagick/issues/3334 |
Item_func_ifnull::real_op()
{
DBUG_ASSERT(fixed == 1);
double value= args[0]->val_real();
if (!args[0]->null_value)
{
null_value=0;
return value;
}
value= args[1]->val_real();
if ((null_value=args[1]->null_value))
return 0.0;
return value;
} | 0 | [
"CWE-617"
] | server | 807945f2eb5fa22e6f233cc17b85a2e141efe2c8 | 323,896,477,683,745,760,000,000,000,000,000,000,000 | 14 | MDEV-26402: A SEGV in Item_field::used_tables/update_depend_map_for_order...
When doing condition pushdown from HAVING into WHERE,
Item_equal::create_pushable_equalities() calls
item->set_extraction_flag(IMMUTABLE_FL) for constant items.
Then, Item::cleanup_excluding_immutables_processor() checks for this flag
to see if it should call item->cleanup() or leave the item as-is.
The failure happens when a constant item has a non-constant one inside it,
like:
(tbl.col=0 AND impossible_cond)
item->walk(cleanup_excluding_immutables_processor) works in a bottom-up
way so it
1. will call Item_func_eq(tbl.col=0)->cleanup()
2. will not call Item_cond_and->cleanup (as the AND is constant)
This creates an item tree where a fixed Item has an un-fixed Item inside
it which eventually causes an assertion failure.
Fixed by introducing this rule: instead of just calling
item->set_extraction_flag(IMMUTABLE_FL);
we call Item::walk() to set the flag for all sub-items of the item. |
do_setup (GdmSessionWorker *worker)
{
GError *error;
gboolean res;
error = NULL;
res = gdm_session_worker_initialize_pam (worker,
worker->priv->service,
(const char **) worker->priv->extensions,
worker->priv->username,
worker->priv->hostname,
worker->priv->display_is_local,
worker->priv->x11_display_name,
worker->priv->x11_authority_file,
worker->priv->display_device,
worker->priv->display_seat_id,
&error);
if (res) {
g_dbus_method_invocation_return_value (worker->priv->pending_invocation, NULL);
} else {
g_dbus_method_invocation_take_error (worker->priv->pending_invocation, error);
}
worker->priv->pending_invocation = NULL;
} | 0 | [
"CWE-362"
] | gdm | dcdbaaa04012541ad2813cf83559d91d52f208b9 | 72,950,057,497,797,440,000,000,000,000,000,000,000 | 25 | session-worker: Don't switch back VTs until session is fully exited
There's a race condition on shutdown where the session worker is
switching VTs back to the initial VT at the same time as the session
exit is being processed.
This means that manager may try to start a login screen (because of
the VT switch) when autologin is enabled when there shouldn't be a
login screen.
This commit makes sure both the PostSession script, and session-exited
signal emission are complete before initiating the VT switch back
to the initial VT.
https://gitlab.gnome.org/GNOME/gdm/-/issues/660 |
static void arc_emac_set_rx_mode(struct net_device *ndev)
{
struct arc_emac_priv *priv = netdev_priv(ndev);
if (ndev->flags & IFF_PROMISC) {
arc_reg_or(priv, R_CTRL, PROM_MASK);
} else {
arc_reg_clr(priv, R_CTRL, PROM_MASK);
if (ndev->flags & IFF_ALLMULTI) {
arc_reg_set(priv, R_LAFL, ~0);
arc_reg_set(priv, R_LAFH, ~0);
} else {
struct netdev_hw_addr *ha;
unsigned int filter[2] = { 0, 0 };
int bit;
netdev_for_each_mc_addr(ha, ndev) {
bit = ether_crc_le(ETH_ALEN, ha->addr) >> 26;
filter[bit >> 5] |= 1 << (bit & 31);
}
arc_reg_set(priv, R_LAFL, filter[0]);
arc_reg_set(priv, R_LAFH, filter[1]);
}
}
} | 0 | [
"CWE-362"
] | linux | c278c253f3d992c6994d08aa0efb2b6806ca396f | 242,429,746,390,492,440,000,000,000,000,000,000,000 | 27 | net: arc_emac: fix koops caused by sk_buff free
There is a race between arc_emac_tx() and arc_emac_tx_clean().
sk_buff got freed by arc_emac_tx_clean() while arc_emac_tx()
submitting sk_buff.
In order to free sk_buff arc_emac_tx_clean() checks:
if ((info & FOR_EMAC) || !txbd->data)
break;
...
dev_kfree_skb_irq(skb);
If condition false, arc_emac_tx_clean() free sk_buff.
In order to submit txbd, arc_emac_tx() do:
priv->tx_buff[*txbd_curr].skb = skb;
...
priv->txbd[*txbd_curr].data = cpu_to_le32(addr);
...
... <== arc_emac_tx_clean() check condition here
... <== (info & FOR_EMAC) is false
... <== !txbd->data is false
...
*info = cpu_to_le32(FOR_EMAC | FIRST_OR_LAST_MASK | len);
In order to reproduce the situation,
run device:
# iperf -s
run on host:
# iperf -t 600 -c <device-ip-addr>
[ 28.396284] ------------[ cut here ]------------
[ 28.400912] kernel BUG at .../net/core/skbuff.c:1355!
[ 28.414019] Internal error: Oops - BUG: 0 [#1] SMP ARM
[ 28.419150] Modules linked in:
[ 28.422219] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G B 4.4.0+ #120
[ 28.429516] Hardware name: Rockchip (Device Tree)
[ 28.434216] task: c0665070 ti: c0660000 task.ti: c0660000
[ 28.439622] PC is at skb_put+0x10/0x54
[ 28.443381] LR is at arc_emac_poll+0x260/0x474
[ 28.447821] pc : [<c03af580>] lr : [<c028fec4>] psr: a0070113
[ 28.447821] sp : c0661e58 ip : eea68502 fp : ef377000
[ 28.459280] r10: 0000012c r9 : f08b2000 r8 : eeb57100
[ 28.464498] r7 : 00000000 r6 : ef376594 r5 : 00000077 r4 : ef376000
[ 28.471015] r3 : 0030488b r2 : ef13e880 r1 : 000005ee r0 : eeb57100
[ 28.477534] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
[ 28.484658] Control: 10c5387d Table: 8eaf004a DAC: 00000051
[ 28.490396] Process swapper/0 (pid: 0, stack limit = 0xc0660210)
[ 28.496393] Stack: (0xc0661e58 to 0xc0662000)
[ 28.500745] 1e40: 00000002 00000000
[ 28.508913] 1e60: 00000000 ef376520 00000028 f08b23b8 00000000 ef376520 ef7b6900 c028fc64
[ 28.517082] 1e80: 2f158000 c0661ea8 c0661eb0 0000012c c065e900 c03bdeac ffff95e9 c0662100
[ 28.525250] 1ea0: c0663924 00000028 c0661ea8 c0661ea8 c0661eb0 c0661eb0 0000001e c0660000
[ 28.533417] 1ec0: 40000003 00000008 c0695a00 0000000a c066208c 00000100 c0661ee0 c0027410
[ 28.541584] 1ee0: ef0fb700 2f158000 00200000 ffff95e8 00000004 c0662100 c0662080 00000003
[ 28.549751] 1f00: 00000000 00000000 00000000 c065b45c 0000001e ef005000 c0647a30 00000000
[ 28.557919] 1f20: 00000000 c0027798 00000000 c005cf40 f0802100 c0662ffc c0661f60 f0803100
[ 28.566088] 1f40: c0661fb8 c00093bc c000ffb4 60070013 ffffffff c0661f94 c0661fb8 c00137d4
[ 28.574267] 1f60: 00000001 00000000 00000000 c001ffa0 00000000 c0660000 00000000 c065a364
[ 28.582441] 1f80: c0661fb8 c0647a30 00000000 00000000 00000000 c0661fb0 c000ffb0 c000ffb4
[ 28.590608] 1fa0: 60070013 ffffffff 00000051 00000000 00000000 c005496c c0662400 c061bc40
[ 28.598776] 1fc0: ffffffff ffffffff 00000000 c061b680 00000000 c0647a30 00000000 c0695294
[ 28.606943] 1fe0: c0662488 c0647a2c c066619c 6000406a 413fc090 6000807c 00000000 00000000
[ 28.615127] [<c03af580>] (skb_put) from [<ef376520>] (0xef376520)
[ 28.621218] Code: e5902054 e590c090 e3520000 0a000000 (e7f001f2)
[ 28.627307] ---[ end trace 4824734e2243fdb6 ]---
[ 34.377068] Internal error: Oops: 17 [#1] SMP ARM
[ 34.382854] Modules linked in:
[ 34.385947] CPU: 0 PID: 3 Comm: ksoftirqd/0 Not tainted 4.4.0+ #120
[ 34.392219] Hardware name: Rockchip (Device Tree)
[ 34.396937] task: ef02d040 ti: ef05c000 task.ti: ef05c000
[ 34.402376] PC is at __dev_kfree_skb_irq+0x4/0x80
[ 34.407121] LR is at arc_emac_poll+0x130/0x474
[ 34.411583] pc : [<c03bb640>] lr : [<c028fd94>] psr: 60030013
[ 34.411583] sp : ef05de68 ip : 0008e83c fp : ef377000
[ 34.423062] r10: c001bec4 r9 : 00000000 r8 : f08b24c8
[ 34.428296] r7 : f08b2400 r6 : 00000075 r5 : 00000019 r4 : ef376000
[ 34.434827] r3 : 00060000 r2 : 00000042 r1 : 00000001 r0 : 00000000
[ 34.441365] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
[ 34.448507] Control: 10c5387d Table: 8f25c04a DAC: 00000051
[ 34.454262] Process ksoftirqd/0 (pid: 3, stack limit = 0xef05c210)
[ 34.460449] Stack: (0xef05de68 to 0xef05e000)
[ 34.464827] de60: ef376000 c028fd94 00000000 c0669480 c0669480 ef376520
[ 34.473022] de80: 00000028 00000001 00002ae4 ef376520 ef7b6900 c028fc64 2f158000 ef05dec0
[ 34.481215] dea0: ef05dec8 0000012c c065e900 c03bdeac ffff983f c0662100 c0663924 00000028
[ 34.489409] dec0: ef05dec0 ef05dec0 ef05dec8 ef05dec8 ef7b6000 ef05c000 40000003 00000008
[ 34.497600] dee0: c0695a00 0000000a c066208c 00000100 ef05def8 c0027410 ef7b6000 40000000
[ 34.505795] df00: 04208040 ffff983e 00000004 c0662100 c0662080 00000003 ef05c000 ef027340
[ 34.513985] df20: ef05c000 c0666c2c 00000000 00000001 00000002 00000000 00000000 c0027568
[ 34.522176] df40: ef027340 c003ef48 ef027300 00000000 ef027340 c003edd4 00000000 00000000
[ 34.530367] df60: 00000000 c003c37c ffffff7f 00000001 00000000 ef027340 00000000 00030003
[ 34.538559] df80: ef05df80 ef05df80 00000000 00000000 ef05df90 ef05df90 ef05dfac ef027300
[ 34.546750] dfa0: c003c2a4 00000000 00000000 c000f578 00000000 00000000 00000000 00000000
[ 34.554939] dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 34.563129] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000 ffffffff dfff7fff
[ 34.571360] [<c03bb640>] (__dev_kfree_skb_irq) from [<c028fd94>] (arc_emac_poll+0x130/0x474)
[ 34.579840] [<c028fd94>] (arc_emac_poll) from [<c03bdeac>] (net_rx_action+0xdc/0x28c)
[ 34.587712] [<c03bdeac>] (net_rx_action) from [<c0027410>] (__do_softirq+0xcc/0x1f8)
[ 34.595482] [<c0027410>] (__do_softirq) from [<c0027568>] (run_ksoftirqd+0x2c/0x50)
[ 34.603168] [<c0027568>] (run_ksoftirqd) from [<c003ef48>] (smpboot_thread_fn+0x174/0x18c)
[ 34.611466] [<c003ef48>] (smpboot_thread_fn) from [<c003c37c>] (kthread+0xd8/0xec)
[ 34.619075] [<c003c37c>] (kthread) from [<c000f578>] (ret_from_fork+0x14/0x3c)
[ 34.626317] Code: e8bd8010 e3a00000 e12fff1e e92d4010 (e59030a4)
[ 34.632572] ---[ end trace cca5a3d86a82249a ]---
Signed-off-by: Alexander Kochetkov <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
static int vxlan_nl2flag(struct vxlan_config *conf, struct nlattr *tb[],
int attrtype, unsigned long mask, bool changelink,
bool changelink_supported,
struct netlink_ext_ack *extack)
{
unsigned long flags;
if (!tb[attrtype])
return 0;
if (changelink && !changelink_supported) {
vxlan_flag_attr_error(attrtype, extack);
return -EOPNOTSUPP;
}
if (vxlan_policy[attrtype].type == NLA_FLAG)
flags = conf->flags | mask;
else if (nla_get_u8(tb[attrtype]))
flags = conf->flags | mask;
else
flags = conf->flags & ~mask;
conf->flags = flags;
return 0;
} | 0 | [] | net | 6c8991f41546c3c472503dff1ea9daaddf9331c2 | 253,309,002,586,065,450,000,000,000,000,000,000,000 | 26 | net: ipv6_stub: use ip6_dst_lookup_flow instead of ip6_dst_lookup
ipv6_stub uses the ip6_dst_lookup function to allow other modules to
perform IPv6 lookups. However, this function skips the XFRM layer
entirely.
All users of ipv6_stub->ip6_dst_lookup use ip_route_output_flow (via the
ip_route_output_key and ip_route_output helpers) for their IPv4 lookups,
which calls xfrm_lookup_route(). This patch fixes this inconsistent
behavior by switching the stub to ip6_dst_lookup_flow, which also calls
xfrm_lookup_route().
This requires some changes in all the callers, as these two functions
take different arguments and have different return types.
Fixes: 5f81bd2e5d80 ("ipv6: export a stub for IPv6 symbols used by vxlan")
Reported-by: Xiumei Mu <[email protected]>
Signed-off-by: Sabrina Dubroca <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
_dbus_validate_member (const DBusString *str,
int start,
int len)
{
const unsigned char *s;
const unsigned char *end;
const unsigned char *member;
_dbus_assert (start >= 0);
_dbus_assert (len >= 0);
_dbus_assert (start <= _dbus_string_get_length (str));
if (len > _dbus_string_get_length (str) - start)
return FALSE;
if (len > DBUS_MAXIMUM_NAME_LENGTH)
return FALSE;
if (len == 0)
return FALSE;
member = _dbus_string_get_const_data (str) + start;
end = member + len;
s = member;
/* check special cases of first char so it doesn't have to be done
* in the loop. Note we know len > 0
*/
if (_DBUS_UNLIKELY (!VALID_INITIAL_NAME_CHARACTER (*s)))
return FALSE;
else
++s;
while (s != end)
{
if (_DBUS_UNLIKELY (!VALID_NAME_CHARACTER (*s)))
{
return FALSE;
}
++s;
}
return TRUE;
} | 0 | [
"CWE-20"
] | dbus | 7b10b46c5c8658449783ce45f1273dd35c353bce | 328,065,107,448,287,330,000,000,000,000,000,000,000 | 46 | Bug 17803: Panic from dbus_signature_validate
* dbus/dbus-marshal-validate.c: Ensure we validate
a basic type before calling is_basic on it.
* dbus-marshal-validate-util.c: Test. |
static inline u8 l2cap_get_auth_type(struct l2cap_chan *chan)
{
switch (chan->chan_type) {
case L2CAP_CHAN_RAW:
switch (chan->sec_level) {
case BT_SECURITY_HIGH:
case BT_SECURITY_FIPS:
return HCI_AT_DEDICATED_BONDING_MITM;
case BT_SECURITY_MEDIUM:
return HCI_AT_DEDICATED_BONDING;
default:
return HCI_AT_NO_BONDING;
}
break;
case L2CAP_CHAN_CONN_LESS:
if (chan->psm == cpu_to_le16(L2CAP_PSM_3DSP)) {
if (chan->sec_level == BT_SECURITY_LOW)
chan->sec_level = BT_SECURITY_SDP;
}
if (chan->sec_level == BT_SECURITY_HIGH ||
chan->sec_level == BT_SECURITY_FIPS)
return HCI_AT_NO_BONDING_MITM;
else
return HCI_AT_NO_BONDING;
break;
case L2CAP_CHAN_CONN_ORIENTED:
if (chan->psm == cpu_to_le16(L2CAP_PSM_SDP)) {
if (chan->sec_level == BT_SECURITY_LOW)
chan->sec_level = BT_SECURITY_SDP;
if (chan->sec_level == BT_SECURITY_HIGH ||
chan->sec_level == BT_SECURITY_FIPS)
return HCI_AT_NO_BONDING_MITM;
else
return HCI_AT_NO_BONDING;
}
/* fall through */
default:
switch (chan->sec_level) {
case BT_SECURITY_HIGH:
case BT_SECURITY_FIPS:
return HCI_AT_GENERAL_BONDING_MITM;
case BT_SECURITY_MEDIUM:
return HCI_AT_GENERAL_BONDING;
default:
return HCI_AT_NO_BONDING;
}
break;
}
} | 0 | [
"CWE-787"
] | linux | e860d2c904d1a9f38a24eb44c9f34b8f915a6ea3 | 64,611,403,381,245,610,000,000,000,000,000,000,000 | 50 | Bluetooth: Properly check L2CAP config option output buffer length
Validate the output buffer length for L2CAP config requests and responses
to avoid overflowing the stack buffer used for building the option blocks.
Cc: [email protected]
Signed-off-by: Ben Seri <[email protected]>
Signed-off-by: Marcel Holtmann <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]> |
static void enable_unsafe_renegotiation(gnutls_priority_t c)
{
c->sr = SR_UNSAFE;
} | 0 | [
"CWE-310"
] | gnutls | 21f89efad7014a5ee0debd4cd3d59e27774b29e6 | 211,096,531,644,668,670,000,000,000,000,000,000,000 | 4 | handshake: add FALLBACK_SCSV priority option
This allows clients to enable the TLS_FALLBACK_SCSV mechanism during
the handshake, as defined in RFC7507. |
static gint msg_data_find(struct message_data *a, struct message_data *b)
{
if (a->fid == b->fid
&& a->frame == b->frame
&& a->msg_id == b->msg_id
&& a->smb_level == b->smb_level
&& a->is_request == b->is_request) {
return 0;
}
return 1;
} | 0 | [
"CWE-770"
] | wireshark | b7a0650e061b5418ab4a8f72c6e4b00317aff623 | 91,122,263,574,742,820,000,000,000,000,000,000,000 | 11 | MS-WSP: Don't allocate huge amounts of memory.
Add a couple of memory allocation sanity checks, one of which
fixes #17331. |
static char *linetoken(FILE *stream)
{
int ch, idx;
while ((ch = fgetc(stream)) == ' ' || ch == '\t' );
idx = 0;
while (ch != EOF && ch != lineterm && idx < MAX_NAME)
{
ident[idx++] = ch;
ch = fgetc(stream);
} /* while */
ungetc(ch, stream);
ident[idx] = 0;
return(ident); /* returns pointer to the token */
} /* linetoken */ | 1 | [] | evince | efadec4ffcdde3373f6f4ca0eaac98dc963c4fd5 | 127,373,773,716,473,140,000,000,000,000,000,000,000 | 19 | dvi: Another fix for buffer overwrite in dvi-backend
https://bugzilla.gnome.org/show_bug.cgi?id=643882 |
virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDefPtr **seclabels_rtn,
size_t *nseclabels_rtn,
xmlXPathContextPtr ctxt,
unsigned int flags)
{
VIR_XPATH_NODE_AUTORESTORE(ctxt);
virSecurityDeviceLabelDefPtr *seclabels = NULL;
size_t nseclabels = 0;
int n;
size_t i, j;
char *model, *relabel, *label, *labelskip;
g_autofree xmlNodePtr *list = NULL;
if ((n = virXPathNodeSet("./seclabel", ctxt, &list)) < 0)
goto error;
if (n == 0)
return 0;
if (VIR_ALLOC_N(seclabels, n) < 0)
goto error;
nseclabels = n;
for (i = 0; i < n; i++) {
if (VIR_ALLOC(seclabels[i]) < 0)
goto error;
}
for (i = 0; i < n; i++) {
/* get model associated to this override */
model = virXMLPropString(list[i], "model");
if (model) {
/* check for duplicate seclabels */
for (j = 0; j < i; j++) {
if (STREQ_NULLABLE(model, seclabels[j]->model)) {
virReportError(VIR_ERR_XML_DETAIL,
_("seclabel for model %s is already provided"), model);
goto error;
}
}
seclabels[i]->model = model;
}
relabel = virXMLPropString(list[i], "relabel");
if (relabel != NULL) {
if (virStringParseYesNo(relabel, &seclabels[i]->relabel) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid security relabel value %s"),
relabel);
VIR_FREE(relabel);
goto error;
}
VIR_FREE(relabel);
} else {
seclabels[i]->relabel = true;
}
/* labelskip is only parsed on live images */
labelskip = virXMLPropString(list[i], "labelskip");
seclabels[i]->labelskip = false;
if (labelskip && !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
ignore_value(virStringParseYesNo(labelskip, &seclabels[i]->labelskip));
VIR_FREE(labelskip);
ctxt->node = list[i];
label = virXPathStringLimit("string(./label)",
VIR_SECURITY_LABEL_BUFLEN-1, ctxt);
seclabels[i]->label = label;
if (label && !seclabels[i]->relabel) {
virReportError(VIR_ERR_XML_ERROR,
_("Cannot specify a label if relabelling is "
"turned off. model=%s"),
NULLSTR(seclabels[i]->model));
goto error;
}
}
*nseclabels_rtn = nseclabels;
*seclabels_rtn = seclabels;
return 0;
error:
for (i = 0; i < nseclabels; i++)
virSecurityDeviceLabelDefFree(seclabels[i]);
VIR_FREE(seclabels);
return -1;
} | 0 | [
"CWE-212"
] | libvirt | a5b064bf4b17a9884d7d361733737fb614ad8979 | 36,384,644,019,019,034,000,000,000,000,000,000,000 | 87 | conf: Don't format http cookies unless VIR_DOMAIN_DEF_FORMAT_SECURE is used
Starting with 3b076391befc3fe72deb0c244ac6c2b4c100b410
(v6.1.0-122-g3b076391be) we support http cookies. Since they may contain
somewhat sensitive information we should not format them into the XML
unless VIR_DOMAIN_DEF_FORMAT_SECURE is asserted.
Reported-by: Han Han <[email protected]>
Signed-off-by: Peter Krempa <[email protected]>
Reviewed-by: Erik Skultety <[email protected]> |
static int srp_tmr_to_tcm(int fn)
{
switch (fn) {
case SRP_TSK_ABORT_TASK:
return TMR_ABORT_TASK;
case SRP_TSK_ABORT_TASK_SET:
return TMR_ABORT_TASK_SET;
case SRP_TSK_CLEAR_TASK_SET:
return TMR_CLEAR_TASK_SET;
case SRP_TSK_LUN_RESET:
return TMR_LUN_RESET;
case SRP_TSK_CLEAR_ACA:
return TMR_CLEAR_ACA;
default:
return -1;
}
} | 0 | [
"CWE-200",
"CWE-476"
] | linux | 51093254bf879bc9ce96590400a87897c7498463 | 143,154,480,695,754,570,000,000,000,000,000,000,000 | 17 | IB/srpt: Simplify srpt_handle_tsk_mgmt()
Let the target core check task existence instead of the SRP target
driver. Additionally, let the target core check the validity of the
task management request instead of the ib_srpt driver.
This patch fixes the following kernel crash:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000001
IP: [<ffffffffa0565f37>] srpt_handle_new_iu+0x6d7/0x790 [ib_srpt]
Oops: 0002 [#1] SMP
Call Trace:
[<ffffffffa05660ce>] srpt_process_completion+0xde/0x570 [ib_srpt]
[<ffffffffa056669f>] srpt_compl_thread+0x13f/0x160 [ib_srpt]
[<ffffffff8109726f>] kthread+0xcf/0xe0
[<ffffffff81613cfc>] ret_from_fork+0x7c/0xb0
Signed-off-by: Bart Van Assche <[email protected]>
Fixes: 3e4f574857ee ("ib_srpt: Convert TMR path to target_submit_tmr")
Tested-by: Alex Estrin <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Cc: Nicholas Bellinger <[email protected]>
Cc: Sagi Grimberg <[email protected]>
Cc: stable <[email protected]>
Signed-off-by: Doug Ledford <[email protected]> |
str_frozen_check(VALUE s)
{
if (OBJ_FROZEN(s)) {
rb_raise(rb_eRuntimeError, "string frozen");
}
} | 0 | [
"CWE-119"
] | ruby | 1c2ef610358af33f9ded3086aa2d70aac03dcac5 | 333,305,999,144,152,820,000,000,000,000,000,000,000 | 6 | * string.c (rb_str_justify): CVE-2009-4124.
Fixes a bug reported by
Emmanouel Kellinis <Emmanouel.Kellinis AT kpmg.co.uk>, KPMG London;
Patch by nobu.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e |
dwg_paper_space_object (Dwg_Data *dwg)
{
Dwg_Object_Ref *psref = dwg_paper_space_ref (dwg);
Dwg_Object_BLOCK_CONTROL *ctrl;
if (psref && psref->obj && psref->obj->type == DWG_TYPE_BLOCK_HEADER)
return psref->obj;
ctrl = dwg_block_control (dwg);
if (ctrl && ctrl->paper_space && ctrl->paper_space->obj)
return ctrl->paper_space->obj;
if (dwg->header_vars.BLOCK_RECORD_PSPACE
&& dwg->header_vars.BLOCK_RECORD_PSPACE->obj)
return dwg->header_vars.BLOCK_RECORD_PSPACE->obj;
else
return NULL;
} | 0 | [
"CWE-787"
] | libredwg | ecf5183d8b3b286afe2a30021353b7116e0208dd | 112,577,199,836,337,280,000,000,000,000,000,000,000 | 16 | dwg_section_wtype: fix fuzzing overflow
with illegal and overlong section names. Fixes GH #349, #352
section names cannot be longer than 24 |
static MagickBooleanType WritePICTImage(const ImageInfo *image_info,
Image *image)
{
#define MaxCount 128
#define PictCropRegionOp 0x01
#define PictEndOfPictureOp 0xff
#define PictJPEGOp 0x8200
#define PictInfoOp 0x0C00
#define PictInfoSize 512
#define PictPixmapOp 0x9A
#define PictPICTOp 0x98
#define PictVersion 0x11
const StringInfo
*profile;
double
x_resolution,
y_resolution;
MagickBooleanType
status;
MagickOffsetType
offset;
PICTPixmap
pixmap;
PICTRectangle
bounds,
crop_rectangle,
destination_rectangle,
frame_rectangle,
size_rectangle,
source_rectangle;
register const IndexPacket
*indexes;
register const PixelPacket
*p;
register ssize_t
i,
x;
size_t
bytes_per_line,
count,
row_bytes,
storage_class;
ssize_t
y;
unsigned char
*buffer,
*packed_scanline,
*scanline;
unsigned short
base_address,
transfer_mode;
/*
Open output image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
if ((image->columns > 65535L) || (image->rows > 65535L))
ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit");
status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
if (status == MagickFalse)
return(status);
if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)
(void) TransformImageColorspace(image,sRGBColorspace);
/*
Initialize image info.
*/
size_rectangle.top=0;
size_rectangle.left=0;
size_rectangle.bottom=(short) image->rows;
size_rectangle.right=(short) image->columns;
frame_rectangle=size_rectangle;
crop_rectangle=size_rectangle;
source_rectangle=size_rectangle;
destination_rectangle=size_rectangle;
base_address=0xff;
row_bytes=image->columns;
bounds.top=0;
bounds.left=0;
bounds.bottom=(short) image->rows;
bounds.right=(short) image->columns;
pixmap.version=0;
pixmap.pack_type=0;
pixmap.pack_size=0;
pixmap.pixel_type=0;
pixmap.bits_per_pixel=8;
pixmap.component_count=1;
pixmap.component_size=8;
pixmap.plane_bytes=0;
pixmap.table=0;
pixmap.reserved=0;
transfer_mode=0;
x_resolution=image->x_resolution != 0.0 ? image->x_resolution :
DefaultResolution;
y_resolution=image->y_resolution != 0.0 ? image->y_resolution :
DefaultResolution;
storage_class=image->storage_class;
if (image_info->compression == JPEGCompression)
storage_class=DirectClass;
if (storage_class == DirectClass)
{
pixmap.component_count=image->matte != MagickFalse ? 4 : 3;
pixmap.pixel_type=16;
pixmap.bits_per_pixel=32;
pixmap.pack_type=0x04;
transfer_mode=0x40;
row_bytes=4*image->columns;
}
/*
Allocate memory.
*/
bytes_per_line=image->columns;
if (storage_class == DirectClass)
bytes_per_line*=image->matte != MagickFalse ? 4 : 3;
buffer=(unsigned char *) AcquireQuantumMemory(PictInfoSize,sizeof(*buffer));
packed_scanline=(unsigned char *) AcquireQuantumMemory((size_t)
(row_bytes+MaxCount),sizeof(*packed_scanline));
scanline=(unsigned char *) AcquireQuantumMemory(row_bytes,sizeof(*scanline));
if ((buffer == (unsigned char *) NULL) ||
(packed_scanline == (unsigned char *) NULL) ||
(scanline == (unsigned char *) NULL))
{
if (scanline != (unsigned char *) NULL)
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
if (packed_scanline != (unsigned char *) NULL)
packed_scanline=(unsigned char *) RelinquishMagickMemory(
packed_scanline);
if (buffer != (unsigned char *) NULL)
buffer=(unsigned char *) RelinquishMagickMemory(buffer);
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
}
(void) memset(scanline,0,row_bytes);
(void) memset(packed_scanline,0,(size_t) (row_bytes+MaxCount));
/*
Write header, header size, size bounding box, version, and reserved.
*/
(void) memset(buffer,0,PictInfoSize);
(void) WriteBlob(image,PictInfoSize,buffer);
(void) WriteBlobMSBShort(image,0);
(void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.top);
(void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.left);
(void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.bottom);
(void) WriteBlobMSBShort(image,(unsigned short) size_rectangle.right);
(void) WriteBlobMSBShort(image,PictVersion);
(void) WriteBlobMSBShort(image,0x02ff); /* version #2 */
(void) WriteBlobMSBShort(image,PictInfoOp);
(void) WriteBlobMSBLong(image,0xFFFE0000U);
/*
Write full size of the file, resolution, frame bounding box, and reserved.
*/
(void) WriteBlobMSBShort(image,(unsigned short) x_resolution);
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBShort(image,(unsigned short) y_resolution);
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.top);
(void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.left);
(void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.bottom);
(void) WriteBlobMSBShort(image,(unsigned short) frame_rectangle.right);
(void) WriteBlobMSBLong(image,0x00000000L);
profile=GetImageProfile(image,"iptc");
if (profile != (StringInfo *) NULL)
{
(void) WriteBlobMSBShort(image,0xa1);
(void) WriteBlobMSBShort(image,0x1f2);
(void) WriteBlobMSBShort(image,(unsigned short)
(GetStringInfoLength(profile)+4));
(void) WriteBlobString(image,"8BIM");
(void) WriteBlob(image,GetStringInfoLength(profile),
GetStringInfoDatum(profile));
}
profile=GetImageProfile(image,"icc");
if (profile != (StringInfo *) NULL)
{
(void) WriteBlobMSBShort(image,0xa1);
(void) WriteBlobMSBShort(image,0xe0);
(void) WriteBlobMSBShort(image,(unsigned short)
(GetStringInfoLength(profile)+4));
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlob(image,GetStringInfoLength(profile),
GetStringInfoDatum(profile));
(void) WriteBlobMSBShort(image,0xa1);
(void) WriteBlobMSBShort(image,0xe0);
(void) WriteBlobMSBShort(image,4);
(void) WriteBlobMSBLong(image,0x00000002U);
}
/*
Write crop region opcode and crop bounding box.
*/
(void) WriteBlobMSBShort(image,PictCropRegionOp);
(void) WriteBlobMSBShort(image,0xa);
(void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.top);
(void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.left);
(void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.bottom);
(void) WriteBlobMSBShort(image,(unsigned short) crop_rectangle.right);
if (image_info->compression == JPEGCompression)
{
Image
*jpeg_image;
ImageInfo
*jpeg_info;
size_t
length;
unsigned char
*blob;
jpeg_image=CloneImage(image,0,0,MagickTrue,&image->exception);
if (jpeg_image == (Image *) NULL)
{
(void) CloseBlob(image);
return(MagickFalse);
}
jpeg_info=CloneImageInfo(image_info);
(void) CopyMagickString(jpeg_info->magick,"JPEG",MaxTextExtent);
length=0;
blob=(unsigned char *) ImageToBlob(jpeg_info,jpeg_image,&length,
&image->exception);
jpeg_info=DestroyImageInfo(jpeg_info);
if (blob == (unsigned char *) NULL)
return(MagickFalse);
jpeg_image=DestroyImage(jpeg_image);
(void) WriteBlobMSBShort(image,PictJPEGOp);
(void) WriteBlobMSBLong(image,(unsigned int) length+154);
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBLong(image,0x00010000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00010000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x40000000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00400000U);
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBShort(image,(unsigned short) image->rows);
(void) WriteBlobMSBShort(image,(unsigned short) image->columns);
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBShort(image,768);
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00566A70U);
(void) WriteBlobMSBLong(image,0x65670000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00000001U);
(void) WriteBlobMSBLong(image,0x00016170U);
(void) WriteBlobMSBLong(image,0x706C0000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBShort(image,768);
(void) WriteBlobMSBShort(image,(unsigned short) image->columns);
(void) WriteBlobMSBShort(image,(unsigned short) image->rows);
(void) WriteBlobMSBShort(image,(unsigned short) x_resolution);
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBShort(image,(unsigned short) y_resolution);
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBLong(image,length);
(void) WriteBlobMSBShort(image,0x0001);
(void) WriteBlobMSBLong(image,0x0B466F74U);
(void) WriteBlobMSBLong(image,0x6F202D20U);
(void) WriteBlobMSBLong(image,0x4A504547U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x00000000U);
(void) WriteBlobMSBLong(image,0x0018FFFFU);
(void) WriteBlob(image,length,blob);
if ((length & 0x01) != 0)
(void) WriteBlobByte(image,'\0');
blob=(unsigned char *) RelinquishMagickMemory(blob);
}
/*
Write picture opcode, row bytes, and picture bounding box, and version.
*/
if (storage_class == PseudoClass)
(void) WriteBlobMSBShort(image,PictPICTOp);
else
{
(void) WriteBlobMSBShort(image,PictPixmapOp);
(void) WriteBlobMSBLong(image,(unsigned int) base_address);
}
(void) WriteBlobMSBShort(image,(unsigned short) (row_bytes | 0x8000));
(void) WriteBlobMSBShort(image,(unsigned short) bounds.top);
(void) WriteBlobMSBShort(image,(unsigned short) bounds.left);
(void) WriteBlobMSBShort(image,(unsigned short) bounds.bottom);
(void) WriteBlobMSBShort(image,(unsigned short) bounds.right);
/*
Write pack type, pack size, resolution, pixel type, and pixel size.
*/
(void) WriteBlobMSBShort(image,(unsigned short) pixmap.version);
(void) WriteBlobMSBShort(image,(unsigned short) pixmap.pack_type);
(void) WriteBlobMSBLong(image,(unsigned int) pixmap.pack_size);
(void) WriteBlobMSBShort(image,(unsigned short) (x_resolution+0.5));
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBShort(image,(unsigned short) (y_resolution+0.5));
(void) WriteBlobMSBShort(image,0x0000);
(void) WriteBlobMSBShort(image,(unsigned short) pixmap.pixel_type);
(void) WriteBlobMSBShort(image,(unsigned short) pixmap.bits_per_pixel);
/*
Write component count, size, plane bytes, table size, and reserved.
*/
(void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_count);
(void) WriteBlobMSBShort(image,(unsigned short) pixmap.component_size);
(void) WriteBlobMSBLong(image,(unsigned int) pixmap.plane_bytes);
(void) WriteBlobMSBLong(image,(unsigned int) pixmap.table);
(void) WriteBlobMSBLong(image,(unsigned int) pixmap.reserved);
if (storage_class == PseudoClass)
{
/*
Write image colormap.
*/
(void) WriteBlobMSBLong(image,0x00000000L); /* color seed */
(void) WriteBlobMSBShort(image,0L); /* color flags */
(void) WriteBlobMSBShort(image,(unsigned short) (image->colors-1));
for (i=0; i < (ssize_t) image->colors; i++)
{
(void) WriteBlobMSBShort(image,(unsigned short) i);
(void) WriteBlobMSBShort(image,ScaleQuantumToShort(
image->colormap[i].red));
(void) WriteBlobMSBShort(image,ScaleQuantumToShort(
image->colormap[i].green));
(void) WriteBlobMSBShort(image,ScaleQuantumToShort(
image->colormap[i].blue));
}
}
/*
Write source and destination rectangle.
*/
(void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.top);
(void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.left);
(void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.bottom);
(void) WriteBlobMSBShort(image,(unsigned short) source_rectangle.right);
(void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.top);
(void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.left);
(void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.bottom);
(void) WriteBlobMSBShort(image,(unsigned short) destination_rectangle.right);
(void) WriteBlobMSBShort(image,(unsigned short) transfer_mode);
/*
Write picture data.
*/
count=0;
if (storage_class == PseudoClass)
for (y=0; y < (ssize_t) image->rows; y++)
{
p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
if (p == (const PixelPacket *) NULL)
break;
indexes=GetVirtualIndexQueue(image);
for (x=0; x < (ssize_t) image->columns; x++)
scanline[x]=(unsigned char) GetPixelIndex(indexes+x);
count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF),
packed_scanline);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
else
if (image_info->compression == JPEGCompression)
{
(void) memset(scanline,0,row_bytes);
for (y=0; y < (ssize_t) image->rows; y++)
count+=EncodeImage(image,scanline,(size_t) (row_bytes & 0x7FFF),
packed_scanline);
}
else
{
register unsigned char
*blue,
*green,
*opacity,
*red;
red=scanline;
green=scanline+image->columns;
blue=scanline+2*image->columns;
opacity=scanline+3*image->columns;
for (y=0; y < (ssize_t) image->rows; y++)
{
p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
if (p == (const PixelPacket *) NULL)
break;
red=scanline;
green=scanline+image->columns;
blue=scanline+2*image->columns;
if (image->matte != MagickFalse)
{
opacity=scanline;
red=scanline+image->columns;
green=scanline+2*image->columns;
blue=scanline+3*image->columns;
}
for (x=0; x < (ssize_t) image->columns; x++)
{
*red++=ScaleQuantumToChar(GetPixelRed(p));
*green++=ScaleQuantumToChar(GetPixelGreen(p));
*blue++=ScaleQuantumToChar(GetPixelBlue(p));
if (image->matte != MagickFalse)
*opacity++=ScaleQuantumToChar((Quantum) (GetPixelAlpha(p)));
p++;
}
count+=EncodeImage(image,scanline,bytes_per_line,packed_scanline);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
}
if ((count & 0x01) != 0)
(void) WriteBlobByte(image,'\0');
(void) WriteBlobMSBShort(image,PictEndOfPictureOp);
offset=TellBlob(image);
offset=SeekBlob(image,512,SEEK_SET);
(void) WriteBlobMSBShort(image,(unsigned short) offset);
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
packed_scanline=(unsigned char *) RelinquishMagickMemory(packed_scanline);
buffer=(unsigned char *) RelinquishMagickMemory(buffer);
(void) CloseBlob(image);
return(MagickTrue);
} | 0 | [
"CWE-252"
] | ImageMagick6 | 11d9dac3d991c62289d1ef7a097670166480e76c | 58,722,874,922,381,620,000,000,000,000,000,000,000 | 449 | https://github.com/ImageMagick/ImageMagick/issues/1199 |
static inline void
__skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4)
{
__skb_set_hash(skb, hash, true, is_l4); | 0 | [
"CWE-20"
] | linux | 2b16f048729bf35e6c28a40cbfad07239f9dcd90 | 114,335,209,156,634,260,000,000,000,000,000,000,000 | 4 | net: create skb_gso_validate_mac_len()
If you take a GSO skb, and split it into packets, will the MAC
length (L2 + L3 + L4 headers + payload) of those packets be small
enough to fit within a given length?
Move skb_gso_mac_seglen() to skbuff.h with other related functions
like skb_gso_network_seglen() so we can use it, and then create
skb_gso_validate_mac_len to do the full calculation.
Signed-off-by: Daniel Axtens <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
Item_return_date_time(THD *thd, const char *name_arg, uint length_arg,
enum_field_types field_type_arg, uint dec_arg= 0):
Item_partition_func_safe_string(thd, name_arg, length_arg, &my_charset_bin),
date_time_field_type(field_type_arg)
{ decimals= dec_arg; } | 0 | [
"CWE-617"
] | server | 807945f2eb5fa22e6f233cc17b85a2e141efe2c8 | 320,087,167,001,433,600,000,000,000,000,000,000,000 | 5 | MDEV-26402: A SEGV in Item_field::used_tables/update_depend_map_for_order...
When doing condition pushdown from HAVING into WHERE,
Item_equal::create_pushable_equalities() calls
item->set_extraction_flag(IMMUTABLE_FL) for constant items.
Then, Item::cleanup_excluding_immutables_processor() checks for this flag
to see if it should call item->cleanup() or leave the item as-is.
The failure happens when a constant item has a non-constant one inside it,
like:
(tbl.col=0 AND impossible_cond)
item->walk(cleanup_excluding_immutables_processor) works in a bottom-up
way so it
1. will call Item_func_eq(tbl.col=0)->cleanup()
2. will not call Item_cond_and->cleanup (as the AND is constant)
This creates an item tree where a fixed Item has an un-fixed Item inside
it which eventually causes an assertion failure.
Fixed by introducing this rule: instead of just calling
item->set_extraction_flag(IMMUTABLE_FL);
we call Item::walk() to set the flag for all sub-items of the item. |
int dlpar_acquire_drc(u32 drc_index)
{
int dr_status, rc;
rc = rtas_call(rtas_token("get-sensor-state"), 2, 2, &dr_status,
DR_ENTITY_SENSE, drc_index);
if (rc || dr_status != DR_ENTITY_UNUSABLE)
return -1;
rc = rtas_set_indicator(ALLOCATION_STATE, drc_index, ALLOC_USABLE);
if (rc)
return rc;
rc = rtas_set_indicator(ISOLATION_STATE, drc_index, UNISOLATE);
if (rc) {
rtas_set_indicator(ALLOCATION_STATE, drc_index, ALLOC_UNUSABLE);
return rc;
}
return 0;
} | 0 | [
"CWE-476"
] | linux | efa9ace68e487ddd29c2b4d6dd23242158f1f607 | 16,482,626,441,416,672,000,000,000,000,000,000,000 | 21 | powerpc/pseries/dlpar: Fix a missing check in dlpar_parse_cc_property()
In dlpar_parse_cc_property(), 'prop->name' is allocated by kstrdup().
kstrdup() may return NULL, so it should be checked and handle error.
And prop should be freed if 'prop->name' is NULL.
Signed-off-by: Gen Zhang <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]> |
static void build_xref(char *msgid, char *buf, size_t size, int body_only)
{
struct xref_rock xrock = { buf, size };
snprintf(buf, size, "%s%s", body_only ? "" : "Xref: ", config_servername);
duplicate_find(msgid, &xref_cb, &xrock);
} | 0 | [
"CWE-119"
] | cyrus-imapd | 0f8f026699829b65733c3081657b24e2174f4f4d | 105,222,744,148,603,920,000,000,000,000,000,000,000 | 7 | CVE-2011-3208 - fix buffer overflow in nntpd |
void assertResult(int expectedResult, const BSONObj& spec) {
intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
BSONObj specObj = BSON("" << spec);
BSONElement specElement = specObj.firstElement();
VariablesParseState vps = expCtx->variablesParseState;
intrusive_ptr<Expression> expression = Expression::parseOperand(expCtx, specElement, vps);
ASSERT_BSONOBJ_EQ(constify(spec), expressionToBson(expression));
ASSERT_BSONOBJ_EQ(BSON("" << expectedResult), toBson(expression->evaluate(Document())));
} | 0 | [
"CWE-835"
] | mongo | 0a076417d1d7fba3632b73349a1fd29a83e68816 | 58,101,029,326,356,520,000,000,000,000,000,000,000 | 9 | SERVER-38070 fix infinite loop in agg expression |
_nc_retrace_int(int code)
{
T((T_RETURN("%d"), code));
return code;
} | 0 | [] | ncurses | 790a85dbd4a81d5f5d8dd02a44d84f01512ef443 | 146,091,281,061,030,250,000,000,000,000,000,000,000 | 5 | ncurses 6.2 - patch 20200531
+ correct configure version-check/warnng for g++ to allow for 10.x
+ re-enable "bel" in konsole-base (report by Nia Huang)
+ add linux-s entry (patch by Alexandre Montaron).
+ drop long-obsolete convert_configure.pl
+ add test/test_parm.c, for checking tparm changes.
+ improve parameter-checking for tparm, adding function _nc_tiparm() to
handle the most-used case, which accepts only numeric parameters
(report/testcase by "puppet-meteor").
+ use a more conservative estimate of the buffer-size in lib_tparm.c's
save_text() and save_number(), in case the sprintf() function
passes-through unexpected characters from a format specifier
(report/testcase by "puppet-meteor").
+ add a check for end-of-string in cvtchar to handle a malformed
string in infotocap (report/testcase by "puppet-meteor"). |
virNodeDeviceCapSCSIDefFormat(virBufferPtr buf,
const virNodeDevCapData *data)
{
virBufferAsprintf(buf, "<host>%d</host>\n", data->scsi.host);
virBufferAsprintf(buf, "<bus>%d</bus>\n", data->scsi.bus);
virBufferAsprintf(buf, "<target>%d</target>\n",
data->scsi.target);
virBufferAsprintf(buf, "<lun>%d</lun>\n", data->scsi.lun);
if (data->scsi.type)
virBufferEscapeString(buf, "<type>%s</type>\n",
data->scsi.type);
} | 0 | [
"CWE-119"
] | libvirt | 4c4d0e2da07b5a035b26a0ff13ec27070f7c7b1a | 162,604,784,477,687,630,000,000,000,000,000,000,000 | 12 | conf: Fix segfault when parsing mdev types
Commit f1b0890 introduced a potential crash due to incorrect operator
precedence when accessing an element from a pointer to an array.
Backtrace below:
#0 virNodeDeviceGetMdevTypesCaps (sysfspath=0x7fff801661e0 "/sys/devices/pci0000:00/0000:00:02.0", mdev_types=0x7fff801c9b40, nmdev_types=0x7fff801c9b48) at ../src/conf/node_device_conf.c:2676
#1 0x00007ffff7caf53d in virNodeDeviceGetPCIDynamicCaps (sysfsPath=0x7fff801661e0 "/sys/devices/pci0000:00/0000:00:02.0", pci_dev=0x7fff801c9ac8) at ../src/conf/node_device_conf.c:2705
#2 0x00007ffff7cae38f in virNodeDeviceUpdateCaps (def=0x7fff80168a10) at ../src/conf/node_device_conf.c:2342
#3 0x00007ffff7cb11c0 in virNodeDeviceObjMatch (obj=0x7fff84002e50, flags=0) at ../src/conf/virnodedeviceobj.c:850
#4 0x00007ffff7cb153d in virNodeDeviceObjListExportCallback (payload=0x7fff84002e50, name=0x7fff801cbc20 "pci_0000_00_02_0", opaque=0x7fffe2ffc6a0) at ../src/conf/virnodedeviceobj.c:909
#5 0x00007ffff7b69146 in virHashForEach (table=0x7fff9814b700 = {...}, iter=0x7ffff7cb149e <virNodeDeviceObjListExportCallback>, opaque=0x7fffe2ffc6a0) at ../src/util/virhash.c:394
#6 0x00007ffff7cb1694 in virNodeDeviceObjListExport (conn=0x7fff98013170, devs=0x7fff98154430, devices=0x7fffe2ffc798, filter=0x7ffff7cf47a1 <virConnectListAllNodeDevicesCheckACL>, flags=0)
at ../src/conf/virnodedeviceobj.c:943
#7 0x00007fffe00694b2 in nodeConnectListAllNodeDevices (conn=0x7fff98013170, devices=0x7fffe2ffc798, flags=0) at ../src/node_device/node_device_driver.c:228
#8 0x00007ffff7e703aa in virConnectListAllNodeDevices (conn=0x7fff98013170, devices=0x7fffe2ffc798, flags=0) at ../src/libvirt-nodedev.c:130
#9 0x000055555557f796 in remoteDispatchConnectListAllNodeDevices (server=0x555555627080, client=0x5555556bf050, msg=0x5555556c0000, rerr=0x7fffe2ffc8a0, args=0x7fffd4008470, ret=0x7fffd40084e0)
at src/remote/remote_daemon_dispatch_stubs.h:1613
#10 0x000055555557f6f9 in remoteDispatchConnectListAllNodeDevicesHelper (server=0x555555627080, client=0x5555556bf050, msg=0x5555556c0000, rerr=0x7fffe2ffc8a0, args=0x7fffd4008470, ret=0x7fffd40084e0)
at src/remote/remote_daemon_dispatch_stubs.h:1591
#11 0x00007ffff7ce9542 in virNetServerProgramDispatchCall (prog=0x555555690c10, server=0x555555627080, client=0x5555556bf050, msg=0x5555556c0000) at ../src/rpc/virnetserverprogram.c:428
#12 0x00007ffff7ce90bd in virNetServerProgramDispatch (prog=0x555555690c10, server=0x555555627080, client=0x5555556bf050, msg=0x5555556c0000) at ../src/rpc/virnetserverprogram.c:302
#13 0x00007ffff7cf042b in virNetServerProcessMsg (srv=0x555555627080, client=0x5555556bf050, prog=0x555555690c10, msg=0x5555556c0000) at ../src/rpc/virnetserver.c:137
#14 0x00007ffff7cf04eb in virNetServerHandleJob (jobOpaque=0x5555556b66b0, opaque=0x555555627080) at ../src/rpc/virnetserver.c:154
#15 0x00007ffff7bd912f in virThreadPoolWorker (opaque=0x55555562bc70) at ../src/util/virthreadpool.c:163
#16 0x00007ffff7bd8645 in virThreadHelper (data=0x55555562bc90) at ../src/util/virthread.c:233
#17 0x00007ffff6d90432 in start_thread () at /lib64/libpthread.so.0
#18 0x00007ffff75c5913 in clone () at /lib64/libc.so.6
Signed-off-by: Jonathon Jongsma <[email protected]>
Reviewed-by: Ján Tomko <[email protected]>
Signed-off-by: Ján Tomko <[email protected]> |
void handler::ha_release_auto_increment()
{
DBUG_ENTER("ha_release_auto_increment");
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK ||
(!next_insert_id && !insert_id_for_cur_row));
release_auto_increment();
insert_id_for_cur_row= 0;
auto_inc_interval_for_cur_row.replace(0, 0, 0);
auto_inc_intervals_count= 0;
if (next_insert_id > 0)
{
next_insert_id= 0;
/*
this statement used forced auto_increment values if there were some,
wipe them away for other statements.
*/
table->in_use->auto_inc_intervals_forced.empty();
}
DBUG_VOID_RETURN;
} | 0 | [
"CWE-416"
] | server | af810407f78b7f792a9bb8c47c8c532eb3b3a758 | 25,080,681,977,565,336,000,000,000,000,000,000,000 | 21 | 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 double mp_complex_conj(_cimg_math_parser& mp) {
const double real = _mp_arg(2), imag = _mp_arg(3);
double *ptrd = &_mp_arg(1) + 1;
ptrd[0] = real;
ptrd[1] = -imag;
return cimg::type<double>::nan();
} | 0 | [
"CWE-770"
] | cimg | 619cb58dd90b4e03ac68286c70ed98acbefd1c90 | 214,368,592,413,833,600,000,000,000,000,000,000,000 | 7 | CImg<>::load_bmp() and CImg<>::load_pandore(): Check that dimensions encoded in file does not exceed file size. |
inline void Slice(const tflite::SliceParams& op_params,
const RuntimeShape& input_shape, const T* input_data,
const RuntimeShape& output_shape, T* output_data) {
SequentialTensorWriter<T> writer(input_data, output_data);
return Slice(op_params, input_shape, output_shape, &writer);
} | 0 | [
"CWE-476",
"CWE-369"
] | tensorflow | 15691e456c7dc9bd6be203b09765b063bf4a380c | 330,470,015,524,464,970,000,000,000,000,000,000,000 | 6 | Prevent dereferencing of null pointers in TFLite's `add.cc`.
PiperOrigin-RevId: 387244946
Change-Id: I56094233327fbd8439b92e1dbb1262176e00eeb9 |
static int r_bin_dwarf_init_die(RBinDwarfDIE *die) {
if (!die) {
return -EINVAL;
}
die->attr_values = calloc (sizeof (RBinDwarfAttrValue), 8);
if (!die->attr_values) {
return -ENOMEM;
}
die->capacity = 8;
die->length = 0;
return 0;
} | 0 | [
"CWE-119",
"CWE-125"
] | radare2 | d37d2b858ac47f2f108034be0bcecadaddfbc8b3 | 20,370,446,414,565,339,000,000,000,000,000,000,000 | 12 | Fix #10465 - Avoid string on low addresses (workaround) for corrupted dwarf (#10478) |
template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
inline void swap(T1& a1, T1& b1, T2& a2, T2& b2, T3& a3, T3& b3, T4& a4, T4& b4, T5& a5, T5& b5, T6& a6, T6& b6,
T7& a7, T7& b7) {
cimg::swap(a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,a6,b6); cimg::swap(a7,b7); | 0 | [
"CWE-125"
] | CImg | 10af1e8c1ad2a58a0a3342a856bae63e8f257abb | 340,202,050,820,771,740,000,000,000,000,000,000,000 | 4 | Fix other issues in 'CImg<T>::load_bmp()'. |
rpmsg_sg_init(struct scatterlist *sg, void *cpu_addr, unsigned int len)
{
if (is_vmalloc_addr(cpu_addr)) {
sg_init_table(sg, 1);
sg_set_page(sg, vmalloc_to_page(cpu_addr), len,
offset_in_page(cpu_addr));
} else {
WARN_ON(!virt_addr_valid(cpu_addr));
sg_init_one(sg, cpu_addr, len);
}
} | 0 | [
"CWE-415"
] | linux | 1680939e9ecf7764fba8689cfb3429c2fe2bb23c | 236,814,153,133,131,320,000,000,000,000,000,000,000 | 11 | rpmsg: virtio: Fix possible double free in rpmsg_virtio_add_ctrl_dev()
vch will be free in virtio_rpmsg_release_device() when
rpmsg_ctrldev_register_device() fails. There is no need to call
kfree() again.
Fixes: c486682ae1e2 ("rpmsg: virtio: Register the rpmsg_char device")
Signed-off-by: Hangyu Hua <[email protected]>
Tested-by: Arnaud Pouliquen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mathieu Poirier <[email protected]> |
static int svm_hardware_enable(void *garbage)
{
struct svm_cpu_data *sd;
uint64_t efer;
struct desc_ptr gdt_descr;
struct desc_struct *gdt;
int me = raw_smp_processor_id();
rdmsrl(MSR_EFER, efer);
if (efer & EFER_SVME)
return -EBUSY;
if (!has_svm()) {
printk(KERN_ERR "svm_hardware_enable: err EOPNOTSUPP on %d\n",
me);
return -EINVAL;
}
sd = per_cpu(svm_data, me);
if (!sd) {
printk(KERN_ERR "svm_hardware_enable: svm_data is NULL on %d\n",
me);
return -EINVAL;
}
sd->asid_generation = 1;
sd->max_asid = cpuid_ebx(SVM_CPUID_FUNC) - 1;
sd->next_asid = sd->max_asid + 1;
native_store_gdt(&gdt_descr);
gdt = (struct desc_struct *)gdt_descr.address;
sd->tss_desc = (struct kvm_ldttss_desc *)(gdt + GDT_ENTRY_TSS);
wrmsrl(MSR_EFER, efer | EFER_SVME);
wrmsrl(MSR_VM_HSAVE_PA, page_to_pfn(sd->save_area) << PAGE_SHIFT);
svm_init_erratum_383();
return 0;
} | 0 | [
"CWE-400"
] | linux-2.6 | 9581d442b9058d3699b4be568b6e5eae38a41493 | 21,733,307,716,095,124,000,000,000,000,000,000,000 | 42 | KVM: Fix fs/gs reload oops with invalid ldt
kvm reloads the host's fs and gs blindly, however the underlying segment
descriptors may be invalid due to the user modifying the ldt after loading
them.
Fix by using the safe accessors (loadsegment() and load_gs_index()) instead
of home grown unsafe versions.
This is CVE-2010-3698.
KVM-Stable-Tag.
Signed-off-by: Avi Kivity <[email protected]>
Signed-off-by: Marcelo Tosatti <[email protected]> |
void change_file_owner_to_parent(connection_struct *conn,
const char *inherit_from_dir,
files_struct *fsp)
{
struct smb_filename *smb_fname_parent;
int ret;
smb_fname_parent = synthetic_smb_fname(talloc_tos(),
inherit_from_dir,
NULL,
NULL,
0);
if (smb_fname_parent == NULL) {
return;
}
ret = SMB_VFS_STAT(conn, smb_fname_parent);
if (ret == -1) {
DEBUG(0,("change_file_owner_to_parent: failed to stat parent "
"directory %s. Error was %s\n",
smb_fname_str_dbg(smb_fname_parent),
strerror(errno)));
TALLOC_FREE(smb_fname_parent);
return;
}
if (smb_fname_parent->st.st_ex_uid == fsp->fsp_name->st.st_ex_uid) {
/* Already this uid - no need to change. */
DEBUG(10,("change_file_owner_to_parent: file %s "
"is already owned by uid %d\n",
fsp_str_dbg(fsp),
(int)fsp->fsp_name->st.st_ex_uid ));
TALLOC_FREE(smb_fname_parent);
return;
}
become_root();
ret = SMB_VFS_FCHOWN(fsp, smb_fname_parent->st.st_ex_uid, (gid_t)-1);
unbecome_root();
if (ret == -1) {
DEBUG(0,("change_file_owner_to_parent: failed to fchown "
"file %s to parent directory uid %u. Error "
"was %s\n", fsp_str_dbg(fsp),
(unsigned int)smb_fname_parent->st.st_ex_uid,
strerror(errno) ));
} else {
DEBUG(10,("change_file_owner_to_parent: changed new file %s to "
"parent directory uid %u.\n", fsp_str_dbg(fsp),
(unsigned int)smb_fname_parent->st.st_ex_uid));
/* Ensure the uid entry is updated. */
fsp->fsp_name->st.st_ex_uid = smb_fname_parent->st.st_ex_uid;
}
TALLOC_FREE(smb_fname_parent);
} | 0 | [
"CWE-835"
] | samba | 10c3e3923022485c720f322ca4f0aca5d7501310 | 311,949,792,876,273,660,000,000,000,000,000,000,000 | 55 | s3: smbd: Don't loop infinitely on bad-symlink resolution.
In the FILE_OPEN_IF case we have O_CREAT, but not
O_EXCL. Previously we went into a loop trying first
~(O_CREAT|O_EXCL), and if that returned ENOENT
try (O_CREAT|O_EXCL). We kept looping indefinately
until we got an error, or the file was created or
opened.
The big problem here is dangling symlinks. Opening
without O_NOFOLLOW means both bad symlink
and missing path return -1, ENOENT from open(). As POSIX
is pathname based it's not possible to tell
the difference between these two cases in a
non-racy way, so change to try only two attempts before
giving up.
We don't have this problem for the O_NOFOLLOW
case as we just return NT_STATUS_OBJECT_PATH_NOT_FOUND
mapped from the ELOOP POSIX error and immediately
returned.
Unroll the loop logic to two tries instead.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12572
Pair-programmed-with: Ralph Boehme <[email protected]>
Signed-off-by: Jeremy Allison <[email protected]>
Signed-off-by: Ralph Boehme <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]> |
static int kvm_ioctl_create_device(struct kvm *kvm,
struct kvm_create_device *cd)
{
struct kvm_device_ops *ops = NULL;
struct kvm_device *dev;
bool test = cd->flags & KVM_CREATE_DEVICE_TEST;
int ret;
if (cd->type >= ARRAY_SIZE(kvm_device_ops_table))
return -ENODEV;
ops = kvm_device_ops_table[cd->type];
if (ops == NULL)
return -ENODEV;
if (test)
return 0;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev)
return -ENOMEM;
dev->ops = ops;
dev->kvm = kvm;
mutex_lock(&kvm->lock);
ret = ops->create(dev, cd->type);
if (ret < 0) {
mutex_unlock(&kvm->lock);
kfree(dev);
return ret;
}
list_add(&dev->vm_node, &kvm->devices);
mutex_unlock(&kvm->lock);
if (ops->init)
ops->init(dev);
ret = anon_inode_getfd(ops->name, &kvm_device_fops, dev, O_RDWR | O_CLOEXEC);
if (ret < 0) {
mutex_lock(&kvm->lock);
list_del(&dev->vm_node);
mutex_unlock(&kvm->lock);
ops->destroy(dev);
return ret;
}
kvm_get_kvm(kvm);
cd->fd = ret;
return 0;
} | 1 | [
"CWE-416",
"CWE-362"
] | linux | cfa39381173d5f969daf43582c95ad679189cbc9 | 213,282,364,006,884,100,000,000,000,000,000,000,000 | 51 | kvm: fix kvm_ioctl_create_device() reference counting (CVE-2019-6974)
kvm_ioctl_create_device() does the following:
1. creates a device that holds a reference to the VM object (with a borrowed
reference, the VM's refcount has not been bumped yet)
2. initializes the device
3. transfers the reference to the device to the caller's file descriptor table
4. calls kvm_get_kvm() to turn the borrowed reference to the VM into a real
reference
The ownership transfer in step 3 must not happen before the reference to the VM
becomes a proper, non-borrowed reference, which only happens in step 4.
After step 3, an attacker can close the file descriptor and drop the borrowed
reference, which can cause the refcount of the kvm object to drop to zero.
This means that we need to grab a reference for the device before
anon_inode_getfd(), otherwise the VM can disappear from under us.
Fixes: 852b6d57dc7f ("kvm: add device control API")
Cc: [email protected]
Signed-off-by: Jann Horn <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]> |
static int ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
{
zend_op *opline = EX(opline);
zend_free_op free_op1, free_op2;
zval **container = _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
zval *offset = _get_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC);
if (IS_VAR != IS_VAR || container) {
if (IS_VAR == IS_CV && container != &EG(uninitialized_zval_ptr)) {
SEPARATE_ZVAL_IF_NOT_REF(container);
}
switch (Z_TYPE_PP(container)) {
case IS_ARRAY: {
HashTable *ht = Z_ARRVAL_PP(container);
switch (Z_TYPE_P(offset)) {
case IS_DOUBLE:
zend_hash_index_del(ht, zend_dval_to_lval(Z_DVAL_P(offset)));
break;
case IS_RESOURCE:
case IS_BOOL:
case IS_LONG:
zend_hash_index_del(ht, Z_LVAL_P(offset));
break;
case IS_STRING:
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
Z_ADDREF_P(offset);
}
if (zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1) == SUCCESS &&
ht == &EG(symbol_table)) {
zend_execute_data *ex;
ulong hash_value = zend_inline_hash_func(offset->value.str.val, offset->value.str.len+1);
for (ex = execute_data; ex; ex = ex->prev_execute_data) {
if (ex->op_array && ex->symbol_table == ht) {
int i;
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset->value.str.len &&
!memcmp(ex->op_array->vars[i].name, offset->value.str.val, offset->value.str.len)) {
ex->CVs[i] = NULL;
break;
}
}
}
}
}
if (IS_VAR == IS_CV || IS_VAR == IS_VAR) {
zval_ptr_dtor(&offset);
}
break;
case IS_NULL:
zend_hash_del(ht, "", sizeof(""));
break;
default:
zend_error(E_WARNING, "Illegal offset type in unset");
break;
}
if (free_op2.var) {zval_ptr_dtor(&free_op2.var);};
break;
}
case IS_OBJECT:
if (!Z_OBJ_HT_P(*container)->unset_dimension) {
zend_error_noreturn(E_ERROR, "Cannot use object as array");
}
if (0) {
MAKE_REAL_ZVAL_PTR(offset);
}
Z_OBJ_HT_P(*container)->unset_dimension(*container, offset TSRMLS_CC);
if (0) {
zval_ptr_dtor(&offset);
} else {
if (free_op2.var) {zval_ptr_dtor(&free_op2.var);};
}
break;
case IS_STRING:
zend_error_noreturn(E_ERROR, "Cannot unset string offsets");
ZEND_VM_CONTINUE(); /* bailed out before */
default:
if (free_op2.var) {zval_ptr_dtor(&free_op2.var);};
break;
}
} else {
if (free_op2.var) {zval_ptr_dtor(&free_op2.var);};
}
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
ZEND_VM_NEXT_OPCODE();
} | 0 | [] | php-src | ce96fd6b0761d98353761bf78d5bfb55291179fd | 282,486,573,066,273,870,000,000,000,000,000,000,000 | 90 | - 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 |
check_cedit(void)
{
int n;
if (*p_cedit == NUL)
cedit_key = -1;
else
{
n = string_to_key(p_cedit, FALSE);
if (vim_isprintc(n))
return e_invalid_argument;
cedit_key = n;
}
return NULL;
} | 0 | [
"CWE-122",
"CWE-787"
] | vim | 85b6747abc15a7a81086db31289cf1b8b17e6cb1 | 209,833,978,907,603,900,000,000,000,000,000,000,000 | 15 | patch 8.2.4214: illegal memory access with large 'tabstop' in Ex mode
Problem: Illegal memory access with large 'tabstop' in Ex mode.
Solution: Allocate enough memory. |
dfaoptimize (struct dfa *d)
{
size_t i;
if (!MBS_SUPPORT || !using_utf8())
return;
for (i = 0; i < d->tindex; ++i)
{
switch(d->tokens[i])
{
case ANYCHAR:
/* Lowered. */
abort ();
case MBCSET:
/* Requires multi-byte algorithm. */
return;
default:
break;
}
}
free_mbdata (d);
d->mb_cur_max = 1;
} | 0 | [
"CWE-189"
] | grep | cbbc1a45b9f843c811905c97c90a5d31f8e6c189 | 145,143,775,329,670,500,000,000,000,000,000,000,000 | 25 | grep: fix some core dumps with long lines etc.
These problems mostly occur because the code attempts to stuff
sizes into int or into unsigned int; this doesn't work on most
64-bit hosts and the errors can lead to core dumps.
* NEWS: Document this.
* src/dfa.c (token): Typedef to ptrdiff_t, since the enum's
range could be as small as -128 .. 127 on practical hosts.
(position.index): Now size_t, not unsigned int.
(leaf_set.elems): Now size_t *, not unsigned int *.
(dfa_state.hash, struct mb_char_classes.nchars, .nch_classes)
(.nranges, .nequivs, .ncoll_elems, struct dfa.cindex, .calloc, .tindex)
(.talloc, .depth, .nleaves, .nregexps, .nmultibyte_prop, .nmbcsets):
(.mbcsets_alloc): Now size_t, not int.
(dfa_state.first_end): Now token, not int.
(state_num): New type.
(struct mb_char_classes.cset): Now ptrdiff_t, not int.
(struct dfa.utf8_anychar_classes): Now token[5], not int[5].
(struct dfa.sindex, .salloc, .tralloc): Now state_num, not int.
(struct dfa.trans, .realtrans, .fails): Now state_num **, not int **.
(struct dfa.newlines): Now state_num *, not int *.
(prtok): Don't assume 'token' is no wider than int.
(lexleft, parens, depth): Now size_t, not int.
(charclass_index, nsubtoks)
(parse_bracket_exp, addtok, copytoks, closure, insert, merge, delete)
(state_index, epsclosure, state_separate_contexts)
(dfaanalyze, dfastate, build_state, realloc_trans_if_necessary)
(transit_state_singlebyte, match_anychar, match_mb_charset)
(check_matching_with_multibyte_ops, transit_state_consume_1char)
(transit_state, dfaexec, free_mbdata, dfaoptimize, dfafree)
(freelist, enlist, addlists, inboth, dfamust):
Don't assume indexes fit in 'int'.
(lex): Avoid overflow in string-to-{hi,lo} conversions.
(dfaanalyze): Redo indexing so that it works with size_t values,
which cannot go negative.
* src/dfa.h (dfaexec): Count argument is now size_t *, not int *.
(dfastate): State numbers are now ptrdiff_t, not int.
* src/dfasearch.c: Include "intprops.h", for TYPE_MAXIMUM.
(kwset_exact_matches): Now size_t, not int.
(EGexecute): Don't assume indexes fit in 'int'.
Check for overflow before converting a ptrdiff_t to a regoff_t,
as regoff_t is narrower than ptrdiff_t in 64-bit glibc (contra POSIX).
Check for memory exhaustion in re_search rather than treating
it merely as failure to match; use xalloc_die () to report any error.
* src/kwset.c (struct trie.accepting): Now size_t, not unsigned int.
(struct kwset.words): Now ptrdiff_t, not int.
* src/kwset.h (struct kwsmatch.index): Now size_t, not int. |
UINT rdpgfx_read_point16(wStream* s, RDPGFX_POINT16* pt16)
{
if (Stream_GetRemainingLength(s) < 4)
{
WLog_ERR(TAG, "not enough data!");
return ERROR_INVALID_DATA;
}
Stream_Read_UINT16(s, pt16->x); /* x (2 bytes) */
Stream_Read_UINT16(s, pt16->y); /* y (2 bytes) */
return CHANNEL_RC_OK;
} | 0 | [
"CWE-190"
] | FreeRDP | 40393700642ad38437982e8a3afc34ff33ccf28e | 140,340,059,713,873,570,000,000,000,000,000,000,000 | 12 | Fixed input sanitation in rdpgfx_recv_solid_fill_pdu
The input rectangle must be checked for plausibility.
Thanks to Sunglin and HuanGMz of the Knownsec 404 security team and pangzi of pwnzen |
hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags)
{
struct hstate *h = hstate_file(file);
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
unsigned long task_size = TASK_SIZE;
if (test_thread_flag(TIF_32BIT))
task_size = STACK_TOP32;
if (len & ~huge_page_mask(h))
return -EINVAL;
if (len > task_size)
return -ENOMEM;
if (flags & MAP_FIXED) {
if (prepare_hugepage_range(file, addr, len))
return -EINVAL;
return addr;
}
if (addr) {
addr = ALIGN(addr, huge_page_size(h));
vma = find_vma(mm, addr);
if (task_size - len >= addr &&
(!vma || addr + len <= vma->vm_start))
return addr;
}
if (mm->get_unmapped_area == arch_get_unmapped_area)
return hugetlb_get_unmapped_area_bottomup(file, addr, len,
pgoff, flags);
else
return hugetlb_get_unmapped_area_topdown(file, addr, len,
pgoff, flags);
} | 1 | [
"CWE-119"
] | linux | 1be7107fbe18eed3e319a6c3e83c78254b693acb | 329,330,308,593,772,580,000,000,000,000,000,000,000 | 36 | 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]> |
date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
{
VALUE str, sg;
rb_scan_args(argc, argv, "02", &str, &sg);
switch (argc) {
case 0:
str = rb_str_new2("-4712-01-01");
case 1:
sg = INT2FIX(DEFAULT_SG);
}
{
VALUE hash = date_s__xmlschema(klass, str);
return d_new_by_frags(klass, hash, sg);
}
} | 1 | [] | date | 3959accef8da5c128f8a8e2fd54e932a4fb253b0 | 115,890,751,631,592,720,000,000,000,000,000,000,000 | 18 | Add length limit option for methods that parses date strings
`Date.parse` now raises an ArgumentError when a given date string is
longer than 128. You can configure the limit by giving `limit` keyword
arguments like `Date.parse(str, limit: 1000)`. If you pass `limit: nil`,
the limit is disabled.
Not only `Date.parse` but also the following methods are changed.
* Date._parse
* Date.parse
* DateTime.parse
* Date._iso8601
* Date.iso8601
* DateTime.iso8601
* Date._rfc3339
* Date.rfc3339
* DateTime.rfc3339
* Date._xmlschema
* Date.xmlschema
* DateTime.xmlschema
* Date._rfc2822
* Date.rfc2822
* DateTime.rfc2822
* Date._rfc822
* Date.rfc822
* DateTime.rfc822
* Date._jisx0301
* Date.jisx0301
* DateTime.jisx0301 |
AP_DECLARE(int) ap_update_child_status_from_server(ap_sb_handle_t *sbh, int status,
conn_rec *c, server_rec *s)
{
if (!sbh || (sbh->child_num < 0))
return -1;
return update_child_status_internal(sbh->child_num, sbh->thread_num,
status, c, s, NULL, NULL);
} | 0 | [
"CWE-476"
] | httpd | fa7b2a5250e54363b3a6c8ac3aaa7de4e8da9b2e | 133,909,992,576,688,870,000,000,000,000,000,000,000 | 9 | Merge r1878092 from trunk:
Fix a NULL pointer dereference
* server/scoreboard.c (ap_increment_counts): In certain cases like certain
invalid requests r->method might be NULL here. r->method_number defaults
to M_GET and hence is M_GET in these cases.
Submitted by: rpluem
Reviewed by: covener, ylavic, jfclere
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1893051 13f79535-47bb-0310-9956-ffa450edef68 |
static void epsf_gencode(GVJ_t * job, node_t * n)
{
obj_state_t *obj = job->obj;
epsf_t *desc;
int doMap = (obj->url || obj->explicit_tooltip);
desc = (epsf_t *) (ND_shape_info(n));
if (!desc)
return;
if (doMap && !(job->flags & EMIT_CLUSTERS_LAST))
gvrender_begin_anchor(job,
obj->url, obj->tooltip, obj->target,
obj->id);
if (desc)
fprintf(job->output_file,
"%.5g %.5g translate newpath user_shape_%d\n",
ND_coord(n).x + desc->offset.x,
ND_coord(n).y + desc->offset.y, desc->macro_id);
ND_label(n)->pos = ND_coord(n);
emit_label(job, EMIT_NLABEL, ND_label(n));
if (doMap) {
if (job->flags & EMIT_CLUSTERS_LAST)
gvrender_begin_anchor(job,
obj->url, obj->tooltip, obj->target,
obj->id);
gvrender_end_anchor(job);
}
} | 0 | [
"CWE-120"
] | graphviz | 784411ca3655c80da0f6025ab20634b2a6ff696b | 164,135,295,299,288,100,000,000,000,000,000,000,000 | 30 | fix: out-of-bounds write on invalid label
When the label for a node cannot be parsed (due to it being malformed), it falls
back on the symbol name of the node itself. I.e. the default label the node
would have had if it had no label attribute at all. However, this is applied by
dynamically altering the node's label to "\N", a shortcut for the symbol name of
the node. All of this is fine, however if the hand written label itself is
shorter than the literal string "\N", not enough memory would have been
allocated to write "\N" into the label text.
Here we account for the possibility of error during label parsing, and assume
that the label text may need to be overwritten with "\N" after the fact. Fixes
issue #1700. |
void gfs2_quota_cleanup(struct gfs2_sbd *sdp)
{
struct list_head *head = &sdp->sd_quota_list;
struct gfs2_quota_data *qd;
unsigned int x;
spin_lock(&qd_lru_lock);
while (!list_empty(head)) {
qd = list_entry(head->prev, struct gfs2_quota_data, qd_list);
if (atomic_read(&qd->qd_count) > 1 ||
(atomic_read(&qd->qd_count) &&
!test_bit(QDF_CHANGE, &qd->qd_flags))) {
list_move(&qd->qd_list, head);
spin_unlock(&qd_lru_lock);
schedule();
spin_lock(&qd_lru_lock);
continue;
}
list_del(&qd->qd_list);
/* Also remove if this qd exists in the reclaim list */
if (!list_empty(&qd->qd_reclaim)) {
list_del_init(&qd->qd_reclaim);
atomic_dec(&qd_lru_count);
}
atomic_dec(&sdp->sd_quota_count);
spin_unlock(&qd_lru_lock);
if (!atomic_read(&qd->qd_count)) {
gfs2_assert_warn(sdp, !qd->qd_change);
gfs2_assert_warn(sdp, !qd->qd_slot_count);
} else
gfs2_assert_warn(sdp, qd->qd_slot_count == 1);
gfs2_assert_warn(sdp, !qd->qd_bh_count);
gfs2_glock_put(qd->qd_gl);
kmem_cache_free(gfs2_quotad_cachep, qd);
spin_lock(&qd_lru_lock);
}
spin_unlock(&qd_lru_lock);
gfs2_assert_warn(sdp, !atomic_read(&sdp->sd_quota_count));
if (sdp->sd_quota_bitmap) {
for (x = 0; x < sdp->sd_quota_chunks; x++)
kfree(sdp->sd_quota_bitmap[x]);
kfree(sdp->sd_quota_bitmap);
}
} | 0 | [
"CWE-399"
] | linux-2.6 | 7e619bc3e6252dc746f64ac3b486e784822e9533 | 16,651,190,888,038,492,000,000,000,000,000,000,000 | 51 | GFS2: Fix writing to non-page aligned gfs2_quota structures
This is the upstream fix for this bug. This patch differs
from the RHEL5 fix (Red Hat bz #555754) which simply writes to the 8-byte
value field of the quota. In upstream quota code, we're
required to write the entire quota (88 bytes) which can be split
across a page boundary. We check for such quotas, and read/write
the two parts from/to the corresponding pages holding these parts.
With this patch, I don't see the bug anymore using the reproducer
in Red Hat bz 555754. I successfully ran a couple of simple tests/mounts/
umounts and it doesn't seem like this patch breaks anything else.
Signed-off-by: Abhi Das <[email protected]>
Signed-off-by: Steven Whitehouse <[email protected]> |
static uint16_t nvme_get_feature_timestamp(NvmeCtrl *n, NvmeRequest *req)
{
uint64_t timestamp = nvme_get_timestamp(n);
return nvme_c2h(n, (uint8_t *)×tamp, sizeof(timestamp), req);
} | 0 | [] | qemu | 736b01642d85be832385063f278fe7cd4ffb5221 | 170,894,446,092,025,440,000,000,000,000,000,000,000 | 6 | hw/nvme: fix CVE-2021-3929
This fixes CVE-2021-3929 "locally" by denying DMA to the iomem of the
device itself. This still allows DMA to MMIO regions of other devices
(e.g. doing P2P DMA to the controller memory buffer of another NVMe
device).
Fixes: CVE-2021-3929
Reported-by: Qiuhao Li <[email protected]>
Reviewed-by: Keith Busch <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Klaus Jensen <[email protected]> |
void do_write_file(struct st_command *command)
{
do_write_file_command(command, FALSE);
} | 0 | [
"CWE-284",
"CWE-295"
] | mysql-server | 3bd5589e1a5a93f9c224badf983cd65c45215390 | 59,545,940,779,632,300,000,000,000,000,000,000,000 | 4 | 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 |
router_get_runningrouters_hash(const char *s, char *digest)
{
return router_get_hash_impl(s, strlen(s), digest,
"network-status","\ndirectory-signature", '\n',
DIGEST_SHA1);
} | 0 | [
"CWE-399"
] | tor | 57e35ad3d91724882c345ac709666a551a977f0f | 309,244,801,409,716,350,000,000,000,000,000,000,000 | 6 | Avoid possible segfault when handling networkstatus vote with bad flavor
Fix for 6530; fix on 0.2.2.6-alpha. |
void vp7_decode_mvs(VP8Context *s, VP8Macroblock *mb,
int mb_x, int mb_y, int layout)
{
VP8Macroblock *mb_edge[12];
enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR };
enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
int idx = CNT_ZERO;
VP56mv near_mv[3];
uint8_t cnt[3] = { 0 };
VP56RangeCoder *c = &s->c;
int i;
AV_ZERO32(&near_mv[0]);
AV_ZERO32(&near_mv[1]);
AV_ZERO32(&near_mv[2]);
for (i = 0; i < VP7_MV_PRED_COUNT; i++) {
const VP7MVPred * pred = &vp7_mv_pred[i];
int edge_x, edge_y;
if (vp7_calculate_mb_offset(mb_x, mb_y, s->mb_width, pred->xoffset,
pred->yoffset, !s->profile, &edge_x, &edge_y)) {
VP8Macroblock *edge = mb_edge[i] = (s->mb_layout == 1)
? s->macroblocks_base + 1 + edge_x +
(s->mb_width + 1) * (edge_y + 1)
: s->macroblocks + edge_x +
(s->mb_height - edge_y - 1) * 2;
uint32_t mv = AV_RN32A(get_bmv_ptr(edge, vp7_mv_pred[i].subblock));
if (mv) {
if (AV_RN32A(&near_mv[CNT_NEAREST])) {
if (mv == AV_RN32A(&near_mv[CNT_NEAREST])) {
idx = CNT_NEAREST;
} else if (AV_RN32A(&near_mv[CNT_NEAR])) {
if (mv != AV_RN32A(&near_mv[CNT_NEAR]))
continue;
idx = CNT_NEAR;
} else {
AV_WN32A(&near_mv[CNT_NEAR], mv);
idx = CNT_NEAR;
}
} else {
AV_WN32A(&near_mv[CNT_NEAREST], mv);
idx = CNT_NEAREST;
}
} else {
idx = CNT_ZERO;
}
} else {
idx = CNT_ZERO;
}
cnt[idx] += vp7_mv_pred[i].score;
}
mb->partitioning = VP8_SPLITMVMODE_NONE;
if (vp56_rac_get_prob_branchy(c, vp7_mode_contexts[cnt[CNT_ZERO]][0])) {
mb->mode = VP8_MVMODE_MV;
if (vp56_rac_get_prob_branchy(c, vp7_mode_contexts[cnt[CNT_NEAREST]][1])) {
if (vp56_rac_get_prob_branchy(c, vp7_mode_contexts[cnt[CNT_NEAR]][2])) {
if (cnt[CNT_NEAREST] > cnt[CNT_NEAR])
AV_WN32A(&mb->mv, cnt[CNT_ZERO] > cnt[CNT_NEAREST] ? 0 : AV_RN32A(&near_mv[CNT_NEAREST]));
else
AV_WN32A(&mb->mv, cnt[CNT_ZERO] > cnt[CNT_NEAR] ? 0 : AV_RN32A(&near_mv[CNT_NEAR]));
if (vp56_rac_get_prob_branchy(c, vp7_mode_contexts[cnt[CNT_NEAR]][3])) {
mb->mode = VP8_MVMODE_SPLIT;
mb->mv = mb->bmv[decode_splitmvs(s, c, mb, layout, IS_VP7) - 1];
} else {
mb->mv.y += vp7_read_mv_component(c, s->prob->mvc[0]);
mb->mv.x += vp7_read_mv_component(c, s->prob->mvc[1]);
mb->bmv[0] = mb->mv;
}
} else {
mb->mv = near_mv[CNT_NEAR];
mb->bmv[0] = mb->mv;
}
} else {
mb->mv = near_mv[CNT_NEAREST];
mb->bmv[0] = mb->mv;
}
} else {
mb->mode = VP8_MVMODE_ZERO;
AV_ZERO32(&mb->mv);
mb->bmv[0] = mb->mv;
}
} | 0 | [
"CWE-119",
"CWE-787"
] | FFmpeg | 6b5d3fb26fb4be48e4966e4b1d97c2165538d4ef | 256,445,019,649,412,350,000,000,000,000,000,000,000 | 89 | avcodec/webp: Always set pix_fmt
Fixes: out of array access
Fixes: 1434/clusterfuzz-testcase-minimized-6314998085189632
Fixes: 1435/clusterfuzz-testcase-minimized-6483783723253760
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Reviewed-by: "Ronald S. Bultje" <[email protected]>
Signed-off-by: Michael Niedermayer <[email protected]> |
void CLASS foveon_dp_load_raw()
{
#ifdef LIBRAW_LIBRARY_BUILD
if(!image)
throw LIBRAW_EXCEPTION_IO_CORRUPT;
#endif
unsigned c, roff[4], row, col, diff;
ushort huff[512], vpred[2][2], hpred[2];
fseek (ifp, 8, SEEK_CUR);
foveon_huff (huff);
roff[0] = 48;
FORC3 roff[c+1] = -(-(roff[c] + get4()) & -16);
FORC3 {
fseek (ifp, data_offset+roff[c], SEEK_SET);
getbits(-1);
vpred[0][0] = vpred[0][1] = vpred[1][0] = vpred[1][1] = 512;
for (row=0; row < height; row++) {
#ifdef LIBRAW_LIBRARY_BUILD
checkCancel();
#endif
for (col=0; col < width; col++) {
diff = ljpeg_diff(huff);
if (col < 2) hpred[col] = vpred[row & 1][col] += diff;
else hpred[col & 1] += diff;
image[row*width+col][c] = hpred[col & 1];
}
}
}
} | 0 | [
"CWE-369",
"CWE-704"
] | LibRaw | 9f26ce37f5be86ea11bfc6831366558650b1f6ff | 328,493,655,557,920,540,000,000,000,000,000,000,000 | 30 | SA81000: LibRaw 0.18.8 |
int tipc_nl_node_dump_link(struct sk_buff *skb, struct netlink_callback *cb)
{
struct net *net = sock_net(skb->sk);
struct nlattr **attrs = genl_dumpit_info(cb)->attrs;
struct nlattr *link[TIPC_NLA_LINK_MAX + 1];
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct tipc_node *node;
struct tipc_nl_msg msg;
u32 prev_node = cb->args[0];
u32 prev_link = cb->args[1];
int done = cb->args[2];
bool bc_link = cb->args[3];
int err;
if (done)
return 0;
if (!prev_node) {
/* Check if broadcast-receiver links dumping is needed */
if (attrs && attrs[TIPC_NLA_LINK]) {
err = nla_parse_nested_deprecated(link,
TIPC_NLA_LINK_MAX,
attrs[TIPC_NLA_LINK],
tipc_nl_link_policy,
NULL);
if (unlikely(err))
return err;
if (unlikely(!link[TIPC_NLA_LINK_BROADCAST]))
return -EINVAL;
bc_link = true;
}
}
msg.skb = skb;
msg.portid = NETLINK_CB(cb->skb).portid;
msg.seq = cb->nlh->nlmsg_seq;
rcu_read_lock();
if (prev_node) {
node = tipc_node_find(net, prev_node);
if (!node) {
/* We never set seq or call nl_dump_check_consistent()
* this means that setting prev_seq here will cause the
* consistence check to fail in the netlink callback
* handler. Resulting in the last NLMSG_DONE message
* having the NLM_F_DUMP_INTR flag set.
*/
cb->prev_seq = 1;
goto out;
}
tipc_node_put(node);
list_for_each_entry_continue_rcu(node, &tn->node_list,
list) {
tipc_node_read_lock(node);
err = __tipc_nl_add_node_links(net, &msg, node,
&prev_link, bc_link);
tipc_node_read_unlock(node);
if (err)
goto out;
prev_node = node->addr;
}
} else {
err = tipc_nl_add_bc_link(net, &msg, tn->bcl);
if (err)
goto out;
list_for_each_entry_rcu(node, &tn->node_list, list) {
tipc_node_read_lock(node);
err = __tipc_nl_add_node_links(net, &msg, node,
&prev_link, bc_link);
tipc_node_read_unlock(node);
if (err)
goto out;
prev_node = node->addr;
}
}
done = 1;
out:
rcu_read_unlock();
cb->args[0] = prev_node;
cb->args[1] = prev_link;
cb->args[2] = done;
cb->args[3] = bc_link;
return skb->len;
} | 0 | [] | linux | 0217ed2848e8538bcf9172d97ed2eeb4a26041bb | 200,687,478,918,726,070,000,000,000,000,000,000,000 | 90 | 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]> |
int cli_matchmeta(cli_ctx *ctx, const char *fname, size_t fsizec, size_t fsizer, int encrypted, unsigned int filepos, int res1, void *res2)
{
const struct cli_cdb *cdb;
unsigned int viruses_found = 0;
int ret = CL_CLEAN;
cli_dbgmsg("CDBNAME:%s:%llu:%s:%llu:%llu:%d:%u:%u:%p\n",
cli_ftname(cli_get_container(ctx, -1)), (long long unsigned)fsizec, fname, (long long unsigned)fsizec, (long long unsigned)fsizer,
encrypted, filepos, res1, res2);
if (ctx->engine && ctx->engine->cb_meta)
if (ctx->engine->cb_meta(cli_ftname(cli_get_container(ctx, -1)), fsizec, fname, fsizer, encrypted, filepos, ctx->cb_ctx) == CL_VIRUS) {
cli_dbgmsg("inner file blacklisted by callback: %s\n", fname);
ret = cli_append_virus(ctx, "Detected.By.Callback");
viruses_found++;
if(!SCAN_ALL || ret != CL_CLEAN)
return ret;
}
if(!ctx->engine || !(cdb = ctx->engine->cdb))
return CL_CLEAN;
do {
if(cdb->ctype != CL_TYPE_ANY && cdb->ctype != cli_get_container(ctx, -1))
continue;
if(cdb->encrypted != 2 && cdb->encrypted != encrypted)
continue;
if(cdb->res1 && (cdb->ctype == CL_TYPE_ZIP || cdb->ctype == CL_TYPE_RAR) && cdb->res1 != res1)
continue;
#define CDBRANGE(field, val) \
if(field[0] != CLI_OFF_ANY) { \
if(field[0] == field[1] && field[0] != val) \
continue; \
else if(field[0] != field[1] && ((field[0] && field[0] > val) ||\
(field[1] && field[1] < val))) \
continue; \
}
CDBRANGE(cdb->csize, cli_get_container_size(ctx, -1));
CDBRANGE(cdb->fsizec, fsizec);
CDBRANGE(cdb->fsizer, fsizer);
CDBRANGE(cdb->filepos, filepos);
if(cdb->name.re_magic && (!fname || cli_regexec(&cdb->name, fname, 0, NULL, 0) == REG_NOMATCH))
continue;
ret = cli_append_virus(ctx, cdb->virname);
viruses_found++;
if(!SCAN_ALL || ret != CL_CLEAN)
return ret;
} while((cdb = cdb->next));
if (SCAN_ALL && viruses_found)
return CL_VIRUS;
return CL_CLEAN;
} | 0 | [] | clamav-devel | 167c0079292814ec5523d0b97a9e1b002bf8819b | 295,328,636,666,345,420,000,000,000,000,000,000,000 | 61 | fix 0.99.3 false negative of virus Pdf.Exploit.CVE_2016_1046-1. |
get_real_name (const char *name, const char *gecos)
{
char *locale_string, *part_before_comma, *capitalized_login_name, *real_name;
if (gecos == NULL) {
return NULL;
}
locale_string = eel_str_strip_substring_and_after (gecos, ",");
if (!g_utf8_validate (locale_string, -1, NULL)) {
part_before_comma = g_locale_to_utf8 (locale_string, -1, NULL, NULL, NULL);
g_free (locale_string);
} else {
part_before_comma = locale_string;
}
if (!g_utf8_validate (name, -1, NULL)) {
locale_string = g_locale_to_utf8 (name, -1, NULL, NULL, NULL);
} else {
locale_string = g_strdup (name);
}
capitalized_login_name = eel_str_capitalize (locale_string);
g_free (locale_string);
if (capitalized_login_name == NULL) {
real_name = part_before_comma;
} else {
real_name = eel_str_replace_substring
(part_before_comma, "&", capitalized_login_name);
g_free (part_before_comma);
}
if (eel_str_is_empty (real_name)
|| eel_strcmp (name, real_name) == 0
|| eel_strcmp (capitalized_login_name, real_name) == 0) {
g_free (real_name);
real_name = NULL;
}
g_free (capitalized_login_name);
return real_name;
} | 0 | [] | nautilus | 7632a3e13874a2c5e8988428ca913620a25df983 | 195,824,255,090,614,500,000,000,000,000,000,000,000 | 45 | Check for trusted desktop file launchers.
2009-02-24 Alexander Larsson <[email protected]>
* libnautilus-private/nautilus-directory-async.c:
Check for trusted desktop file launchers.
* libnautilus-private/nautilus-file-private.h:
* libnautilus-private/nautilus-file.c:
* libnautilus-private/nautilus-file.h:
Add nautilus_file_is_trusted_link.
Allow unsetting of custom display name.
* libnautilus-private/nautilus-mime-actions.c:
Display dialog when trying to launch a non-trusted desktop file.
svn path=/trunk/; revision=15003 |
htmlParseComment(htmlParserCtxtPtr ctxt) {
xmlChar *buf = NULL;
int len;
int size = HTML_PARSER_BUFFER_SIZE;
int q, ql;
int r, rl;
int cur, l;
xmlParserInputState state;
/*
* Check that there is a comment right here.
*/
if ((RAW != '<') || (NXT(1) != '!') ||
(NXT(2) != '-') || (NXT(3) != '-')) return;
state = ctxt->instate;
ctxt->instate = XML_PARSER_COMMENT;
SHRINK;
SKIP(4);
buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
if (buf == NULL) {
htmlErrMemory(ctxt, "buffer allocation failed\n");
ctxt->instate = state;
return;
}
q = CUR_CHAR(ql);
NEXTL(ql);
r = CUR_CHAR(rl);
NEXTL(rl);
cur = CUR_CHAR(l);
len = 0;
while (IS_CHAR(cur) &&
((cur != '>') ||
(r != '-') || (q != '-'))) {
if (len + 5 >= size) {
xmlChar *tmp;
size *= 2;
tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
if (tmp == NULL) {
xmlFree(buf);
htmlErrMemory(ctxt, "growing buffer failed\n");
ctxt->instate = state;
return;
}
buf = tmp;
}
COPY_BUF(ql,buf,len,q);
q = r;
ql = rl;
r = cur;
rl = l;
NEXTL(l);
cur = CUR_CHAR(l);
if (cur == 0) {
SHRINK;
GROW;
cur = CUR_CHAR(l);
}
}
buf[len] = 0;
if (!IS_CHAR(cur)) {
htmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
"Comment not terminated \n<!--%.50s\n", buf, NULL);
xmlFree(buf);
} else {
NEXT;
if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
(!ctxt->disableSAX))
ctxt->sax->comment(ctxt->userData, buf);
xmlFree(buf);
}
ctxt->instate = state;
} | 1 | [
"CWE-119"
] | libxml2 | e724879d964d774df9b7969fc846605aa1bac54c | 330,234,725,374,202,500,000,000,000,000,000,000,000 | 74 | Fix parsing short unclosed comment uninitialized access
For https://bugzilla.gnome.org/show_bug.cgi?id=746048
The HTML parser was too optimistic when processing comments and
didn't check for the end of the stream on the first 2 characters |
_cupsSNMPRead(int fd, /* I - SNMP socket file descriptor */
cups_snmp_t *packet, /* I - SNMP packet buffer */
double timeout) /* I - Timeout in seconds */
{
unsigned char buffer[CUPS_SNMP_MAX_PACKET];
/* Data packet */
ssize_t bytes; /* Number of bytes received */
socklen_t addrlen; /* Source address length */
http_addr_t address; /* Source address */
/*
* Range check input...
*/
DEBUG_printf(("4_cupsSNMPRead(fd=%d, packet=%p, timeout=%.1f)", fd, packet,
timeout));
if (fd < 0 || !packet)
{
DEBUG_puts("5_cupsSNMPRead: Returning NULL");
return (NULL);
}
/*
* Optionally wait for a response...
*/
if (timeout >= 0.0)
{
int ready; /* Data ready on socket? */
#ifdef HAVE_POLL
struct pollfd pfd; /* Polled file descriptor */
pfd.fd = fd;
pfd.events = POLLIN;
while ((ready = poll(&pfd, 1, (int)(timeout * 1000.0))) < 0 &&
(errno == EINTR || errno == EAGAIN));
#else
fd_set input_set; /* select() input set */
struct timeval stimeout; /* select() timeout */
do
{
FD_ZERO(&input_set);
FD_SET(fd, &input_set);
stimeout.tv_sec = (int)timeout;
stimeout.tv_usec = (int)((timeout - stimeout.tv_sec) * 1000000);
ready = select(fd + 1, &input_set, NULL, NULL, &stimeout);
}
# ifdef _WIN32
while (ready < 0 && WSAGetLastError() == WSAEINTR);
# else
while (ready < 0 && (errno == EINTR || errno == EAGAIN));
# endif /* _WIN32 */
#endif /* HAVE_POLL */
/*
* If we don't have any data ready, return right away...
*/
if (ready <= 0)
{
DEBUG_puts("5_cupsSNMPRead: Returning NULL (timeout)");
return (NULL);
}
}
/*
* Read the response data...
*/
addrlen = sizeof(address);
if ((bytes = recvfrom(fd, buffer, sizeof(buffer), 0, (void *)&address,
&addrlen)) < 0)
{
DEBUG_printf(("5_cupsSNMPRead: Returning NULL (%s)", strerror(errno)));
return (NULL);
}
/*
* Look for the response status code in the SNMP message header...
*/
asn1_debug("DEBUG: IN ", buffer, (size_t)bytes, 0);
asn1_decode_snmp(buffer, (size_t)bytes, packet);
memcpy(&(packet->address), &address, sizeof(packet->address));
/*
* Return decoded data packet...
*/
DEBUG_puts("5_cupsSNMPRead: Returning packet");
return (packet);
} | 0 | [
"CWE-120"
] | cups | f24e6cf6a39300ad0c3726a41a4aab51ad54c109 | 131,689,902,096,561,400,000,000,000,000,000,000,000 | 106 | Fix multiple security/disclosure issues:
- CVE-2019-8696 and CVE-2019-8675: Fixed SNMP buffer overflows (rdar://51685251)
- Fixed IPP buffer overflow (rdar://50035411)
- Fixed memory disclosure issue in the scheduler (rdar://51373853)
- Fixed DoS issues in the scheduler (rdar://51373929) |
stop_all_other_conversations (GdmSession *self,
GdmSessionConversation *conversation_to_keep,
gboolean now)
{
GHashTableIter iter;
gpointer key, value;
if (self->priv->conversations == NULL) {
return;
}
if (conversation_to_keep == NULL) {
g_debug ("GdmSession: Stopping all conversations");
} else {
g_debug ("GdmSession: Stopping all conversations except for %s",
conversation_to_keep->service_name);
}
g_hash_table_iter_init (&iter, self->priv->conversations);
while (g_hash_table_iter_next (&iter, &key, &value)) {
GdmSessionConversation *conversation;
conversation = (GdmSessionConversation *) value;
if (conversation == conversation_to_keep) {
if (now) {
g_hash_table_iter_steal (&iter);
g_free (key);
}
} else {
if (now) {
stop_conversation_now (conversation);
} else {
stop_conversation (conversation);
}
}
}
if (now) {
g_hash_table_remove_all (self->priv->conversations);
if (conversation_to_keep != NULL) {
g_hash_table_insert (self->priv->conversations,
g_strdup (conversation_to_keep->service_name),
conversation_to_keep);
}
if (self->priv->session_conversation != conversation_to_keep) {
self->priv->session_conversation = NULL;
}
}
} | 0 | [] | gdm | 5ac224602f1d603aac5eaa72e1760d3e33a26f0a | 259,350,754,607,174,200,000,000,000,000,000,000,000 | 53 | 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 drbg_fini_hash_kernel(struct drbg_state *drbg)
{
struct sdesc *sdesc = (struct sdesc *)drbg->priv_data;
if (sdesc) {
crypto_free_shash(sdesc->shash.tfm);
kzfree(sdesc);
}
drbg->priv_data = NULL;
return 0;
} | 0 | [
"CWE-476"
] | linux | 8fded5925d0a733c46f8d0b5edd1c9b315882b1d | 108,718,495,148,080,460,000,000,000,000,000,000,000 | 10 | crypto: drbg - Convert to new rng interface
This patch converts the DRBG implementation to the new low-level
rng interface.
This allows us to get rid of struct drbg_gen by using the new RNG
API instead.
Signed-off-by: Herbert Xu <[email protected]>
Acked-by: Stephan Mueller <[email protected]> |
int nghttp2_should_send_window_update(int32_t local_window_size,
int32_t recv_window_size) {
return recv_window_size > 0 && recv_window_size >= local_window_size / 2;
} | 0 | [
"CWE-707"
] | nghttp2 | 336a98feb0d56b9ac54e12736b18785c27f75090 | 283,254,248,171,763,200,000,000,000,000,000,000,000 | 4 | Implement max settings option |
int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_type, char *sig, int sig_len, char *fname, char **signature, int *signature_len, char **error) /* {{{ */
{
int read_size, len;
zend_off_t read_len;
unsigned char buf[1024];
php_stream_rewind(fp);
switch (sig_type) {
case PHAR_SIG_OPENSSL: {
#ifdef PHAR_HAVE_OPENSSL
BIO *in;
EVP_PKEY *key;
EVP_MD *mdtype = (EVP_MD *) EVP_sha1();
EVP_MD_CTX md_ctx;
#else
int tempsig;
#endif
zend_string *pubkey = NULL;
char *pfile;
php_stream *pfp;
#ifndef PHAR_HAVE_OPENSSL
if (!zend_hash_str_exists(&module_registry, "openssl", sizeof("openssl")-1)) {
if (error) {
spprintf(error, 0, "openssl not loaded");
}
return FAILURE;
}
#endif
/* use __FILE__ . '.pubkey' for public key file */
spprintf(&pfile, 0, "%s.pubkey", fname);
pfp = php_stream_open_wrapper(pfile, "rb", 0, NULL);
efree(pfile);
if (!pfp || !(pubkey = php_stream_copy_to_mem(pfp, PHP_STREAM_COPY_ALL, 0)) || !ZSTR_LEN(pubkey)) {
if (pfp) {
php_stream_close(pfp);
}
if (error) {
spprintf(error, 0, "openssl public key could not be read");
}
return FAILURE;
}
php_stream_close(pfp);
#ifndef PHAR_HAVE_OPENSSL
tempsig = sig_len;
if (FAILURE == phar_call_openssl_signverify(0, fp, end_of_phar, pubkey ? ZSTR_VAL(pubkey) : NULL, pubkey ? ZSTR_LEN(pubkey) : 0, &sig, &tempsig)) {
if (pubkey) {
zend_string_release(pubkey);
}
if (error) {
spprintf(error, 0, "openssl signature could not be verified");
}
return FAILURE;
}
if (pubkey) {
zend_string_release(pubkey);
}
sig_len = tempsig;
#else
in = BIO_new_mem_buf(pubkey ? ZSTR_VAL(pubkey) : NULL, pubkey ? ZSTR_LEN(pubkey) : 0);
if (NULL == in) {
zend_string_release(pubkey);
if (error) {
spprintf(error, 0, "openssl signature could not be processed");
}
return FAILURE;
}
key = PEM_read_bio_PUBKEY(in, NULL,NULL, NULL);
BIO_free(in);
zend_string_release(pubkey);
if (NULL == key) {
if (error) {
spprintf(error, 0, "openssl signature could not be processed");
}
return FAILURE;
}
EVP_VerifyInit(&md_ctx, mdtype);
read_len = end_of_phar;
if (read_len > sizeof(buf)) {
read_size = sizeof(buf);
} else {
read_size = (int)read_len;
}
php_stream_seek(fp, 0, SEEK_SET);
while (read_size && (len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
EVP_VerifyUpdate (&md_ctx, buf, len);
read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
}
if (EVP_VerifyFinal(&md_ctx, (unsigned char *)sig, sig_len, key) != 1) {
/* 1: signature verified, 0: signature does not match, -1: failed signature operation */
EVP_MD_CTX_cleanup(&md_ctx);
if (error) {
spprintf(error, 0, "broken openssl signature");
}
return FAILURE;
}
EVP_MD_CTX_cleanup(&md_ctx);
#endif
*signature_len = phar_hex_str((const char*)sig, sig_len, signature);
}
break;
#ifdef PHAR_HASH_OK
case PHAR_SIG_SHA512: {
unsigned char digest[64];
PHP_SHA512_CTX context;
PHP_SHA512Init(&context);
read_len = end_of_phar;
if (read_len > sizeof(buf)) {
read_size = sizeof(buf);
} else {
read_size = (int)read_len;
}
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_SHA512Update(&context, buf, len);
read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
}
PHP_SHA512Final(digest, &context);
if (memcmp(digest, sig, sizeof(digest))) {
if (error) {
spprintf(error, 0, "broken signature");
}
return FAILURE;
}
*signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature);
break;
}
case PHAR_SIG_SHA256: {
unsigned char digest[32];
PHP_SHA256_CTX context;
PHP_SHA256Init(&context);
read_len = end_of_phar;
if (read_len > sizeof(buf)) {
read_size = sizeof(buf);
} else {
read_size = (int)read_len;
}
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_SHA256Update(&context, buf, len);
read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
}
PHP_SHA256Final(digest, &context);
if (memcmp(digest, sig, sizeof(digest))) {
if (error) {
spprintf(error, 0, "broken signature");
}
return FAILURE;
}
*signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature);
break;
}
#else
case PHAR_SIG_SHA512:
case PHAR_SIG_SHA256:
if (error) {
spprintf(error, 0, "unsupported signature");
}
return FAILURE;
#endif
case PHAR_SIG_SHA1: {
unsigned char digest[20];
PHP_SHA1_CTX context;
PHP_SHA1Init(&context);
read_len = end_of_phar;
if (read_len > sizeof(buf)) {
read_size = sizeof(buf);
} else {
read_size = (int)read_len;
}
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_SHA1Update(&context, buf, len);
read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
}
PHP_SHA1Final(digest, &context);
if (memcmp(digest, sig, sizeof(digest))) {
if (error) {
spprintf(error, 0, "broken signature");
}
return FAILURE;
}
*signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature);
break;
}
case PHAR_SIG_MD5: {
unsigned char digest[16];
PHP_MD5_CTX context;
PHP_MD5Init(&context);
read_len = end_of_phar;
if (read_len > sizeof(buf)) {
read_size = sizeof(buf);
} else {
read_size = (int)read_len;
}
while ((len = php_stream_read(fp, (char*)buf, read_size)) > 0) {
PHP_MD5Update(&context, buf, len);
read_len -= (zend_off_t)len;
if (read_len < read_size) {
read_size = (int)read_len;
}
}
PHP_MD5Final(digest, &context);
if (memcmp(digest, sig, sizeof(digest))) {
if (error) {
spprintf(error, 0, "broken signature");
}
return FAILURE;
}
*signature_len = phar_hex_str((const char*)digest, sizeof(digest), signature);
break;
}
default:
if (error) {
spprintf(error, 0, "broken or unsupported signature");
}
return FAILURE;
}
return SUCCESS;
} | 1 | [
"CWE-119",
"CWE-787"
] | php-src | 0bfb970f43acd1e81d11be1154805f86655f15d5 | 254,520,604,440,096,230,000,000,000,000,000,000,000 | 273 | Fix bug #72928 - Out of bound when verify signature of zip phar in phar_parse_zipfile
(cherry picked from commit 19484ab77466f99c78fc0e677f7e03da0584d6a2) |
int64 GetMemoryLimitInBytes() override {
return std::numeric_limits<int64>::max();
} | 0 | [
"CWE-476",
"CWE-703"
] | tensorflow | 6972f9dfe325636b3db4e0bc517ee22a159365c0 | 33,740,872,612,261,063,000,000,000,000,000,000,000 | 3 | Add missing valuidation to FusedBatchNorm.
PiperOrigin-RevId: 372460336
Change-Id: Ic8c4e4de67c58a741bd87f2e182bed07247d1126 |
SPL_METHOD(MultipleIterator, key)
{
spl_SplObjectStorage *intern;
intern = Z_SPLOBJSTORAGE_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
spl_multiple_iterator_get_all(intern, SPL_MULTIPLE_ITERATOR_GET_ALL_KEY, return_value);
} | 0 | [
"CWE-119",
"CWE-787"
] | php-src | 61cdd1255d5b9c8453be71aacbbf682796ac77d4 | 218,842,457,031,898,760,000,000,000,000,000,000,000 | 11 | Fix bug #73257 and bug #73258 - SplObjectStorage unserialize allows use of non-object as key |
agent_readkey (ctrl_t ctrl, int fromcard, const char *hexkeygrip,
unsigned char **r_pubkey)
{
gpg_error_t err;
membuf_t data;
size_t len;
unsigned char *buf;
char line[ASSUAN_LINELENGTH];
struct default_inq_parm_s dfltparm;
memset (&dfltparm, 0, sizeof dfltparm);
dfltparm.ctrl = ctrl;
*r_pubkey = NULL;
err = start_agent (ctrl, 0);
if (err)
return err;
dfltparm.ctx = agent_ctx;
err = assuan_transact (agent_ctx, "RESET",NULL, NULL, NULL, NULL, NULL, NULL);
if (err)
return err;
snprintf (line, DIM(line)-1, "%sREADKEY %s", fromcard? "SCD ":"", hexkeygrip);
init_membuf (&data, 1024);
err = assuan_transact (agent_ctx, line,
membuf_data_cb, &data,
default_inq_cb, &dfltparm,
NULL, NULL);
if (err)
{
xfree (get_membuf (&data, &len));
return err;
}
buf = get_membuf (&data, &len);
if (!buf)
return gpg_error_from_syserror ();
if (!gcry_sexp_canon_len (buf, len, NULL, NULL))
{
xfree (buf);
return gpg_error (GPG_ERR_INV_SEXP);
}
*r_pubkey = buf;
return 0;
} | 0 | [
"CWE-20"
] | gnupg | 2183683bd633818dd031b090b5530951de76f392 | 38,597,741,065,183,106,000,000,000,000,000,000,000 | 46 | Use inline functions to convert buffer data to scalars.
* common/host2net.h (buf16_to_ulong, buf16_to_uint): New.
(buf16_to_ushort, buf16_to_u16): New.
(buf32_to_size_t, buf32_to_ulong, buf32_to_uint, buf32_to_u32): New.
--
Commit 91b826a38880fd8a989318585eb502582636ddd8 was not enough to
avoid all sign extension on shift problems. Hanno Böck found a case
with an invalid read due to this problem. To fix that once and for
all almost all uses of "<< 24" and "<< 8" are changed by this patch to
use an inline function from host2net.h.
Signed-off-by: Werner Koch <[email protected]> |
void ConnectionManagerImpl::handleCodecError(absl::string_view error) {
ENVOY_CONN_LOG(debug, "dispatch error: {}", read_callbacks_->connection(), error);
read_callbacks_->connection().streamInfo().setResponseCodeDetails(
absl::StrCat("codec error: ", error));
read_callbacks_->connection().streamInfo().setResponseFlag(
StreamInfo::ResponseFlag::DownstreamProtocolError);
// HTTP/1.1 codec has already sent a 400 response if possible. HTTP/2 codec has already sent
// GOAWAY.
doConnectionClose(Network::ConnectionCloseType::FlushWriteAndDelay,
StreamInfo::ResponseFlag::DownstreamProtocolError);
} | 0 | [
"CWE-400"
] | envoy | 0e49a495826ea9e29134c1bd54fdeb31a034f40c | 52,266,358,578,575,950,000,000,000,000,000,000,000 | 12 | 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]> |
HGraph* HGraphBuilder::CreateGraph() {
graph_ = new(zone()) HGraph(info());
if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info());
{
HPhase phase("H_Block building");
current_block_ = graph()->entry_block();
Scope* scope = info()->scope();
if (scope->HasIllegalRedeclaration()) {
Bailout("function with illegal redeclaration");
return NULL;
}
if (scope->calls_eval()) {
Bailout("function calls eval");
return NULL;
}
SetUpScope(scope);
// Add an edge to the body entry. This is warty: the graph's start
// environment will be used by the Lithium translation as the initial
// environment on graph entry, but it has now been mutated by the
// Hydrogen translation of the instructions in the start block. This
// environment uses values which have not been defined yet. These
// Hydrogen instructions will then be replayed by the Lithium
// translation, so they cannot have an environment effect. The edge to
// the body's entry block (along with some special logic for the start
// block in HInstruction::InsertAfter) seals the start block from
// getting unwanted instructions inserted.
//
// TODO(kmillikin): Fix this. Stop mutating the initial environment.
// Make the Hydrogen instructions in the initial block into Hydrogen
// values (but not instructions), present in the initial environment and
// not replayed by the Lithium translation.
HEnvironment* initial_env = environment()->CopyWithoutHistory();
HBasicBlock* body_entry = CreateBasicBlock(initial_env);
current_block()->Goto(body_entry);
body_entry->SetJoinId(BailoutId::FunctionEntry());
set_current_block(body_entry);
// Handle implicit declaration of the function name in named function
// expressions before other declarations.
if (scope->is_function_scope() && scope->function() != NULL) {
VisitVariableDeclaration(scope->function());
}
VisitDeclarations(scope->declarations());
AddSimulate(BailoutId::Declarations());
HValue* context = environment()->LookupContext();
AddInstruction(
new(zone()) HStackCheck(context, HStackCheck::kFunctionEntry));
VisitStatements(info()->function()->body());
if (HasStackOverflow()) return NULL;
if (current_block() != NULL) {
HReturn* instr = new(zone()) HReturn(graph()->GetConstantUndefined());
current_block()->FinishExit(instr);
set_current_block(NULL);
}
// If the checksum of the number of type info changes is the same as the
// last time this function was compiled, then this recompile is likely not
// due to missing/inadequate type feedback, but rather too aggressive
// optimization. Disable optimistic LICM in that case.
Handle<Code> unoptimized_code(info()->shared_info()->code());
ASSERT(unoptimized_code->kind() == Code::FUNCTION);
Handle<Object> maybe_type_info(unoptimized_code->type_feedback_info());
Handle<TypeFeedbackInfo> type_info(
Handle<TypeFeedbackInfo>::cast(maybe_type_info));
int checksum = type_info->own_type_change_checksum();
int composite_checksum = graph()->update_type_change_checksum(checksum);
graph()->set_use_optimistic_licm(
!type_info->matches_inlined_type_change_checksum(composite_checksum));
type_info->set_inlined_type_change_checksum(composite_checksum);
}
return graph();
} | 0 | [] | node | fd80a31e0697d6317ce8c2d289575399f4e06d21 | 100,533,818,759,086,670,000,000,000,000,000,000,000 | 79 | deps: backport 5f836c from v8 upstream
Original commit message:
Fix Hydrogen bounds check elimination
When combining bounds checks, they must all be moved before the first load/store
that they are guarding.
BUG=chromium:344186
LOG=y
[email protected]
Review URL: https://codereview.chromium.org/172093002
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@19475 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
fix #8070 |
static int compat_table_info(const struct xt_table_info *info,
struct xt_table_info *newinfo)
{
struct arpt_entry *iter;
void *loc_cpu_entry;
int ret;
if (!newinfo || !info)
return -EINVAL;
/* we dont care about newinfo->entries[] */
memcpy(newinfo, info, offsetof(struct xt_table_info, entries));
newinfo->initial_entries = 0;
loc_cpu_entry = info->entries[raw_smp_processor_id()];
xt_compat_init_offsets(NFPROTO_ARP, info->number);
xt_entry_foreach(iter, loc_cpu_entry, info->size) {
ret = compat_calc_entry(iter, info, loc_cpu_entry, newinfo);
if (ret != 0)
return ret;
}
return 0;
} | 0 | [
"CWE-200"
] | linux-2.6 | 42eab94fff18cb1091d3501cd284d6bd6cc9c143 | 45,830,580,893,746,700,000,000,000,000,000,000,000 | 22 | netfilter: arp_tables: fix infoleak to userspace
Structures ipt_replace, compat_ipt_replace, and xt_get_revision are
copied from userspace. Fields of these structs that are
zero-terminated strings are not checked. When they are used as argument
to a format string containing "%s" in request_module(), some sensitive
information is leaked to userspace via argument of spawned modprobe
process.
The first bug was introduced before the git epoch; the second is
introduced by 6b7d31fc (v2.6.15-rc1); the third is introduced by
6b7d31fc (v2.6.15-rc1). To trigger the bug one should have
CAP_NET_ADMIN.
Signed-off-by: Vasiliy Kulikov <[email protected]>
Signed-off-by: Patrick McHardy <[email protected]> |
void SshIo::SshImpl::writeRemote(const byte* data, size_t size, long from, long to)
{
if (protocol_ == pSftp) throw Error(kerErrorMessage, "not support SFTP write access.");
//printf("ssh update size=%ld from=%ld to=%ld\n", (long)size, from, to);
assert(isMalloced_);
std::string tempFile = hostInfo_.Path + ".exiv2tmp";
std::string response;
std::stringstream ss;
// copy the head (byte 0 to byte fromByte) of original file to filepath.exiv2tmp
ss << "head -c " << from
<< " " << hostInfo_.Path
<< " > " << tempFile;
std::string cmd = ss.str();
if (ssh_->runCommand(cmd, &response) != 0) {
throw Error(kerErrorMessage, "SSH: Unable to cope the head of file to temp");
}
// upload the data (the byte ranges which are different between the original
// file and the new file) to filepath.exiv2datatemp
if (ssh_->scp(hostInfo_.Path + ".exiv2datatemp", data, size) != 0) {
throw Error(kerErrorMessage, "SSH: Unable to copy file");
}
// concatenate the filepath.exiv2datatemp to filepath.exiv2tmp
cmd = "cat " + hostInfo_.Path + ".exiv2datatemp >> " + tempFile;
if (ssh_->runCommand(cmd, &response) != 0) {
throw Error(kerErrorMessage, "SSH: Unable to copy the rest");
}
// copy the tail (from byte toByte to the end of file) of original file to filepath.exiv2tmp
ss.str("");
ss << "tail -c+" << (to + 1)
<< " " << hostInfo_.Path
<< " >> " << tempFile;
cmd = ss.str();
if (ssh_->runCommand(cmd, &response) != 0) {
throw Error(kerErrorMessage, "SSH: Unable to copy the rest");
}
// replace the original file with filepath.exiv2tmp
cmd = "mv " + tempFile + " " + hostInfo_.Path;
if (ssh_->runCommand(cmd, &response) != 0) {
throw Error(kerErrorMessage, "SSH: Unable to copy the rest");
}
// remove filepath.exiv2datatemp
cmd = "rm " + hostInfo_.Path + ".exiv2datatemp";
if (ssh_->runCommand(cmd, &response) != 0) {
throw Error(kerErrorMessage, "SSH: Unable to copy the rest");
}
} | 0 | [
"CWE-190"
] | exiv2 | c73d1e27198a389ce7caf52ac30f8e2120acdafd | 172,915,916,437,163,670,000,000,000,000,000,000,000 | 53 | Avoid negative integer overflow when `filesize < io_->tell()`.
This fixes #791. |
Value ExpressionSetIsSubset::evaluate(const Document& root) const {
const Value lhs = vpOperand[0]->evaluate(root);
const Value rhs = vpOperand[1]->evaluate(root);
uassert(17046,
str::stream() << "both operands of $setIsSubset must be arrays. First "
<< "argument is of type: "
<< typeName(lhs.getType()),
lhs.isArray());
uassert(17042,
str::stream() << "both operands of $setIsSubset must be arrays. Second "
<< "argument is of type: "
<< typeName(rhs.getType()),
rhs.isArray());
return setIsSubsetHelper(lhs.getArray(),
arrayToSet(rhs, getExpressionContext()->getValueComparator()));
} | 0 | [
"CWE-835"
] | mongo | 0a076417d1d7fba3632b73349a1fd29a83e68816 | 110,581,119,347,402,630,000,000,000,000,000,000,000 | 18 | SERVER-38070 fix infinite loop in agg expression |
static struct timing_generator *dce80_timing_generator_create(
struct dc_context *ctx,
uint32_t instance,
const struct dce110_timing_generator_offsets *offsets)
{
struct dce110_timing_generator *tg110 =
kzalloc(sizeof(struct dce110_timing_generator), GFP_KERNEL);
if (!tg110)
return NULL;
dce80_timing_generator_construct(tg110, ctx, instance, offsets);
return &tg110->base;
} | 0 | [
"CWE-400",
"CWE-703",
"CWE-401"
] | linux | 055e547478a11a6360c7ce05e2afc3e366968a12 | 317,934,530,012,857,170,000,000,000,000,000,000,000 | 14 | 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]> |
handle_signal(unsigned long sig, struct k_sigaction *ka,
siginfo_t *info, sigset_t *oldset, struct pt_regs * regs)
{
int ret;
/* Set up the stack frame */
if (ka->sa.sa_flags & SA_SIGINFO)
ret = setup_rt_frame(sig, ka, info, oldset, regs);
else
ret = setup_frame(sig, ka, oldset, regs);
if (ret == 0) {
spin_lock_irq(¤t->sighand->siglock);
sigorsets(¤t->blocked,¤t->blocked,&ka->sa.sa_mask);
if (!(ka->sa.sa_flags & SA_NODEFER))
sigaddset(¤t->blocked,sig);
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
}
return ret;
} | 0 | [] | linux-2.6 | ee18d64c1f632043a02e6f5ba5e045bb26a5465f | 173,912,273,178,984,100,000,000,000,000,000,000,000 | 22 | KEYS: Add a keyctl to install a process's session keyring on its parent [try #6]
Add a keyctl to install a process's session keyring onto its parent. This
replaces the parent's session keyring. Because the COW credential code does
not permit one process to change another process's credentials directly, the
change is deferred until userspace next starts executing again. Normally this
will be after a wait*() syscall.
To support this, three new security hooks have been provided:
cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in
the blank security creds and key_session_to_parent() - which asks the LSM if
the process may replace its parent's session keyring.
The replacement may only happen if the process has the same ownership details
as its parent, and the process has LINK permission on the session keyring, and
the session keyring is owned by the process, and the LSM permits it.
Note that this requires alteration to each architecture's notify_resume path.
This has been done for all arches barring blackfin, m68k* and xtensa, all of
which need assembly alteration to support TIF_NOTIFY_RESUME. This allows the
replacement to be performed at the point the parent process resumes userspace
execution.
This allows the userspace AFS pioctl emulation to fully emulate newpag() and
the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to
alter the parent process's PAG membership. However, since kAFS doesn't use
PAGs per se, but rather dumps the keys into the session keyring, the session
keyring of the parent must be replaced if, for example, VIOCSETTOK is passed
the newpag flag.
This can be tested with the following program:
#include <stdio.h>
#include <stdlib.h>
#include <keyutils.h>
#define KEYCTL_SESSION_TO_PARENT 18
#define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0)
int main(int argc, char **argv)
{
key_serial_t keyring, key;
long ret;
keyring = keyctl_join_session_keyring(argv[1]);
OSERROR(keyring, "keyctl_join_session_keyring");
key = add_key("user", "a", "b", 1, keyring);
OSERROR(key, "add_key");
ret = keyctl(KEYCTL_SESSION_TO_PARENT);
OSERROR(ret, "KEYCTL_SESSION_TO_PARENT");
return 0;
}
Compiled and linked with -lkeyutils, you should see something like:
[dhowells@andromeda ~]$ keyctl show
Session Keyring
-3 --alswrv 4043 4043 keyring: _ses
355907932 --alswrv 4043 -1 \_ keyring: _uid.4043
[dhowells@andromeda ~]$ /tmp/newpag
[dhowells@andromeda ~]$ keyctl show
Session Keyring
-3 --alswrv 4043 4043 keyring: _ses
1055658746 --alswrv 4043 4043 \_ user: a
[dhowells@andromeda ~]$ /tmp/newpag hello
[dhowells@andromeda ~]$ keyctl show
Session Keyring
-3 --alswrv 4043 4043 keyring: hello
340417692 --alswrv 4043 4043 \_ user: a
Where the test program creates a new session keyring, sticks a user key named
'a' into it and then installs it on its parent.
Signed-off-by: David Howells <[email protected]>
Signed-off-by: James Morris <[email protected]> |
struct fpm_scoreboard_proc_s *fpm_scoreboard_proc_acquire(struct fpm_scoreboard_s *scoreboard, int child_index, int nohang) /* {{{ */
{
struct fpm_scoreboard_proc_s *proc;
proc = fpm_scoreboard_proc_get(scoreboard, child_index);
if (!proc) {
return NULL;
}
if (!fpm_spinlock(&proc->lock, nohang)) {
return NULL;
}
return proc;
} | 0 | [
"CWE-787"
] | php-src | fadb1f8c1d08ae62b4f0a16917040fde57a3b93b | 117,728,055,952,749,790,000,000,000,000,000,000,000 | 15 | Fix bug #81026 (PHP-FPM oob R/W in root process leading to priv escalation)
The main change is to store scoreboard procs directly to the variable sized
array rather than indirectly through the pointer.
Signed-off-by: Stanislav Malyshev <[email protected]> |
static struct sock *udp_get_idx(struct seq_file *seq, loff_t pos)
{
struct sock *sk = udp_get_first(seq);
if (sk)
while (pos && (sk = udp_get_next(seq, sk)) != NULL)
--pos;
return pos ? NULL : sk;
} | 0 | [] | linux-2.6 | 32c1da70810017a98aa6c431a5494a302b6b9a30 | 229,982,021,387,065,700,000,000,000,000,000,000,000 | 9 | [UDP]: Randomize port selection.
This patch causes UDP port allocation to be randomized like TCP.
The earlier code would always choose same port (ie first empty list).
Signed-off-by: Stephen Hemminger <[email protected]>
Signed-off-by: David S. Miller <[email protected]> |
bgp_attr_as4_aggregator (struct bgp_attr_parser_args *args,
as_t *as4_aggregator_as,
struct in_addr *as4_aggregator_addr)
{
struct peer *const peer = args->peer;
struct attr *const attr = args->attr;
const bgp_size_t length = args->length;
if (length != 8)
{
zlog (peer->log, LOG_ERR, "New Aggregator length is not 8 [%d]",
length);
return bgp_attr_malformed (args,
BGP_NOTIFY_UPDATE_ATTR_LENG_ERR,
0);
}
*as4_aggregator_as = stream_getl (peer->ibuf);
as4_aggregator_addr->s_addr = stream_get_ipv4 (peer->ibuf);
attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AS4_AGGREGATOR);
return BGP_ATTR_PARSE_PROCEED;
} | 0 | [] | quagga | 8794e8d229dc9fe29ea31424883433d4880ef408 | 146,211,019,617,987,060,000,000,000,000,000,000,000 | 24 | bgpd: Fix regression in args consolidation, total should be inited from args
* bgp_attr.c: (bgp_attr_unknown) total should be initialised from the args. |
Elf64_Shdr const *PackLinuxElf64::elf_find_section_type(
unsigned const type
) const
{
Elf64_Shdr const *shdr = shdri;
int j = e_shnum;
for (; 0 <=--j; ++shdr) {
if (type==get_te32(&shdr->sh_type)) {
return shdr;
}
}
return 0;
} | 0 | [
"CWE-476"
] | upx | ef336dbcc6dc8344482f8cf6c909ae96c3286317 | 16,868,327,926,478,270,000,000,000,000,000,000,000 | 13 | Protect against bad crafted input.
https://github.com/upx/upx/issues/128
modified: p_lx_elf.cpp |
bool IsValidStrideCompactRowMajorData(int64_t* shape_arr, int64_t* stride_arr,
int ndim) {
if (ndim >= 1 && stride_arr[ndim - 1] != 1) {
return false;
}
for (int i = ndim - 2; i >= 0; --i) {
if (stride_arr[i] != shape_arr[i + 1] * stride_arr[i + 1]) {
return false;
}
}
return true;
} | 0 | [
"CWE-20",
"CWE-476",
"CWE-908"
] | tensorflow | 22e07fb204386768e5bcbea563641ea11f96ceb8 | 146,269,294,639,356,070,000,000,000,000,000,000,000 | 12 | Fix multiple vulnerabilities in `tf.experimental.dlpack.to_dlpack`.
We have a use after free caused by memory coruption, a segmentation fault caused by memory corruption, several memory leaks and an undefined behavior when taking the reference of a nullptr.
PiperOrigin-RevId: 332568894
Change-Id: Ife0fc05e103b35325094ae5d822ee5fdea764572 |
void DcmSCP::notifySENDProgress(const unsigned long byteCount)
{
DCMNET_TRACE("Bytes sent: " << byteCount);
} | 0 | [
"CWE-264"
] | dcmtk | beaf5a5c24101daeeafa48c375120b16197c9e95 | 255,860,272,753,701,300,000,000,000,000,000,000,000 | 4 | Make sure to handle setuid() return code properly.
In some tools the return value of setuid() is not checked. In the worst
case this could lead to privilege escalation since the process does not
give up its root privileges and continue as root. |
void ImportEPUB::ReadManifestItemElement(QXmlStreamReader *opf_reader)
{
QString id = opf_reader->attributes().value("", "id").toString();
QString href = opf_reader->attributes().value("", "href").toString();
QString type = opf_reader->attributes().value("", "media-type").toString();
QString properties = opf_reader->attributes().value("", "properties").toString();
// Paths are percent encoded in the OPF, we use "normal" paths internally.
href = Utility::URLDecodePath(href);
QString extension = QFileInfo(href).suffix().toLower();
// find the epub root relative file path from the opf location and the item href
QString file_path = m_opfDir.absolutePath() + "/" + href;
file_path = file_path.remove(0, m_ExtractedFolderPath.length() + 1);
if (type != NCX_MIMETYPE && extension != NCX_EXTENSION) {
if (!m_ManifestFilePaths.contains(file_path)) {
if (m_Files.contains(id)) {
// We have an error situation with a duplicate id in the epub.
// We must warn the user, but attempt to use another id so the epub can still be loaded.
QString base_id = QFileInfo(href).fileName();
QString new_id(base_id);
int duplicate_index = 0;
while (m_Files.contains(new_id)) {
duplicate_index++;
new_id = QString("%1%2").arg(base_id).arg(duplicate_index);
}
const QString load_warning = QObject::tr("The OPF manifest contains duplicate ids for: %1").arg(id) +
" - " + QObject::tr("A temporary id has been assigned to load this EPUB. You should edit your OPF file to remove the duplication.");
id = new_id;
AddLoadWarning(load_warning);
}
m_Files[ id ] = href;
m_FileMimetypes[ id ] = type;
m_ManifestFilePaths << file_path;
// store information about any nav document
if (properties.contains("nav")) {
m_NavId = id;
m_NavHref = href;
}
}
} else {
m_NcxCandidates[ id ] = href;
m_ManifestFilePaths << file_path;
}
} | 0 | [
"CWE-22"
] | Sigil | 04e2f280cc4a0766bedcc7b9eb56449ceecc2ad4 | 181,472,077,261,786,800,000,000,000,000,000,000,000 | 49 | further harden against malicious epubs and produce error message |
static inline void add_offset_pair(zval *result, char *str, int len, int offset, char *name)
{
zval *match_pair;
ALLOC_ZVAL(match_pair);
array_init(match_pair);
INIT_PZVAL(match_pair);
/* Add (match, offset) to the return value */
add_next_index_stringl(match_pair, str, len, 1);
add_next_index_long(match_pair, offset);
if (name) {
zval_add_ref(&match_pair);
zend_hash_update(Z_ARRVAL_P(result), name, strlen(name)+1, &match_pair, sizeof(zval *), NULL);
}
zend_hash_next_index_insert(Z_ARRVAL_P(result), &match_pair, sizeof(zval *), NULL);
} | 1 | [] | php-src | 03964892c054d0c736414c10b3edc7a40318b975 | 245,912,582,882,633,100,000,000,000,000,000,000,000 | 18 | Fix bug #70345 (Multiple vulnerabilities related to PCRE functions) |
TRIO_PUBLIC int trio_printf TRIO_VARGS2((format, va_alist), TRIO_CONST char* format, TRIO_VA_DECL)
{
int status;
va_list args;
assert(VALID(format));
TRIO_VA_START(args, format);
status = TrioFormat(stdout, 0, TrioOutStreamFile, format, args, NULL, NULL);
TRIO_VA_END(args);
return status;
} | 0 | [
"CWE-190",
"CWE-125"
] | FreeRDP | 05cd9ea2290d23931f615c1b004d4b2e69074e27 | 240,903,785,403,262,170,000,000,000,000,000,000,000 | 12 | Fixed TrioParse and trio_length limts.
CVE-2020-4030 thanks to @antonio-morales for finding this. |
origin_remote_matches (OstreeRepo *repo,
const char *remote_name,
const char *url,
const char *main_ref,
gboolean gpg_verify,
const char *collection_id)
{
g_autofree char *real_url = NULL;
g_autofree char *real_main_ref = NULL;
g_autofree char *real_collection_id = NULL;
gboolean noenumerate;
gboolean real_gpg_verify;
/* Must match url */
if (url == NULL)
return FALSE;
if (!ostree_repo_remote_get_url (repo, remote_name, &real_url, NULL))
return FALSE;
if (g_strcmp0 (url, real_url) != 0)
return FALSE;
/* Must be noenumerate */
if (!ostree_repo_get_remote_boolean_option (repo, remote_name,
"xa.noenumerate",
FALSE, &noenumerate,
NULL) ||
!noenumerate)
return FALSE;
/* Must match gpg-verify
* NOTE: We assume if all else matches the actual gpg key matches too. */
if (!ostree_repo_get_remote_boolean_option (repo, remote_name,
"gpg-verify",
FALSE, &real_gpg_verify,
NULL) ||
real_gpg_verify != gpg_verify)
return FALSE;
/* Must match main-ref */
if (ostree_repo_get_remote_option (repo, remote_name,
"xa.main-ref",
NULL, &real_main_ref,
NULL) &&
g_strcmp0 (main_ref, real_main_ref) != 0)
return FALSE;
/* Must match collection ID */
if (ostree_repo_get_remote_option (repo, remote_name,
"collection-id",
NULL, &real_collection_id,
NULL) &&
g_strcmp0 (main_ref, real_main_ref) != 0)
return FALSE;
return TRUE;
} | 0 | [
"CWE-668"
] | flatpak | cd2142888fc4c199723a0dfca1f15ea8788a5483 | 222,428,426,215,882,560,000,000,000,000,000,000,000 | 58 | Don't expose /proc when running apply_extra
As shown by CVE-2019-5736, it is sometimes possible for the sandbox
app to access outside files using /proc/self/exe. This is not
typically an issue for flatpak as the sandbox runs as the user which
has no permissions to e.g. modify the host files.
However, when installing apps using extra-data into the system repo
we *do* actually run a sandbox as root. So, in this case we disable mounting
/proc in the sandbox, which will neuter attacks like this. |
PackLinuxElf64ppcle::~PackLinuxElf64ppcle()
{
} | 0 | [
"CWE-476"
] | upx | ef336dbcc6dc8344482f8cf6c909ae96c3286317 | 130,148,209,435,141,590,000,000,000,000,000,000,000 | 3 | Protect against bad crafted input.
https://github.com/upx/upx/issues/128
modified: p_lx_elf.cpp |
static int SRP_Verify_N_and_g(const BIGNUM *N, const BIGNUM *g)
{
BN_CTX *bn_ctx = BN_CTX_new();
BIGNUM *p = BN_new();
BIGNUM *r = BN_new();
int ret =
g != NULL && N != NULL && bn_ctx != NULL && BN_is_odd(N) &&
BN_is_prime(N,SRP_NUMBER_ITERATIONS_FOR_PRIME,NULL,bn_ctx,NULL) &&
p != NULL && BN_rshift1(p, N) &&
/* p = (N-1)/2 */
BN_is_prime(p,SRP_NUMBER_ITERATIONS_FOR_PRIME,NULL,bn_ctx,NULL) &&
r != NULL &&
/* verify g^((N-1)/2) == -1 (mod N) */
BN_mod_exp(r, g, p, N, bn_ctx) &&
BN_add_word(r, 1) &&
BN_cmp(r, N) == 0;
if(r)
BN_free(r);
if(p)
BN_free(p);
if(bn_ctx)
BN_CTX_free(bn_ctx);
return ret;
} | 0 | [] | openssl | edc032b5e3f3ebb1006a9c89e0ae00504f47966f | 181,919,925,247,499,100,000,000,000,000,000,000,000 | 27 | Add SRP support. |
sha1_handle_first_client_response (DBusAuth *auth,
const DBusString *data)
{
/* We haven't sent a challenge yet, we're expecting a desired
* username from the client.
*/
DBusString tmp;
DBusString tmp2;
dbus_bool_t retval = FALSE;
DBusError error = DBUS_ERROR_INIT;
_dbus_string_set_length (&auth->challenge, 0);
if (_dbus_string_get_length (data) > 0)
{
if (_dbus_string_get_length (&auth->identity) > 0)
{
/* Tried to send two auth identities, wtf */
_dbus_verbose ("%s: client tried to send auth identity, but we already have one\n",
DBUS_AUTH_NAME (auth));
return send_rejected (auth);
}
else
{
/* this is our auth identity */
if (!_dbus_string_copy (data, 0, &auth->identity, 0))
return FALSE;
}
}
if (!_dbus_credentials_add_from_user (auth->desired_identity, data))
{
_dbus_verbose ("%s: Did not get a valid username from client\n",
DBUS_AUTH_NAME (auth));
return send_rejected (auth);
}
if (!_dbus_string_init (&tmp))
return FALSE;
if (!_dbus_string_init (&tmp2))
{
_dbus_string_free (&tmp);
return FALSE;
}
/* we cache the keyring for speed, so here we drop it if it's the
* wrong one. FIXME caching the keyring here is useless since we use
* a different DBusAuth for every connection.
*/
if (auth->keyring &&
!_dbus_keyring_is_for_credentials (auth->keyring,
auth->desired_identity))
{
_dbus_keyring_unref (auth->keyring);
auth->keyring = NULL;
}
if (auth->keyring == NULL)
{
auth->keyring = _dbus_keyring_new_for_credentials (auth->desired_identity,
&auth->context,
&error);
if (auth->keyring == NULL)
{
if (dbus_error_has_name (&error,
DBUS_ERROR_NO_MEMORY))
{
dbus_error_free (&error);
goto out;
}
else
{
_DBUS_ASSERT_ERROR_IS_SET (&error);
_dbus_verbose ("%s: Error loading keyring: %s\n",
DBUS_AUTH_NAME (auth), error.message);
if (send_rejected (auth))
retval = TRUE; /* retval is only about mem */
dbus_error_free (&error);
goto out;
}
}
else
{
_dbus_assert (!dbus_error_is_set (&error));
}
}
_dbus_assert (auth->keyring != NULL);
auth->cookie_id = _dbus_keyring_get_best_key (auth->keyring, &error);
if (auth->cookie_id < 0)
{
_DBUS_ASSERT_ERROR_IS_SET (&error);
_dbus_verbose ("%s: Could not get a cookie ID to send to client: %s\n",
DBUS_AUTH_NAME (auth), error.message);
if (send_rejected (auth))
retval = TRUE;
dbus_error_free (&error);
goto out;
}
else
{
_dbus_assert (!dbus_error_is_set (&error));
}
if (!_dbus_string_copy (&auth->context, 0,
&tmp2, _dbus_string_get_length (&tmp2)))
goto out;
if (!_dbus_string_append (&tmp2, " "))
goto out;
if (!_dbus_string_append_int (&tmp2, auth->cookie_id))
goto out;
if (!_dbus_string_append (&tmp2, " "))
goto out;
if (!_dbus_generate_random_bytes (&tmp, N_CHALLENGE_BYTES, &error))
{
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
{
dbus_error_free (&error);
goto out;
}
else
{
_DBUS_ASSERT_ERROR_IS_SET (&error);
_dbus_verbose ("%s: Error generating challenge: %s\n",
DBUS_AUTH_NAME (auth), error.message);
if (send_rejected (auth))
retval = TRUE; /* retval is only about mem */
dbus_error_free (&error);
goto out;
}
}
_dbus_string_set_length (&auth->challenge, 0);
if (!_dbus_string_hex_encode (&tmp, 0, &auth->challenge, 0))
goto out;
if (!_dbus_string_hex_encode (&tmp, 0, &tmp2,
_dbus_string_get_length (&tmp2)))
goto out;
if (!send_data (auth, &tmp2))
goto out;
goto_state (auth, &server_state_waiting_for_data);
retval = TRUE;
out:
_dbus_string_zero (&tmp);
_dbus_string_free (&tmp);
_dbus_string_zero (&tmp2);
_dbus_string_free (&tmp2);
return retval;
} | 1 | [
"CWE-59"
] | dbus | 47b1a4c41004bf494b87370987b222c934b19016 | 12,067,234,396,677,446,000,000,000,000,000,000,000 | 162 | auth: Reject DBUS_COOKIE_SHA1 for users other than the server owner
The DBUS_COOKIE_SHA1 authentication mechanism aims to prove ownership
of a shared home directory by having the server write a secret "cookie"
into a .dbus-keyrings subdirectory of the desired identity's home
directory with 0700 permissions, and having the client prove that it can
read the cookie. This never actually worked for non-malicious clients in
the case where server uid != client uid (unless the server and client
both have privileges, such as Linux CAP_DAC_OVERRIDE or traditional
Unix uid 0) because an unprivileged server would fail to write out the
cookie, and an unprivileged client would be unable to read the resulting
file owned by the server.
Additionally, since dbus 1.7.10 we have checked that ~/.dbus-keyrings
is owned by the uid of the server (a side-effect of a check added to
harden our use of XDG_RUNTIME_DIR), further ruling out successful use
by a non-malicious client with a uid differing from the server's.
Joe Vennix of Apple Information Security discovered that the
implementation of DBUS_COOKIE_SHA1 was susceptible to a symbolic link
attack: a malicious client with write access to its own home directory
could manipulate a ~/.dbus-keyrings symlink to cause the DBusServer to
read and write in unintended locations. In the worst case this could
result in the DBusServer reusing a cookie that is known to the
malicious client, and treating that cookie as evidence that a subsequent
client connection came from an attacker-chosen uid, allowing
authentication bypass.
This is mitigated by the fact that by default, the well-known system
dbus-daemon (since 2003) and the well-known session dbus-daemon (in
stable releases since dbus 1.10.0 in 2015) only accept the EXTERNAL
authentication mechanism, and as a result will reject DBUS_COOKIE_SHA1
at an early stage, before manipulating cookies. As a result, this
vulnerability only applies to:
* system or session dbus-daemons with non-standard configuration
* third-party dbus-daemon invocations such as at-spi2-core (although
in practice at-spi2-core also only accepts EXTERNAL by default)
* third-party uses of DBusServer such as the one in Upstart
Avoiding symlink attacks in a portable way is difficult, because APIs
like openat() and Linux /proc/self/fd are not universally available.
However, because DBUS_COOKIE_SHA1 already doesn't work in practice for
a non-matching uid, we can solve this vulnerability in an easier way
without regressions, by rejecting it early (before looking at
~/.dbus-keyrings) whenever the requested identity doesn't match the
identity of the process hosting the DBusServer.
Signed-off-by: Simon McVittie <[email protected]>
Closes: https://gitlab.freedesktop.org/dbus/dbus/issues/269
Closes: CVE-2019-12749 |
parser_emit_cbc_push_number (parser_context_t *context_p, /**< context */
bool is_negative_number) /**< sign is negative */
{
uint16_t value = context_p->lit_object.index;
uint16_t lit_value = PARSER_INVALID_LITERAL_INDEX;
if (context_p->last_cbc_opcode != PARSER_CBC_UNAVAILABLE)
{
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL)
{
lit_value = context_p->last_cbc.literal_index;
}
else
{
if (context_p->last_cbc_opcode == CBC_PUSH_TWO_LITERALS)
{
context_p->last_cbc_opcode = CBC_PUSH_LITERAL;
lit_value = context_p->last_cbc.value;
}
else if (context_p->last_cbc_opcode == CBC_PUSH_THREE_LITERALS)
{
context_p->last_cbc_opcode = CBC_PUSH_TWO_LITERALS;
lit_value = context_p->last_cbc.third_literal_index;
}
parser_flush_cbc (context_p);
}
}
if (value == 0)
{
if (lit_value == PARSER_INVALID_LITERAL_INDEX)
{
context_p->last_cbc_opcode = CBC_PUSH_NUMBER_0;
return;
}
context_p->last_cbc_opcode = CBC_PUSH_LITERAL_PUSH_NUMBER_0;
context_p->last_cbc.literal_index = lit_value;
return;
}
uint16_t opcode;
if (lit_value == PARSER_INVALID_LITERAL_INDEX)
{
opcode = (is_negative_number ? CBC_PUSH_NUMBER_NEG_BYTE
: CBC_PUSH_NUMBER_POS_BYTE);
JERRY_ASSERT (CBC_STACK_ADJUST_VALUE (PARSER_GET_FLAGS (opcode)) == 1);
}
else
{
opcode = (is_negative_number ? CBC_PUSH_LITERAL_PUSH_NUMBER_NEG_BYTE
: CBC_PUSH_LITERAL_PUSH_NUMBER_POS_BYTE);
JERRY_ASSERT (CBC_STACK_ADJUST_VALUE (PARSER_GET_FLAGS (opcode)) == 2);
context_p->last_cbc.literal_index = lit_value;
}
JERRY_ASSERT (value > 0 && value <= CBC_PUSH_NUMBER_BYTE_RANGE_END);
context_p->last_cbc_opcode = opcode;
context_p->last_cbc.value = (uint16_t) (value - 1);
} /* parser_emit_cbc_push_number */ | 0 | [
"CWE-416"
] | jerryscript | 3bcd48f72d4af01d1304b754ef19fe1a02c96049 | 38,085,292,512,559,280,000,000,000,000,000,000,000 | 65 | Improve parse_identifier (#4691)
Ascii string length is no longer computed during string allocation.
JerryScript-DCO-1.0-Signed-off-by: Daniel Batiz [email protected] |
int cap_task_setioprio(struct task_struct *p, int ioprio)
{
return cap_safe_nice(p);
} | 0 | [
"CWE-264"
] | linux | 259e5e6c75a910f3b5e656151dc602f53f9d7548 | 149,243,793,457,941,900,000,000,000,000,000,000,000 | 4 | Add PR_{GET,SET}_NO_NEW_PRIVS to prevent execve from granting privs
With this change, calling
prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)
disables privilege granting operations at execve-time. For example, a
process will not be able to execute a setuid binary to change their uid
or gid if this bit is set. The same is true for file capabilities.
Additionally, LSM_UNSAFE_NO_NEW_PRIVS is defined to ensure that
LSMs respect the requested behavior.
To determine if the NO_NEW_PRIVS bit is set, a task may call
prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0);
It returns 1 if set and 0 if it is not set. If any of the arguments are
non-zero, it will return -1 and set errno to -EINVAL.
(PR_SET_NO_NEW_PRIVS behaves similarly.)
This functionality is desired for the proposed seccomp filter patch
series. By using PR_SET_NO_NEW_PRIVS, it allows a task to modify the
system call behavior for itself and its child tasks without being
able to impact the behavior of a more privileged task.
Another potential use is making certain privileged operations
unprivileged. For example, chroot may be considered "safe" if it cannot
affect privileged tasks.
Note, this patch causes execve to fail when PR_SET_NO_NEW_PRIVS is
set and AppArmor is in use. It is fixed in a subsequent patch.
Signed-off-by: Andy Lutomirski <[email protected]>
Signed-off-by: Will Drewry <[email protected]>
Acked-by: Eric Paris <[email protected]>
Acked-by: Kees Cook <[email protected]>
v18: updated change desc
v17: using new define values as per 3.4
Signed-off-by: James Morris <[email protected]> |
static int treo_attach(struct usb_serial *serial)
{
struct usb_serial_port *swap_port;
/* Only do this endpoint hack for the Handspring devices with
* interrupt in endpoints, which for now are the Treo devices. */
if (!((le16_to_cpu(serial->dev->descriptor.idVendor)
== HANDSPRING_VENDOR_ID) ||
(le16_to_cpu(serial->dev->descriptor.idVendor)
== KYOCERA_VENDOR_ID)) ||
(serial->num_interrupt_in == 0))
return 0;
/*
* It appears that Treos and Kyoceras want to use the
* 1st bulk in endpoint to communicate with the 2nd bulk out endpoint,
* so let's swap the 1st and 2nd bulk in and interrupt endpoints.
* Note that swapping the bulk out endpoints would break lots of
* apps that want to communicate on the second port.
*/
#define COPY_PORT(dest, src) \
do { \
int i; \
\
for (i = 0; i < ARRAY_SIZE(src->read_urbs); ++i) { \
dest->read_urbs[i] = src->read_urbs[i]; \
dest->read_urbs[i]->context = dest; \
dest->bulk_in_buffers[i] = src->bulk_in_buffers[i]; \
} \
dest->read_urb = src->read_urb; \
dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress;\
dest->bulk_in_buffer = src->bulk_in_buffer; \
dest->bulk_in_size = src->bulk_in_size; \
dest->interrupt_in_urb = src->interrupt_in_urb; \
dest->interrupt_in_urb->context = dest; \
dest->interrupt_in_endpointAddress = \
src->interrupt_in_endpointAddress;\
dest->interrupt_in_buffer = src->interrupt_in_buffer; \
} while (0);
swap_port = kmalloc(sizeof(*swap_port), GFP_KERNEL);
if (!swap_port)
return -ENOMEM;
COPY_PORT(swap_port, serial->port[0]);
COPY_PORT(serial->port[0], serial->port[1]);
COPY_PORT(serial->port[1], swap_port);
kfree(swap_port);
return 0;
} | 1 | [
"CWE-476",
"CWE-703"
] | linux | cac9b50b0d75a1d50d6c056ff65c005f3224c8e0 | 168,323,757,430,524,630,000,000,000,000,000,000,000 | 50 | USB: visor: fix null-deref at probe
Fix null-pointer dereference at probe should a (malicious) Treo device
lack the expected endpoints.
Specifically, the Treo port-setup hack was dereferencing the bulk-in and
interrupt-in urbs without first making sure they had been allocated by
core.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable <[email protected]>
Signed-off-by: Johan Hovold <[email protected]> |
void region16_print(const REGION16* region)
{
const RECTANGLE_16* rects;
UINT32 nbRects, i;
int currentBandY = -1;
rects = region16_rects(region, &nbRects);
WLog_DBG(TAG, "nrects=%"PRIu32"", nbRects);
for (i = 0; i < nbRects; i++, rects++)
{
if (rects->top != currentBandY)
{
currentBandY = rects->top;
WLog_DBG(TAG, "band %d: ", currentBandY);
}
WLog_DBG(TAG, "(%"PRIu16",%"PRIu16"-%"PRIu16",%"PRIu16")", rects->left, rects->top, rects->right,
rects->bottom);
}
} | 0 | [
"CWE-401"
] | FreeRDP | 9fee4ae076b1ec97b97efb79ece08d1dab4df29a | 8,564,372,628,131,661,000,000,000,000,000,000,000 | 20 | Fixed #5645: realloc return handling |
gather_termleader(void)
{
int i;
int len = 0;
#ifdef FEAT_GUI
if (gui.in_use)
termleader[len++] = CSI; // the GUI codes are not in termcodes[]
#endif
#ifdef FEAT_TERMRESPONSE
if (check_for_codes || *T_CRS != NUL)
termleader[len++] = DCS; // the termcode response starts with DCS
// in 8-bit mode
#endif
termleader[len] = NUL;
for (i = 0; i < tc_len; ++i)
if (vim_strchr(termleader, termcodes[i].code[0]) == NULL)
{
termleader[len++] = termcodes[i].code[0];
termleader[len] = NUL;
}
need_gather = FALSE;
} | 0 | [
"CWE-125",
"CWE-787"
] | vim | e178af5a586ea023622d460779fdcabbbfac0908 | 264,959,741,649,594,600,000,000,000,000,000,000,000 | 25 | patch 8.2.5160: accessing invalid memory after changing terminal size
Problem: Accessing invalid memory after changing terminal size.
Solution: Adjust cmdline_row and msg_row to the value of Rows. |
void PeerListWidget::displayToggleColumnsMenu(const QPoint&)
{
QMenu hideshowColumn(this);
hideshowColumn.setTitle(tr("Column visibility"));
QList<QAction*> actions;
for (int i = 0; i < PeerListDelegate::IP_HIDDEN; ++i) {
if ((i == PeerListDelegate::COUNTRY) && !Preferences::instance()->resolvePeerCountries()) {
actions.append(nullptr); // keep the index in sync
continue;
}
QAction *myAct = hideshowColumn.addAction(m_listModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
myAct->setCheckable(true);
myAct->setChecked(!isColumnHidden(i));
actions.append(myAct);
}
int visibleCols = 0;
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; i++) {
if (!isColumnHidden(i))
visibleCols++;
if (visibleCols > 1)
break;
}
// Call menu
QAction *act = hideshowColumn.exec(QCursor::pos());
if (act) {
int col = actions.indexOf(act);
Q_ASSERT(col >= 0);
Q_ASSERT(visibleCols > 0);
if (!isColumnHidden(col) && (visibleCols == 1))
return;
qDebug("Toggling column %d visibility", col);
setColumnHidden(col, !isColumnHidden(col));
if (!isColumnHidden(col) && (columnWidth(col) <= 5))
setColumnWidth(col, 100);
saveSettings();
}
} | 0 | [
"CWE-20",
"CWE-79"
] | qBittorrent | 6ca3e4f094da0a0017cb2d483ec1db6176bb0b16 | 174,044,310,831,329,580,000,000,000,000,000,000,000 | 39 | Add Utils::String::toHtmlEscaped |
static u64 compute_guest_tsc(struct kvm_vcpu *vcpu, s64 kernel_ns)
{
u64 tsc = pvclock_scale_delta(kernel_ns-vcpu->arch.last_tsc_nsec,
vcpu->kvm->arch.virtual_tsc_mult,
vcpu->kvm->arch.virtual_tsc_shift);
tsc += vcpu->arch.last_tsc_write;
return tsc;
} | 0 | [
"CWE-200"
] | kvm | 831d9d02f9522e739825a51a11e3bc5aa531a905 | 158,094,150,696,418,130,000,000,000,000,000,000,000 | 8 | KVM: x86: fix information leak to userland
Structures kvm_vcpu_events, kvm_debugregs, kvm_pit_state2 and
kvm_clock_data are copied to userland with some padding and reserved
fields unitialized. It leads to leaking of contents of kernel stack
memory. We have to initialize them to zero.
In patch v1 Jan Kiszka suggested to fill reserved fields with zeros
instead of memset'ting the whole struct. It makes sense as these
fields are explicitly marked as padding. No more fields need zeroing.
KVM-Stable-Tag.
Signed-off-by: Vasiliy Kulikov <[email protected]>
Signed-off-by: Marcelo Tosatti <[email protected]> |
prepareAcceleratedURL(ConnStateData * conn, const Http1::RequestParserPointer &hp)
{
int vhost = conn->port->vhost;
int vport = conn->port->vport;
static char ipbuf[MAX_IPSTRLEN];
/* BUG: Squid cannot deal with '*' URLs (RFC2616 5.1.2) */
static const SBuf cache_object("cache_object://");
if (hp->requestUri().startsWith(cache_object))
return nullptr; /* already in good shape */
// XXX: re-use proper URL parser for this
SBuf url = hp->requestUri(); // use full provided URI if we abort
do { // use a loop so we can break out of it
::Parser::Tokenizer tok(url);
if (tok.skip('/')) // origin-form URL already.
break;
if (conn->port->vhost)
return nullptr; /* already in good shape */
// skip the URI scheme
static const CharacterSet uriScheme = CharacterSet("URI-scheme","+-.") + CharacterSet::ALPHA + CharacterSet::DIGIT;
static const SBuf uriSchemeEnd("://");
if (!tok.skipAll(uriScheme) || !tok.skip(uriSchemeEnd))
break;
// skip the authority segment
// RFC 3986 complex nested ABNF for "authority" boils down to this:
static const CharacterSet authority = CharacterSet("authority","-._~%:@[]!$&'()*+,;=") +
CharacterSet::HEXDIG + CharacterSet::ALPHA + CharacterSet::DIGIT;
if (!tok.skipAll(authority))
break;
static const SBuf slashUri("/");
const SBuf t = tok.remaining();
if (t.isEmpty())
url = slashUri;
else if (t[0]=='/') // looks like path
url = t;
else if (t[0]=='?' || t[0]=='#') { // looks like query or fragment. fix '/'
url = slashUri;
url.append(t);
} // else do nothing. invalid path
} while(false);
#if SHOULD_REJECT_UNKNOWN_URLS
// reject URI which are not well-formed even after the processing above
if (url.isEmpty() || url[0] != '/') {
hp->parseStatusCode = Http::scBadRequest;
return conn->abortRequestParsing("error:invalid-request");
}
#endif
if (vport < 0)
vport = conn->clientConnection->local.port();
char *receivedHost = nullptr;
if (vhost && (receivedHost = hp->getHostHeaderField())) {
SBuf host(receivedHost);
debugs(33, 5, "ACCEL VHOST REWRITE: vhost=" << host << " + vport=" << vport);
if (vport > 0) {
// remove existing :port (if any), cope with IPv6+ without port
const auto lastColonPos = host.rfind(':');
if (lastColonPos != SBuf::npos && *host.rbegin() != ']') {
host.chop(0, lastColonPos); // truncate until the last colon
}
host.appendf(":%d", vport);
} // else nothing to alter port-wise.
const SBuf &scheme = AnyP::UriScheme(conn->transferProtocol.protocol).image();
const auto url_sz = scheme.length() + host.length() + url.length() + 32;
char *uri = static_cast<char *>(xcalloc(url_sz, 1));
snprintf(uri, url_sz, SQUIDSBUFPH "://" SQUIDSBUFPH SQUIDSBUFPH, SQUIDSBUFPRINT(scheme), SQUIDSBUFPRINT(host), SQUIDSBUFPRINT(url));
debugs(33, 5, "ACCEL VHOST REWRITE: " << uri);
return uri;
} else if (conn->port->defaultsite /* && !vhost */) {
debugs(33, 5, "ACCEL DEFAULTSITE REWRITE: defaultsite=" << conn->port->defaultsite << " + vport=" << vport);
char vportStr[32];
vportStr[0] = '\0';
if (vport > 0) {
snprintf(vportStr, sizeof(vportStr),":%d",vport);
}
const SBuf &scheme = AnyP::UriScheme(conn->transferProtocol.protocol).image();
const int url_sz = scheme.length() + strlen(conn->port->defaultsite) + sizeof(vportStr) + url.length() + 32;
char *uri = static_cast<char *>(xcalloc(url_sz, 1));
snprintf(uri, url_sz, SQUIDSBUFPH "://%s%s" SQUIDSBUFPH,
SQUIDSBUFPRINT(scheme), conn->port->defaultsite, vportStr, SQUIDSBUFPRINT(url));
debugs(33, 5, "ACCEL DEFAULTSITE REWRITE: " << uri);
return uri;
} else if (vport > 0 /* && (!vhost || no Host:) */) {
debugs(33, 5, "ACCEL VPORT REWRITE: *_port IP + vport=" << vport);
/* Put the local socket IP address as the hostname, with whatever vport we found */
conn->clientConnection->local.toHostStr(ipbuf,MAX_IPSTRLEN);
const SBuf &scheme = AnyP::UriScheme(conn->transferProtocol.protocol).image();
const int url_sz = scheme.length() + sizeof(ipbuf) + url.length() + 32;
char *uri = static_cast<char *>(xcalloc(url_sz, 1));
snprintf(uri, url_sz, SQUIDSBUFPH "://%s:%d" SQUIDSBUFPH,
SQUIDSBUFPRINT(scheme), ipbuf, vport, SQUIDSBUFPRINT(url));
debugs(33, 5, "ACCEL VPORT REWRITE: " << uri);
return uri;
}
return nullptr;
} | 0 | [
"CWE-444"
] | squid | fd68382860633aca92065e6c343cfd1b12b126e7 | 12,604,947,198,250,145,000,000,000,000,000,000,000 | 106 | Improve Transfer-Encoding handling (#702)
Reject messages containing Transfer-Encoding header with coding other
than chunked or identity. Squid does not support other codings.
For simplicity and security sake, also reject messages where
Transfer-Encoding contains unnecessary complex values that are
technically equivalent to "chunked" or "identity" (e.g., ",,chunked" or
"identity, chunked").
RFC 7230 formally deprecated and removed identity coding, but it is
still used by some agents. |
static MagickBooleanType ReadDCMPixels(Image *image,DCMInfo *info,
DCMStreamInfo *stream_info,MagickBooleanType first_segment,
ExceptionInfo *exception)
{
int
byte,
index;
MagickBooleanType
status;
PixelPacket
pixel;
register ssize_t
i,
x;
register Quantum
*q;
ssize_t
y;
/*
Convert DCM Medical image to pixel packets.
*/
byte=0;
i=0;
status=MagickTrue;
(void) memset(&pixel,0,sizeof(pixel));
for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
if (info->samples_per_pixel == 1)
{
int
pixel_value;
if (info->bytes_per_pixel == 1)
pixel_value=info->polarity != MagickFalse ?
((int) info->max_value-ReadDCMByte(stream_info,image)) :
ReadDCMByte(stream_info,image);
else
if ((info->bits_allocated != 12) || (info->significant_bits != 12))
{
if (info->signed_data)
pixel_value=ReadDCMSignedShort(stream_info,image);
else
pixel_value=(int) ReadDCMShort(stream_info,image);
if (info->polarity != MagickFalse)
pixel_value=(int)info->max_value-pixel_value;
}
else
{
if ((i & 0x01) != 0)
pixel_value=(ReadDCMByte(stream_info,image) << 8) |
byte;
else
{
pixel_value=ReadDCMSignedShort(stream_info,image);
byte=(int) (pixel_value & 0x0f);
pixel_value>>=4;
}
i++;
}
if (info->signed_data == 1)
pixel_value-=32767;
index=pixel_value;
if (info->rescale != MagickFalse)
{
double
scaled_value;
scaled_value=pixel_value*info->rescale_slope+
info->rescale_intercept;
index=(int) scaled_value;
if (info->window_width != 0)
{
double
window_max,
window_min;
window_min=ceil(info->window_center-
(info->window_width-1.0)/2.0-0.5);
window_max=floor(info->window_center+
(info->window_width-1.0)/2.0+0.5);
if (scaled_value <= window_min)
index=0;
else
if (scaled_value > window_max)
index=(int) info->max_value;
else
index=(int) (info->max_value*(((scaled_value-
info->window_center-0.5)/(info->window_width-1))+0.5));
}
}
index&=info->mask;
index=(int) ConstrainColormapIndex(image,(ssize_t) index,exception);
if (first_segment)
SetPixelIndex(image,(Quantum) index,q);
else
SetPixelIndex(image,(Quantum) (((size_t) index) |
(((size_t) GetPixelIndex(image,q)) << 8)),q);
pixel.red=(unsigned int) image->colormap[index].red;
pixel.green=(unsigned int) image->colormap[index].green;
pixel.blue=(unsigned int) image->colormap[index].blue;
}
else
{
if (info->bytes_per_pixel == 1)
{
pixel.red=(unsigned int) ReadDCMByte(stream_info,image);
pixel.green=(unsigned int) ReadDCMByte(stream_info,image);
pixel.blue=(unsigned int) ReadDCMByte(stream_info,image);
}
else
{
pixel.red=ReadDCMShort(stream_info,image);
pixel.green=ReadDCMShort(stream_info,image);
pixel.blue=ReadDCMShort(stream_info,image);
}
pixel.red&=info->mask;
pixel.green&=info->mask;
pixel.blue&=info->mask;
if (info->scale != (Quantum *) NULL)
{
if ((MagickSizeType) pixel.red <= GetQuantumRange(info->depth))
pixel.red=info->scale[pixel.red];
if ((MagickSizeType) pixel.green <= GetQuantumRange(info->depth))
pixel.green=info->scale[pixel.green];
if ((MagickSizeType) pixel.blue <= GetQuantumRange(info->depth))
pixel.blue=info->scale[pixel.blue];
}
}
if (first_segment != MagickFalse)
{
SetPixelRed(image,(Quantum) pixel.red,q);
SetPixelGreen(image,(Quantum) pixel.green,q);
SetPixelBlue(image,(Quantum) pixel.blue,q);
}
else
{
SetPixelRed(image,(Quantum) (((size_t) pixel.red) |
(((size_t) GetPixelRed(image,q)) << 8)),q);
SetPixelGreen(image,(Quantum) (((size_t) pixel.green) |
(((size_t) GetPixelGreen(image,q)) << 8)),q);
SetPixelBlue(image,(Quantum) (((size_t) pixel.blue) |
(((size_t) GetPixelBlue(image,q)) << 8)),q);
}
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
return(status);
} | 0 | [
"CWE-20",
"CWE-252"
] | ImageMagick | 6b6bff054d569a77973f2140c0e86366e6168a6c | 263,209,798,976,031,370,000,000,000,000,000,000,000 | 168 | https://github.com/ImageMagick/ImageMagick/issues/1199 |
compare_keys_by_id(const void *a, const void *b)
{
const Key *c = (const Key *) a;
const Key *d = (const Key *) b;
if (c->id < d->id) {
return -1;
} else if (c->id > d->id) {
return +1;
} else {
return 0;
}
} | 0 | [
"CWE-59"
] | chrony | e18903a6b56341481a2e08469c0602010bf7bfe3 | 283,366,478,290,392,300,000,000,000,000,000,000,000 | 14 | switch to new util file functions
Replace all fopen(), rename(), and unlink() calls with the new util
functions. |
int SaveEXRImageToFile(const EXRImage *exr_image, const EXRHeader *exr_header,
const char *filename, const char **err) {
if (exr_image == NULL || filename == NULL ||
exr_header->compression_type < 0) {
tinyexr::SetErrorMessage("Invalid argument for SaveEXRImageToFile", err);
return TINYEXR_ERROR_INVALID_ARGUMENT;
}
#if !TINYEXR_USE_PIZ
if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_PIZ) {
tinyexr::SetErrorMessage("PIZ compression is not supported in this build",
err);
return TINYEXR_ERROR_UNSUPPORTED_FEATURE;
}
#endif
#if !TINYEXR_USE_ZFP
if (exr_header->compression_type == TINYEXR_COMPRESSIONTYPE_ZFP) {
tinyexr::SetErrorMessage("ZFP compression is not supported in this build",
err);
return TINYEXR_ERROR_UNSUPPORTED_FEATURE;
}
#endif
#ifdef _WIN32
FILE *fp = NULL;
fopen_s(&fp, filename, "wb");
#else
FILE *fp = fopen(filename, "wb");
#endif
if (!fp) {
tinyexr::SetErrorMessage("Cannot write a file", err);
return TINYEXR_ERROR_CANT_WRITE_FILE;
}
unsigned char *mem = NULL;
size_t mem_size = SaveEXRImageToMemory(exr_image, exr_header, &mem, err);
if (mem_size == 0) {
return TINYEXR_ERROR_SERIALZATION_FAILED;
}
size_t written_size = 0;
if ((mem_size > 0) && mem) {
written_size = fwrite(mem, 1, mem_size, fp);
}
free(mem);
fclose(fp);
if (written_size != mem_size) {
tinyexr::SetErrorMessage("Cannot write a file", err);
return TINYEXR_ERROR_CANT_WRITE_FILE;
}
return TINYEXR_SUCCESS;
} | 0 | [
"CWE-20",
"CWE-190"
] | tinyexr | a685e3332f61cd4e59324bf3f669d36973d64270 | 153,623,393,625,513,420,000,000,000,000,000,000,000 | 56 | Make line_no with too large value(2**20) invalid. Fixes #124 |
cdp_decode(struct lldpd *cfg, char *frame, int s,
struct lldpd_hardware *hardware,
struct lldpd_chassis **newchassis, struct lldpd_port **newport)
{
struct lldpd_chassis *chassis;
struct lldpd_port *port;
struct lldpd_mgmt *mgmt;
struct in_addr addr;
#if 0
u_int16_t cksum;
#endif
u_int8_t *software = NULL, *platform = NULL;
int software_len = 0, platform_len = 0, proto, version, nb, caps;
const unsigned char cdpaddr[] = CDP_MULTICAST_ADDR;
#ifdef ENABLE_FDP
const unsigned char fdpaddr[] = CDP_MULTICAST_ADDR;
int fdp = 0;
#endif
u_int8_t *pos, *tlv, *pos_address, *pos_next_address;
int length, len_eth, tlv_type, tlv_len, addresses_len, address_len;
#ifdef ENABLE_DOT1
struct lldpd_vlan *vlan;
#endif
log_debug("cdp", "decode CDP frame received on %s",
hardware->h_ifname);
if ((chassis = calloc(1, sizeof(struct lldpd_chassis))) == NULL) {
log_warn("cdp", "failed to allocate remote chassis");
return -1;
}
TAILQ_INIT(&chassis->c_mgmt);
if ((port = calloc(1, sizeof(struct lldpd_port))) == NULL) {
log_warn("cdp", "failed to allocate remote port");
free(chassis);
return -1;
}
#ifdef ENABLE_DOT1
TAILQ_INIT(&port->p_vlans);
#endif
length = s;
pos = (u_int8_t*)frame;
if (length < 2*ETHER_ADDR_LEN + sizeof(u_int16_t) /* Ethernet */ +
8 /* LLC */ + 4 /* CDP header */) {
log_warn("cdp", "too short CDP/FDP frame received on %s", hardware->h_ifname);
goto malformed;
}
if (PEEK_CMP(cdpaddr, sizeof(cdpaddr)) != 0) {
#ifdef ENABLE_FDP
PEEK_RESTORE((u_int8_t*)frame);
if (PEEK_CMP(fdpaddr, sizeof(fdpaddr)) != 0)
fdp = 1;
else {
#endif
log_info("cdp", "frame not targeted at CDP/FDP multicast address received on %s",
hardware->h_ifname);
goto malformed;
#ifdef ENABLE_FDP
}
#endif
}
PEEK_DISCARD(ETHER_ADDR_LEN); /* Don't care of source address */
len_eth = PEEK_UINT16;
if (len_eth > length) {
log_warnx("cdp", "incorrect 802.3 frame size reported on %s",
hardware->h_ifname);
goto malformed;
}
PEEK_DISCARD(6); /* Skip beginning of LLC */
proto = PEEK_UINT16;
if (proto != LLC_PID_CDP) {
if ((proto != LLC_PID_DRIP) &&
(proto != LLC_PID_PAGP) &&
(proto != LLC_PID_PVSTP) &&
(proto != LLC_PID_UDLD) &&
(proto != LLC_PID_VTP) &&
(proto != LLC_PID_DTP) &&
(proto != LLC_PID_STP))
log_debug("cdp", "incorrect LLC protocol ID received on %s",
hardware->h_ifname);
goto malformed;
}
#if 0
/* Check checksum */
cksum = frame_checksum(pos, len_eth - 8,
#ifdef ENABLE_FDP
!fdp /* fdp = 0 -> cisco checksum */
#else
1 /* cisco checksum */
#endif
);
if (cksum != 0) {
log_info("cdp", "incorrect CDP/FDP checksum for frame received on %s (%d)",
hardware->h_ifname, cksum);
goto malformed;
}
#endif
/* Check version */
version = PEEK_UINT8;
if ((version != 1) && (version != 2)) {
log_warnx("cdp", "incorrect CDP/FDP version (%d) for frame received on %s",
version, hardware->h_ifname);
goto malformed;
}
chassis->c_ttl = PEEK_UINT8; /* TTL */
PEEK_DISCARD_UINT16; /* Checksum, already checked */
while (length) {
if (length < 4) {
log_warnx("cdp", "CDP/FDP TLV header is too large for "
"frame received on %s",
hardware->h_ifname);
goto malformed;
}
tlv_type = PEEK_UINT16;
tlv_len = PEEK_UINT16 - 4;
(void)PEEK_SAVE(tlv);
if ((tlv_len < 0) || (length < tlv_len)) {
log_warnx("cdp", "incorrect size in CDP/FDP TLV header for frame "
"received on %s",
hardware->h_ifname);
goto malformed;
}
switch (tlv_type) {
case CDP_TLV_CHASSIS:
if ((chassis->c_name = (char *)calloc(1, tlv_len + 1)) == NULL) {
log_warn("cdp", "unable to allocate memory for chassis name");
goto malformed;
}
PEEK_BYTES(chassis->c_name, tlv_len);
chassis->c_id_subtype = LLDP_CHASSISID_SUBTYPE_LOCAL;
if ((chassis->c_id = (char *)malloc(tlv_len)) == NULL) {
log_warn("cdp", "unable to allocate memory for chassis ID");
goto malformed;
}
memcpy(chassis->c_id, chassis->c_name, tlv_len);
chassis->c_id_len = tlv_len;
break;
case CDP_TLV_ADDRESSES:
CHECK_TLV_SIZE(4, "Address");
addresses_len = tlv_len - 4;
for (nb = PEEK_UINT32; nb > 0; nb--) {
(void)PEEK_SAVE(pos_address);
/* We first try to get the real length of the packet */
if (addresses_len < 2) {
log_warn("cdp", "too short address subframe "
"received on %s",
hardware->h_ifname);
goto malformed;
}
PEEK_DISCARD_UINT8; addresses_len--;
address_len = PEEK_UINT8; addresses_len--;
if (addresses_len < address_len + 2) {
log_warn("cdp", "too short address subframe "
"received on %s",
hardware->h_ifname);
goto malformed;
}
PEEK_DISCARD(address_len);
addresses_len -= address_len;
address_len = PEEK_UINT16; addresses_len -= 2;
if (addresses_len < address_len) {
log_warn("cdp", "too short address subframe "
"received on %s",
hardware->h_ifname);
goto malformed;
}
PEEK_DISCARD(address_len);
(void)PEEK_SAVE(pos_next_address);
/* Next, we go back and try to extract
IPv4 address */
PEEK_RESTORE(pos_address);
if ((PEEK_UINT8 == 1) && (PEEK_UINT8 == 1) &&
(PEEK_UINT8 == CDP_ADDRESS_PROTO_IP) &&
(PEEK_UINT16 == sizeof(struct in_addr))) {
PEEK_BYTES(&addr, sizeof(struct in_addr));
mgmt = lldpd_alloc_mgmt(LLDPD_AF_IPV4, &addr,
sizeof(struct in_addr), 0);
if (mgmt == NULL) {
if (errno == ENOMEM)
log_warn("cdp",
"unable to allocate memory for management address");
else
log_warn("cdp",
"too large management address received on %s",
hardware->h_ifname);
goto malformed;
}
TAILQ_INSERT_TAIL(&chassis->c_mgmt, mgmt, m_entries);
}
/* Go to the end of the address */
PEEK_RESTORE(pos_next_address);
}
break;
case CDP_TLV_PORT:
if (tlv_len == 0) {
log_warn("cdp", "too short port description received");
goto malformed;
}
if ((port->p_descr = (char *)calloc(1, tlv_len + 1)) == NULL) {
log_warn("cdp", "unable to allocate memory for port description");
goto malformed;
}
PEEK_BYTES(port->p_descr, tlv_len);
port->p_id_subtype = LLDP_PORTID_SUBTYPE_IFNAME;
if ((port->p_id = (char *)calloc(1, tlv_len)) == NULL) {
log_warn("cdp", "unable to allocate memory for port ID");
goto malformed;
}
memcpy(port->p_id, port->p_descr, tlv_len);
port->p_id_len = tlv_len;
break;
case CDP_TLV_CAPABILITIES:
#ifdef ENABLE_FDP
if (fdp) {
/* Capabilities are string with FDP */
if (!strncmp("Router", (char*)pos, tlv_len))
chassis->c_cap_enabled = LLDP_CAP_ROUTER;
else if (!strncmp("Switch", (char*)pos, tlv_len))
chassis->c_cap_enabled = LLDP_CAP_BRIDGE;
else if (!strncmp("Bridge", (char*)pos, tlv_len))
chassis->c_cap_enabled = LLDP_CAP_REPEATER;
else
chassis->c_cap_enabled = LLDP_CAP_STATION;
chassis->c_cap_available = chassis->c_cap_enabled;
break;
}
#endif
CHECK_TLV_SIZE(4, "Capabilities");
caps = PEEK_UINT32;
if (caps & CDP_CAP_ROUTER)
chassis->c_cap_enabled |= LLDP_CAP_ROUTER;
if (caps & 0x0e)
chassis->c_cap_enabled |= LLDP_CAP_BRIDGE;
if (chassis->c_cap_enabled == 0)
chassis->c_cap_enabled = LLDP_CAP_STATION;
chassis->c_cap_available = chassis->c_cap_enabled;
break;
case CDP_TLV_SOFTWARE:
software_len = tlv_len;
(void)PEEK_SAVE(software);
break;
case CDP_TLV_PLATFORM:
platform_len = tlv_len;
(void)PEEK_SAVE(platform);
break;
#ifdef ENABLE_DOT1
case CDP_TLV_NATIVEVLAN:
CHECK_TLV_SIZE(2, "Native VLAN");
if ((vlan = (struct lldpd_vlan *)calloc(1,
sizeof(struct lldpd_vlan))) == NULL) {
log_warn("cdp", "unable to alloc vlan "
"structure for "
"tlv received on %s",
hardware->h_ifname);
goto malformed;
}
vlan->v_vid = port->p_pvid = PEEK_UINT16;
if (asprintf(&vlan->v_name, "VLAN #%d", vlan->v_vid) == -1) {
log_warn("cdp", "unable to alloc VLAN name for "
"TLV received on %s",
hardware->h_ifname);
free(vlan);
goto malformed;
}
TAILQ_INSERT_TAIL(&port->p_vlans,
vlan, v_entries);
break;
#endif
default:
log_debug("cdp", "unknown CDP/FDP TLV type (%d) received on %s",
ntohs(tlv_type), hardware->h_ifname);
hardware->h_rx_unrecognized_cnt++;
}
PEEK_DISCARD(tlv + tlv_len - pos);
}
if (!software && platform) {
if ((chassis->c_descr = (char *)calloc(1,
platform_len + 1)) == NULL) {
log_warn("cdp", "unable to allocate memory for chassis description");
goto malformed;
}
memcpy(chassis->c_descr, platform, platform_len);
} else if (software && !platform) {
if ((chassis->c_descr = (char *)calloc(1,
software_len + 1)) == NULL) {
log_warn("cdp", "unable to allocate memory for chassis description");
goto malformed;
}
memcpy(chassis->c_descr, software, software_len);
} else if (software && platform) {
#define CONCAT_PLATFORM " running on\n"
if ((chassis->c_descr = (char *)calloc(1,
software_len + platform_len +
strlen(CONCAT_PLATFORM) + 1)) == NULL) {
log_warn("cdp", "unable to allocate memory for chassis description");
goto malformed;
}
memcpy(chassis->c_descr, platform, platform_len);
memcpy(chassis->c_descr + platform_len,
CONCAT_PLATFORM, strlen(CONCAT_PLATFORM));
memcpy(chassis->c_descr + platform_len + strlen(CONCAT_PLATFORM),
software, software_len);
}
if ((chassis->c_id == NULL) ||
(port->p_id == NULL) ||
(chassis->c_name == NULL) ||
(chassis->c_descr == NULL) ||
(port->p_descr == NULL) ||
(chassis->c_ttl == 0) ||
(chassis->c_cap_enabled == 0)) {
log_warnx("cdp", "some mandatory CDP/FDP tlv are missing for frame received on %s",
hardware->h_ifname);
goto malformed;
}
*newchassis = chassis;
*newport = port;
return 1;
malformed:
lldpd_chassis_cleanup(chassis, 1);
lldpd_port_cleanup(port, 1);
free(port);
return -1;
} | 0 | [
"CWE-617",
"CWE-703"
] | lldpd | 9221b5c249f9e4843f77c7f888d5705348d179c0 | 81,913,992,854,605,855,000,000,000,000,000,000,000 | 330 | protocols: don't use assert on paths that can be reached
Malformed packets should not make lldpd crash. Ensure we can handle them
by not using assert() in this part. |
DLLIMPORT cfg_t *cfg_gettsec(cfg_t *cfg, const char *name, const char *title)
{
return cfg_opt_gettsec(cfg_getopt(cfg, name), title);
} | 0 | [] | libconfuse | d73777c2c3566fb2647727bb56d9a2295b81669b | 287,293,291,434,719,130,000,000,000,000,000,000,000 | 4 | Fix #163: unterminated username used with getpwnam()
Signed-off-by: Joachim Wiberg <[email protected]> |
TEST_P(SslSocketTest, ClientAuthMultipleCAs) {
const std::string server_ctx_yaml = R"EOF(
common_tls_context:
tls_certificates:
certificate_chain:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_cert.pem"
private_key:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_key.pem"
validation_context:
trusted_ca:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ca_certificates.pem"
)EOF";
envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext server_tls_context;
TestUtility::loadFromYaml(TestEnvironment::substitute(server_ctx_yaml), server_tls_context);
auto server_cfg = std::make_unique<ServerContextConfigImpl>(server_tls_context, factory_context_);
ContextManagerImpl manager(time_system_);
Stats::TestUtil::TestStore server_stats_store;
ServerSslSocketFactory server_ssl_socket_factory(std::move(server_cfg), manager,
server_stats_store, std::vector<std::string>{});
auto socket = std::make_shared<Network::Test::TcpListenSocketImmediateListen>(
Network::Test::getCanonicalLoopbackAddress(GetParam()));
Network::MockTcpListenerCallbacks callbacks;
Network::ListenerPtr listener =
dispatcher_->createListener(socket, callbacks, runtime_, true, false);
const std::string client_ctx_yaml = R"EOF(
common_tls_context:
tls_certificates:
certificate_chain:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/no_san_cert.pem"
private_key:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/no_san_key.pem"
)EOF";
envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext tls_context;
TestUtility::loadFromYaml(TestEnvironment::substitute(client_ctx_yaml), tls_context);
auto client_cfg = std::make_unique<ClientContextConfigImpl>(tls_context, factory_context_);
Stats::TestUtil::TestStore client_stats_store;
ClientSslSocketFactory ssl_socket_factory(std::move(client_cfg), manager, client_stats_store);
Network::ClientConnectionPtr client_connection = dispatcher_->createClientConnection(
socket->connectionInfoProvider().localAddress(), Network::Address::InstanceConstSharedPtr(),
ssl_socket_factory.createTransportSocket(nullptr), nullptr);
// Verify that server sent list with 2 acceptable client certificate CA names.
const SslHandshakerImpl* ssl_socket =
dynamic_cast<const SslHandshakerImpl*>(client_connection->ssl().get());
SSL_set_cert_cb(
ssl_socket->ssl(),
[](SSL* ssl, void*) -> int {
STACK_OF(X509_NAME)* list = SSL_get_client_CA_list(ssl);
EXPECT_NE(nullptr, list);
EXPECT_EQ(2U, sk_X509_NAME_num(list));
return 1;
},
nullptr);
client_connection->connect();
Network::ConnectionPtr server_connection;
Network::MockConnectionCallbacks server_connection_callbacks;
EXPECT_CALL(callbacks, onAccept_(_))
.WillOnce(Invoke([&](Network::ConnectionSocketPtr& socket) -> void {
server_connection = dispatcher_->createServerConnection(
std::move(socket), server_ssl_socket_factory.createTransportSocket(nullptr),
stream_info_);
server_connection->addConnectionCallbacks(server_connection_callbacks);
}));
EXPECT_CALL(server_connection_callbacks, onEvent(Network::ConnectionEvent::Connected))
.WillOnce(Invoke([&](Network::ConnectionEvent) -> void {
server_connection->close(Network::ConnectionCloseType::NoFlush);
client_connection->close(Network::ConnectionCloseType::NoFlush);
dispatcher_->exit();
}));
EXPECT_CALL(server_connection_callbacks, onEvent(Network::ConnectionEvent::LocalClose));
dispatcher_->run(Event::Dispatcher::RunType::Block);
EXPECT_EQ(1UL, server_stats_store.counter("ssl.handshake").value());
} | 0 | [
"CWE-362",
"CWE-295"
] | envoy | e9f936d85dc1edc34fabd0a1725ec180f2316353 | 200,781,096,389,422,470,000,000,000,000,000,000,000 | 82 | CVE-2022-21654
tls allows re-use when some cert validation settings have changed
Signed-off-by: Yan Avlasov <[email protected]> |
Subsets and Splits