func
stringlengths 12
2.67k
| cwe
stringclasses 7
values | __index_level_0__
int64 0
20k
|
---|---|---|
StreamWriteResult StreamBase::Write(
uv_buf_t* bufs,
size_t count,
uv_stream_t* send_handle,
v8::Local<v8::Object> req_wrap_obj) {
Environment* env = stream_env();
int err;
size_t total_bytes = 0;
for (size_t i = 0; i < count; ++i)
total_bytes += bufs[i].len;
bytes_written_ += total_bytes;
if (send_handle == nullptr) {
err = DoTryWrite(&bufs, &count);
if (err != 0 || count == 0) {
return StreamWriteResult { false, err, nullptr, total_bytes };
}
}
v8::HandleScope handle_scope(env->isolate());
if (req_wrap_obj.IsEmpty()) {
if (!env->write_wrap_template()
->NewInstance(env->context())
.ToLocal(&req_wrap_obj)) {
return StreamWriteResult { false, UV_EBUSY, nullptr, 0 };
}
StreamReq::ResetObject(req_wrap_obj);
}
AsyncHooks::DefaultTriggerAsyncIdScope trigger_scope(GetAsyncWrap());
WriteWrap* req_wrap = CreateWriteWrap(req_wrap_obj);
err = DoWrite(req_wrap, bufs, count, send_handle);
bool async = err == 0;
if (!async) {
req_wrap->Dispose();
req_wrap = nullptr;
}
const char* msg = Error();
if (msg != nullptr) {
req_wrap_obj->Set(env->context(),
env->error_string(),
OneByteString(env->isolate(), msg)).Check();
ClearError();
}
return StreamWriteResult { async, err, req_wrap, total_bytes };
}
|
CWE-416
| 18,670 |
int StreamBase::Shutdown(v8::Local<v8::Object> req_wrap_obj) {
Environment* env = stream_env();
v8::HandleScope handle_scope(env->isolate());
if (req_wrap_obj.IsEmpty()) {
if (!env->shutdown_wrap_template()
->NewInstance(env->context())
.ToLocal(&req_wrap_obj)) {
return UV_EBUSY;
}
StreamReq::ResetObject(req_wrap_obj);
}
AsyncHooks::DefaultTriggerAsyncIdScope trigger_scope(GetAsyncWrap());
ShutdownWrap* req_wrap = CreateShutdownWrap(req_wrap_obj);
int err = DoShutdown(req_wrap);
if (err != 0 && req_wrap != nullptr) {
req_wrap->Dispose();
}
const char* msg = Error();
if (msg != nullptr) {
req_wrap_obj->Set(
env->context(),
env->error_string(), OneByteString(env->isolate(), msg)).Check();
ClearError();
}
return err;
}
|
CWE-416
| 18,671 |
int main(int argc, char **argv)
{
int fd;
int ret;
/* Create a temporary raw image */
fd = mkstemp(test_image);
g_assert(fd >= 0);
ret = ftruncate(fd, TEST_IMAGE_SIZE);
g_assert(ret == 0);
close(fd);
/* Run the tests */
g_test_init(&argc, &argv, NULL);
qtest_start("-machine pc -device floppy,id=floppy0");
qtest_irq_intercept_in(global_qtest, "ioapic");
qtest_add_func("/fdc/cmos", test_cmos);
qtest_add_func("/fdc/no_media_on_start", test_no_media_on_start);
qtest_add_func("/fdc/read_without_media", test_read_without_media);
qtest_add_func("/fdc/media_change", test_media_change);
qtest_add_func("/fdc/sense_interrupt", test_sense_interrupt);
qtest_add_func("/fdc/relative_seek", test_relative_seek);
qtest_add_func("/fdc/read_id", test_read_id);
qtest_add_func("/fdc/verify", test_verify);
qtest_add_func("/fdc/media_insert", test_media_insert);
qtest_add_func("/fdc/read_no_dma_1", test_read_no_dma_1);
qtest_add_func("/fdc/read_no_dma_18", test_read_no_dma_18);
qtest_add_func("/fdc/read_no_dma_19", test_read_no_dma_19);
qtest_add_func("/fdc/fuzz-registers", fuzz_registers);
qtest_add_func("/fdc/fuzz/cve_2021_20196", test_cve_2021_20196);
ret = g_test_run();
/* Cleanup */
qtest_end();
unlink(test_image);
return ret;
}
|
CWE-787
| 18,689 |
void Http2Stream::SubmitRstStream(const uint32_t code) {
CHECK(!this->is_destroyed());
code_ = code;
// If RST_STREAM frame is received and stream is not writable
// because it is busy reading data, don't try force purging it.
// Instead add the stream to pending stream list and process
// the pending data when it is safe to do so. This is to avoid
// double free error due to unwanted behavior of nghttp2.
// Ref:https://github.com/nodejs/node/issues/38964
// Add stream to the pending list if it is received with scope
// below in the stack. The pending list may not get processed
// if RST_STREAM received is not in scope and added to the list
// causing endpoint to hang.
if (session_->is_in_scope() &&
!is_writable() && is_reading()) {
session_->AddPendingRstStream(id_);
return;
}
// If possible, force a purge of any currently pending data here to make sure
// it is sent before closing the stream. If it returns non-zero then we need
// to wait until the current write finishes and try again to avoid nghttp2
// behaviour where it prioritizes RstStream over everything else.
if (session_->SendPendingData() != 0) {
session_->AddPendingRstStream(id_);
return;
}
FlushRstStream();
}
|
CWE-416
| 18,717 |
int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki)
{
EVP_PKEY *pkey;
ASN1_IA5STRING *chal;
ASN1_OBJECT *spkioid;
int i, n;
char *s;
BIO_printf(out, "Netscape SPKI:\n");
X509_PUBKEY_get0_param(&spkioid, NULL, NULL, NULL, spki->spkac->pubkey);
i = OBJ_obj2nid(spkioid);
BIO_printf(out, " Public Key Algorithm: %s\n",
(i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i));
pkey = X509_PUBKEY_get(spki->spkac->pubkey);
if (!pkey)
BIO_printf(out, " Unable to load public key\n");
else {
EVP_PKEY_print_public(out, pkey, 4, NULL);
EVP_PKEY_free(pkey);
}
chal = spki->spkac->challenge;
if (chal->length)
BIO_printf(out, " Challenge String: %s\n", chal->data);
i = OBJ_obj2nid(spki->sig_algor.algorithm);
BIO_printf(out, " Signature Algorithm: %s",
(i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i));
n = spki->signature->length;
s = (char *)spki->signature->data;
for (i = 0; i < n; i++) {
if ((i % 18) == 0)
BIO_write(out, "\n ", 7);
BIO_printf(out, "%02x%s", (unsigned char)s[i],
((i + 1) == n) ? "" : ":");
}
BIO_write(out, "\n", 1);
return 1;
}
|
CWE-125
| 18,722 |
static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, const ASN1_IA5STRING *email)
{
char *emtmp;
/* First some sanity checks */
if (email->type != V_ASN1_IA5STRING)
return 1;
if (!email->data || !email->length)
return 1;
if (*sk == NULL)
*sk = sk_OPENSSL_STRING_new(sk_strcmp);
if (*sk == NULL)
return 0;
/* Don't add duplicates */
if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1)
return 1;
emtmp = OPENSSL_strdup((char *)email->data);
if (emtmp == NULL || !sk_OPENSSL_STRING_push(*sk, emtmp)) {
OPENSSL_free(emtmp); /* free on push failure */
X509_email_free(*sk);
*sk = NULL;
return 0;
}
return 1;
}
|
CWE-125
| 18,723 |
static int test_x509_time(int idx)
{
ASN1_TIME *t = NULL;
int result, rv = 0;
if (x509_format_tests[idx].set_string) {
/* set-string mode */
t = ASN1_TIME_new();
if (t == NULL) {
TEST_info("test_x509_time(%d) failed: internal error\n", idx);
return 0;
}
}
result = ASN1_TIME_set_string_X509(t, x509_format_tests[idx].data);
/* time string parsing result is always checked against what's expected */
if (!TEST_int_eq(result, x509_format_tests[idx].expected)) {
TEST_info("test_x509_time(%d) failed: expected %d, got %d\n",
idx, x509_format_tests[idx].expected, result);
goto out;
}
/* if t is not NULL but expected_type is ignored(-1), it is an 'OK' case */
if (t != NULL && x509_format_tests[idx].expected_type != -1) {
if (!TEST_int_eq(t->type, x509_format_tests[idx].expected_type)) {
TEST_info("test_x509_time(%d) failed: expected_type %d, got %d\n",
idx, x509_format_tests[idx].expected_type, t->type);
goto out;
}
}
/* if t is not NULL but expected_string is NULL, it is an 'OK' case too */
if (t != NULL && x509_format_tests[idx].expected_string) {
if (!TEST_str_eq((const char *)t->data,
x509_format_tests[idx].expected_string)) {
TEST_info("test_x509_time(%d) failed: expected_string %s, got %s\n",
idx, x509_format_tests[idx].expected_string, t->data);
goto out;
}
}
rv = 1;
out:
if (t != NULL)
ASN1_TIME_free(t);
return rv;
}
|
CWE-125
| 18,724 |
static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base)
{
const char *baseptr = (char *)base->data;
const char *hostptr = (char *)uri->data;
const char *p = strchr(hostptr, ':');
int hostlen;
/* Check for foo:// and skip past it */
if (!p || (p[1] != '/') || (p[2] != '/'))
return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX;
hostptr = p + 3;
/* Determine length of hostname part of URI */
/* Look for a port indicator as end of hostname first */
p = strchr(hostptr, ':');
/* Otherwise look for trailing slash */
if (!p)
p = strchr(hostptr, '/');
if (!p)
hostlen = strlen(hostptr);
else
hostlen = p - hostptr;
if (hostlen == 0)
return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX;
/* Special case: initial '.' is RHS match */
if (*baseptr == '.') {
if (hostlen > base->length) {
p = hostptr + hostlen - base->length;
if (ia5ncasecmp(p, baseptr, base->length) == 0)
return X509_V_OK;
}
return X509_V_ERR_PERMITTED_VIOLATION;
}
if ((base->length != (int)hostlen)
|| ia5ncasecmp(hostptr, baseptr, hostlen))
return X509_V_ERR_PERMITTED_VIOLATION;
return X509_V_OK;
}
|
CWE-125
| 18,725 |
static int ia5ncasecmp(const char *s1, const char *s2, size_t n)
{
for (; n > 0; n--, s1++, s2++) {
if (*s1 != *s2) {
unsigned char c1 = (unsigned char)*s1, c2 = (unsigned char)*s2;
/* Convert to lower case */
if (c1 >= 0x41 /* A */ && c1 <= 0x5A /* Z */)
c1 += 0x20;
if (c2 >= 0x41 /* A */ && c2 <= 0x5A /* Z */)
c2 += 0x20;
if (c1 == c2)
continue;
if (c1 < c2)
return -1;
/* c1 > c2 */
return 1;
} else if (*s1 == 0) {
/* If we get here we know that *s2 == 0 too */
return 0;
}
}
return 0;
}
|
CWE-125
| 18,726 |
static int ia5casecmp(const char *s1, const char *s2)
{
return ia5ncasecmp(s1, s2, SIZE_MAX);
}
|
CWE-125
| 18,727 |
static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base)
{
char *baseptr = (char *)base->data;
char *dnsptr = (char *)dns->data;
/* Empty matches everything */
if (!*baseptr)
return X509_V_OK;
/*
* Otherwise can add zero or more components on the left so compare RHS
* and if dns is longer and expect '.' as preceding character.
*/
if (dns->length > base->length) {
dnsptr += dns->length - base->length;
if (*baseptr != '.' && dnsptr[-1] != '.')
return X509_V_ERR_PERMITTED_VIOLATION;
}
if (ia5casecmp(baseptr, dnsptr))
return X509_V_ERR_PERMITTED_VIOLATION;
return X509_V_OK;
}
|
CWE-125
| 18,728 |
static int nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base)
{
const char *baseptr = (char *)base->data;
const char *emlptr = (char *)eml->data;
const char *baseat = strchr(baseptr, '@');
const char *emlat = strchr(emlptr, '@');
if (!emlat)
return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX;
/* Special case: initial '.' is RHS match */
if (!baseat && (*baseptr == '.')) {
if (eml->length > base->length) {
emlptr += eml->length - base->length;
if (ia5casecmp(baseptr, emlptr) == 0)
return X509_V_OK;
}
return X509_V_ERR_PERMITTED_VIOLATION;
}
/* If we have anything before '@' match local part */
if (baseat) {
if (baseat != baseptr) {
if ((baseat - baseptr) != (emlat - emlptr))
return X509_V_ERR_PERMITTED_VIOLATION;
/* Case sensitive match of local part */
if (strncmp(baseptr, emlptr, emlat - emlptr))
return X509_V_ERR_PERMITTED_VIOLATION;
}
/* Position base after '@' */
baseptr = baseat + 1;
}
emlptr = emlat + 1;
/* Just have hostname left to match: case insensitive */
if (ia5casecmp(baseptr, emlptr))
return X509_V_ERR_PERMITTED_VIOLATION;
return X509_V_OK;
}
|
CWE-125
| 18,730 |
static int i2r_pci(X509V3_EXT_METHOD *method, PROXY_CERT_INFO_EXTENSION *pci,
BIO *out, int indent)
{
BIO_printf(out, "%*sPath Length Constraint: ", indent, "");
if (pci->pcPathLengthConstraint)
i2a_ASN1_INTEGER(out, pci->pcPathLengthConstraint);
else
BIO_printf(out, "infinite");
BIO_puts(out, "\n");
BIO_printf(out, "%*sPolicy Language: ", indent, "");
i2a_ASN1_OBJECT(out, pci->proxyPolicy->policyLanguage);
BIO_puts(out, "\n");
if (pci->proxyPolicy->policy && pci->proxyPolicy->policy->data)
BIO_printf(out, "%*sPolicy Text: %s\n", indent, "",
pci->proxyPolicy->policy->data);
return 1;
}
|
CWE-125
| 18,731 |
static void print_qualifiers(BIO *out, STACK_OF(POLICYQUALINFO) *quals,
int indent)
{
POLICYQUALINFO *qualinfo;
int i;
for (i = 0; i < sk_POLICYQUALINFO_num(quals); i++) {
qualinfo = sk_POLICYQUALINFO_value(quals, i);
switch (OBJ_obj2nid(qualinfo->pqualid)) {
case NID_id_qt_cps:
BIO_printf(out, "%*sCPS: %s\n", indent, "",
qualinfo->d.cpsuri->data);
break;
case NID_id_qt_unotice:
BIO_printf(out, "%*sUser Notice:\n", indent, "");
print_notice(out, qualinfo->d.usernotice, indent + 2);
break;
default:
BIO_printf(out, "%*sUnknown Qualifier: ", indent + 2, "");
i2a_ASN1_OBJECT(out, qualinfo->pqualid);
BIO_puts(out, "\n");
break;
}
}
}
|
CWE-125
| 18,732 |
static void print_notice(BIO *out, USERNOTICE *notice, int indent)
{
int i;
if (notice->noticeref) {
NOTICEREF *ref;
ref = notice->noticeref;
BIO_printf(out, "%*sOrganization: %s\n", indent, "",
ref->organization->data);
BIO_printf(out, "%*sNumber%s: ", indent, "",
sk_ASN1_INTEGER_num(ref->noticenos) > 1 ? "s" : "");
for (i = 0; i < sk_ASN1_INTEGER_num(ref->noticenos); i++) {
ASN1_INTEGER *num;
char *tmp;
num = sk_ASN1_INTEGER_value(ref->noticenos, i);
if (i)
BIO_puts(out, ", ");
if (num == NULL)
BIO_puts(out, "(null)");
else {
tmp = i2s_ASN1_INTEGER(NULL, num);
if (tmp == NULL)
return;
BIO_puts(out, tmp);
OPENSSL_free(tmp);
}
}
BIO_puts(out, "\n");
}
if (notice->exptext)
BIO_printf(out, "%*sExplicit Text: %s\n", indent, "",
notice->exptext->data);
}
|
CWE-125
| 18,733 |
static bool fix_all_session_vcol_exprs(THD *thd, TABLE_LIST *tables)
{
Security_context *save_security_ctx= thd->security_ctx;
TABLE_LIST *first_not_own= thd->lex->first_not_own_table();
DBUG_ENTER("fix_session_vcol_expr");
int error= 0;
for (TABLE_LIST *table= tables; table && table != first_not_own && !error;
table= table->next_global)
{
TABLE *t= table->table;
if (!table->placeholder() && t->s->vcols_need_refixing &&
table->lock_type >= TL_WRITE_ALLOW_WRITE)
{
Query_arena *stmt_backup= thd->stmt_arena;
if (thd->stmt_arena->is_conventional())
thd->stmt_arena= t->expr_arena;
if (table->security_ctx)
thd->security_ctx= table->security_ctx;
error= t->fix_vcol_exprs(thd);
thd->security_ctx= save_security_ctx;
thd->stmt_arena= stmt_backup;
}
}
DBUG_RETURN(error);
}
|
CWE-416
| 18,824 |
static bool fix_vcol_expr(THD *thd, Virtual_column_info *vcol)
{
DBUG_ENTER("fix_vcol_expr");
const enum enum_column_usage saved_column_usage= thd->column_usage;
thd->column_usage= COLUMNS_WRITE;
int error= vcol->expr->fix_fields(thd, &vcol->expr);
thd->column_usage= saved_column_usage;
if (unlikely(error))
{
StringBuffer<MAX_FIELD_WIDTH> str;
vcol->print(&str);
my_error(ER_ERROR_EVALUATING_EXPRESSION, MYF(0), str.c_ptr_safe());
DBUG_RETURN(1);
}
DBUG_RETURN(0);
}
|
CWE-416
| 18,827 |
bool fix_session_vcol_expr(THD *thd, Virtual_column_info *vcol)
{
DBUG_ENTER("fix_session_vcol_expr");
if (!(vcol->flags & (VCOL_TIME_FUNC|VCOL_SESSION_FUNC)))
DBUG_RETURN(0);
vcol->expr->walk(&Item::cleanup_excluding_fields_processor, 0, 0);
DBUG_ASSERT(!vcol->expr->fixed);
DBUG_RETURN(fix_vcol_expr(thd, vcol));
}
|
CWE-416
| 18,829 |
static bool mysql_drop_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
{
char path[FN_REFLEN+1];
partition_info *part_info= lpt->table->part_info;
List_iterator<partition_element> part_it(part_info->partitions);
uint i= 0;
uint remove_count= 0;
int error;
DBUG_ENTER("mysql_drop_partitions");
DBUG_ASSERT(lpt->thd->mdl_context.is_lock_owner(MDL_key::TABLE,
lpt->table->s->db.str,
lpt->table->s->table_name.str,
MDL_EXCLUSIVE));
build_table_filename(path, sizeof(path) - 1, lpt->db.str, lpt->table_name.str, "", 0);
if ((error= lpt->table->file->ha_drop_partitions(path)))
{
lpt->table->file->print_error(error, MYF(0));
DBUG_RETURN(TRUE);
}
do
{
partition_element *part_elem= part_it++;
if (part_elem->part_state == PART_IS_DROPPED)
{
part_it.remove();
remove_count++;
}
} while (++i < part_info->num_parts);
part_info->num_parts-= remove_count;
DBUG_RETURN(FALSE);
}
|
CWE-416
| 18,831 |
bool fix_session_vcol_expr_for_read(THD *thd, Field *field,
Virtual_column_info *vcol)
{
DBUG_ENTER("fix_session_vcol_expr_for_read");
TABLE_LIST *tl= field->table->pos_in_table_list;
if (!tl || tl->lock_type >= TL_WRITE_ALLOW_WRITE)
DBUG_RETURN(0);
Security_context *save_security_ctx= thd->security_ctx;
if (tl->security_ctx)
thd->security_ctx= tl->security_ctx;
bool res= fix_session_vcol_expr(thd, vcol);
thd->security_ctx= save_security_ctx;
DBUG_RETURN(res);
}
|
CWE-416
| 18,833 |
int TABLE::fix_vcol_exprs(THD *thd)
{
for (Field **vf= vfield; vf && *vf; vf++)
if (fix_session_vcol_expr(thd, (*vf)->vcol_info))
return 1;
for (Field **df= default_field; df && *df; df++)
if ((*df)->default_value &&
fix_session_vcol_expr(thd, (*df)->default_value))
return 1;
for (Virtual_column_info **cc= check_constraints; cc && *cc; cc++)
if (fix_session_vcol_expr(thd, (*cc)))
return 1;
return 0;
}
|
CWE-416
| 18,834 |
static bool check_vcol_forward_refs(Field *field, Virtual_column_info *vcol,
bool check_constraint)
{
bool res;
uint32 flags= field->flags;
if (check_constraint)
{
/* Check constraints can refer it itself */
field->flags|= NO_DEFAULT_VALUE_FLAG;
}
res= (vcol &&
vcol->expr->walk(&Item::check_field_expression_processor, 0, field));
field->flags= flags;
return res;
}
|
CWE-416
| 18,837 |
void close_thread_table(THD *thd, TABLE **table_ptr)
{
TABLE *table= *table_ptr;
DBUG_ENTER("close_thread_table");
DBUG_PRINT("tcache", ("table: '%s'.'%s' %p", table->s->db.str,
table->s->table_name.str, table));
DBUG_ASSERT(!table->file->keyread_enabled());
DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
/*
The metadata lock must be released after giving back
the table to the table cache.
*/
DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE,
table->s->db.str,
table->s->table_name.str,
MDL_SHARED));
table->mdl_ticket= NULL;
if (table->file)
{
table->file->update_global_table_stats();
table->file->update_global_index_stats();
}
/*
This look is needed to allow THD::notify_shared_lock() to
traverse the thd->open_tables list without having to worry that
some of the tables are removed from under it
*/
mysql_mutex_lock(&thd->LOCK_thd_data);
*table_ptr=table->next;
mysql_mutex_unlock(&thd->LOCK_thd_data);
if (! table->needs_reopen())
{
/* Avoid having MERGE tables with attached children in table cache. */
table->file->extra(HA_EXTRA_DETACH_CHILDREN);
/* Free memory and reset for next loop. */
free_field_buffers_larger_than(table, MAX_TDC_BLOB_SIZE);
table->file->ha_reset();
}
/*
Do this *before* entering the TABLE_SHARE::tdc.LOCK_table_share
critical section.
*/
MYSQL_UNBIND_TABLE(table->file);
tc_release_table(table);
DBUG_VOID_RETURN;
}
|
CWE-416
| 18,838 |
int TABLE::update_virtual_field(Field *vf)
{
DBUG_ENTER("TABLE::update_virtual_field");
Query_arena backup_arena;
Counting_error_handler count_errors;
in_use->push_internal_handler(&count_errors);
in_use->set_n_backup_active_arena(expr_arena, &backup_arena);
bitmap_clear_all(&tmp_set);
vf->vcol_info->expr->walk(&Item::update_vcol_processor, 0, &tmp_set);
vf->vcol_info->expr->save_in_field(vf, 0);
in_use->restore_active_arena(expr_arena, &backup_arena);
in_use->pop_internal_handler();
DBUG_RETURN(count_errors.errors);
}
|
CWE-416
| 18,839 |
Event_db_repository::open_event_table(THD *thd, enum thr_lock_type lock_type,
TABLE **table)
{
TABLE_LIST tables;
DBUG_ENTER("Event_db_repository::open_event_table");
tables.init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_EVENT_NAME, 0, lock_type);
if (open_and_lock_tables(thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT))
DBUG_RETURN(TRUE);
*table= tables.table;
tables.table->use_all_columns();
if (table_intact.check(*table, &event_table_def))
{
close_thread_tables(thd);
my_error(ER_EVENT_OPEN_TABLE_FAILED, MYF(0));
DBUG_RETURN(TRUE);
}
DBUG_RETURN(FALSE);
}
|
CWE-416
| 18,841 |
bool Virtual_column_info::fix_session_expr(THD *thd)
{
DBUG_ENTER("fix_session_vcol_expr");
if (!(flags & (VCOL_TIME_FUNC|VCOL_SESSION_FUNC)))
DBUG_RETURN(0);
expr->walk(&Item::cleanup_excluding_fields_processor, 0, 0);
DBUG_ASSERT(!expr->fixed);
DBUG_RETURN(fix_expr(thd));
}
|
CWE-416
| 18,843 |
bool TABLE::vcol_fix_exprs(THD *thd)
{
if (pos_in_table_list->placeholder() || !s->vcols_need_refixing ||
pos_in_table_list->lock_type < TL_WRITE_ALLOW_WRITE)
return false;
DBUG_ASSERT(pos_in_table_list != thd->lex->first_not_own_table());
bool result= true;
Security_context *save_security_ctx= thd->security_ctx;
Query_arena *stmt_backup= thd->stmt_arena;
if (thd->stmt_arena->is_conventional())
thd->stmt_arena= expr_arena;
if (pos_in_table_list->security_ctx)
thd->security_ctx= pos_in_table_list->security_ctx;
for (Field **vf= vfield; vf && *vf; vf++)
if ((*vf)->vcol_info->fix_session_expr(thd))
goto end;
for (Field **df= default_field; df && *df; df++)
if ((*df)->default_value &&
(*df)->default_value->fix_session_expr(thd))
goto end;
for (Virtual_column_info **cc= check_constraints; cc && *cc; cc++)
if ((*cc)->fix_session_expr(thd))
goto end;
result= false;
end:
thd->security_ctx= save_security_ctx;
thd->stmt_arena= stmt_backup;
return result;
}
|
CWE-416
| 18,845 |
int TABLE::update_default_fields(bool ignore_errors)
{
Query_arena backup_arena;
Field **field_ptr;
int res= 0;
DBUG_ENTER("TABLE::update_default_fields");
DBUG_ASSERT(default_field);
in_use->set_n_backup_active_arena(expr_arena, &backup_arena);
/* Iterate over fields with default functions in the table */
for (field_ptr= default_field; *field_ptr ; field_ptr++)
{
Field *field= (*field_ptr);
/*
If an explicit default value for a field overrides the default,
do not update the field with its automatic default value.
*/
if (!field->has_explicit_value())
{
if (field->default_value &&
(field->default_value->flags || field->flags & BLOB_FLAG))
res|= (field->default_value->expr->save_in_field(field, 0) < 0);
if (!ignore_errors && res)
{
my_error(ER_CALCULATING_DEFAULT_VALUE, MYF(0), field->field_name.str);
break;
}
res= 0;
}
}
in_use->restore_active_arena(expr_arena, &backup_arena);
DBUG_RETURN(res);
}
|
CWE-416
| 18,847 |
bool Virtual_column_info::fix_session_expr_for_read(THD *thd, Field *field)
{
DBUG_ENTER("fix_session_vcol_expr_for_read");
TABLE_LIST *tl= field->table->pos_in_table_list;
if (!tl || tl->lock_type >= TL_WRITE_ALLOW_WRITE)
DBUG_RETURN(0);
Security_context *save_security_ctx= thd->security_ctx;
if (tl->security_ctx)
thd->security_ctx= tl->security_ctx;
bool res= fix_session_expr(thd);
thd->security_ctx= save_security_ctx;
DBUG_RETURN(res);
}
|
CWE-416
| 18,848 |
int Field::set_default()
{
if (default_value)
{
Query_arena backup_arena;
table->in_use->set_n_backup_active_arena(table->expr_arena, &backup_arena);
int rc= default_value->expr->save_in_field(this, 0);
table->in_use->restore_active_arena(table->expr_arena, &backup_arena);
return rc;
}
/* Copy constant value stored in s->default_values */
my_ptrdiff_t l_offset= (my_ptrdiff_t) (table->s->default_values -
table->record[0]);
memcpy(ptr, ptr + l_offset, pack_length_in_rec());
if (maybe_null_in_table())
*null_ptr= ((*null_ptr & (uchar) ~null_bit) |
(null_ptr[l_offset] & null_bit));
return 0;
}
|
CWE-416
| 18,850 |
virtual Type type() const
{
return TABLE_ARENA;
}
|
CWE-416
| 18,854 |
bool is_item_tree_change_register_required()
{
return !stmt_arena->is_conventional()
|| stmt_arena->type() == Query_arena::TABLE_ARENA;
}
|
CWE-416
| 18,855 |
Table_arena(MEM_ROOT *mem_root, enum enum_state state_arg) :
Query_arena(mem_root, state_arg){}
|
CWE-416
| 18,857 |
static void fix_dl_name(MEM_ROOT *root, LEX_STRING *dl)
{
const size_t so_ext_len= sizeof(SO_EXT) - 1;
if (my_strcasecmp(&my_charset_latin1, dl->str + dl->length - so_ext_len,
SO_EXT))
{
char *s= (char*)alloc_root(root, dl->length + so_ext_len + 1);
memcpy(s, dl->str, dl->length);
strcpy(s + dl->length, SO_EXT);
dl->str= s;
dl->length+= so_ext_len;
}
}
|
CWE-416
| 18,861 |
xbstream_open(ds_ctxt_t *ctxt, const char *path, MY_STAT *mystat)
{
ds_file_t *file;
ds_stream_file_t *stream_file;
ds_stream_ctxt_t *stream_ctxt;
ds_ctxt_t *dest_ctxt;
xb_wstream_t *xbstream;
xb_wstream_file_t *xbstream_file;
xb_ad(ctxt->pipe_ctxt != NULL);
dest_ctxt = ctxt->pipe_ctxt;
stream_ctxt = (ds_stream_ctxt_t *) ctxt->ptr;
pthread_mutex_lock(&stream_ctxt->mutex);
if (stream_ctxt->dest_file == NULL) {
stream_ctxt->dest_file = ds_open(dest_ctxt, path, mystat);
if (stream_ctxt->dest_file == NULL) {
return NULL;
}
}
pthread_mutex_unlock(&stream_ctxt->mutex);
file = (ds_file_t *) my_malloc(sizeof(ds_file_t) +
sizeof(ds_stream_file_t),
MYF(MY_FAE));
stream_file = (ds_stream_file_t *) (file + 1);
xbstream = stream_ctxt->xbstream;
xbstream_file = xb_stream_write_open(xbstream, path, mystat,
stream_ctxt,
my_xbstream_write_callback);
if (xbstream_file == NULL) {
msg("xb_stream_write_open() failed.");
goto err;
}
stream_file->xbstream_file = xbstream_file;
stream_file->stream_ctxt = stream_ctxt;
file->ptr = stream_file;
file->path = stream_ctxt->dest_file->path;
return file;
err:
if (stream_ctxt->dest_file) {
ds_close(stream_ctxt->dest_file);
stream_ctxt->dest_file = NULL;
}
my_free(file);
return NULL;
}
|
CWE-703
| 18,887 |
create_worker_threads(uint n)
{
comp_thread_ctxt_t *threads;
uint i;
threads = (comp_thread_ctxt_t *)
my_malloc(sizeof(comp_thread_ctxt_t) * n, MYF(MY_FAE));
for (i = 0; i < n; i++) {
comp_thread_ctxt_t *thd = threads + i;
thd->num = i + 1;
thd->started = FALSE;
thd->cancelled = FALSE;
thd->data_avail = FALSE;
thd->to = (char *) my_malloc(COMPRESS_CHUNK_SIZE +
MY_QLZ_COMPRESS_OVERHEAD,
MYF(MY_FAE));
/* Initialize the control mutex and condition var */
if (pthread_mutex_init(&thd->ctrl_mutex, NULL) ||
pthread_cond_init(&thd->ctrl_cond, NULL)) {
goto err;
}
/* Initialize and data mutex and condition var */
if (pthread_mutex_init(&thd->data_mutex, NULL) ||
pthread_cond_init(&thd->data_cond, NULL)) {
goto err;
}
pthread_mutex_lock(&thd->ctrl_mutex);
if (pthread_create(&thd->id, NULL, compress_worker_thread_func,
thd)) {
msg("compress: pthread_create() failed: "
"errno = %d", errno);
goto err;
}
}
/* Wait for the threads to start */
for (i = 0; i < n; i++) {
comp_thread_ctxt_t *thd = threads + i;
while (thd->started == FALSE)
pthread_cond_wait(&thd->ctrl_cond, &thd->ctrl_mutex);
pthread_mutex_unlock(&thd->ctrl_mutex);
}
return threads;
err:
my_free(threads);
return NULL;
}
|
CWE-703
| 18,888 |
create_worker_threads(uint n)
{
comp_thread_ctxt_t *threads;
uint i;
threads = (comp_thread_ctxt_t *)
my_malloc(sizeof(comp_thread_ctxt_t) * n, MYF(MY_FAE));
for (i = 0; i < n; i++) {
comp_thread_ctxt_t *thd = threads + i;
thd->num = i + 1;
thd->started = FALSE;
thd->cancelled = FALSE;
thd->data_avail = FALSE;
thd->to = (char *) my_malloc(COMPRESS_CHUNK_SIZE +
MY_QLZ_COMPRESS_OVERHEAD,
MYF(MY_FAE));
/* Initialize the control mutex and condition var */
if (pthread_mutex_init(&thd->ctrl_mutex, NULL) ||
pthread_cond_init(&thd->ctrl_cond, NULL)) {
goto err;
}
/* Initialize and data mutex and condition var */
if (pthread_mutex_init(&thd->data_mutex, NULL) ||
pthread_cond_init(&thd->data_cond, NULL)) {
goto err;
}
pthread_mutex_lock(&thd->ctrl_mutex);
if (pthread_create(&thd->id, NULL, compress_worker_thread_func,
thd)) {
msg("compress: pthread_create() failed: "
"errno = %d", errno);
pthread_mutex_unlock(&thd->ctrl_mutex);
goto err;
}
}
/* Wait for the threads to start */
for (i = 0; i < n; i++) {
comp_thread_ctxt_t *thd = threads + i;
while (thd->started == FALSE)
pthread_cond_wait(&thd->ctrl_cond, &thd->ctrl_mutex);
pthread_mutex_unlock(&thd->ctrl_mutex);
}
return threads;
err:
my_free(threads);
return NULL;
}
|
CWE-703
| 18,889 |
push_new_name_resolution_context(THD *thd,
TABLE_LIST *left_op, TABLE_LIST *right_op)
{
Name_resolution_context *on_context;
if (!(on_context= new (thd->mem_root) Name_resolution_context))
return TRUE;
on_context->init();
on_context->first_name_resolution_table=
left_op->first_leaf_for_name_resolution();
on_context->last_name_resolution_table=
right_op->last_leaf_for_name_resolution();
LEX *lex= thd->lex;
on_context->select_lex = lex->current_select;
st_select_lex *curr_select= lex->pop_select();
st_select_lex *outer_sel= lex->select_stack_head();
lex->push_select(curr_select);
on_context->outer_context = outer_sel ? &outer_sel->context : 0;
return lex->push_context(on_context);
}
|
CWE-703
| 18,909 |
static int post_msg(struct pptp_conn_t *conn, void *buf, int size)
{
int n;
if (conn->out_size) {
log_error("pptp: buffer is not empty\n");
return -1;
}
again:
n=write(conn->hnd.fd, buf, size);
if (n < 0) {
if (errno == EINTR)
goto again;
else if (errno == EAGAIN)
n = 0;
else {
if (errno != EPIPE) {
if (conf_verbose)
log_ppp_info2("pptp: write: %s\n", strerror(errno));
return -1;
}
}
}
if ( n<size ) {
memcpy(conn->out_buf, (uint8_t *)buf + n, size - n);
triton_md_enable_handler(&conn->hnd, MD_MODE_WRITE);
}
return 0;
}
|
CWE-787
| 18,911 |
static void dtls1_clear_queues(SSL *s)
{
pitem *item = NULL;
hm_fragment *frag = NULL;
DTLS1_RECORD_DATA *rdata;
while( (item = pqueue_pop(s->d1->unprocessed_rcds.q)) != NULL)
{
rdata = (DTLS1_RECORD_DATA *) item->data;
if (rdata->rbuf.buf)
{
OPENSSL_free(rdata->rbuf.buf);
}
OPENSSL_free(item->data);
pitem_free(item);
}
while( (item = pqueue_pop(s->d1->processed_rcds.q)) != NULL)
{
rdata = (DTLS1_RECORD_DATA *) item->data;
if (rdata->rbuf.buf)
{
OPENSSL_free(rdata->rbuf.buf);
}
OPENSSL_free(item->data);
pitem_free(item);
}
while( (item = pqueue_pop(s->d1->buffered_messages)) != NULL)
{
frag = (hm_fragment *)item->data;
OPENSSL_free(frag->fragment);
OPENSSL_free(frag);
pitem_free(item);
}
while ( (item = pqueue_pop(s->d1->sent_messages)) != NULL)
{
frag = (hm_fragment *)item->data;
OPENSSL_free(frag->fragment);
OPENSSL_free(frag);
pitem_free(item);
}
while ( (item = pqueue_pop(s->d1->buffered_app_data.q)) != NULL)
{
frag = (hm_fragment *)item->data;
OPENSSL_free(frag->fragment);
OPENSSL_free(frag);
pitem_free(item);
}
}
|
CWE-119
| 18,913 |
cl_ulong4 Dispatcher::Device::createSeed() {
#ifdef PROFANITY_DEBUG
cl_ulong4 r;
r.s[0] = 1;
r.s[1] = 1;
r.s[2] = 1;
r.s[3] = 1;
return r;
#else
// Randomize private keys
std::random_device rd;
std::mt19937_64 eng(rd());
std::uniform_int_distribution<cl_ulong> distr;
cl_ulong4 r;
r.s[0] = distr(eng);
r.s[1] = distr(eng);
r.s[2] = distr(eng);
r.s[3] = distr(eng);
return r;
#endif
}
|
CWE-703
| 18,914 |
process(register int code, unsigned char** fill)
{
int incode;
static unsigned char firstchar;
if (code == clear) {
codesize = datasize + 1;
codemask = (1 << codesize) - 1;
avail = clear + 2;
oldcode = -1;
return 1;
}
if (oldcode == -1) {
*(*fill)++ = suffix[code];
firstchar = oldcode = code;
return 1;
}
if (code > avail) {
fprintf(stderr, "code %d too large for %d\n", code, avail);
return 0;
}
incode = code;
if (code == avail) { /* the first code is always < avail */
*stackp++ = firstchar;
code = oldcode;
}
while (code > clear) {
*stackp++ = suffix[code];
code = prefix[code];
}
*stackp++ = firstchar = suffix[code];
prefix[avail] = oldcode;
suffix[avail] = firstchar;
avail++;
if (((avail & codemask) == 0) && (avail < 4096)) {
codesize++;
codemask += avail;
}
oldcode = incode;
do {
*(*fill)++ = *--stackp;
} while (stackp > stack);
return 1;
}
|
CWE-119
| 18,916 |
inline st_select_lex_node* get_slave() { return slave; }
|
CWE-703
| 18,917 |
void LEX::relink_hack(st_select_lex *select_lex)
{
if (!select_stack_top) // Statements of the second type
{
if (!select_lex->get_master()->get_master())
((st_select_lex *) select_lex->get_master())->
set_master(&builtin_select);
if (!builtin_select.get_slave())
builtin_select.set_slave(select_lex->get_master());
}
}
|
CWE-703
| 18,918 |
unsigned int X509v3_addr_get_afi(const IPAddressFamily *f)
{
return ((f != NULL &&
f->addressFamily != NULL && f->addressFamily->data != NULL)
? ((f->addressFamily->data[0] << 8) | (f->addressFamily->data[1]))
: 0);
}
|
CWE-119
| 18,934 |
static void do_free_upto(BIO *f, BIO *upto)
{
if (upto)
{
BIO *tbio;
do
{
tbio = BIO_pop(f);
BIO_free(f);
f = tbio;
}
while (f != upto);
}
else
BIO_free_all(f);
}
|
CWE-703
| 18,940 |
static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)
{
unsigned char buf[4096];
int r = 0, i;
BIO *tmpout = NULL;
if (out == NULL)
tmpout = BIO_new(BIO_s_null());
else if (flags & CMS_TEXT)
{
tmpout = BIO_new(BIO_s_mem());
BIO_set_mem_eof_return(tmpout, 0);
}
else
tmpout = out;
if(!tmpout)
{
CMSerr(CMS_F_CMS_COPY_CONTENT,ERR_R_MALLOC_FAILURE);
goto err;
}
/* Read all content through chain to process digest, decrypt etc */
for (;;)
{
i=BIO_read(in,buf,sizeof(buf));
if (i <= 0)
{
if (BIO_method_type(in) == BIO_TYPE_CIPHER)
{
if (!BIO_get_cipher_status(in))
goto err;
}
if (i < 0)
goto err;
break;
}
if (tmpout && (BIO_write(tmpout, buf, i) != i))
goto err;
}
if(flags & CMS_TEXT)
{
if(!SMIME_text(tmpout, out))
{
CMSerr(CMS_F_CMS_COPY_CONTENT,CMS_R_SMIME_TEXT_ERROR);
goto err;
}
}
r = 1;
err:
if (tmpout && (tmpout != out))
BIO_free(tmpout);
return r;
}
|
CWE-703
| 18,942 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.