project
stringclasses 791
values | commit_id
stringlengths 6
81
| CVE ID
stringlengths 13
16
| CWE ID
stringclasses 127
values | func
stringlengths 5
484k
| vul
int8 0
1
|
---|---|---|---|---|---|
Chrome | a9cbaa7a40e2b2723cfc2f266c42f4980038a949 | NOT_APPLICABLE | NOT_APPLICABLE | void BaseAudioContext::PerformCleanupOnMainThread() {
DCHECK(IsMainThread());
GraphAutoLocker locker(this);
if (is_resolving_resume_promises_) {
for (auto& resolver : resume_resolvers_) {
if (context_state_ == kClosed) {
resolver->Reject(DOMException::Create(
DOMExceptionCode::kInvalidStateError,
"Cannot resume a context that has been closed"));
} else {
SetContextState(kRunning);
resolver->Resolve();
}
}
resume_resolvers_.clear();
is_resolving_resume_promises_ = false;
}
if (active_source_nodes_.size()) {
for (AudioNode* node : active_source_nodes_) {
if (node->Handler().GetNodeType() ==
AudioHandler::kNodeTypeAudioBufferSource) {
AudioBufferSourceNode* source_node =
static_cast<AudioBufferSourceNode*>(node);
source_node->GetAudioBufferSourceHandler().HandleStoppableSourceNode();
}
}
Vector<AudioHandler*> finished_handlers;
{
MutexLocker lock(finished_source_handlers_mutex_);
finished_source_handlers_.swap(finished_handlers);
}
unsigned remove_count = 0;
Vector<bool> removables;
removables.resize(active_source_nodes_.size());
for (AudioHandler* handler : finished_handlers) {
for (unsigned i = 0; i < active_source_nodes_.size(); ++i) {
if (handler == &active_source_nodes_[i]->Handler()) {
handler->BreakConnectionWithLock();
removables[i] = true;
remove_count++;
break;
}
}
}
if (remove_count > 0) {
HeapVector<Member<AudioNode>> actives;
DCHECK_GE(active_source_nodes_.size(), remove_count);
size_t initial_capacity =
std::min(active_source_nodes_.size() - remove_count,
active_source_nodes_.size());
actives.ReserveInitialCapacity(initial_capacity);
for (unsigned i = 0; i < removables.size(); ++i) {
if (!removables[i])
actives.push_back(active_source_nodes_[i]);
}
active_source_nodes_.swap(actives);
}
}
has_posted_cleanup_task_ = false;
}
| 0 |
linux | 2172fa709ab32ca60e86179dc67d0857be8e2c98 | NOT_APPLICABLE | NOT_APPLICABLE | int security_context_to_sid_force(const char *scontext, u32 scontext_len,
u32 *sid)
{
return security_context_to_sid_core(scontext, scontext_len,
sid, SECSID_NULL, GFP_KERNEL, 1);
}
| 0 |
firejail | 1884ea22a90d225950d81c804f1771b42ae55f54 | NOT_APPLICABLE | NOT_APPLICABLE | void fs_private_dir_mount(const char *private_dir, const char *private_run_dir) {
assert(private_dir);
assert(private_run_dir);
if (arg_debug)
printf("Mount-bind %s on top of %s\n", private_run_dir, private_dir);
// nothing to do if directory does not exist
struct stat s;
if (stat(private_dir, &s) == -1) {
if (arg_debug)
printf("Cannot find %s: %s\n", private_dir, strerror(errno));
return;
}
if (mount(private_run_dir, private_dir, NULL, MS_BIND|MS_REC, NULL) < 0)
errExit("mount bind");
fs_logger2("mount", private_dir);
// mask private_run_dir (who knows if there are writable paths, and it is mounted exec)
if (mount("tmpfs", private_run_dir, "tmpfs", MS_NOSUID | MS_NODEV | MS_STRICTATIME, "mode=755,gid=0") < 0)
errExit("mounting tmpfs");
fs_logger2("tmpfs", private_run_dir);
} | 0 |
passenger | 34b1087870c2bf85ebfd72c30b78577e10ab9744 | NOT_APPLICABLE | NOT_APPLICABLE | runAndPrintExceptions(const boost::function<void ()> &func, bool toAbort) {
try {
func();
} catch (const boost::thread_interrupted &) {
throw;
} catch (const tracable_exception &e) {
P_ERROR("Exception: " << e.what() << "\n" << e.backtrace());
if (toAbort) {
abort();
}
}
} | 0 |
raptor | a676f235309a59d4aa78eeffd2574ae5d341fcb0 | NOT_APPLICABLE | NOT_APPLICABLE | raptor_libxml_endDocument(void* user_data) {
raptor_sax2* sax2 = (raptor_sax2*)user_data;
xmlParserCtxtPtr xc = sax2->xc;
libxml2_endDocument(sax2->xc);
if(xc->myDoc) {
xmlFreeDoc(xc->myDoc);
xc->myDoc = NULL;
}
}
| 0 |
server | 3c209bfc040ddfc41ece8357d772547432353fd2 | NOT_APPLICABLE | NOT_APPLICABLE | subselect_hash_sj_engine::get_strategy_using_schema()
{
Item_in_subselect *item_in= (Item_in_subselect *) item;
if (item_in->is_top_level_item())
return COMPLETE_MATCH;
else
{
List_iterator<Item> inner_col_it(*item_in->unit->get_column_types(false));
Item *outer_col, *inner_col;
for (uint i= 0; i < item_in->left_expr->cols(); i++)
{
outer_col= item_in->left_expr->element_index(i);
inner_col= inner_col_it++;
if (!inner_col->maybe_null && !outer_col->maybe_null)
bitmap_set_bit(&non_null_key_parts, i);
else
{
bitmap_set_bit(&partial_match_key_parts, i);
++count_partial_match_columns;
}
}
}
/* If no column contains NULLs use regular hash index lookups. */
if (count_partial_match_columns)
return PARTIAL_MATCH;
return COMPLETE_MATCH;
} | 0 |
qemu | 449e8171f96a6a944d1f3b7d3627ae059eae21ca | NOT_APPLICABLE | NOT_APPLICABLE | static bool is_empty(const char *name)
{
return name[0] == '\0';
} | 0 |
FFmpeg | 4f05e2e2dc1a89f38cd9f0960a6561083d714f1e | NOT_APPLICABLE | NOT_APPLICABLE | static int read_table(AVFormatContext *avctx, AVStream *st,
int (*parse)(AVFormatContext *avctx, AVStream *st,
const char *name, int size))
{
int count, i;
AVIOContext *pb = avctx->pb;
avio_skip(pb, 4);
count = avio_rb32(pb);
avio_skip(pb, 4);
for (i = 0; i < count; i++) {
char name[17];
int size;
avio_read(pb, name, 16);
name[sizeof(name) - 1] = 0;
size = avio_rb32(pb);
if (size < 0) {
av_log(avctx, AV_LOG_ERROR, "entry size %d is invalid\n", size);
return AVERROR_INVALIDDATA;
}
if (parse(avctx, st, name, size) < 0) {
avpriv_request_sample(avctx, "Variable %s", name);
avio_skip(pb, size);
}
}
return 0;
}
| 0 |
server | af810407f78b7f792a9bb8c47c8c532eb3b3a758 | NOT_APPLICABLE | NOT_APPLICABLE | int ha_discover_table_names(THD *thd, LEX_CSTRING *db, MY_DIR *dirp,
Discovered_table_list *result, bool reusable)
{
int error;
DBUG_ENTER("ha_discover_table_names");
if (engines_with_discover_file_names == 0 && !reusable)
{
st_discover_names_args args= {db, NULL, result, 0};
error= ext_table_discovery_simple(dirp, result) ||
plugin_foreach(thd, discover_names,
MYSQL_STORAGE_ENGINE_PLUGIN, &args);
}
else
{
st_discover_names_args args= {db, dirp, result, 0};
/* extension_based_table_discovery relies on dirp being sorted */
my_qsort(dirp->dir_entry, dirp->number_of_files,
sizeof(FILEINFO), cmp_file_names);
error= extension_based_table_discovery(dirp, reg_ext, result) ||
plugin_foreach(thd, discover_names,
MYSQL_STORAGE_ENGINE_PLUGIN, &args);
if (args.possible_duplicates > 0)
result->remove_duplicates();
}
DBUG_RETURN(error);
} | 0 |
Pillow | 6dcbf5bd96b717c58d7b642949da8d323099928e | NOT_APPLICABLE | NOT_APPLICABLE | int ImagingLibTiffInit(ImagingCodecState state, int fp, int offset) {
TIFFSTATE *clientstate = (TIFFSTATE *)state->context;
TRACE(("initing libtiff\n"));
TRACE(("filepointer: %d \n", fp));
TRACE(("State: count %d, state %d, x %d, y %d, ystep %d\n", state->count, state->state,
state->x, state->y, state->ystep));
TRACE(("State: xsize %d, ysize %d, xoff %d, yoff %d \n", state->xsize, state->ysize,
state->xoff, state->yoff));
TRACE(("State: bits %d, bytes %d \n", state->bits, state->bytes));
TRACE(("State: context %p \n", state->context));
clientstate->loc = 0;
clientstate->size = 0;
clientstate->data = 0;
clientstate->fp = fp;
clientstate->ifd = offset;
clientstate->eof = 0;
return 1;
} | 0 |
udisks | 0fcc7cb3b66f23fac53ae08647aa0007a2bd56c4 | NOT_APPLICABLE | NOT_APPLICABLE | sysfs_get_int (const char *dir,
const char *attribute)
{
int result;
char *contents;
char *filename;
result = 0;
filename = g_build_filename (dir, attribute, NULL);
if (g_file_get_contents (filename, &contents, NULL, NULL))
{
result = strtol (contents, NULL, 0);
g_free (contents);
}
g_free (filename);
return result;
}
| 0 |
FFmpeg | 18f94df8af04f2c02a25a7dec512289feff6517f | NOT_APPLICABLE | NOT_APPLICABLE | static void decode_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
{
int smp = bd->block_length - 1;
int32_t val = *bd->raw_samples;
int32_t *dst = bd->raw_samples + 1;
// write raw samples into buffer
for (; smp; smp--)
*dst++ = val;
} | 0 |
linux | 050fad7c4534c13c8eb1d9c2ba66012e014773cb | NOT_APPLICABLE | NOT_APPLICABLE | bool is_bpf_text_address(unsigned long addr)
{
bool ret;
rcu_read_lock();
ret = bpf_prog_kallsyms_find(addr) != NULL;
rcu_read_unlock();
return ret;
} | 0 |
Chrome | f6ac1dba5e36f338a490752a2cbef3339096d9fe | NOT_APPLICABLE | NOT_APPLICABLE | bool WebGLRenderingContextBase::ValidateBlendFuncFactors(
const char* function_name,
GLenum src,
GLenum dst) {
if (((src == GL_CONSTANT_COLOR || src == GL_ONE_MINUS_CONSTANT_COLOR) &&
(dst == GL_CONSTANT_ALPHA || dst == GL_ONE_MINUS_CONSTANT_ALPHA)) ||
((dst == GL_CONSTANT_COLOR || dst == GL_ONE_MINUS_CONSTANT_COLOR) &&
(src == GL_CONSTANT_ALPHA || src == GL_ONE_MINUS_CONSTANT_ALPHA))) {
SynthesizeGLError(GL_INVALID_OPERATION, function_name,
"incompatible src and dst");
return false;
}
return true;
}
| 0 |
Chrome | bb9cfb0aba25f4b13e57bdd4a9fac80ba071e7b9 | NOT_APPLICABLE | NOT_APPLICABLE | bool BaseMultipleFieldsDateAndTimeInputType::shouldSpinButtonRespondToWheelEvents()
{
if (!shouldSpinButtonRespondToMouseEvents())
return false;
return m_dateTimeEditElement && m_dateTimeEditElement->hasFocusedField();
}
| 0 |
Chrome | 673ce95d481ea9368c4d4d43ac756ba1d6d9e608 | NOT_APPLICABLE | NOT_APPLICABLE | void NotifyProcessHostDisconnected(const ChildProcessData& data) {
for (auto& observer : g_browser_child_process_observers.Get())
observer.BrowserChildProcessHostDisconnected(data);
}
| 0 |
linux | 74b6b20df8cfe90ada777d621b54c32e69e27cd7 | NOT_APPLICABLE | NOT_APPLICABLE | static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *param, int len)
{
int ret = 0;
struct sta_info *psta = NULL;
struct adapter *padapter = rtw_netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct sta_priv *pstapriv = &padapter->stapriv;
struct ieee_param_ex *param_ex = (struct ieee_param_ex *)param;
struct sta_data *psta_data = (struct sta_data *)param_ex->data;
DBG_88E("rtw_ioctl_get_sta_info, sta_addr: %pM\n", (param_ex->sta_addr));
if (!check_fwstate(pmlmepriv, _FW_LINKED | WIFI_AP_STATE))
return -EINVAL;
if (is_broadcast_ether_addr(param_ex->sta_addr))
return -EINVAL;
psta = rtw_get_stainfo(pstapriv, param_ex->sta_addr);
if (psta) {
psta_data->aid = (u16)psta->aid;
psta_data->capability = psta->capability;
psta_data->flags = psta->flags;
/*
nonerp_set : BIT(0)
no_short_slot_time_set : BIT(1)
no_short_preamble_set : BIT(2)
no_ht_gf_set : BIT(3)
no_ht_set : BIT(4)
ht_20mhz_set : BIT(5)
*/
psta_data->sta_set = ((psta->nonerp_set) |
(psta->no_short_slot_time_set << 1) |
(psta->no_short_preamble_set << 2) |
(psta->no_ht_gf_set << 3) |
(psta->no_ht_set << 4) |
(psta->ht_20mhz_set << 5));
psta_data->tx_supp_rates_len = psta->bssratelen;
memcpy(psta_data->tx_supp_rates, psta->bssrateset, psta->bssratelen);
memcpy(&psta_data->ht_cap,
&psta->htpriv.ht_cap, sizeof(struct ieee80211_ht_cap));
psta_data->rx_pkts = psta->sta_stats.rx_data_pkts;
psta_data->rx_bytes = psta->sta_stats.rx_bytes;
psta_data->rx_drops = psta->sta_stats.rx_drops;
psta_data->tx_pkts = psta->sta_stats.tx_pkts;
psta_data->tx_bytes = psta->sta_stats.tx_bytes;
psta_data->tx_drops = psta->sta_stats.tx_drops;
} else {
ret = -1;
}
return ret;
} | 0 |
linux | fac8e0f579695a3ecbc4d3cac369139d7f819971 | NOT_APPLICABLE | NOT_APPLICABLE | static int dev_alloc_name_ns(struct net *net,
struct net_device *dev,
const char *name)
{
char buf[IFNAMSIZ];
int ret;
ret = __dev_alloc_name(net, name, buf);
if (ret >= 0)
strlcpy(dev->name, buf, IFNAMSIZ);
return ret;
}
| 0 |
optee_os | d5c5b0b77b2b589666024d219a8007b3f5b6faeb | NOT_APPLICABLE | NOT_APPLICABLE | TEE_Result syscall_open_ta_session(const TEE_UUID *dest,
unsigned long cancel_req_to,
struct utee_params *usr_param, uint32_t *ta_sess,
uint32_t *ret_orig)
{
TEE_Result res;
uint32_t ret_o = TEE_ORIGIN_TEE;
struct tee_ta_session *s = NULL;
struct tee_ta_session *sess;
struct mobj *mobj_param = NULL;
TEE_UUID *uuid = malloc(sizeof(TEE_UUID));
struct tee_ta_param *param = malloc(sizeof(struct tee_ta_param));
TEE_Identity *clnt_id = malloc(sizeof(TEE_Identity));
void *tmp_buf_va[TEE_NUM_PARAMS] = { NULL };
struct user_ta_ctx *utc;
if (uuid == NULL || param == NULL || clnt_id == NULL) {
res = TEE_ERROR_OUT_OF_MEMORY;
goto out_free_only;
}
memset(param, 0, sizeof(struct tee_ta_param));
res = tee_ta_get_current_session(&sess);
if (res != TEE_SUCCESS)
goto out_free_only;
utc = to_user_ta_ctx(sess->ctx);
res = tee_svc_copy_from_user(uuid, dest, sizeof(TEE_UUID));
if (res != TEE_SUCCESS)
goto function_exit;
clnt_id->login = TEE_LOGIN_TRUSTED_APP;
memcpy(&clnt_id->uuid, &sess->ctx->uuid, sizeof(TEE_UUID));
res = tee_svc_copy_param(sess, NULL, usr_param, param, tmp_buf_va,
&mobj_param);
if (res != TEE_SUCCESS)
goto function_exit;
res = tee_ta_open_session(&ret_o, &s, &utc->open_sessions, uuid,
clnt_id, cancel_req_to, param);
tee_mmu_set_ctx(&utc->ctx);
if (res != TEE_SUCCESS)
goto function_exit;
res = tee_svc_update_out_param(param, tmp_buf_va, usr_param);
function_exit:
mobj_free(mobj_param);
if (res == TEE_SUCCESS)
tee_svc_copy_kaddr_to_uref(ta_sess, s);
tee_svc_copy_to_user(ret_orig, &ret_o, sizeof(ret_o));
out_free_only:
free(param);
free(uuid);
free(clnt_id);
return res;
}
| 0 |
cyrus-imapd | 53c4137bd924b954432c6c59da7572c4c5ffa901 | NOT_APPLICABLE | NOT_APPLICABLE | static void cmd_capability(char *tag)
{
imapd_check(NULL, 0);
prot_printf(imapd_out, "* CAPABILITY ");
capa_response(CAPA_PREAUTH|CAPA_POSTAUTH);
prot_printf(imapd_out, "\r\n%s OK %s\r\n", tag,
error_message(IMAP_OK_COMPLETED));
}
| 0 |
sqlite | 57f7ece78410a8aae86aa4625fb7556897db384c | NOT_APPLICABLE | NOT_APPLICABLE | void sqlite3ExprCodeFactorable(Parse *pParse, Expr *pExpr, int target){
if( pParse->okConstFactor && sqlite3ExprIsConstantNotJoin(pExpr) ){
sqlite3ExprCodeAtInit(pParse, pExpr, target);
}else{
sqlite3ExprCode(pParse, pExpr, target);
}
} | 0 |
Android | a24543157ae2cdd25da43e20f4e48a07481e6ceb | NOT_APPLICABLE | NOT_APPLICABLE | static Handle<Object> GetImpl(Isolate* isolate, FixedArrayBase* parameters,
uint32_t entry) {
Handle<FixedArray> parameter_map(FixedArray::cast(parameters), isolate);
uint32_t length = parameter_map->length() - 2;
if (entry < length) {
DisallowHeapAllocation no_gc;
Object* probe = parameter_map->get(entry + 2);
Context* context = Context::cast(parameter_map->get(0));
int context_entry = Smi::cast(probe)->value();
DCHECK(!context->get(context_entry)->IsTheHole(isolate));
return handle(context->get(context_entry), isolate);
} else {
Handle<Object> result = ArgumentsAccessor::GetImpl(
isolate, FixedArray::cast(parameter_map->get(1)), entry - length);
if (result->IsAliasedArgumentsEntry()) {
DisallowHeapAllocation no_gc;
AliasedArgumentsEntry* alias = AliasedArgumentsEntry::cast(*result);
Context* context = Context::cast(parameter_map->get(0));
int context_entry = alias->aliased_context_slot();
DCHECK(!context->get(context_entry)->IsTheHole(isolate));
return handle(context->get(context_entry), isolate);
}
return result;
}
}
| 0 |
server | 807945f2eb5fa22e6f233cc17b85a2e141efe2c8 | NOT_APPLICABLE | NOT_APPLICABLE | void Item_func_nullif::print(String *str, enum_query_type query_type)
{
/*
NULLIF(a,b) is implemented according to the SQL standard as a short for
CASE WHEN a=b THEN NULL ELSE a END
The constructor of Item_func_nullif sets args[0] and args[2] to the
same item "a", and sets args[1] to "b".
If "this" is a part of a WHERE or ON condition, then:
- the left "a" is a subject to equal field propagation with ANY_SUBST.
- the right "a" is a subject to equal field propagation with IDENTITY_SUBST.
Therefore, after equal field propagation args[0] and args[2] can point
to different items.
*/
if ((query_type & QT_ITEM_ORIGINAL_FUNC_NULLIF) ||
(arg_count == 2) ||
(args[0] == args[2]))
{
/*
If QT_ITEM_ORIGINAL_FUNC_NULLIF is requested,
that means we want the original NULLIF() representation,
e.g. when we are in:
SHOW CREATE {VIEW|FUNCTION|PROCEDURE}
The original representation is possible only if
args[0] and args[2] still point to the same Item.
The caller must never pass call print() with QT_ITEM_ORIGINAL_FUNC_NULLIF
if an expression has undergone some optimization
(e.g. equal field propagation done in optimize_cond()) already and
NULLIF() potentially has two different representations of "a":
- one "a" for comparison
- another "a" for the returned value!
*/
DBUG_ASSERT(arg_count == 2 ||
args[0] == args[2] || current_thd->lex->context_analysis_only);
str->append(func_name());
str->append('(');
if (arg_count == 2)
args[0]->print(str, query_type);
else
args[2]->print(str, query_type);
str->append(',');
args[1]->print(str, query_type);
str->append(')');
}
else
{
/*
args[0] and args[2] are different items.
This is possible after WHERE optimization (equal fields propagation etc),
e.g. in EXPLAIN EXTENDED or EXPLAIN FORMAT=JSON.
As it's not possible to print as a function with 2 arguments any more,
do it in the CASE style.
*/
str->append(STRING_WITH_LEN("(case when "));
args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" = "));
args[1]->print(str, query_type);
str->append(STRING_WITH_LEN(" then NULL else "));
args[2]->print(str, query_type);
str->append(STRING_WITH_LEN(" end)"));
}
} | 0 |
Android | f9ed2fe6d61259e779a37d4c2d7edb33a1c1f8ba | NOT_APPLICABLE | NOT_APPLICABLE | OMX_ERRORTYPE OMX::OnEvent(
node_id node,
OMX_IN OMX_EVENTTYPE eEvent,
OMX_IN OMX_U32 nData1,
OMX_IN OMX_U32 nData2,
OMX_IN OMX_PTR pEventData) {
ALOGV("OnEvent(%d, %" PRIu32", %" PRIu32 ")", eEvent, nData1, nData2);
findInstance(node)->onEvent(eEvent, nData1, nData2);
sp<OMX::CallbackDispatcher> dispatcher = findDispatcher(node);
if (eEvent == OMX_EventOutputRendered) {
if (pEventData == NULL) {
return OMX_ErrorBadParameter;
}
OMX_VIDEO_RENDEREVENTTYPE *renderData = (OMX_VIDEO_RENDEREVENTTYPE *)pEventData;
for (size_t i = 0; i < nData1; ++i) {
omx_message msg;
msg.type = omx_message::FRAME_RENDERED;
msg.node = node;
msg.fenceFd = -1;
msg.u.render_data.timestamp = renderData[i].nMediaTimeUs;
msg.u.render_data.nanoTime = renderData[i].nSystemTimeNs;
dispatcher->post(msg, false /* realTime */);
}
return OMX_ErrorNone;
}
omx_message msg;
msg.type = omx_message::EVENT;
msg.node = node;
msg.fenceFd = -1;
msg.u.event_data.event = eEvent;
msg.u.event_data.data1 = nData1;
msg.u.event_data.data2 = nData2;
dispatcher->post(msg, true /* realTime */);
return OMX_ErrorNone;
}
| 0 |
linux | aa9f7d5172fac9bf1f09e678c35e287a40a7b7dd | NOT_APPLICABLE | NOT_APPLICABLE | SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
const unsigned long __user *, old_nodes,
const unsigned long __user *, new_nodes)
{
return kernel_migrate_pages(pid, maxnode, old_nodes, new_nodes);
} | 0 |
mod_auth_openidc | 00c315cb0c8ab77c67be4a2ac08a71a83ac58751 | NOT_APPLICABLE | NOT_APPLICABLE | static oidc_provider_t* oidc_get_provider_for_issuer(request_rec *r,
oidc_cfg *c, const char *issuer, apr_byte_t allow_discovery) {
/* by default we'll assume that we're dealing with a single statically configured OP */
oidc_provider_t *provider = NULL;
if (oidc_provider_static_config(r, c, &provider) == FALSE)
return NULL;
/* unless a metadata directory was configured, so we'll try and get the provider settings from there */
if (c->metadata_dir != NULL) {
/* try and get metadata from the metadata directory for the OP that sent this response */
if ((oidc_metadata_get(r, c, issuer, &provider, allow_discovery)
== FALSE) || (provider == NULL)) {
/* don't know nothing about this OP/issuer */
oidc_error(r, "no provider metadata found for issuer \"%s\"",
issuer);
return NULL;
}
}
return provider;
} | 0 |
mapserver | e52a436c0e1c5e9f7ef13428dba83194a800f4df | NOT_APPLICABLE | NOT_APPLICABLE | char *FLTGetSpatialComparisonCommonExpression(FilterEncodingNode *psNode, layerObj *lp)
{
char *pszExpression = NULL;
shapeObj *psQueryShape = NULL;
double dfDistance = -1;
int nUnit = -1, nLayerUnit = -1;
char *pszWktText = NULL;
char szBuffer[256];
char *pszTmp=NULL;
projectionObj sProjTmp;
rectObj sQueryRect;
shapeObj *psTmpShape=NULL;
int bBBoxQuery = 0;
int bAlreadyReprojected = 0;
if (psNode == NULL || lp == NULL)
return NULL;
if (psNode->eType != FILTER_NODE_TYPE_SPATIAL)
return NULL;
/* get the shape */
if (FLTIsBBoxFilter(psNode)) {
char szPolygon[512];
FLTGetBBOX(psNode, &sQueryRect);
snprintf(szPolygon, sizeof(szPolygon),
"POLYGON((%.18f %.18f,%.18f %.18f,%.18f %.18f,%.18f %.18f,%.18f %.18f))",
sQueryRect.minx, sQueryRect.miny,
sQueryRect.minx, sQueryRect.maxy,
sQueryRect.maxx, sQueryRect.maxy,
sQueryRect.maxx, sQueryRect.miny,
sQueryRect.minx, sQueryRect.miny);
psTmpShape = msShapeFromWKT(szPolygon);
/*
** This is a horrible hack to deal with world-extent requests and
** reprojection. msProjectRect() detects if reprojection from longlat to
** projected SRS, and in that case it transforms the bbox to -1e-15,-1e-15,1e15,1e15
** to ensure that all features are returned.
**
** Make wfs_200_cite_filter_bbox_world.xml and wfs_200_cite_postgis_bbox_world.xml pass
*/
if (fabs(sQueryRect.minx - -180.0) < 1e-5 &&
fabs(sQueryRect.miny - -90.0) < 1e-5 &&
fabs(sQueryRect.maxx - 180.0) < 1e-5 &&
fabs(sQueryRect.maxy - 90.0) < 1e-5)
{
if (lp->projection.numargs > 0) {
if (psNode->pszSRS)
msInitProjection(&sProjTmp);
if (psNode->pszSRS) {
/* Use the non EPSG variant since axis swapping is done in FLTDoAxisSwappingIfNecessary */
if (msLoadProjectionString(&sProjTmp, psNode->pszSRS) == 0) {
msProjectRect(&sProjTmp, &lp->projection, &sQueryRect);
}
} else if (lp->map->projection.numargs > 0)
msProjectRect(&lp->map->projection, &lp->projection, &sQueryRect);
if (psNode->pszSRS)
msFreeProjection(&sProjTmp);
}
if (sQueryRect.minx <= -1e14) {
msFreeShape(psTmpShape);
msFree(psTmpShape);
psTmpShape = (shapeObj*) msSmallMalloc(sizeof(shapeObj));
msInitShape(psTmpShape);
msRectToPolygon(sQueryRect, psTmpShape);
bAlreadyReprojected = 1;
}
}
bBBoxQuery = 1;
} else {
/* other geos type operations */
/* project shape to layer projection. If the proj is not part of the filter query,
assume that the cooredinates are in the map projection */
psQueryShape = FLTGetShape(psNode, &dfDistance, &nUnit);
if ((strcasecmp(psNode->pszValue, "DWithin") == 0 || strcasecmp(psNode->pszValue, "Beyond") == 0 ) && dfDistance > 0) {
nLayerUnit = lp->units;
if(nLayerUnit == -1) nLayerUnit = GetMapserverUnitUsingProj(&lp->projection);
if(nLayerUnit == -1) nLayerUnit = lp->map->units;
if(nLayerUnit == -1) nLayerUnit = GetMapserverUnitUsingProj(&lp->map->projection);
if (nUnit >= 0 && nUnit != nLayerUnit)
dfDistance *= msInchesPerUnit(nUnit,0)/msInchesPerUnit(nLayerUnit,0); /* target is layer units */
}
psTmpShape = psQueryShape;
}
if (psTmpShape) {
/*
** target is layer projection
*/
if (!bAlreadyReprojected && lp->projection.numargs > 0) {
if (psNode->pszSRS)
msInitProjection(&sProjTmp);
if (psNode->pszSRS) {
/* Use the non EPSG variant since axis swapping is done in FLTDoAxisSwappingIfNecessary */
if (msLoadProjectionString(&sProjTmp, psNode->pszSRS) == 0) {
msProjectShape(&sProjTmp, &lp->projection, psTmpShape);
}
} else if (lp->map->projection.numargs > 0)
msProjectShape(&lp->map->projection, &lp->projection, psTmpShape);
if (psNode->pszSRS)
msFreeProjection(&sProjTmp);
}
/* function name */
if (bBBoxQuery) {
sprintf(szBuffer, "%s", "intersects");
} else {
if (strncasecmp(psNode->pszValue, "intersect", 9) == 0)
sprintf(szBuffer, "%s", "intersects");
else {
pszTmp = msStrdup(psNode->pszValue);
msStringToLower(pszTmp);
sprintf(szBuffer, "%s", pszTmp);
msFree(pszTmp);
}
}
pszExpression = msStringConcatenate(pszExpression, szBuffer);
pszExpression = msStringConcatenate(pszExpression, "(");
/* geometry binding */
sprintf(szBuffer, "%s", "[shape]");
pszExpression = msStringConcatenate(pszExpression, szBuffer);
pszExpression = msStringConcatenate(pszExpression, ",");
/* filter geometry */
pszWktText = msGEOSShapeToWKT(psTmpShape);
sprintf(szBuffer, "%s", "fromText('");
pszExpression = msStringConcatenate(pszExpression, szBuffer);
pszExpression = msStringConcatenate(pszExpression, pszWktText);
sprintf(szBuffer, "%s", "')");
pszExpression = msStringConcatenate(pszExpression, szBuffer);
msGEOSFreeWKT(pszWktText);
/* (optional) beyond/dwithin distance, always 0.0 since we apply the distance as a buffer earlier */
if ((strcasecmp(psNode->pszValue, "DWithin") == 0 || strcasecmp(psNode->pszValue, "Beyond") == 0)) {
sprintf(szBuffer, ",%g", dfDistance);
pszExpression = msStringConcatenate(pszExpression, szBuffer);
}
/* terminate the function */
pszExpression = msStringConcatenate(pszExpression, ") = TRUE");
}
/*
** Cleanup
*/
if (bBBoxQuery) {
msFreeShape(psTmpShape);
msFree(psTmpShape);
}
return pszExpression;
}
| 0 |
linux | 1d3ff0950e2b40dc861b1739029649d03f591820 | NOT_APPLICABLE | NOT_APPLICABLE | static const char *dccp_feat_fname(const u8 feat)
{
static const char *const feature_names[] = {
[DCCPF_RESERVED] = "Reserved",
[DCCPF_CCID] = "CCID",
[DCCPF_SHORT_SEQNOS] = "Allow Short Seqnos",
[DCCPF_SEQUENCE_WINDOW] = "Sequence Window",
[DCCPF_ECN_INCAPABLE] = "ECN Incapable",
[DCCPF_ACK_RATIO] = "Ack Ratio",
[DCCPF_SEND_ACK_VECTOR] = "Send ACK Vector",
[DCCPF_SEND_NDP_COUNT] = "Send NDP Count",
[DCCPF_MIN_CSUM_COVER] = "Min. Csum Coverage",
[DCCPF_DATA_CHECKSUM] = "Send Data Checksum",
};
if (feat > DCCPF_DATA_CHECKSUM && feat < DCCPF_MIN_CCID_SPECIFIC)
return feature_names[DCCPF_RESERVED];
if (feat == DCCPF_SEND_LEV_RATE)
return "Send Loss Event Rate";
if (feat >= DCCPF_MIN_CCID_SPECIFIC)
return "CCID-specific";
return feature_names[feat];
} | 0 |
cpp-peglib | 0061f393de54cf0326621c079dc2988336d1ebb3 | NOT_APPLICABLE | NOT_APPLICABLE | inline void LiteralString::accept(Visitor &v) { v.visit(*this); } | 0 |
ppp | 7658e8257183f062dc01f87969c140707c7e52cb | NOT_APPLICABLE | NOT_APPLICABLE | user_unsetenv(argv)
char **argv;
{
struct userenv *uep, **insp;
char *arg = argv[0];
if (strchr(arg, '=') != NULL) {
option_error("unexpected = in name: %s", arg);
return 0;
}
if (arg == '\0') {
option_error("missing variable name for unset");
return 0;
}
for (uep = userenv_list; uep != NULL; uep = uep->ue_next) {
if (strcmp(arg, uep->ue_name) == 0)
break;
}
/* Ignore attempts by unprivileged users to override privileged sources */
if (uep != NULL && !privileged_option && uep->ue_priv)
return 1;
/* The name never changes, so allocate it with the structure */
if (uep == NULL) {
uep = malloc(sizeof (*uep) + strlen(arg));
strcpy(uep->ue_name, arg);
uep->ue_next = NULL;
insp = &userenv_list;
while (*insp != NULL)
insp = &(*insp)->ue_next;
*insp = uep;
} else {
struct userenv *uep2;
for (uep2 = userenv_list; uep2 != NULL; uep2 = uep2->ue_next) {
if (uep2 != uep && uep2->ue_isset)
break;
}
if (uep2 == NULL && uep->ue_isset)
find_option("set")->flags |= OPT_NOPRINT;
free(uep->ue_value);
}
uep->ue_isset = 0;
uep->ue_priv = privileged_option;
uep->ue_source = option_source;
uep->ue_value = NULL;
curopt->flags &= ~OPT_NOPRINT;
return 1;
}
| 0 |
php-src | 0da8b8b801f9276359262f1ef8274c7812d3dfda | NOT_APPLICABLE | NOT_APPLICABLE | static inline unsigned int get_next_char(
enum entity_charset charset,
const unsigned char *str,
size_t str_len,
size_t *cursor,
int *status)
{
size_t pos = *cursor;
unsigned int this_char = 0;
*status = SUCCESS;
assert(pos <= str_len);
if (!CHECK_LEN(pos, 1))
MB_FAILURE(pos, 1);
switch (charset) {
case cs_utf_8:
{
/* We'll follow strategy 2. from section 3.6.1 of UTR #36:
* "In a reported illegal byte sequence, do not include any
* non-initial byte that encodes a valid character or is a leading
* byte for a valid sequence." */
unsigned char c;
c = str[pos];
if (c < 0x80) {
this_char = c;
pos++;
} else if (c < 0xc2) {
MB_FAILURE(pos, 1);
} else if (c < 0xe0) {
if (!CHECK_LEN(pos, 2))
MB_FAILURE(pos, 1);
if (!utf8_trail(str[pos + 1])) {
MB_FAILURE(pos, utf8_lead(str[pos + 1]) ? 1 : 2);
}
this_char = ((c & 0x1f) << 6) | (str[pos + 1] & 0x3f);
if (this_char < 0x80) { /* non-shortest form */
MB_FAILURE(pos, 2);
}
pos += 2;
} else if (c < 0xf0) {
size_t avail = str_len - pos;
if (avail < 3 ||
!utf8_trail(str[pos + 1]) || !utf8_trail(str[pos + 2])) {
if (avail < 2 || utf8_lead(str[pos + 1]))
MB_FAILURE(pos, 1);
else if (avail < 3 || utf8_lead(str[pos + 2]))
MB_FAILURE(pos, 2);
else
MB_FAILURE(pos, 3);
}
this_char = ((c & 0x0f) << 12) | ((str[pos + 1] & 0x3f) << 6) | (str[pos + 2] & 0x3f);
if (this_char < 0x800) { /* non-shortest form */
MB_FAILURE(pos, 3);
} else if (this_char >= 0xd800 && this_char <= 0xdfff) { /* surrogate */
MB_FAILURE(pos, 3);
}
pos += 3;
} else if (c < 0xf5) {
size_t avail = str_len - pos;
if (avail < 4 ||
!utf8_trail(str[pos + 1]) || !utf8_trail(str[pos + 2]) ||
!utf8_trail(str[pos + 3])) {
if (avail < 2 || utf8_lead(str[pos + 1]))
MB_FAILURE(pos, 1);
else if (avail < 3 || utf8_lead(str[pos + 2]))
MB_FAILURE(pos, 2);
else if (avail < 4 || utf8_lead(str[pos + 3]))
MB_FAILURE(pos, 3);
else
MB_FAILURE(pos, 4);
}
this_char = ((c & 0x07) << 18) | ((str[pos + 1] & 0x3f) << 12) | ((str[pos + 2] & 0x3f) << 6) | (str[pos + 3] & 0x3f);
if (this_char < 0x10000 || this_char > 0x10FFFF) { /* non-shortest form or outside range */
MB_FAILURE(pos, 4);
}
pos += 4;
} else {
MB_FAILURE(pos, 1);
}
}
break;
case cs_big5:
/* reference http://demo.icu-project.org/icu-bin/convexp?conv=big5 */
{
unsigned char c = str[pos];
if (c >= 0x81 && c <= 0xFE) {
unsigned char next;
if (!CHECK_LEN(pos, 2))
MB_FAILURE(pos, 1);
next = str[pos + 1];
if ((next >= 0x40 && next <= 0x7E) ||
(next >= 0xA1 && next <= 0xFE)) {
this_char = (c << 8) | next;
} else {
MB_FAILURE(pos, 1);
}
pos += 2;
} else {
this_char = c;
pos += 1;
}
}
break;
case cs_big5hkscs:
{
unsigned char c = str[pos];
if (c >= 0x81 && c <= 0xFE) {
unsigned char next;
if (!CHECK_LEN(pos, 2))
MB_FAILURE(pos, 1);
next = str[pos + 1];
if ((next >= 0x40 && next <= 0x7E) ||
(next >= 0xA1 && next <= 0xFE)) {
this_char = (c << 8) | next;
} else if (next != 0x80 && next != 0xFF) {
MB_FAILURE(pos, 1);
} else {
MB_FAILURE(pos, 2);
}
pos += 2;
} else {
this_char = c;
pos += 1;
}
}
break;
case cs_gb2312: /* EUC-CN */
{
unsigned char c = str[pos];
if (c >= 0xA1 && c <= 0xFE) {
unsigned char next;
if (!CHECK_LEN(pos, 2))
MB_FAILURE(pos, 1);
next = str[pos + 1];
if (gb2312_trail(next)) {
this_char = (c << 8) | next;
} else if (gb2312_lead(next)) {
MB_FAILURE(pos, 1);
} else {
MB_FAILURE(pos, 2);
}
pos += 2;
} else if (gb2312_lead(c)) {
this_char = c;
pos += 1;
} else {
MB_FAILURE(pos, 1);
}
}
break;
case cs_sjis:
{
unsigned char c = str[pos];
if ((c >= 0x81 && c <= 0x9F) || (c >= 0xE0 && c <= 0xFC)) {
unsigned char next;
if (!CHECK_LEN(pos, 2))
MB_FAILURE(pos, 1);
next = str[pos + 1];
if (sjis_trail(next)) {
this_char = (c << 8) | next;
} else if (sjis_lead(next)) {
MB_FAILURE(pos, 1);
} else {
MB_FAILURE(pos, 2);
}
pos += 2;
} else if (c < 0x80 || (c >= 0xA1 && c <= 0xDF)) {
this_char = c;
pos += 1;
} else {
MB_FAILURE(pos, 1);
}
}
break;
case cs_eucjp:
{
unsigned char c = str[pos];
if (c >= 0xA1 && c <= 0xFE) {
unsigned next;
if (!CHECK_LEN(pos, 2))
MB_FAILURE(pos, 1);
next = str[pos + 1];
if (next >= 0xA1 && next <= 0xFE) {
/* this a jis kanji char */
this_char = (c << 8) | next;
} else {
MB_FAILURE(pos, (next != 0xA0 && next != 0xFF) ? 1 : 2);
}
pos += 2;
} else if (c == 0x8E) {
unsigned next;
if (!CHECK_LEN(pos, 2))
MB_FAILURE(pos, 1);
next = str[pos + 1];
if (next >= 0xA1 && next <= 0xDF) {
/* JIS X 0201 kana */
this_char = (c << 8) | next;
} else {
MB_FAILURE(pos, (next != 0xA0 && next != 0xFF) ? 1 : 2);
}
pos += 2;
} else if (c == 0x8F) {
size_t avail = str_len - pos;
if (avail < 3 || !(str[pos + 1] >= 0xA1 && str[pos + 1] <= 0xFE) ||
!(str[pos + 2] >= 0xA1 && str[pos + 2] <= 0xFE)) {
if (avail < 2 || (str[pos + 1] != 0xA0 && str[pos + 1] != 0xFF))
MB_FAILURE(pos, 1);
else if (avail < 3 || (str[pos + 2] != 0xA0 && str[pos + 2] != 0xFF))
MB_FAILURE(pos, 2);
else
MB_FAILURE(pos, 3);
} else {
/* JIS X 0212 hojo-kanji */
this_char = (c << 16) | (str[pos + 1] << 8) | str[pos + 2];
}
pos += 3;
} else if (c != 0xA0 && c != 0xFF) {
/* character encoded in 1 code unit */
this_char = c;
pos += 1;
} else {
MB_FAILURE(pos, 1);
}
}
break;
default:
/* single-byte charsets */
this_char = str[pos++];
break;
}
*cursor = pos;
return this_char;
} | 0 |
linux | 104c307147ad379617472dd91a5bcb368d72bd6d | NOT_APPLICABLE | NOT_APPLICABLE | enum dc_status dcn10_add_stream_to_ctx(
struct dc *dc,
struct dc_state *new_ctx,
struct dc_stream_state *dc_stream)
{
enum dc_status result = DC_ERROR_UNEXPECTED;
result = resource_map_pool_resources(dc, new_ctx, dc_stream);
if (result == DC_OK)
result = resource_map_phy_clock_resources(dc, new_ctx, dc_stream);
if (result == DC_OK)
result = build_mapped_resource(dc, new_ctx, dc_stream);
return result;
} | 0 |
Chrome | 88c4913f11967abfd08a8b22b4423710322ac49b | NOT_APPLICABLE | NOT_APPLICABLE | CCLayerTreeHost::~CCLayerTreeHost()
{
ASSERT(CCProxy::isMainThread());
TRACE_EVENT("CCLayerTreeHost::~CCLayerTreeHost", this, 0);
m_proxy->stop();
m_proxy.clear();
clearPendingUpdate();
}
| 0 |
Chrome | 5d78b84d39bd34bc9fce9d01c0dcd5a22a330d34 | NOT_APPLICABLE | NOT_APPLICABLE | ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const {
ManagedMemoryPolicy actual = cached_managed_memory_policy_;
if (debug_state_.rasterize_only_visible_content) {
actual.priority_cutoff_when_visible =
gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY;
} else if (use_gpu_rasterization()) {
actual.priority_cutoff_when_visible =
gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE;
}
return actual;
}
| 0 |
Chrome | ce1446c00f0fd8f5a3b00727421be2124cb7370f | NOT_APPLICABLE | NOT_APPLICABLE | std::string XmlStringToStdString(const xmlChar* xmlstring) {
if (xmlstring)
return std::string(reinterpret_cast<const char*>(xmlstring));
else
return "";
}
| 0 |
linux | bb1fceca22492109be12640d49f5ea5a544c6bb4 | NOT_APPLICABLE | NOT_APPLICABLE | static inline char *tcp_ca_get_name_by_key(u32 key, char *buffer)
{
return NULL;
} | 0 |
php | 73cabfedf519298e1a11192699f44d53c529315e | NOT_APPLICABLE | NOT_APPLICABLE | PHP_FUNCTION(openssl_public_decrypt)
{
zval *key, *crypted;
EVP_PKEY *pkey;
int cryptedlen;
zend_string *cryptedbuf = NULL;
unsigned char *crypttemp;
int successful = 0;
zend_resource *keyresource = NULL;
zend_long padding = RSA_PKCS1_PADDING;
char * data;
size_t data_len;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz/z|l", &data, &data_len, &crypted, &key, &padding) == FAILURE) {
return;
}
RETVAL_FALSE;
pkey = php_openssl_evp_from_zval(key, 1, NULL, 0, 0, &keyresource);
if (pkey == NULL) {
php_error_docref(NULL, E_WARNING, "key parameter is not a valid public key");
RETURN_FALSE;
}
PHP_OPENSSL_CHECK_SIZE_T_TO_INT(data_len, data);
cryptedlen = EVP_PKEY_size(pkey);
crypttemp = emalloc(cryptedlen + 1);
switch (EVP_PKEY_id(pkey)) {
case EVP_PKEY_RSA:
case EVP_PKEY_RSA2:
cryptedlen = RSA_public_decrypt((int)data_len,
(unsigned char *)data,
crypttemp,
EVP_PKEY_get0_RSA(pkey),
(int)padding);
if (cryptedlen != -1) {
cryptedbuf = zend_string_alloc(cryptedlen, 0);
memcpy(ZSTR_VAL(cryptedbuf), crypttemp, cryptedlen);
successful = 1;
}
break;
default:
php_error_docref(NULL, E_WARNING, "key type not supported in this PHP build!");
}
efree(crypttemp);
if (successful) {
zval_dtor(crypted);
ZSTR_VAL(cryptedbuf)[cryptedlen] = '\0';
ZVAL_NEW_STR(crypted, cryptedbuf);
cryptedbuf = NULL;
RETVAL_TRUE;
}
if (cryptedbuf) {
zend_string_release(cryptedbuf);
}
if (keyresource == NULL) {
EVP_PKEY_free(pkey);
}
}
| 0 |
CImg | ac8003393569aba51048c9d67e1491559877b1d1 | NOT_APPLICABLE | NOT_APPLICABLE | }
inline int mod(const int x, const int m) {
return x>=0?x%m:(x%m?m + x%m:0); | 0 |
Chrome | 673ce95d481ea9368c4d4d43ac756ba1d6d9e608 | NOT_APPLICABLE | NOT_APPLICABLE | void VideoCaptureImpl::OnClientBufferFinished(
int buffer_id,
scoped_refptr<ClientBuffer> buffer,
double consumer_resource_utilization) {
DCHECK(io_thread_checker_.CalledOnValidThread());
#if DCHECK_IS_ON()
DCHECK(!buffer->HasOneRef());
ClientBuffer* const buffer_raw_ptr = buffer.get();
buffer = nullptr;
DCHECK(buffer_raw_ptr->HasOneRef());
#else
buffer = nullptr;
#endif
GetVideoCaptureHost()->ReleaseBuffer(
device_id_, buffer_id, consumer_resource_utilization);
}
| 0 |
Chrome | a4150b688a754d3d10d2ca385155b1c95d77d6ae | NOT_APPLICABLE | NOT_APPLICABLE | LRUCanvasResourceProviderCache(wtf_size_t capacity)
: resource_providers_(capacity) {}
| 0 |
ImageMagick | f6e9d0d9955e85bdd7540b251cd50d598dacc5e6 | NOT_APPLICABLE | NOT_APPLICABLE | static void *AcquireBZIPMemory(void *context,int items,int size)
{
(void) context;
return((void *) AcquireQuantumMemory((size_t) items,(size_t) size));
}
| 0 |
linux | 12ca6ad2e3a896256f086497a7c7406a547ee373 | NOT_APPLICABLE | NOT_APPLICABLE | perf_event_mux_interval_ms_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct pmu *pmu = dev_get_drvdata(dev);
int timer, cpu, ret;
ret = kstrtoint(buf, 0, &timer);
if (ret)
return ret;
if (timer < 1)
return -EINVAL;
/* same value, noting to do */
if (timer == pmu->hrtimer_interval_ms)
return count;
mutex_lock(&mux_interval_mutex);
pmu->hrtimer_interval_ms = timer;
/* update all cpuctx for this PMU */
get_online_cpus();
for_each_online_cpu(cpu) {
struct perf_cpu_context *cpuctx;
cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
cpuctx->hrtimer_interval = ns_to_ktime(NSEC_PER_MSEC * timer);
cpu_function_call(cpu,
(remote_function_f)perf_mux_hrtimer_restart, cpuctx);
}
put_online_cpus();
mutex_unlock(&mux_interval_mutex);
return count;
}
| 0 |
qemu | 3251bdcf1c67427d964517053c3d185b46e618e8 | NOT_APPLICABLE | NOT_APPLICABLE | static bool cmd_smart(IDEState *s, uint8_t cmd)
{
int n;
if (s->hcyl != 0xc2 || s->lcyl != 0x4f) {
goto abort_cmd;
}
if (!s->smart_enabled && s->feature != SMART_ENABLE) {
goto abort_cmd;
}
switch (s->feature) {
case SMART_DISABLE:
s->smart_enabled = 0;
return true;
case SMART_ENABLE:
s->smart_enabled = 1;
return true;
case SMART_ATTR_AUTOSAVE:
switch (s->sector) {
case 0x00:
s->smart_autosave = 0;
break;
case 0xf1:
s->smart_autosave = 1;
break;
default:
goto abort_cmd;
}
return true;
case SMART_STATUS:
if (!s->smart_errors) {
s->hcyl = 0xc2;
s->lcyl = 0x4f;
} else {
s->hcyl = 0x2c;
s->lcyl = 0xf4;
}
return true;
case SMART_READ_THRESH:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01; /* smart struct version */
for (n = 0; n < ARRAY_SIZE(smart_attributes); n++) {
s->io_buffer[2 + 0 + (n * 12)] = smart_attributes[n][0];
s->io_buffer[2 + 1 + (n * 12)] = smart_attributes[n][11];
}
/* checksum */
for (n = 0; n < 511; n++) {
s->io_buffer[511] += s->io_buffer[n];
}
s->io_buffer[511] = 0x100 - s->io_buffer[511];
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
return false;
case SMART_READ_DATA:
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01; /* smart struct version */
for (n = 0; n < ARRAY_SIZE(smart_attributes); n++) {
int i;
for (i = 0; i < 11; i++) {
s->io_buffer[2 + i + (n * 12)] = smart_attributes[n][i];
}
}
s->io_buffer[362] = 0x02 | (s->smart_autosave ? 0x80 : 0x00);
if (s->smart_selftest_count == 0) {
s->io_buffer[363] = 0;
} else {
s->io_buffer[363] =
s->smart_selftest_data[3 +
(s->smart_selftest_count - 1) *
24];
}
s->io_buffer[364] = 0x20;
s->io_buffer[365] = 0x01;
/* offline data collection capacity: execute + self-test*/
s->io_buffer[367] = (1 << 4 | 1 << 3 | 1);
s->io_buffer[368] = 0x03; /* smart capability (1) */
s->io_buffer[369] = 0x00; /* smart capability (2) */
s->io_buffer[370] = 0x01; /* error logging supported */
s->io_buffer[372] = 0x02; /* minutes for poll short test */
s->io_buffer[373] = 0x36; /* minutes for poll ext test */
s->io_buffer[374] = 0x01; /* minutes for poll conveyance */
for (n = 0; n < 511; n++) {
s->io_buffer[511] += s->io_buffer[n];
}
s->io_buffer[511] = 0x100 - s->io_buffer[511];
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
return false;
case SMART_READ_LOG:
switch (s->sector) {
case 0x01: /* summary smart error log */
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
s->io_buffer[1] = 0x00; /* no error entries */
s->io_buffer[452] = s->smart_errors & 0xff;
s->io_buffer[453] = (s->smart_errors & 0xff00) >> 8;
for (n = 0; n < 511; n++) {
s->io_buffer[511] += s->io_buffer[n];
}
s->io_buffer[511] = 0x100 - s->io_buffer[511];
break;
case 0x06: /* smart self test log */
memset(s->io_buffer, 0, 0x200);
s->io_buffer[0] = 0x01;
if (s->smart_selftest_count == 0) {
s->io_buffer[508] = 0;
} else {
s->io_buffer[508] = s->smart_selftest_count;
for (n = 2; n < 506; n++) {
s->io_buffer[n] = s->smart_selftest_data[n];
}
}
for (n = 0; n < 511; n++) {
s->io_buffer[511] += s->io_buffer[n];
}
s->io_buffer[511] = 0x100 - s->io_buffer[511];
break;
default:
goto abort_cmd;
}
s->status = READY_STAT | SEEK_STAT;
ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop);
ide_set_irq(s->bus);
return false;
case SMART_EXECUTE_OFFLINE:
switch (s->sector) {
case 0: /* off-line routine */
case 1: /* short self test */
case 2: /* extended self test */
s->smart_selftest_count++;
if (s->smart_selftest_count > 21) {
s->smart_selftest_count = 1;
}
n = 2 + (s->smart_selftest_count - 1) * 24;
s->smart_selftest_data[n] = s->sector;
s->smart_selftest_data[n + 1] = 0x00; /* OK and finished */
s->smart_selftest_data[n + 2] = 0x34; /* hour count lsb */
s->smart_selftest_data[n + 3] = 0x12; /* hour count msb */
break;
default:
goto abort_cmd;
}
return true;
}
abort_cmd:
ide_abort_command(s);
return true;
}
| 0 |
Chrome | 673ce95d481ea9368c4d4d43ac756ba1d6d9e608 | NOT_APPLICABLE | NOT_APPLICABLE | RenderProcessHost* FindProcess(const std::string& site) {
SiteToProcessMap::iterator i = map_.find(site);
if (i != map_.end())
return i->second;
return nullptr;
}
| 0 |
Chrome | 507241119f279c31766bd41c33d6ffb6851e2d7e | CVE-2017-5089 | CWE-20 | void CheckClientDownloadRequest::UploadBinary(
DownloadCheckResult result,
DownloadCheckResultReason reason) {
saved_result_ = result;
saved_reason_ = reason;
bool upload_for_dlp = ShouldUploadForDlpScan();
bool upload_for_malware = ShouldUploadForMalwareScan(reason);
auto request = std::make_unique<DownloadItemRequest>(
item_, /*read_immediately=*/true,
base::BindOnce(&CheckClientDownloadRequest::OnDeepScanningComplete,
weakptr_factory_.GetWeakPtr()));
Profile* profile = Profile::FromBrowserContext(GetBrowserContext());
if (upload_for_dlp) {
DlpDeepScanningClientRequest dlp_request;
dlp_request.set_content_source(DlpDeepScanningClientRequest::FILE_DOWNLOAD);
request->set_request_dlp_scan(std::move(dlp_request));
}
if (upload_for_malware) {
MalwareDeepScanningClientRequest malware_request;
malware_request.set_population(
MalwareDeepScanningClientRequest::POPULATION_ENTERPRISE);
malware_request.set_download_token(
DownloadProtectionService::GetDownloadPingToken(item_));
request->set_request_malware_scan(std::move(malware_request));
}
request->set_dm_token(
policy::BrowserDMTokenStorage::Get()->RetrieveDMToken());
service()->UploadForDeepScanning(profile, std::move(request));
}
| 1 |
linux | 5d26a105b5a73e5635eae0629b42fa0a90e07b7b | NOT_APPLICABLE | NOT_APPLICABLE | static int ecb_des3_decrypt(struct blkcipher_desc *desc,
struct scatterlist *dst, struct scatterlist *src,
unsigned int nbytes)
{
struct s390_des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
struct blkcipher_walk walk;
blkcipher_walk_init(&walk, dst, src, nbytes);
return ecb_desall_crypt(desc, KM_TDEA_192_DECRYPT, ctx->key, &walk);
}
| 0 |
linux | 86acdca1b63e6890540fa19495cfc708beff3d8b | NOT_APPLICABLE | NOT_APPLICABLE | SYSCALL_DEFINE3(symlinkat, const char __user *, oldname,
int, newdfd, const char __user *, newname)
{
int error;
char *from;
char *to;
struct dentry *dentry;
struct nameidata nd;
from = getname(oldname);
if (IS_ERR(from))
return PTR_ERR(from);
error = user_path_parent(newdfd, newname, &nd, &to);
if (error)
goto out_putname;
dentry = lookup_create(&nd, 0);
error = PTR_ERR(dentry);
if (IS_ERR(dentry))
goto out_unlock;
error = mnt_want_write(nd.path.mnt);
if (error)
goto out_dput;
error = security_path_symlink(&nd.path, dentry, from);
if (error)
goto out_drop_write;
error = vfs_symlink(nd.path.dentry->d_inode, dentry, from);
out_drop_write:
mnt_drop_write(nd.path.mnt);
out_dput:
dput(dentry);
out_unlock:
mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
path_put(&nd.path);
putname(to);
out_putname:
putname(from);
return error;
}
| 0 |
libavif | 0a8e7244d494ae98e9756355dfbfb6697ded2ff9 | NOT_APPLICABLE | NOT_APPLICABLE | static uint32_t avifCodecConfigurationBoxGetDepth(const avifCodecConfigurationBox * av1C)
{
if (av1C->twelveBit) {
return 12;
} else if (av1C->highBitdepth) {
return 10;
}
return 8;
} | 0 |
linux | 5d2be1422e02ccd697ccfcd45c85b4a26e6178e2 | CVE-2016-5243 | CWE-200 | static int tipc_nl_compat_link_dump(struct tipc_nl_compat_msg *msg,
struct nlattr **attrs)
{
struct nlattr *link[TIPC_NLA_LINK_MAX + 1];
struct tipc_link_info link_info;
int err;
if (!attrs[TIPC_NLA_LINK])
return -EINVAL;
err = nla_parse_nested(link, TIPC_NLA_LINK_MAX, attrs[TIPC_NLA_LINK],
NULL);
if (err)
return err;
link_info.dest = nla_get_flag(link[TIPC_NLA_LINK_DEST]);
link_info.up = htonl(nla_get_flag(link[TIPC_NLA_LINK_UP]));
strcpy(link_info.str, nla_data(link[TIPC_NLA_LINK_NAME]));
return tipc_add_tlv(msg->rep, TIPC_TLV_LINK_INFO,
&link_info, sizeof(link_info));
}
| 1 |
Chrome | f6ac1dba5e36f338a490752a2cbef3339096d9fe | NOT_APPLICABLE | NOT_APPLICABLE | WebGLSampler* WebGL2RenderingContextBase::createSampler() {
if (isContextLost())
return nullptr;
return WebGLSampler::Create(this);
}
| 0 |
php-src | f06a069c462d37c2e009f6d1d93b8c8e7b713393 | NOT_APPLICABLE | NOT_APPLICABLE | SPL_METHOD(SplObjectStorage, getInfo)
{
spl_SplObjectStorageElement *element;
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (zend_hash_get_current_data_ex(&intern->storage, (void**)&element, &intern->pos) == FAILURE) {
return;
}
RETVAL_ZVAL(element->inf, 1, 0);
} /* }}} */ | 0 |
mvfst | a67083ff4b8dcbb7ee2839da6338032030d712b0 | NOT_APPLICABLE | NOT_APPLICABLE | TEST_F(
QuicServerTransportForciblySetUDUPayloadSizeTest,
TestHandleTransportKnobParamForciblySetUDPPayloadSize) {
EXPECT_LT(server->getConn().udpSendPacketLen, 1452);
server->handleKnobParams(
{{static_cast<uint64_t>(
TransportKnobParamId::FORCIBLY_SET_UDP_PAYLOAD_SIZE),
1}});
EXPECT_EQ(server->getConn().udpSendPacketLen, 1452);
} | 0 |
mruby | aaa28a508903041dd7399d4159a8ace9766b022f | NOT_APPLICABLE | NOT_APPLICABLE | cipush(mrb_state *mrb, mrb_int push_stacks, uint8_t cci,
struct RClass *target_class, const struct RProc *proc, mrb_sym mid, uint8_t argc)
{
struct mrb_context *c = mrb->c;
mrb_callinfo *ci = c->ci;
if (ci + 1 == c->ciend) {
ptrdiff_t size = ci - c->cibase;
if (size > MRB_CALL_LEVEL_MAX) {
mrb_exc_raise(mrb, mrb_obj_value(mrb->stack_err));
}
c->cibase = (mrb_callinfo *)mrb_realloc(mrb, c->cibase, sizeof(mrb_callinfo)*size*2);
c->ci = c->cibase + size;
c->ciend = c->cibase + size * 2;
}
ci = ++c->ci;
ci->mid = mid;
mrb_vm_ci_proc_set(ci, proc);
ci->stack = ci[-1].stack + push_stacks;
ci->n = argc & 0xf;
ci->nk = (argc>>4) & 0xf;
ci->cci = cci;
ci->u.target_class = target_class;
return ci;
} | 0 |
ekiga | 7d09807257963a4f5168a01aec1795a398746372 | NOT_APPLICABLE | NOT_APPLICABLE | Opal::Call::on_missed_call ()
{
OpalCall::OnCleared ();
} | 0 |
wolfssl | 9b9568d500f31f964af26ba8d01e542e1f27e5ca | NOT_APPLICABLE | NOT_APPLICABLE | int wc_ecc_get_curve_size_from_name(const char* curveName)
{
int curve_idx;
if (curveName == NULL)
return BAD_FUNC_ARG;
curve_idx = wc_ecc_get_curve_idx_from_name(curveName);
if (curve_idx < 0)
return curve_idx;
return ecc_sets[curve_idx].size;
}
| 0 |
Chrome | c3957448cfc6e299165196a33cd954b790875fdb | NOT_APPLICABLE | NOT_APPLICABLE | int64_t Document::UkmSourceID() const {
return ukm_source_id_;
}
| 0 |
mongo | f3604b901d688c194de5e430c7fbab060c9dc8e0 | NOT_APPLICABLE | NOT_APPLICABLE | getSortAndGroupStagesFromPipeline(const Pipeline::SourceContainer& sources) {
boost::intrusive_ptr<DocumentSourceSort> sortStage = nullptr;
boost::intrusive_ptr<DocumentSourceGroup> groupStage = nullptr;
auto sourcesIt = sources.begin();
if (sourcesIt != sources.end()) {
sortStage = dynamic_cast<DocumentSourceSort*>(sourcesIt->get());
if (sortStage) {
if (!sortStage->hasLimit()) {
++sourcesIt;
} else {
// This $sort stage was previously followed by a $limit stage.
sourcesIt = sources.end();
}
}
}
if (sourcesIt != sources.end()) {
groupStage = dynamic_cast<DocumentSourceGroup*>(sourcesIt->get());
}
return std::make_pair(sortStage, groupStage);
} | 0 |
linux | d0cb50185ae942b03c4327be322055d622dc79f6 | NOT_APPLICABLE | NOT_APPLICABLE | int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
struct inode **delegated_inode, unsigned int flags)
{
int error;
bool is_dir = d_is_dir(old_dentry);
struct inode *source = old_dentry->d_inode;
struct inode *target = new_dentry->d_inode;
bool new_is_dir = false;
unsigned max_links = new_dir->i_sb->s_max_links;
struct name_snapshot old_name;
if (source == target)
return 0;
error = may_delete(old_dir, old_dentry, is_dir);
if (error)
return error;
if (!target) {
error = may_create(new_dir, new_dentry);
} else {
new_is_dir = d_is_dir(new_dentry);
if (!(flags & RENAME_EXCHANGE))
error = may_delete(new_dir, new_dentry, is_dir);
else
error = may_delete(new_dir, new_dentry, new_is_dir);
}
if (error)
return error;
if (!old_dir->i_op->rename)
return -EPERM;
/*
* If we are going to change the parent - check write permissions,
* we'll need to flip '..'.
*/
if (new_dir != old_dir) {
if (is_dir) {
error = inode_permission(source, MAY_WRITE);
if (error)
return error;
}
if ((flags & RENAME_EXCHANGE) && new_is_dir) {
error = inode_permission(target, MAY_WRITE);
if (error)
return error;
}
}
error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry,
flags);
if (error)
return error;
take_dentry_name_snapshot(&old_name, old_dentry);
dget(new_dentry);
if (!is_dir || (flags & RENAME_EXCHANGE))
lock_two_nondirectories(source, target);
else if (target)
inode_lock(target);
error = -EBUSY;
if (is_local_mountpoint(old_dentry) || is_local_mountpoint(new_dentry))
goto out;
if (max_links && new_dir != old_dir) {
error = -EMLINK;
if (is_dir && !new_is_dir && new_dir->i_nlink >= max_links)
goto out;
if ((flags & RENAME_EXCHANGE) && !is_dir && new_is_dir &&
old_dir->i_nlink >= max_links)
goto out;
}
if (!is_dir) {
error = try_break_deleg(source, delegated_inode);
if (error)
goto out;
}
if (target && !new_is_dir) {
error = try_break_deleg(target, delegated_inode);
if (error)
goto out;
}
error = old_dir->i_op->rename(old_dir, old_dentry,
new_dir, new_dentry, flags);
if (error)
goto out;
if (!(flags & RENAME_EXCHANGE) && target) {
if (is_dir) {
shrink_dcache_parent(new_dentry);
target->i_flags |= S_DEAD;
}
dont_mount(new_dentry);
detach_mounts(new_dentry);
}
if (!(old_dir->i_sb->s_type->fs_flags & FS_RENAME_DOES_D_MOVE)) {
if (!(flags & RENAME_EXCHANGE))
d_move(old_dentry, new_dentry);
else
d_exchange(old_dentry, new_dentry);
}
out:
if (!is_dir || (flags & RENAME_EXCHANGE))
unlock_two_nondirectories(source, target);
else if (target)
inode_unlock(target);
dput(new_dentry);
if (!error) {
fsnotify_move(old_dir, new_dir, &old_name.name, is_dir,
!(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry);
if (flags & RENAME_EXCHANGE) {
fsnotify_move(new_dir, old_dir, &old_dentry->d_name,
new_is_dir, NULL, new_dentry);
}
}
release_dentry_name_snapshot(&old_name);
return error;
} | 0 |
CImg | ac8003393569aba51048c9d67e1491559877b1d1 | NOT_APPLICABLE | NOT_APPLICABLE | //! Load image from an Ascii file \inplace.
static CImg<T> get_load_ascii(const char *const filename) {
return CImg<T>().load_ascii(filename); | 0 |
leptonica | 8d6e1755518cfb98536d6c3daf0601f226d16842 | NOT_APPLICABLE | NOT_APPLICABLE | pixGetOuterBorder(CCBORD *ccb,
PIX *pixs,
BOX *box)
{
l_int32 fpx, fpy, spx, spy, qpos;
l_int32 px, py, npx, npy;
l_int32 w, h, wpl;
l_uint32 *data;
PTA *pta;
PIX *pixb; /* with 1 pixel border */
PROCNAME("pixGetOuterBorder");
if (!ccb)
return ERROR_INT("ccb not defined", procName, 1);
if (!pixs)
return ERROR_INT("pixs not defined", procName, 1);
if (!box)
return ERROR_INT("box not defined", procName, 1);
/* Add 1-pixel border all around, and find start pixel */
if ((pixb = pixAddBorder(pixs, 1, 0)) == NULL)
return ERROR_INT("pixs not made", procName, 1);
if (!nextOnPixelInRaster(pixb, 1, 1, &px, &py)) {
pixDestroy(&pixb);
return ERROR_INT("no start pixel found", procName, 1);
}
qpos = 0; /* relative to p */
fpx = px; /* save location of first pixel on border */
fpy = py;
/* Save box and start pixel in relative coords */
boxaAddBox(ccb->boxa, box, L_COPY);
ptaAddPt(ccb->start, px - 1, py - 1);
pta = ptaCreate(0);
ptaaAddPta(ccb->local, pta, L_INSERT);
ptaAddPt(pta, px - 1, py - 1); /* initial point */
pixGetDimensions(pixb, &w, &h, NULL);
data = pixGetData(pixb);
wpl = pixGetWpl(pixb);
/* Get the second point; if there is none, return */
if (findNextBorderPixel(w, h, data, wpl, px, py, &qpos, &npx, &npy)) {
pixDestroy(&pixb);
return 0;
}
spx = npx; /* save location of second pixel on border */
spy = npy;
ptaAddPt(pta, npx - 1, npy - 1); /* second point */
px = npx;
py = npy;
while (1) {
findNextBorderPixel(w, h, data, wpl, px, py, &qpos, &npx, &npy);
if (px == fpx && py == fpy && npx == spx && npy == spy)
break;
ptaAddPt(pta, npx - 1, npy - 1);
px = npx;
py = npy;
}
pixDestroy(&pixb);
return 0;
} | 0 |
Chrome | c995d4fe5e96f4d6d4a88b7867279b08e72d2579 | NOT_APPLICABLE | NOT_APPLICABLE | bool ChromeContentBrowserClient::HandleWebUIReverse(
GURL* url,
content::BrowserContext* browser_context) {
return url->SchemeIs(content::kChromeUIScheme) &&
url->host() == chrome::kChromeUISettingsHost;
}
| 0 |
w3m | d43527cfa0dbb3ccefec4a6f7b32c1434739aa29 | NOT_APPLICABLE | NOT_APPLICABLE | Strnew_m_charp(const char *p, ...)
{
va_list ap;
Str r = Strnew();
va_start(ap, p);
while (p != NULL) {
Strcat_charp(r, p);
p = va_arg(ap, char *);
}
return r;
}
| 0 |
Chrome | c63f2b7fe4fe2977f858a8e36d5f48db17eff2e7 | NOT_APPLICABLE | NOT_APPLICABLE | scoped_refptr<Extension> Extension::CreateWithId(const FilePath& path,
Location location,
const DictionaryValue& value,
int flags,
const std::string& explicit_id,
std::string* error) {
scoped_refptr<Extension> extension = Create(
path, location, value, flags, error);
if (extension.get())
extension->id_ = explicit_id;
return extension;
}
| 0 |
php-src | 28a6ed9f9a36b9c517e4a8a429baf4dd382fc5d5?w=1 | NOT_APPLICABLE | NOT_APPLICABLE | SPL_METHOD(SplDoublyLinkedList, push)
{
zval *value;
spl_dllist_object *intern;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &value) == FAILURE) {
return;
}
intern = Z_SPLDLLIST_P(getThis());
spl_ptr_llist_push(intern->llist, value);
RETURN_TRUE;
}
| 0 |
Chrome | 2f81d000fdb5331121cba7ff81dfaaec25b520a5 | NOT_APPLICABLE | NOT_APPLICABLE | void DownloadResourceHandler::OnReadCompleted(
int bytes_read,
std::unique_ptr<ResourceController> controller) {
DCHECK(!has_controller());
bool defer = false;
if (!core_.OnReadCompleted(bytes_read, &defer)) {
controller->Cancel();
return;
}
if (defer) {
HoldController(std::move(controller));
} else {
controller->Resume();
}
}
| 0 |
linux | 0625b4ba1a5d4703c7fb01c497bd6c156908af00 | NOT_APPLICABLE | NOT_APPLICABLE | static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
u32 *in, size_t inlen,
struct ib_pd *pd)
{
struct mlx5_ib_raw_packet_qp *raw_packet_qp = &qp->raw_packet_qp;
struct mlx5_ib_sq *sq = &raw_packet_qp->sq;
struct mlx5_ib_rq *rq = &raw_packet_qp->rq;
struct ib_uobject *uobj = pd->uobject;
struct ib_ucontext *ucontext = uobj->context;
struct mlx5_ib_ucontext *mucontext = to_mucontext(ucontext);
int err;
u32 tdn = mucontext->tdn;
if (qp->sq.wqe_cnt) {
err = create_raw_packet_qp_tis(dev, qp, sq, tdn);
if (err)
return err;
err = create_raw_packet_qp_sq(dev, sq, in, pd);
if (err)
goto err_destroy_tis;
sq->base.container_mibqp = qp;
sq->base.mqp.event = mlx5_ib_qp_event;
}
if (qp->rq.wqe_cnt) {
rq->base.container_mibqp = qp;
if (qp->flags & MLX5_IB_QP_CVLAN_STRIPPING)
rq->flags |= MLX5_IB_RQ_CVLAN_STRIPPING;
if (qp->flags & MLX5_IB_QP_PCI_WRITE_END_PADDING)
rq->flags |= MLX5_IB_RQ_PCI_WRITE_END_PADDING;
err = create_raw_packet_qp_rq(dev, rq, in, inlen);
if (err)
goto err_destroy_sq;
err = create_raw_packet_qp_tir(dev, rq, tdn,
qp->tunnel_offload_en);
if (err)
goto err_destroy_rq;
}
qp->trans_qp.base.mqp.qpn = qp->sq.wqe_cnt ? sq->base.mqp.qpn :
rq->base.mqp.qpn;
return 0;
err_destroy_rq:
destroy_raw_packet_qp_rq(dev, rq);
err_destroy_sq:
if (!qp->sq.wqe_cnt)
return err;
destroy_raw_packet_qp_sq(dev, sq);
err_destroy_tis:
destroy_raw_packet_qp_tis(dev, sq);
return err;
}
| 0 |
linux | 71bb99a02b32b4cc4265118e85f6035ca72923f0 | NOT_APPLICABLE | NOT_APPLICABLE | static void __bnep_unlink_session(struct bnep_session *s)
{
list_del(&s->list);
}
| 0 |
linux | 499350a5a6e7512d9ed369ed63a4244b6536f4f8 | NOT_APPLICABLE | NOT_APPLICABLE | static unsigned int tcp_xmit_size_goal(struct sock *sk, u32 mss_now,
int large_allowed)
{
struct tcp_sock *tp = tcp_sk(sk);
u32 new_size_goal, size_goal;
if (!large_allowed || !sk_can_gso(sk))
return mss_now;
/* Note : tcp_tso_autosize() will eventually split this later */
new_size_goal = sk->sk_gso_max_size - 1 - MAX_TCP_HEADER;
new_size_goal = tcp_bound_to_half_wnd(tp, new_size_goal);
/* We try hard to avoid divides here */
size_goal = tp->gso_segs * mss_now;
if (unlikely(new_size_goal < size_goal ||
new_size_goal >= size_goal + mss_now)) {
tp->gso_segs = min_t(u16, new_size_goal / mss_now,
sk->sk_gso_max_segs);
size_goal = tp->gso_segs * mss_now;
}
return max(size_goal, mss_now);
}
| 0 |
file | 4a284c89d6ef11aca34da65da7d673050a5ea320 | NOT_APPLICABLE | NOT_APPLICABLE | getvalue(struct magic_set *ms, struct magic *m, const char **p, int action)
{
switch (m->type) {
case FILE_BESTRING16:
case FILE_LESTRING16:
case FILE_STRING:
case FILE_PSTRING:
case FILE_REGEX:
case FILE_SEARCH:
case FILE_NAME:
case FILE_USE:
*p = getstr(ms, m, *p, action == FILE_COMPILE);
if (*p == NULL) {
if (ms->flags & MAGIC_CHECK)
file_magwarn(ms, "cannot get string from `%s'",
m->value.s);
return -1;
}
if (m->type == FILE_REGEX) {
file_regex_t rx;
int rc = file_regcomp(&rx, m->value.s, REG_EXTENDED);
if (rc) {
if (ms->flags & MAGIC_CHECK)
file_regerror(&rx, rc, ms);
}
file_regfree(&rx);
return rc ? -1 : 0;
}
return 0;
case FILE_FLOAT:
case FILE_BEFLOAT:
case FILE_LEFLOAT:
if (m->reln != 'x') {
char *ep;
#ifdef HAVE_STRTOF
m->value.f = strtof(*p, &ep);
#else
m->value.f = (float)strtod(*p, &ep);
#endif
*p = ep;
}
return 0;
case FILE_DOUBLE:
case FILE_BEDOUBLE:
case FILE_LEDOUBLE:
if (m->reln != 'x') {
char *ep;
m->value.d = strtod(*p, &ep);
*p = ep;
}
return 0;
default:
if (m->reln != 'x') {
char *ep;
m->value.q = file_signextend(ms, m,
(uint64_t)strtoull(*p, &ep, 0));
*p = ep;
eatsize(p);
}
return 0;
}
}
| 0 |
Chrome | c0da7c1c6e9ffe5006e146b6426f987238d4bf2e | NOT_APPLICABLE | NOT_APPLICABLE | void RunBeforeUnloadSanityTest(DevToolsDockSide dock_side,
base::Callback<void(void)> close_method,
bool wait_for_browser_close = true) {
OpenDevToolsWindow(kDebuggerTestPage);
window_->SetDockSideForTest(dock_side);
content::WindowedNotificationObserver devtools_close_observer(
content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
content::Source<content::WebContents>(window_->web_contents()));
InjectBeforeUnloadListener(window_->web_contents());
{
DevToolsWindowBeforeUnloadObserver before_unload_observer(window_);
close_method.Run();
CancelModalDialog();
before_unload_observer.Wait();
}
{
content::WindowedNotificationObserver close_observer(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::Source<Browser>(browser()));
close_method.Run();
AcceptModalDialog();
if (wait_for_browser_close)
close_observer.Wait();
}
devtools_close_observer.Wait();
}
| 0 |
Chrome | 0aca6bc05a263ea9eafee515fc6ba14da94c1964 | NOT_APPLICABLE | NOT_APPLICABLE | bool GetTabById(int tab_id,
content::BrowserContext* context,
bool include_incognito,
Browser** browser,
TabStripModel** tab_strip,
content::WebContents** contents,
int* tab_index,
std::string* error_message) {
if (ExtensionTabUtil::GetTabById(tab_id, context, include_incognito, browser,
tab_strip, contents, tab_index)) {
return true;
}
if (error_message) {
*error_message = ErrorUtils::FormatErrorMessage(
keys::kTabNotFoundError, base::IntToString(tab_id));
}
return false;
}
| 0 |
Chrome | 96dbafe288dbe2f0cc45fa3c39daf6d0c37acbab | NOT_APPLICABLE | NOT_APPLICABLE | xsltGetExtInfo(xsltStylesheetPtr style, const xmlChar * URI)
{
xsltExtDataPtr data;
/*
* TODO: Why do we have a return type of xmlHashTablePtr?
* Is the user-allocated data for extension modules expected
* to be a xmlHashTablePtr only? Or is this intended for
* the EXSLT module only?
*/
if (style != NULL && style->extInfos != NULL) {
data = xmlHashLookup(style->extInfos, URI);
if (data != NULL && data->extData != NULL)
return data->extData;
}
return NULL;
}
| 0 |
Little-CMS | 768f70ca405cd3159d990e962d54456773bb8cf8 | NOT_APPLICABLE | NOT_APPLICABLE | cmsBool CMSEXPORT cmsIT8SetPropertyStr(cmsHANDLE hIT8, const char* Key, const char *Val)
{
cmsIT8* it8 = (cmsIT8*) hIT8;
if (!Val) return FALSE;
if (!*Val) return FALSE;
return AddToList(it8, &GetTable(it8)->HeaderList, Key, NULL, Val, WRITE_STRINGIFY) != NULL;
}
| 0 |
linux | 132c94e31b8bca8ea921f9f96a57d684fa4ae0a9 | NOT_APPLICABLE | NOT_APPLICABLE | static void mnt_free_id(struct mount *mnt)
{
int id = mnt->mnt_id;
spin_lock(&mnt_id_lock);
ida_remove(&mnt_id_ida, id);
if (mnt_id_start > id)
mnt_id_start = id;
spin_unlock(&mnt_id_lock);
}
| 0 |
linux | 6e94e0cfb0887e4013b3b930fa6ab1fe6bb6ba91 | NOT_APPLICABLE | NOT_APPLICABLE | static int compat_do_arpt_set_ctl(struct sock *sk, int cmd, void __user *user,
unsigned int len)
{
int ret;
if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN))
return -EPERM;
switch (cmd) {
case ARPT_SO_SET_REPLACE:
ret = compat_do_replace(sock_net(sk), user, len);
break;
case ARPT_SO_SET_ADD_COUNTERS:
ret = do_add_counters(sock_net(sk), user, len, 1);
break;
default:
duprintf("do_arpt_set_ctl: unknown request %i\n", cmd);
ret = -EINVAL;
}
return ret;
}
| 0 |
vte | 58bc3a942f198a1a8788553ca72c19d7c1702b74 | NOT_APPLICABLE | NOT_APPLICABLE | vte_sequence_handler_ta (VteTerminal *terminal, GValueArray *params)
{
VteScreen *screen;
long newcol, col;
/* Calculate which column is the next tab stop. */
screen = terminal->pvt->screen;
newcol = col = screen->cursor_current.col;
g_assert (col >= 0);
if (terminal->pvt->tabstops != NULL) {
/* Find the next tabstop. */
for (newcol++; newcol < VTE_TAB_MAX; newcol++) {
if (_vte_terminal_get_tabstop(terminal, newcol)) {
break;
}
}
}
/* If we have no tab stops or went past the end of the line, stop
* at the right-most column. */
if (newcol >= terminal->column_count) {
newcol = terminal->column_count - 1;
}
/* but make sure we don't move cursor back (bug #340631) */
if (col < newcol) {
VteRowData *rowdata = _vte_terminal_ensure_row (terminal);
/* Smart tab handling: bug 353610
*
* If we currently don't have any cells in the space this
* tab creates, we try to make the tab character copyable,
* by appending a single tab char with lots of fragment
* cells following it.
*
* Otherwise, just append empty cells that will show up
* as a space each.
*/
/* Get rid of trailing empty cells: bug 545924 */
if ((glong) rowdata->cells->len > col)
{
struct vte_charcell *cell;
guint i;
for (i = rowdata->cells->len; (glong) i > col; i--) {
cell = &g_array_index(rowdata->cells,
struct vte_charcell, i - 1);
if (cell->attr.fragment || cell->c != 0)
break;
}
g_array_set_size(rowdata->cells, i);
}
if ((glong) rowdata->cells->len <= col)
{
struct vte_charcell cell;
vte_g_array_fill (rowdata->cells,
&screen->fill_defaults,
col);
cell.attr = screen->fill_defaults.attr;
cell.attr.invisible = 1; /* FIXME: bug 499944 */
cell.attr.columns = newcol - col;
if (cell.attr.columns != newcol - col)
{
/* number of columns doesn't fit one cell. skip
* fancy tabs
*/
goto fallback_tab;
}
cell.c = '\t';
g_array_append_vals(rowdata->cells, &cell, 1);
cell.attr = screen->fill_defaults.attr;
cell.attr.fragment = 1;
vte_g_array_fill (rowdata->cells,
&cell,
newcol);
}
else
{
fallback_tab:
vte_g_array_fill (rowdata->cells,
&screen->fill_defaults,
newcol);
}
_vte_invalidate_cells (terminal,
screen->cursor_current.col,
newcol - screen->cursor_current.col,
screen->cursor_current.row, 1);
screen->cursor_current.col = newcol;
}
} | 0 |
wireshark | 2cb5985bf47bdc8bea78d28483ed224abdd33dc6 | NOT_APPLICABLE | NOT_APPLICABLE | dissect_usb_vid_get_set(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb,
int offset, gboolean is_request,
usb_trans_info_t *usb_trans_info,
usb_conv_info_t *usb_conv_info)
{
const gchar *short_name = NULL;
guint8 control_sel;
guint8 entity_id;
entity_id = usb_trans_info->setup.wIndex >> 8;
control_sel = usb_trans_info->setup.wValue >> 8;
/* Display something informative in the INFO column */
col_append_str(pinfo->cinfo, COL_INFO, " [");
short_name = get_control_selector_name(entity_id, control_sel, usb_conv_info);
if (short_name)
col_append_str(pinfo->cinfo, COL_INFO, short_name);
else
{
short_name = "Unknown";
if (entity_id == 0)
{
col_append_fstr(pinfo->cinfo, COL_INFO, "Interface %u control 0x%x",
usb_conv_info->interfaceNum, control_sel);
}
else
{
col_append_fstr(pinfo->cinfo, COL_INFO, "Unit %u control 0x%x",
entity_id, control_sel);
}
}
col_append_str(pinfo->cinfo, COL_INFO, "]");
col_set_fence(pinfo->cinfo, COL_INFO);
/* Add information on request context,
* as GENERATED fields if not directly available (for filtering)
*/
if (is_request)
{
/* Move gaze to control selector (MSB of wValue) */
offset++;
proto_tree_add_uint_format_value(tree, hf_usb_vid_control_selector, tvb,
offset, 1, control_sel, "%s (0x%02x)", short_name, control_sel);
offset++;
proto_tree_add_item(tree, hf_usb_vid_control_interface, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset++;
proto_tree_add_item(tree, hf_usb_vid_control_entity, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset++;
proto_tree_add_item(tree, hf_usb_vid_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
}
else
{
proto_item *ti;
ti = proto_tree_add_uint(tree, hf_usb_vid_control_interface, tvb, 0, 0,
usb_trans_info->setup.wIndex & 0xFF);
PROTO_ITEM_SET_GENERATED(ti);
ti = proto_tree_add_uint(tree, hf_usb_vid_control_entity, tvb, 0, 0, entity_id);
PROTO_ITEM_SET_GENERATED(ti);
ti = proto_tree_add_uint_format_value(tree, hf_usb_vid_control_selector, tvb,
0, 0, control_sel, "%s (0x%02x)", short_name, control_sel);
PROTO_ITEM_SET_GENERATED(ti);
}
if (!is_request || (usb_trans_info->setup.request == USB_SETUP_SET_CUR))
{
gint value_size = tvb_reported_length_remaining(tvb, offset);
if (value_size != 0)
{
if ((entity_id == 0) && (usb_conv_info->interfaceSubclass == SC_VIDEOSTREAMING))
{
if ((control_sel == VS_PROBE_CONTROL) || (control_sel == VS_COMMIT_CONTROL))
{
int old_offset = offset;
offset = dissect_usb_vid_probe(tree, tvb, offset);
value_size -= (offset - old_offset);
}
}
else
{
if (usb_trans_info->setup.request == USB_SETUP_GET_INFO)
{
dissect_usb_vid_control_info(tree, tvb, offset);
offset++;
value_size--;
}
else if (usb_trans_info->setup.request == USB_SETUP_GET_LEN)
{
proto_tree_add_item(tree, hf_usb_vid_control_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
value_size -= 2;
}
else if ( (usb_trans_info->setup.request == USB_SETUP_GET_CUR)
&& (entity_id == 0)
&& (usb_conv_info->interfaceSubclass == SC_VIDEOCONTROL)
&& (control_sel == VC_REQUEST_ERROR_CODE_CONTROL))
{
proto_tree_add_item(tree, hf_usb_vid_request_error, tvb, offset, 1, ENC_LITTLE_ENDIAN);
offset++;
value_size--;
}
else
{
dissect_usb_vid_control_value(tree, tvb, offset, usb_trans_info->setup.request);
offset += value_size;
value_size = 0;
}
}
if (value_size > 0)
{
proto_tree_add_item(tree, hf_usb_vid_control_data, tvb, offset, -1, ENC_NA);
offset += value_size;
}
}
}
return offset;
}
| 0 |
linux | ded89912156b1a47d940a0c954c43afbabd0c42c | NOT_APPLICABLE | NOT_APPLICABLE | brcmf_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy,
struct wireless_dev *wdev,
u64 cookie)
{
struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct brcmf_cfg80211_vif *vif;
int err = 0;
brcmf_dbg(TRACE, "Enter p2p listen cancel\n");
vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif;
if (vif == NULL) {
brcmf_err("No p2p device available for probe response\n");
err = -ENODEV;
goto exit;
}
brcmf_p2p_cancel_remain_on_channel(vif->ifp);
exit:
return err;
}
| 0 |
Chrome | 016da29386308754274675e65fdb73cf9d59dc2d | NOT_APPLICABLE | NOT_APPLICABLE | Browser* GetBrowserInProfileWithId(Profile* profile,
const int window_id,
bool include_incognito,
std::string* error_message) {
Profile* incognito_profile =
include_incognito && profile->HasOffTheRecordProfile() ?
profile->GetOffTheRecordProfile() : NULL;
for (chrome::BrowserIterator it; !it.done(); it.Next()) {
Browser* browser = *it;
if ((browser->profile() == profile ||
browser->profile() == incognito_profile) &&
ExtensionTabUtil::GetWindowId(browser) == window_id &&
browser->window()) {
return browser;
}
}
if (error_message)
*error_message = ErrorUtils::FormatErrorMessage(
keys::kWindowNotFoundError, base::IntToString(window_id));
return NULL;
}
| 0 |
leptonica | 5ba34b1fe741d69d43a6c8cf767756997eadd87c | NOT_APPLICABLE | NOT_APPLICABLE | tiffCloseCallback(thandle_t handle)
{
L_MEMSTREAM *mstream;
mstream = (L_MEMSTREAM *)handle;
if (mstream->poutdata) { /* writing: save the output data */
*mstream->poutdata = mstream->buffer;
*mstream->poutsize = mstream->hw;
}
LEPT_FREE(mstream); /* never free the buffer! */
return 0;
} | 0 |
Android | 864e2e22fcd0cba3f5e67680ccabd0302dfda45d | NOT_APPLICABLE | NOT_APPLICABLE | static int handle_fuse_request(struct fuse *fuse, struct fuse_handler* handler,
const struct fuse_in_header *hdr, const void *data, size_t data_len)
{
switch (hdr->opcode) {
case FUSE_LOOKUP: { /* bytez[] -> entry_out */
const char* name = data;
return handle_lookup(fuse, handler, hdr, name);
}
case FUSE_FORGET: {
const struct fuse_forget_in *req = data;
return handle_forget(fuse, handler, hdr, req);
}
case FUSE_GETATTR: { /* getattr_in -> attr_out */
const struct fuse_getattr_in *req = data;
return handle_getattr(fuse, handler, hdr, req);
}
case FUSE_SETATTR: { /* setattr_in -> attr_out */
const struct fuse_setattr_in *req = data;
return handle_setattr(fuse, handler, hdr, req);
}
case FUSE_MKNOD: { /* mknod_in, bytez[] -> entry_out */
const struct fuse_mknod_in *req = data;
const char *name = ((const char*) data) + sizeof(*req);
return handle_mknod(fuse, handler, hdr, req, name);
}
case FUSE_MKDIR: { /* mkdir_in, bytez[] -> entry_out */
const struct fuse_mkdir_in *req = data;
const char *name = ((const char*) data) + sizeof(*req);
return handle_mkdir(fuse, handler, hdr, req, name);
}
case FUSE_UNLINK: { /* bytez[] -> */
const char* name = data;
return handle_unlink(fuse, handler, hdr, name);
}
case FUSE_RMDIR: { /* bytez[] -> */
const char* name = data;
return handle_rmdir(fuse, handler, hdr, name);
}
case FUSE_RENAME: { /* rename_in, oldname, newname -> */
const struct fuse_rename_in *req = data;
const char *old_name = ((const char*) data) + sizeof(*req);
const char *new_name = old_name + strlen(old_name) + 1;
return handle_rename(fuse, handler, hdr, req, old_name, new_name);
}
case FUSE_OPEN: { /* open_in -> open_out */
const struct fuse_open_in *req = data;
return handle_open(fuse, handler, hdr, req);
}
case FUSE_READ: { /* read_in -> byte[] */
const struct fuse_read_in *req = data;
return handle_read(fuse, handler, hdr, req);
}
case FUSE_WRITE: { /* write_in, byte[write_in.size] -> write_out */
const struct fuse_write_in *req = data;
const void* buffer = (const __u8*)data + sizeof(*req);
return handle_write(fuse, handler, hdr, req, buffer);
}
case FUSE_STATFS: { /* getattr_in -> attr_out */
return handle_statfs(fuse, handler, hdr);
}
case FUSE_RELEASE: { /* release_in -> */
const struct fuse_release_in *req = data;
return handle_release(fuse, handler, hdr, req);
}
case FUSE_FSYNC:
case FUSE_FSYNCDIR: {
const struct fuse_fsync_in *req = data;
return handle_fsync(fuse, handler, hdr, req);
}
case FUSE_FLUSH: {
return handle_flush(fuse, handler, hdr);
}
case FUSE_OPENDIR: { /* open_in -> open_out */
const struct fuse_open_in *req = data;
return handle_opendir(fuse, handler, hdr, req);
}
case FUSE_READDIR: {
const struct fuse_read_in *req = data;
return handle_readdir(fuse, handler, hdr, req);
}
case FUSE_RELEASEDIR: { /* release_in -> */
const struct fuse_release_in *req = data;
return handle_releasedir(fuse, handler, hdr, req);
}
case FUSE_INIT: { /* init_in -> init_out */
const struct fuse_init_in *req = data;
return handle_init(fuse, handler, hdr, req);
}
default: {
TRACE("[%d] NOTIMPL op=%d uniq=%"PRIx64" nid=%"PRIx64"\n",
handler->token, hdr->opcode, hdr->unique, hdr->nodeid);
return -ENOSYS;
}
}
}
| 0 |
postgres | 28e24125541545483093819efae9bca603441951 | NOT_APPLICABLE | NOT_APPLICABLE | socket_is_send_pending(void)
{
return (PqSendStart < PqSendPointer);
} | 0 |
Android | 3ac044334c3ff6a61cb4238ff3ddaf17c7efcf49 | NOT_APPLICABLE | NOT_APPLICABLE | static EAS_RESULT WT_Initialize (S_VOICE_MGR *pVoiceMgr)
{
EAS_INT i;
for (i = 0; i < NUM_WT_VOICES; i++)
{
pVoiceMgr->wtVoices[i].artIndex = DEFAULT_ARTICULATION_INDEX;
pVoiceMgr->wtVoices[i].eg1State = DEFAULT_EG1_STATE;
pVoiceMgr->wtVoices[i].eg1Value = DEFAULT_EG1_VALUE;
pVoiceMgr->wtVoices[i].eg1Increment = DEFAULT_EG1_INCREMENT;
pVoiceMgr->wtVoices[i].eg2State = DEFAULT_EG2_STATE;
pVoiceMgr->wtVoices[i].eg2Value = DEFAULT_EG2_VALUE;
pVoiceMgr->wtVoices[i].eg2Increment = DEFAULT_EG2_INCREMENT;
/* left and right gain values are needed only if stereo output */
#if (NUM_OUTPUT_CHANNELS == 2)
pVoiceMgr->wtVoices[i].gainLeft = DEFAULT_VOICE_GAIN;
pVoiceMgr->wtVoices[i].gainRight = DEFAULT_VOICE_GAIN;
#endif
pVoiceMgr->wtVoices[i].phaseFrac = DEFAULT_PHASE_FRAC;
pVoiceMgr->wtVoices[i].phaseAccum = DEFAULT_PHASE_INT;
#ifdef _FILTER_ENABLED
pVoiceMgr->wtVoices[i].filter.z1 = DEFAULT_FILTER_ZERO;
pVoiceMgr->wtVoices[i].filter.z2 = DEFAULT_FILTER_ZERO;
#endif
}
return EAS_TRUE;
}
| 0 |
radare2 | cb8b683758edddae2d2f62e8e63a738c39f92683 | NOT_APPLICABLE | NOT_APPLICABLE | R_API int r_core_fgets(char *buf, int len) {
const char *ptr;
RLine *rli = r_line_singleton ();
buf[0] = '\0';
r_line_completion_set (&rli->completion, radare_argc, radare_argv);
rli->completion.run = autocomplete;
rli->completion.run_user = rli->user;
ptr = r_line_readline ();
if (!ptr) {
return -1;
}
strncpy (buf, ptr, len - 1);
buf[len - 1] = 0;
return strlen (buf);
} | 0 |
savannah | efb795c74fe954b9544074aafcebb1be4452b03a | NOT_APPLICABLE | NOT_APPLICABLE | hook_hdata (struct t_weechat_plugin *plugin, const char *hdata_name,
const char *description,
t_hook_callback_hdata *callback, void *callback_data)
{
struct t_hook *new_hook;
struct t_hook_hdata *new_hook_hdata;
int priority;
const char *ptr_hdata_name;
if (!hdata_name || !hdata_name[0] || !callback)
return NULL;
new_hook = malloc (sizeof (*new_hook));
if (!new_hook)
return NULL;
new_hook_hdata = malloc (sizeof (*new_hook_hdata));
if (!new_hook_hdata)
{
free (new_hook);
return NULL;
}
hook_get_priority_and_name (hdata_name, &priority, &ptr_hdata_name);
hook_init_data (new_hook, plugin, HOOK_TYPE_HDATA, priority,
callback_data);
new_hook->hook_data = new_hook_hdata;
new_hook_hdata->callback = callback;
new_hook_hdata->hdata_name = strdup ((ptr_hdata_name) ?
ptr_hdata_name : hdata_name);
new_hook_hdata->description = strdup ((description) ? description : "");
hook_add_to_list (new_hook);
return new_hook;
}
| 0 |
linux | 397d425dc26da728396e66d392d5dcb8dac30c37 | NOT_APPLICABLE | NOT_APPLICABLE | static bool legitimize_links(struct nameidata *nd)
{
int i;
for (i = 0; i < nd->depth; i++) {
struct saved *last = nd->stack + i;
if (unlikely(!legitimize_path(nd, &last->link, last->seq))) {
drop_links(nd);
nd->depth = i + 1;
return false;
}
}
return true;
}
| 0 |
linux | cde93be45a8a90d8c264c776fab63487b5038a65 | NOT_APPLICABLE | NOT_APPLICABLE | struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
struct qstr *name)
{
struct dentry *found;
struct dentry *new;
/*
* First check if a dentry matching the name already exists,
* if not go ahead and create it now.
*/
found = d_hash_and_lookup(dentry->d_parent, name);
if (!found) {
new = d_alloc(dentry->d_parent, name);
if (!new) {
found = ERR_PTR(-ENOMEM);
} else {
found = d_splice_alias(inode, new);
if (found) {
dput(new);
return found;
}
return new;
}
}
iput(inode);
return found;
}
| 0 |
ovs | 9237a63c47bd314b807cda0bd2216264e82edbe8 | NOT_APPLICABLE | NOT_APPLICABLE | parse_truncate_subfield(struct ofpact_output_trunc *output_trunc,
const char *arg_)
{
char *key, *value;
char *arg = CONST_CAST(char *, arg_);
while (ofputil_parse_key_value(&arg, &key, &value)) {
if (!strcmp(key, "port")) {
if (!ofputil_port_from_string(value, &output_trunc->port)) {
return xasprintf("output to unknown truncate port: %s",
value);
}
if (ofp_to_u16(output_trunc->port) > ofp_to_u16(OFPP_MAX)) {
if (output_trunc->port != OFPP_LOCAL &&
output_trunc->port != OFPP_IN_PORT)
return xasprintf("output to unsupported truncate port: %s",
value);
}
} else if (!strcmp(key, "max_len")) {
char *err;
err = str_to_u32(value, &output_trunc->max_len);
if (err) {
return err;
}
} else {
return xasprintf("invalid key '%s' in output_trunc argument",
key);
}
}
return NULL;
}
| 0 |
gnome-session | b0dc999e0b45355314616321dbb6cb71e729fc9d | NOT_APPLICABLE | NOT_APPLICABLE | prop_to_command (SmProp *prop)
{
GString *str;
int i, j;
gboolean need_quotes;
str = g_string_new (NULL);
for (i = 0; i < prop->num_vals; i++) {
char *val = prop->vals[i].value;
need_quotes = FALSE;
for (j = 0; j < prop->vals[i].length; j++) {
if (!g_ascii_isalnum (val[j]) && !strchr ("-_=:./", val[j])) {
need_quotes = TRUE;
break;
}
}
if (i > 0) {
g_string_append_c (str, ' ');
}
if (!need_quotes) {
g_string_append_printf (str,
"%.*s",
prop->vals[i].length,
(char *)prop->vals[i].value);
} else {
g_string_append_c (str, '\'');
while (val < (char *)prop->vals[i].value + prop->vals[i].length) {
if (*val == '\'') {
g_string_append (str, "'\''");
} else {
g_string_append_c (str, *val);
}
val++;
}
g_string_append_c (str, '\'');
}
}
return g_string_free (str, FALSE);
}
| 0 |
Chrome | 3bbc818ed1a7b63b8290bbde9ae975956748cb8a | NOT_APPLICABLE | NOT_APPLICABLE | WebContextMenuProxyGtk* webkitWebViewBaseGetActiveContextMenuProxy(WebKitWebViewBase* webkitWebViewBase)
{
return webkitWebViewBase->priv->activeContextMenuProxy;
}
| 0 |
php | c1224573c773b6845e83505f717fbf820fc18415 | NOT_APPLICABLE | NOT_APPLICABLE | PHP_FUNCTION(openssl_csr_sign)
{
zval ** zcert = NULL, **zcsr, **zpkey, *args = NULL;
long num_days;
long serial = 0L;
X509 * cert = NULL, *new_cert = NULL;
X509_REQ * csr;
EVP_PKEY * key = NULL, *priv_key = NULL;
long csr_resource, certresource = 0, keyresource = -1;
int i;
struct php_x509_request req;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ!Zl|a!l", &zcsr, &zcert, &zpkey, &num_days, &args, &serial) == FAILURE)
return;
RETVAL_FALSE;
PHP_SSL_REQ_INIT(&req);
csr = php_openssl_csr_from_zval(zcsr, 0, &csr_resource TSRMLS_CC);
if (csr == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get CSR from parameter 1");
return;
}
if (zcert) {
cert = php_openssl_x509_from_zval(zcert, 0, &certresource TSRMLS_CC);
if (cert == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get cert from parameter 2");
goto cleanup;
}
}
priv_key = php_openssl_evp_from_zval(zpkey, 0, "", 1, &keyresource TSRMLS_CC);
if (priv_key == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot get private key from parameter 3");
goto cleanup;
}
if (cert && !X509_check_private_key(cert, priv_key)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "private key does not correspond to signing cert");
goto cleanup;
}
if (PHP_SSL_REQ_PARSE(&req, args) == FAILURE) {
goto cleanup;
}
/* Check that the request matches the signature */
key = X509_REQ_get_pubkey(csr);
if (key == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "error unpacking public key");
goto cleanup;
}
i = X509_REQ_verify(csr, key);
if (i < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Signature verification problems");
goto cleanup;
}
else if (i == 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Signature did not match the certificate request");
goto cleanup;
}
/* Now we can get on with it */
new_cert = X509_new();
if (new_cert == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "No memory");
goto cleanup;
}
/* Version 3 cert */
if (!X509_set_version(new_cert, 2))
goto cleanup;
ASN1_INTEGER_set(X509_get_serialNumber(new_cert), serial);
X509_set_subject_name(new_cert, X509_REQ_get_subject_name(csr));
if (cert == NULL) {
cert = new_cert;
}
if (!X509_set_issuer_name(new_cert, X509_get_subject_name(cert))) {
goto cleanup;
}
X509_gmtime_adj(X509_get_notBefore(new_cert), 0);
X509_gmtime_adj(X509_get_notAfter(new_cert), (long)60*60*24*num_days);
i = X509_set_pubkey(new_cert, key);
if (!i) {
goto cleanup;
}
if (req.extensions_section) {
X509V3_CTX ctx;
X509V3_set_ctx(&ctx, cert, new_cert, csr, NULL, 0);
X509V3_set_conf_lhash(&ctx, req.req_config);
if (!X509V3_EXT_add_conf(req.req_config, &ctx, req.extensions_section, new_cert)) {
goto cleanup;
}
}
/* Now sign it */
if (!X509_sign(new_cert, priv_key, req.digest)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to sign it");
goto cleanup;
}
/* Succeeded; lets return the cert */
RETVAL_RESOURCE(zend_list_insert(new_cert, le_x509));
new_cert = NULL;
cleanup:
if (cert == new_cert) {
cert = NULL;
}
PHP_SSL_REQ_DISPOSE(&req);
if (keyresource == -1 && priv_key) {
EVP_PKEY_free(priv_key);
}
if (key) {
EVP_PKEY_free(key);
}
if (csr_resource == -1 && csr) {
X509_REQ_free(csr);
}
if (certresource == -1 && cert) {
X509_free(cert);
}
if (new_cert) {
X509_free(new_cert);
}
}
| 0 |
linux | 4ea77014af0d6205b05503d1c7aac6eace11d473 | NOT_APPLICABLE | NOT_APPLICABLE | static int do_sigtimedwait(const sigset_t *which, siginfo_t *info,
const struct timespec *ts)
{
ktime_t *to = NULL, timeout = KTIME_MAX;
struct task_struct *tsk = current;
sigset_t mask = *which;
int sig, ret = 0;
if (ts) {
if (!timespec_valid(ts))
return -EINVAL;
timeout = timespec_to_ktime(*ts);
to = &timeout;
}
/*
* Invert the set of allowed signals to get those we want to block.
*/
sigdelsetmask(&mask, sigmask(SIGKILL) | sigmask(SIGSTOP));
signotset(&mask);
spin_lock_irq(&tsk->sighand->siglock);
sig = dequeue_signal(tsk, &mask, info);
if (!sig && timeout) {
/*
* None ready, temporarily unblock those we're interested
* while we are sleeping in so that we'll be awakened when
* they arrive. Unblocking is always fine, we can avoid
* set_current_blocked().
*/
tsk->real_blocked = tsk->blocked;
sigandsets(&tsk->blocked, &tsk->blocked, &mask);
recalc_sigpending();
spin_unlock_irq(&tsk->sighand->siglock);
__set_current_state(TASK_INTERRUPTIBLE);
ret = freezable_schedule_hrtimeout_range(to, tsk->timer_slack_ns,
HRTIMER_MODE_REL);
spin_lock_irq(&tsk->sighand->siglock);
__set_task_blocked(tsk, &tsk->real_blocked);
sigemptyset(&tsk->real_blocked);
sig = dequeue_signal(tsk, &mask, info);
}
spin_unlock_irq(&tsk->sighand->siglock);
if (sig)
return sig;
return ret ? -EINTR : -EAGAIN;
}
| 0 |
savannah | a3bc7e9400b214a0f078fdb19596ba54214a1442 | NOT_APPLICABLE | NOT_APPLICABLE | DEFUN (show_ip_bgp_vpnv4_rd_tags,
show_ip_bgp_vpnv4_rd_tags_cmd,
"show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn tags",
SHOW_STR
IP_STR
BGP_STR
"Display VPNv4 NLRI specific information\n"
"Display information for a route distinguisher\n"
"VPN Route Distinguisher\n"
"Display BGP tags for prefixes\n")
{
int ret;
struct prefix_rd prd;
ret = str2prefix_rd (argv[0], &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
return CMD_WARNING;
}
return bgp_show_mpls_vpn (vty, &prd, bgp_show_type_normal, NULL, 1);
}
| 0 |
Chrome | a7d715ae5b654d1f98669fd979a00282a7229044 | NOT_APPLICABLE | NOT_APPLICABLE | void RenderViewImpl::OnUpdateTargetURLAck() {
if (target_url_status_ == TARGET_PENDING)
Send(new ViewHostMsg_UpdateTargetURL(GetRoutingID(), pending_target_url_));
target_url_status_ = TARGET_NONE;
}
| 0 |
jasper | e6c8d5a838b49f94616be14753aa5c89d64605b5 | NOT_APPLICABLE | NOT_APPLICABLE | int jpc_enc_enccblks(jpc_enc_t *enc)
{
jpc_enc_tcmpt_t *tcmpt;
jpc_enc_tcmpt_t *endcomps;
jpc_enc_rlvl_t *lvl;
jpc_enc_rlvl_t *endlvls;
jpc_enc_band_t *band;
jpc_enc_band_t *endbands;
jpc_enc_cblk_t *cblk;
jpc_enc_cblk_t *endcblks;
int i;
int j;
jpc_fix_t mx;
jpc_fix_t bmx;
jpc_fix_t v;
jpc_enc_tile_t *tile;
uint_fast32_t prcno;
jpc_enc_prc_t *prc;
tile = enc->curtile;
endcomps = &tile->tcmpts[tile->numtcmpts];
for (tcmpt = tile->tcmpts; tcmpt != endcomps; ++tcmpt) {
endlvls = &tcmpt->rlvls[tcmpt->numrlvls];
for (lvl = tcmpt->rlvls; lvl != endlvls; ++lvl) {
if (!lvl->bands) {
continue;
}
endbands = &lvl->bands[lvl->numbands];
for (band = lvl->bands; band != endbands; ++band) {
if (!band->data) {
continue;
}
for (prcno = 0, prc = band->prcs; prcno < lvl->numprcs; ++prcno, ++prc) {
if (!prc->cblks) {
continue;
}
bmx = 0;
endcblks = &prc->cblks[prc->numcblks];
for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
mx = 0;
for (i = 0; i < jas_matrix_numrows(cblk->data); ++i) {
for (j = 0; j < jas_matrix_numcols(cblk->data); ++j) {
v = JAS_ABS(jas_matrix_get(cblk->data, i, j));
if (v > mx) {
mx = v;
}
}
}
if (mx > bmx) {
bmx = mx;
}
cblk->numbps = JAS_MAX(jpc_fix_firstone(mx) + 1 - JPC_NUMEXTRABITS, 0);
}
for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
cblk->numimsbs = band->numbps - cblk->numbps;
assert(cblk->numimsbs >= 0);
}
for (cblk = prc->cblks; cblk != endcblks; ++cblk) {
if (jpc_enc_enccblk(enc, cblk->stream, tcmpt, band, cblk)) {
return -1;
}
}
}
}
}
}
return 0;
} | 0 |
node | a3c33d4ce78f74d1cf1765704af5b427aa3840a6 | NOT_APPLICABLE | NOT_APPLICABLE | int Http2Stream::ReadStart() {
Http2Scope h2scope(this);
CHECK(!this->is_destroyed());
set_reading();
Debug(this, "reading starting");
// Tell nghttp2 about our consumption of the data that was handed
// off to JS land.
nghttp2_session_consume_stream(
session_->session(),
id_,
inbound_consumed_data_while_paused_);
inbound_consumed_data_while_paused_ = 0;
return 0;
} | 0 |
thrift | cfaadcc4adcfde2a8232c62ec89870b73ef40df1 | NOT_APPLICABLE | NOT_APPLICABLE | void t_cpp_generator::generate_serialize_field(ofstream& out,
t_field* tfield,
string prefix,
string suffix) {
t_type* type = get_true_type(tfield->get_type());
string name = prefix + tfield->get_name() + suffix;
// Do nothing for void types
if (type->is_void()) {
throw "CANNOT GENERATE SERIALIZE CODE FOR void TYPE: " + name;
}
if (type->is_struct() || type->is_xception()) {
generate_serialize_struct(out, (t_struct*)type, name, is_reference(tfield));
} else if (type->is_container()) {
generate_serialize_container(out, type, name);
} else if (type->is_base_type() || type->is_enum()) {
indent(out) << "xfer += oprot->";
if (type->is_base_type()) {
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
switch (tbase) {
case t_base_type::TYPE_VOID:
throw "compiler error: cannot serialize void field in a struct: " + name;
break;
case t_base_type::TYPE_STRING:
if (((t_base_type*)type)->is_binary()) {
out << "writeBinary(" << name << ");";
} else {
out << "writeString(" << name << ");";
}
break;
case t_base_type::TYPE_BOOL:
out << "writeBool(" << name << ");";
break;
case t_base_type::TYPE_BYTE:
out << "writeByte(" << name << ");";
break;
case t_base_type::TYPE_I16:
out << "writeI16(" << name << ");";
break;
case t_base_type::TYPE_I32:
out << "writeI32(" << name << ");";
break;
case t_base_type::TYPE_I64:
out << "writeI64(" << name << ");";
break;
case t_base_type::TYPE_DOUBLE:
out << "writeDouble(" << name << ");";
break;
default:
throw "compiler error: no C++ writer for base type " + t_base_type::t_base_name(tbase)
+ name;
}
} else if (type->is_enum()) {
out << "writeI32((int32_t)" << name << ");";
}
out << endl;
} else {
printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s' TYPE '%s'\n",
name.c_str(),
type_name(type).c_str());
}
} | 0 |
Chrome | 116d0963cadfbf55ef2ec3d13781987c4d80517a | NOT_APPLICABLE | NOT_APPLICABLE | void PrintPreviewUI::OnHidePreviewTab() {
TabContents* preview_tab =
TabContents::FromWebContents(web_ui()->GetWebContents());
printing::BackgroundPrintingManager* background_printing_manager =
g_browser_process->background_printing_manager();
if (background_printing_manager->HasPrintPreviewTab(preview_tab))
return;
ConstrainedWebDialogDelegate* delegate = GetConstrainedDelegate();
if (!delegate)
return;
delegate->ReleaseTabContentsOnDialogClose();
background_printing_manager->OwnPrintPreviewTab(preview_tab);
OnClosePrintPreviewTab();
}
| 0 |
linux | ce683e5f9d045e5d67d1312a42b359cb2ab2a13c | NOT_APPLICABLE | NOT_APPLICABLE | static int compat_get_entries(struct net *net,
struct compat_arpt_get_entries __user *uptr,
int *len)
{
int ret;
struct compat_arpt_get_entries get;
struct xt_table *t;
if (*len < sizeof(get)) {
duprintf("compat_get_entries: %u < %zu\n", *len, sizeof(get));
return -EINVAL;
}
if (copy_from_user(&get, uptr, sizeof(get)) != 0)
return -EFAULT;
if (*len != sizeof(struct compat_arpt_get_entries) + get.size) {
duprintf("compat_get_entries: %u != %zu\n",
*len, sizeof(get) + get.size);
return -EINVAL;
}
get.name[sizeof(get.name) - 1] = '\0';
xt_compat_lock(NFPROTO_ARP);
t = xt_find_table_lock(net, NFPROTO_ARP, get.name);
if (!IS_ERR_OR_NULL(t)) {
const struct xt_table_info *private = t->private;
struct xt_table_info info;
duprintf("t->private->number = %u\n", private->number);
ret = compat_table_info(private, &info);
if (!ret && get.size == info.size) {
ret = compat_copy_entries_to_user(private->size,
t, uptr->entrytable);
} else if (!ret) {
duprintf("compat_get_entries: I've got %u not %u!\n",
private->size, get.size);
ret = -EAGAIN;
}
xt_compat_flush_offsets(NFPROTO_ARP);
module_put(t->me);
xt_table_unlock(t);
} else
ret = t ? PTR_ERR(t) : -ENOENT;
xt_compat_unlock(NFPROTO_ARP);
return ret;
}
| 0 |
linux | f5449e74802c1112dea984aec8af7a33c4516af1 | NOT_APPLICABLE | NOT_APPLICABLE | static int ucma_set_option_id(struct ucma_context *ctx, int optname,
void *optval, size_t optlen)
{
int ret = 0;
switch (optname) {
case RDMA_OPTION_ID_TOS:
if (optlen != sizeof(u8)) {
ret = -EINVAL;
break;
}
rdma_set_service_type(ctx->cm_id, *((u8 *) optval));
break;
case RDMA_OPTION_ID_REUSEADDR:
if (optlen != sizeof(int)) {
ret = -EINVAL;
break;
}
ret = rdma_set_reuseaddr(ctx->cm_id, *((int *) optval) ? 1 : 0);
break;
case RDMA_OPTION_ID_AFONLY:
if (optlen != sizeof(int)) {
ret = -EINVAL;
break;
}
ret = rdma_set_afonly(ctx->cm_id, *((int *) optval) ? 1 : 0);
break;
case RDMA_OPTION_ID_ACK_TIMEOUT:
if (optlen != sizeof(u8)) {
ret = -EINVAL;
break;
}
ret = rdma_set_ack_timeout(ctx->cm_id, *((u8 *)optval));
break;
default:
ret = -ENOSYS;
}
return ret;
} | 0 |
Subsets and Splits