unique_id
int64 13
189k
| target
int64 0
1
| code
stringlengths 20
241k
| __index_level_0__
int64 0
18.9k
|
---|---|---|---|
185,973 | 1 | void EventBindings::AttachFilteredEvent(
const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK_EQ(2, args.Length());
CHECK(args[0]->IsString());
CHECK(args[1]->IsObject());
std::string event_name = *v8::String::Utf8Value(args[0]);
if (!context()->HasAccessOrThrowError(event_name))
return;
std::unique_ptr<base::DictionaryValue> filter;
{
std::unique_ptr<content::V8ValueConverter> converter(
content::V8ValueConverter::create());
std::unique_ptr<base::Value> filter_value(converter->FromV8Value(
v8::Local<v8::Object>::Cast(args[1]), context()->v8_context()));
if (!filter_value || !filter_value->IsType(base::Value::TYPE_DICTIONARY)) {
args.GetReturnValue().Set(static_cast<int32_t>(-1));
return;
}
filter = base::DictionaryValue::From(std::move(filter_value));
}
// Hold onto a weak reference to |filter| so that it can be used after passing
// ownership to |event_filter|.
base::DictionaryValue* filter_weak = filter.get();
int id = g_event_filter.Get().AddEventMatcher(
event_name, ParseEventMatcher(std::move(filter)));
attached_matcher_ids_.insert(id);
// Only send IPCs the first time a filter gets added.
std::string extension_id = context()->GetExtensionID();
if (AddFilter(event_name, extension_id, *filter_weak)) {
bool lazy = ExtensionFrameHelper::IsContextForEventPage(context());
content::RenderThread::Get()->Send(new ExtensionHostMsg_AddFilteredListener(
extension_id, event_name, *filter_weak, lazy));
}
args.GetReturnValue().Set(static_cast<int32_t>(id));
}
| 17,300 |
58,912 | 0 | static struct sock *__l2cap_get_chan_by_scid(struct l2cap_chan_list *l, u16 cid)
{
struct sock *s;
for (s = l->head; s; s = l2cap_pi(s)->next_c) {
if (l2cap_pi(s)->scid == cid)
break;
}
return s;
}
| 17,301 |
44,376 | 0 | int cg_chown(const char *path, uid_t uid, gid_t gid)
{
struct fuse_context *fc = fuse_get_context();
char *cgdir = NULL, *fpath = NULL, *path1, *path2, *controller;
struct cgfs_files *k = NULL;
const char *cgroup;
int ret;
if (!fc)
return -EIO;
if (strcmp(path, "/cgroup") == 0)
return -EINVAL;
controller = pick_controller_from_path(fc, path);
if (!controller)
return -EINVAL;
cgroup = find_cgroup_in_path(path);
if (!cgroup)
/* this is just /cgroup/controller */
return -EINVAL;
get_cgdir_and_path(cgroup, &cgdir, &fpath);
if (!fpath) {
path1 = "/";
path2 = cgdir;
} else {
path1 = cgdir;
path2 = fpath;
}
if (is_child_cgroup(controller, path1, path2)) {
k = cgfs_get_key(controller, cgroup, "tasks");
} else
k = cgfs_get_key(controller, path1, path2);
if (!k) {
ret = -EINVAL;
goto out;
}
/*
* This being a fuse request, the uid and gid must be valid
* in the caller's namespace. So we can just check to make
* sure that the caller is root in his uid, and privileged
* over the file's current owner.
*/
if (!is_privileged_over(fc->pid, fc->uid, k->uid, NS_ROOT_REQD)) {
ret = -EACCES;
goto out;
}
ret = cgfs_chown_file(controller, cgroup, uid, gid);
out:
free_key(k);
free(cgdir);
return ret;
}
| 17,302 |
3,334 | 0 | static uint32_t fdctrl_read_statusB(FDCtrl *fdctrl)
{
uint32_t retval = fdctrl->srb;
FLOPPY_DPRINTF("status register B: 0x%02x\n", retval);
return retval;
}
| 17,303 |
156,492 | 0 | bool DevToolsAgentHostClient::MayDiscoverTargets() {
return true;
}
| 17,304 |
119,093 | 0 | void OutputPointer(void* pointer, BacktraceOutputHandler* handler) {
char buf[17] = { '\0' };
handler->HandleOutput("0x");
internal::itoa_r(reinterpret_cast<intptr_t>(pointer),
buf, sizeof(buf), 16, 12);
handler->HandleOutput(buf);
}
| 17,305 |
157,970 | 0 | void RenderViewImpl::PrintPage(WebLocalFrame* frame) {
UMA_HISTOGRAM_BOOLEAN("PrintPreview.InitiatedByScript",
frame->Top() == frame);
UMA_HISTOGRAM_BOOLEAN("PrintPreview.OutOfProcessSubframe",
frame->Top()->IsWebRemoteFrame());
RenderFrameImpl::FromWebFrame(frame)->ScriptedPrint(
GetWidget()->input_handler().handling_input_event());
}
| 17,306 |
12,531 | 0 | WhoIsThisWithName(struct rx_call *acall, struct ubik_trans *at, afs_int32 *aid,
char *aname)
{
/* aid is set to the identity of the caller, if known, else ANONYMOUSID */
/* returns -1 and sets aid to ANONYMOUSID on any failure */
struct rx_connection *tconn;
afs_int32 code;
char tcell[MAXKTCREALMLEN];
char name[MAXKTCNAMELEN];
char inst[MAXKTCNAMELEN];
int ilen;
char vname[256];
*aid = ANONYMOUSID;
tconn = rx_ConnectionOf(acall);
code = rx_SecurityClassOf(tconn);
if (code == 0)
return 0;
else if (code == 1) { /* vab class */
goto done; /* no longer supported */
} else if (code == 2) { /* kad class */
int clen;
if ((code = rxkad_GetServerInfo(acall->conn, NULL, 0 /*was &exp */ ,
name, inst, tcell, NULL)))
goto done;
strncpy(vname, name, sizeof(vname));
if ((ilen = strlen(inst))) {
if (strlen(vname) + 1 + ilen >= sizeof(vname))
goto done;
strcat(vname, ".");
strcat(vname, inst);
}
if ((clen = strlen(tcell))) {
int foreign = afs_is_foreign_ticket_name(name,inst,tcell,pr_realmName);
if (foreign) {
if (strlen(vname) + 1 + clen >= sizeof(vname))
goto done;
strcat(vname, "@");
strcat(vname, tcell);
lcstring(vname, vname, sizeof(vname));
code = NameToID(at, vname, aid);
strcpy(aname, vname);
return 2;
}
}
if (strcmp(AUTH_SUPERUSER, vname) == 0)
*aid = SYSADMINID; /* special case for the fileserver */
else {
lcstring(vname, vname, sizeof(vname));
code = NameToID(at, vname, aid);
}
}
done:
if (code && !pr_noAuth)
return -1;
return 0;
}
| 17,307 |
170,348 | 0 | static void MakeFourCCString(uint32_t x, char *s) {
s[0] = x >> 24;
s[1] = (x >> 16) & 0xff;
s[2] = (x >> 8) & 0xff;
s[3] = x & 0xff;
s[4] = '\0';
}
| 17,308 |
69,087 | 0 | static void TIFFWarnings(const char *module,const char *format,va_list warning)
{
char
message[MaxTextExtent];
ExceptionInfo
*exception;
#if defined(MAGICKCORE_HAVE_VSNPRINTF)
(void) vsnprintf(message,MaxTextExtent,format,warning);
#else
(void) vsprintf(message,format,warning);
#endif
(void) ConcatenateMagickString(message,".",MaxTextExtent);
exception=(ExceptionInfo *) GetMagickThreadValue(tiff_exception);
if (exception != (ExceptionInfo *) NULL)
(void) ThrowMagickException(exception,GetMagickModule(),CoderWarning,
message,"`%s'",module);
}
| 17,309 |
99,262 | 0 | Clipboard* ResourceMessageFilter::GetClipboard() {
static Clipboard* clipboard = new Clipboard;
return clipboard;
}
| 17,310 |
46,092 | 0 | void auth_gssapi_display_status(
char *msg,
OM_uint32 major,
OM_uint32 minor)
{
auth_gssapi_display_status_1(msg, major, GSS_C_GSS_CODE, 0);
auth_gssapi_display_status_1(msg, minor, GSS_C_MECH_CODE, 0);
}
| 17,311 |
15,407 | 0 | dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok)
{
hm_fragment *frag = NULL;
pitem *item = NULL;
int i = -1, is_complete;
unsigned char seq64be[8];
unsigned long frag_len = msg_hdr->frag_len, max_len;
if ((msg_hdr->frag_off+frag_len) > msg_hdr->msg_len)
goto err;
/* Determine maximum allowed message size. Depends on (user set)
* maximum certificate length, but 16k is minimum.
*/
if (DTLS1_HM_HEADER_LENGTH + SSL3_RT_MAX_ENCRYPTED_LENGTH < s->max_cert_list)
max_len = s->max_cert_list;
else
max_len = DTLS1_HM_HEADER_LENGTH + SSL3_RT_MAX_ENCRYPTED_LENGTH;
if ((msg_hdr->frag_off+frag_len) > max_len)
goto err;
/* Try to find item in queue */
memset(seq64be,0,sizeof(seq64be));
seq64be[6] = (unsigned char) (msg_hdr->seq>>8);
seq64be[7] = (unsigned char) msg_hdr->seq;
item = pqueue_find(s->d1->buffered_messages, seq64be);
if (item == NULL)
{
frag = dtls1_hm_fragment_new(msg_hdr->msg_len, 1);
if ( frag == NULL)
goto err;
memcpy(&(frag->msg_header), msg_hdr, sizeof(*msg_hdr));
frag->msg_header.frag_len = frag->msg_header.msg_len;
frag->msg_header.frag_off = 0;
}
else
frag = (hm_fragment*) item->data;
/* If message is already reassembled, this must be a
* retransmit and can be dropped.
*/
if (frag->reassembly == NULL)
{
unsigned char devnull [256];
while (frag_len)
{
i = s->method->ssl_read_bytes(s,SSL3_RT_HANDSHAKE,
devnull,
frag_len>sizeof(devnull)?sizeof(devnull):frag_len,0);
if (i<=0) goto err;
frag_len -= i;
}
return DTLS1_HM_FRAGMENT_RETRY;
}
/* read the body of the fragment (header has already been read */
i = s->method->ssl_read_bytes(s,SSL3_RT_HANDSHAKE,
frag->fragment + msg_hdr->frag_off,frag_len,0);
if (i<=0 || (unsigned long)i!=frag_len)
goto err;
RSMBLY_BITMASK_MARK(frag->reassembly, (long)msg_hdr->frag_off,
(long)(msg_hdr->frag_off + frag_len));
RSMBLY_BITMASK_IS_COMPLETE(frag->reassembly, (long)msg_hdr->msg_len,
is_complete);
if (is_complete)
{
OPENSSL_free(frag->reassembly);
frag->reassembly = NULL;
}
if (item == NULL)
{
memset(seq64be,0,sizeof(seq64be));
seq64be[6] = (unsigned char)(msg_hdr->seq>>8);
seq64be[7] = (unsigned char)(msg_hdr->seq);
item = pitem_new(seq64be, frag);
if (item == NULL)
{
goto err;
i = -1;
}
pqueue_insert(s->d1->buffered_messages, item);
}
return DTLS1_HM_FRAGMENT_RETRY;
err:
if (frag != NULL) dtls1_hm_fragment_free(frag);
if (item != NULL) OPENSSL_free(item);
*ok = 0;
return i;
}
| 17,312 |
112,235 | 0 | void HostPortAllocatorSession::ConfigReady(cricket::PortConfiguration* config) {
for (cricket::PortConfiguration::RelayList::iterator relay =
config->relays.begin(); relay != config->relays.end(); ++relay) {
cricket::PortConfiguration::PortList filtered_ports;
for (cricket::PortConfiguration::PortList::iterator port =
relay->ports.begin(); port != relay->ports.end(); ++port) {
if (port->proto == cricket::PROTO_UDP) {
filtered_ports.push_back(*port);
}
}
relay->ports = filtered_ports;
}
cricket::BasicPortAllocatorSession::ConfigReady(config);
}
| 17,313 |
16,236 | 0 | GahpClient::unicore_job_status(const char * job_contact,
char **job_status)
{
static const char* command = "UNICORE_JOB_STATUS";
if (server->m_commands_supported->contains_anycase(command)==FALSE) {
return GAHPCLIENT_COMMAND_NOT_SUPPORTED;
}
if (!job_contact) job_contact=NULLSTRING;
std::string reqline;
int x = sprintf(reqline,"%s",escapeGahpString(job_contact));
ASSERT( x > 0 );
const char *buf = reqline.c_str();
if ( !is_pending(command,buf) ) {
if ( m_mode == results_only ) {
return GAHPCLIENT_COMMAND_NOT_SUBMITTED;
}
now_pending(command,buf,normal_proxy);
}
Gahp_Args* result = get_pending_result(command,buf);
if ( result ) {
if (result->argc != 4) {
EXCEPT("Bad %s Result",command);
}
int rc = 1;
if ( result->argv[1][0] == 'S' ) {
rc = 0;
}
if ( result->argv[2] && strcasecmp(result->argv[2], NULLSTRING) ) {
*job_status = strdup(result->argv[2]);
}
delete result;
return rc;
}
if ( check_pending_timeout(command,buf) ) {
return GAHPCLIENT_COMMAND_TIMED_OUT;
}
return GAHPCLIENT_COMMAND_PENDING;
}
| 17,314 |
65,571 | 0 | static void nfsd4_close_open_stateid(struct nfs4_ol_stateid *s)
{
struct nfs4_client *clp = s->st_stid.sc_client;
bool unhashed;
LIST_HEAD(reaplist);
s->st_stid.sc_type = NFS4_CLOSED_STID;
spin_lock(&clp->cl_lock);
unhashed = unhash_open_stateid(s, &reaplist);
if (clp->cl_minorversion) {
if (unhashed)
put_ol_stateid_locked(s, &reaplist);
spin_unlock(&clp->cl_lock);
free_ol_stateid_reaplist(&reaplist);
} else {
spin_unlock(&clp->cl_lock);
free_ol_stateid_reaplist(&reaplist);
if (unhashed)
move_to_close_lru(s, clp->net);
}
}
| 17,315 |
185,473 | 1 | static inline bool shouldSetStrutOnBlock(const LayoutBlockFlow& block, const RootInlineBox& lineBox, LayoutUnit lineLogicalOffset, int lineIndex, LayoutUnit remainingLogicalHeight)
{
bool wantsStrutOnBlock = false;
if (!block.style()->hasAutoOrphans() && block.style()->orphans() >= lineIndex) {
// Not enough orphans here. Push the entire block to the next column / page as an
// attempt to better satisfy the orphans requirement.
wantsStrutOnBlock = true;
} else if (lineBox == block.firstRootBox() && lineLogicalOffset == block.borderAndPaddingBefore()) {
// This is the first line in the block. We can take the whole block with us to the next page
// or column, rather than keeping a content-less portion of it in the previous one. Only do
// this if the line is flush with the content edge of the block, though. If it isn't, it
// means that the line was pushed downwards by preceding floats that didn't fit beside the
// line, and we don't want to move all that, since it has already been established that it
// fits nicely where it is.
LayoutUnit lineHeight = lineBox.lineBottomWithLeading() - lineBox.lineTopWithLeading();
LayoutUnit totalLogicalHeight = lineHeight + std::max<LayoutUnit>(0, lineLogicalOffset);
LayoutUnit pageLogicalHeightAtNewOffset = block.pageLogicalHeightForOffset(lineLogicalOffset + remainingLogicalHeight);
// It's rather pointless to break before the block if the current line isn't going to
// fit in the same column or page, so check that as well.
if (totalLogicalHeight < pageLogicalHeightAtNewOffset)
wantsStrutOnBlock = true;
}
// The block needs to be contained by a LayoutBlockFlow (and not by e.g. a flexbox or a table
// (which would be the case for table cell or table caption)). The reason for this limitation is
// simply that LayoutBlockFlow child layout code is the only place where we pick up the struts
// and handle them. We handle floats and regular in-flow children, and that's all. We could
// handle this in other layout modes as well (and even for out-of-flow children), but currently
// we don't.
if (!wantsStrutOnBlock || block.isOutOfFlowPositioned())
return false;
LayoutBlock* containingBlock = block.containingBlock();
return containingBlock && containingBlock->isLayoutBlockFlow();
}
| 17,316 |
45,233 | 0 | psf_fwrite (const void *ptr, sf_count_t bytes, sf_count_t items, SF_PRIVATE *psf)
{ sf_count_t total = 0 ;
ssize_t count ;
if (psf->virtual_io)
return psf->vio.write (ptr, bytes*items, psf->vio_user_data) / bytes ;
items *= bytes ;
/* Do this check after the multiplication above. */
if (items <= 0)
return 0 ;
while (items > 0)
{ /* Break the writes down to a sensible size. */
count = (items > SENSIBLE_SIZE) ? SENSIBLE_SIZE : items ;
count = write (psf->file.filedes, ((const char*) ptr) + total, count) ;
if (count == -1)
{ if (errno == EINTR)
continue ;
psf_log_syserr (psf, errno) ;
break ;
} ;
if (count == 0)
break ;
total += count ;
items -= count ;
} ;
return total / bytes ;
} /* psf_fwrite */
| 17,317 |
85,873 | 0 | static int dm_blk_open(struct block_device *bdev, fmode_t mode)
{
struct mapped_device *md;
spin_lock(&_minor_lock);
md = bdev->bd_disk->private_data;
if (!md)
goto out;
if (test_bit(DMF_FREEING, &md->flags) ||
dm_deleting_md(md)) {
md = NULL;
goto out;
}
dm_get(md);
atomic_inc(&md->open_count);
out:
spin_unlock(&_minor_lock);
return md ? 0 : -ENXIO;
}
| 17,318 |
65,534 | 0 | nfs4_put_stid(struct nfs4_stid *s)
{
struct nfs4_file *fp = s->sc_file;
struct nfs4_client *clp = s->sc_client;
might_lock(&clp->cl_lock);
if (!atomic_dec_and_lock(&s->sc_count, &clp->cl_lock)) {
wake_up_all(&close_wq);
return;
}
idr_remove(&clp->cl_stateids, s->sc_stateid.si_opaque.so_id);
spin_unlock(&clp->cl_lock);
s->sc_free(s);
if (fp)
put_nfs4_file(fp);
}
| 17,319 |
131,719 | 0 | static void shadowRootAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
{
TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder());
v8SetReturnValueFast(info, WTF::getPtr(imp->shadowRootAttribute()), imp);
}
| 17,320 |
96,460 | 0 | static int fsmMkfile(rpmfi fi, const char *dest, rpmfiles files,
rpmpsm psm, int nodigest, int *setmeta,
int * firsthardlink)
{
int rc = 0;
int numHardlinks = rpmfiFNlink(fi);
if (numHardlinks > 1) {
/* Create first hardlinked file empty */
if (*firsthardlink < 0) {
*firsthardlink = rpmfiFX(fi);
rc = expandRegular(fi, dest, psm, 1, nodigest, 1);
} else {
/* Create hard links for others */
char *fn = rpmfilesFN(files, *firsthardlink);
rc = link(fn, dest);
if (rc < 0) {
rc = RPMERR_LINK_FAILED;
}
free(fn);
}
}
/* Write normal files or fill the last hardlinked (already
existing) file with content */
if (numHardlinks<=1) {
if (!rc)
rc = expandRegular(fi, dest, psm, 1, nodigest, 0);
} else if (rpmfiArchiveHasContent(fi)) {
if (!rc)
rc = expandRegular(fi, dest, psm, 0, nodigest, 0);
*firsthardlink = -1;
} else {
*setmeta = 0;
}
return rc;
}
| 17,321 |
121,975 | 0 | string16 GetAppListShortcutName() {
chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
if (channel == chrome::VersionInfo::CHANNEL_CANARY)
return l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME_CANARY);
return l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME);
}
| 17,322 |
4,216 | 0 | cff_index_forget_element( CFF_Index idx,
FT_Byte** pbytes )
{
if ( idx->bytes == 0 )
{
FT_Stream stream = idx->stream;
FT_FRAME_RELEASE( *pbytes );
}
}
| 17,323 |
44,300 | 0 | static int write_note_info(struct elf_note_info *info,
struct coredump_params *cprm)
{
bool first = true;
struct elf_thread_core_info *t = info->thread;
do {
int i;
if (!writenote(&t->notes[0], cprm))
return 0;
if (first && !writenote(&info->psinfo, cprm))
return 0;
if (first && !writenote(&info->signote, cprm))
return 0;
if (first && !writenote(&info->auxv, cprm))
return 0;
if (first && info->files.data &&
!writenote(&info->files, cprm))
return 0;
for (i = 1; i < info->thread_notes; ++i)
if (t->notes[i].data &&
!writenote(&t->notes[i], cprm))
return 0;
first = false;
t = t->next;
} while (t);
return 1;
}
| 17,324 |
90,988 | 0 | void CWebServer::Cmd_GetAuth(WebEmSession & session, const request& req, Json::Value &root)
{
root["status"] = "OK";
root["title"] = "GetAuth";
if (session.rights != -1)
{
root["version"] = szAppVersion;
}
root["user"] = session.username;
root["rights"] = session.rights;
}
| 17,325 |
100,405 | 0 | RenderWidgetHostView* RenderViewHostDelegateViewHelper::CreateNewWidget(
int route_id, bool activatable, RenderProcessHost* process) {
RenderWidgetHost* widget_host =
new RenderWidgetHost(process, route_id);
RenderWidgetHostView* widget_view =
RenderWidgetHostView::CreateViewForWidget(widget_host);
widget_view->set_activatable(activatable);
pending_widget_views_[route_id] = widget_view;
return widget_view;
}
| 17,326 |
2,852 | 0 | gst_pngdec_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_pngdec_src_pad_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_pngdec_sink_pad_template));
gst_element_class_set_details (element_class, &gst_pngdec_details);
}
| 17,327 |
119,730 | 0 | void XSLStyleSheet::setParentStyleSheet(XSLStyleSheet* parent)
{
m_parentStyleSheet = parent;
}
| 17,328 |
114,922 | 0 | void TestingAutomationProvider::GetInstantInfo(Browser* browser,
DictionaryValue* args,
IPC::Message* reply_message) {
DictionaryValue* info = new DictionaryValue;
if (browser->instant()) {
InstantController* instant = browser->instant();
info->SetBoolean("enabled", true);
info->SetBoolean("active", (instant->GetPreviewContents() != NULL));
info->SetBoolean("current", instant->IsCurrent());
if (instant->GetPreviewContents() &&
instant->GetPreviewContents()->web_contents()) {
WebContents* contents = instant->GetPreviewContents()->web_contents();
info->SetBoolean("loading", contents->IsLoading());
info->SetString("location", contents->GetURL().spec());
info->SetString("title", contents->GetTitle());
}
} else {
info->SetBoolean("enabled", false);
}
scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
return_value->Set("instant", info);
AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
}
| 17,329 |
72,455 | 0 | static int row_prop_exists(zval *object, zval *member, int check_empty, const zend_literal *key TSRMLS_DC)
{
pdo_stmt_t * stmt = (pdo_stmt_t *) zend_object_store_get_object(object TSRMLS_CC);
int colno = -1;
if (stmt) {
if (Z_TYPE_P(member) == IS_LONG) {
return Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count;
} else {
convert_to_string(member);
/* TODO: replace this with a hash of available column names to column
* numbers */
for (colno = 0; colno < stmt->column_count; colno++) {
if (strcmp(stmt->columns[colno].name, Z_STRVAL_P(member)) == 0) {
int res;
zval *val;
MAKE_STD_ZVAL(val);
fetch_value(stmt, val, colno, NULL TSRMLS_CC);
res = check_empty ? i_zend_is_true(val) : Z_TYPE_P(val) != IS_NULL;
zval_ptr_dtor(&val);
return res;
}
}
}
}
return 0;
}
| 17,330 |
60,831 | 0 | logger_day_changed_signal_cb (const void *pointer, void *data,
const char *signal,
const char *type_data, void *signal_data)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) signal;
(void) type_data;
(void) signal_data;
logger_adjust_log_filenames ();
return WEECHAT_RC_OK;
}
| 17,331 |
161,416 | 0 | void ServiceWorkerHandler::OnWorkerVersionUpdated(
const std::vector<ServiceWorkerVersionInfo>& versions) {
using Version = ServiceWorker::ServiceWorkerVersion;
std::unique_ptr<protocol::Array<Version>> result =
protocol::Array<Version>::create();
for (const auto& version : versions) {
base::flat_set<std::string> client_set;
for (const auto& client : version.clients) {
if (client.second.type ==
blink::mojom::ServiceWorkerProviderType::kForWindow) {
WebContents* web_contents =
client.second.web_contents_getter
? client.second.web_contents_getter.Run()
: WebContents::FromRenderFrameHost(RenderFrameHostImpl::FromID(
client.second.process_id, client.second.route_id));
if (!web_contents)
continue;
client_set.insert(
DevToolsAgentHost::GetOrCreateFor(web_contents)->GetId());
}
}
std::unique_ptr<protocol::Array<std::string>> clients =
protocol::Array<std::string>::create();
for (auto& c : client_set)
clients->addItem(c);
std::unique_ptr<Version> version_value = Version::Create()
.SetVersionId(base::Int64ToString(version.version_id))
.SetRegistrationId(
base::Int64ToString(version.registration_id))
.SetScriptURL(version.script_url.spec())
.SetRunningStatus(
GetVersionRunningStatusString(version.running_status))
.SetStatus(GetVersionStatusString(version.status))
.SetScriptLastModified(
version.script_last_modified.ToDoubleT())
.SetScriptResponseTime(
version.script_response_time.ToDoubleT())
.SetControlledClients(std::move(clients))
.Build();
scoped_refptr<DevToolsAgentHostImpl> host(
ServiceWorkerDevToolsManager::GetInstance()
->GetDevToolsAgentHostForWorker(
version.process_id,
version.devtools_agent_route_id));
if (host)
version_value->SetTargetId(host->GetId());
result->addItem(std::move(version_value));
}
frontend_->WorkerVersionUpdated(std::move(result));
}
| 17,332 |
77,902 | 0 | test_bson_build_child_deep_1 (bson_t *b, int *count)
{
bson_t child;
(*count)++;
BSON_ASSERT (bson_append_document_begin (b, "b", -1, &child));
BSON_ASSERT (!(b->flags & BSON_FLAG_INLINE));
BSON_ASSERT ((b->flags & BSON_FLAG_IN_CHILD));
BSON_ASSERT (!(child.flags & BSON_FLAG_INLINE));
BSON_ASSERT ((child.flags & BSON_FLAG_STATIC));
BSON_ASSERT ((child.flags & BSON_FLAG_CHILD));
if (*count < 100) {
test_bson_build_child_deep_1 (&child, count);
} else {
BSON_ASSERT (bson_append_int32 (&child, "b", -1, 1234));
}
BSON_ASSERT (bson_append_document_end (b, &child));
BSON_ASSERT (!(b->flags & BSON_FLAG_IN_CHILD));
}
| 17,333 |
156,482 | 0 | bool ShouldCreateDevToolsForNode(FrameTreeNode* ftn) {
return !ftn->parent() || ftn->current_frame_host()->IsCrossProcessSubframe();
}
| 17,334 |
167,311 | 0 | void ScrollableShelfView::ScrollToYOffset(float y_target_offset,
bool animating) {
y_target_offset = CalculateClampedScrollOffset(y_target_offset);
const int old_y = scroll_offset_.y();
scroll_offset_.set_y(y_target_offset);
Layout();
const float diff = y_target_offset - old_y;
if (animating)
StartShelfScrollAnimation(diff);
}
| 17,335 |
18,302 | 0 | static void write_and_free(conn *c, char *buf, int bytes) {
if (buf) {
c->write_and_free = buf;
c->wcurr = buf;
c->wbytes = bytes;
conn_set_state(c, conn_write);
c->write_and_go = conn_new_cmd;
} else {
out_string(c, "SERVER_ERROR out of memory writing stats");
}
}
| 17,336 |
35,419 | 0 | void __init early_trap_init(void)
{
set_intr_gate_ist(X86_TRAP_DB, &debug, DEBUG_STACK);
/* int3 can be called from all */
set_system_intr_gate_ist(X86_TRAP_BP, &int3, DEBUG_STACK);
#ifdef CONFIG_X86_32
set_intr_gate(X86_TRAP_PF, page_fault);
#endif
load_idt(&idt_descr);
}
| 17,337 |
34,618 | 0 | static void __sctp_unhash_endpoint(struct sctp_endpoint *ep)
{
struct sctp_hashbucket *head;
struct sctp_ep_common *epb;
epb = &ep->base;
if (hlist_unhashed(&epb->node))
return;
epb->hashent = sctp_ep_hashfn(epb->bind_addr.port);
head = &sctp_ep_hashtable[epb->hashent];
sctp_write_lock(&head->lock);
__hlist_del(&epb->node);
sctp_write_unlock(&head->lock);
}
| 17,338 |
137,650 | 0 | void RenderThreadImpl::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
base::allocator::ReleaseFreeMemory();
if (webkit_platform_support_ && blink::mainThreadIsolate()) {
blink::mainThreadIsolate()->LowMemoryNotification();
}
if (memory_pressure_level ==
base::MemoryPressureListener::MEMORY_PRESSURE_CRITICAL) {
if (webkit_platform_support_) {
blink::WebImageCache::clear();
}
size_t font_cache_limit = SkGraphics::SetFontCacheLimit(0);
SkGraphics::SetFontCacheLimit(font_cache_limit);
}
}
| 17,339 |
147,216 | 0 | static void BooleanOrDOMStringOrUnrestrictedDoubleMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestObject* impl = V8TestObject::ToImpl(info.Holder());
BooleanOrStringOrUnrestrictedDouble result;
impl->booleanOrDOMStringOrUnrestrictedDoubleMethod(result);
V8SetReturnValue(info, result);
}
| 17,340 |
79,540 | 0 | char *imap_set_flags(struct ImapData *idata, struct Header *h, char *s, int *server_changes)
{
struct Context *ctx = idata->ctx;
struct ImapHeader newh = { 0 };
struct ImapHeaderData old_hd;
bool readonly;
int local_changes;
local_changes = h->changed;
struct ImapHeaderData *hd = h->data;
newh.data = hd;
memcpy(&old_hd, hd, sizeof(old_hd));
mutt_debug(2, "parsing FLAGS\n");
s = msg_parse_flags(&newh, s);
if (!s)
return NULL;
/* Update tags system */
driver_tags_replace(&h->tags, mutt_str_strdup(hd->flags_remote));
/* YAUH (yet another ugly hack): temporarily set context to
* read-write even if it's read-only, so *server* updates of
* flags can be processed by mutt_set_flag. ctx->changed must
* be restored afterwards */
readonly = ctx->readonly;
ctx->readonly = false;
/* This is redundant with the following two checks. Removing:
* mutt_set_flag (ctx, h, MUTT_NEW, !(hd->read || hd->old));
*/
set_changed_flag(ctx, h, local_changes, server_changes, MUTT_OLD, old_hd.old,
hd->old, h->old);
set_changed_flag(ctx, h, local_changes, server_changes, MUTT_READ,
old_hd.read, hd->read, h->read);
set_changed_flag(ctx, h, local_changes, server_changes, MUTT_DELETE,
old_hd.deleted, hd->deleted, h->deleted);
set_changed_flag(ctx, h, local_changes, server_changes, MUTT_FLAG,
old_hd.flagged, hd->flagged, h->flagged);
set_changed_flag(ctx, h, local_changes, server_changes, MUTT_REPLIED,
old_hd.replied, hd->replied, h->replied);
/* this message is now definitively *not* changed (mutt_set_flag
* marks things changed as a side-effect) */
if (!local_changes)
h->changed = false;
ctx->changed &= !readonly;
ctx->readonly = readonly;
return s;
}
| 17,341 |
55,048 | 0 | static void alloc_objects(unsigned int cnt)
{
struct object_entry_pool *b;
b = xmalloc(sizeof(struct object_entry_pool)
+ cnt * sizeof(struct object_entry));
b->next_pool = blocks;
b->next_free = b->entries;
b->end = b->entries + cnt;
blocks = b;
alloc_count += cnt;
}
| 17,342 |
171,539 | 0 | void SimpleSoftOMXComponent::onSendCommand(
OMX_COMMANDTYPE cmd, OMX_U32 param) {
switch (cmd) {
case OMX_CommandStateSet:
{
onChangeState((OMX_STATETYPE)param);
break;
}
case OMX_CommandPortEnable:
case OMX_CommandPortDisable:
{
onPortEnable(param, cmd == OMX_CommandPortEnable);
break;
}
case OMX_CommandFlush:
{
onPortFlush(param, true /* sendFlushComplete */);
break;
}
default:
TRESPASS();
break;
}
}
| 17,343 |
155,607 | 0 | base::string16 AuthenticatorWelcomeSheetModel::GetStepTitle() const {
return l10n_util::GetStringFUTF16(IDS_WEBAUTHN_WELCOME_SCREEN_TITLE,
GetRelyingPartyIdString(dialog_model()));
}
| 17,344 |
160,830 | 0 | void RenderViewImpl::SetTouchAction(blink::WebTouchAction touchAction) {
RenderWidget::SetTouchAction(touchAction);
}
| 17,345 |
20,622 | 0 | static uint32_t kvm_get_exit_reason(struct kvm_vcpu *vcpu)
{
struct exit_ctl_data *p_exit_data;
p_exit_data = kvm_get_exit_data(vcpu);
return p_exit_data->exit_reason;
}
| 17,346 |
82,270 | 0 | static long sock_do_ioctl(struct net *net, struct socket *sock,
unsigned int cmd, unsigned long arg)
{
int err;
void __user *argp = (void __user *)arg;
err = sock->ops->ioctl(sock, cmd, arg);
/*
* If this ioctl is unknown try to hand it down
* to the NIC driver.
*/
if (err != -ENOIOCTLCMD)
return err;
if (cmd == SIOCGIFCONF) {
struct ifconf ifc;
if (copy_from_user(&ifc, argp, sizeof(struct ifconf)))
return -EFAULT;
rtnl_lock();
err = dev_ifconf(net, &ifc, sizeof(struct ifreq));
rtnl_unlock();
if (!err && copy_to_user(argp, &ifc, sizeof(struct ifconf)))
err = -EFAULT;
} else {
struct ifreq ifr;
bool need_copyout;
if (copy_from_user(&ifr, argp, sizeof(struct ifreq)))
return -EFAULT;
err = dev_ioctl(net, cmd, &ifr, &need_copyout);
if (!err && need_copyout)
if (copy_to_user(argp, &ifr, sizeof(struct ifreq)))
return -EFAULT;
}
return err;
}
| 17,347 |
157,047 | 0 | void MultibufferDataSource::SetPreload(Preload preload) {
DVLOG(1) << __func__ << "(" << preload << ")";
DCHECK(render_task_runner_->BelongsToCurrentThread());
preload_ = preload;
UpdateBufferSizes();
}
| 17,348 |
46,943 | 0 | static int crc32c_intel_setkey(struct crypto_shash *hash, const u8 *key,
unsigned int keylen)
{
u32 *mctx = crypto_shash_ctx(hash);
if (keylen != sizeof(u32)) {
crypto_shash_set_flags(hash, CRYPTO_TFM_RES_BAD_KEY_LEN);
return -EINVAL;
}
*mctx = le32_to_cpup((__le32 *)key);
return 0;
}
| 17,349 |
166,542 | 0 | bool BrowserCommandController::IsCommandEnabled(int id) const {
return command_updater_.IsCommandEnabled(id);
}
| 17,350 |
99,028 | 0 | void WebGraphicsContext3DDefaultImpl::texImage2D(unsigned target, unsigned level, unsigned internalFormat, unsigned width, unsigned height, unsigned border, unsigned format, unsigned type, const void* pixels)
{
OwnArrayPtr<uint8> zero;
if (!pixels) {
size_t size = imageSizeInBytes(width, height, format, type);
zero.set(new uint8[size]);
memset(zero.get(), 0, size);
pixels = zero.get();
}
glTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels);
}
| 17,351 |
118,659 | 0 | void UserCloudPolicyManagerFactoryChromeOS::BrowserContextDestroyed(
content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
managers_.erase(profile);
BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context);
}
| 17,352 |
121,100 | 0 | void BaseMultipleFieldsDateAndTimeInputType::restoreFormControlState(const FormControlState& state)
{
if (!m_dateTimeEditElement)
return;
DateTimeFieldsState dateTimeFieldsState = DateTimeFieldsState::restoreFormControlState(state);
m_dateTimeEditElement->setValueAsDateTimeFieldsState(dateTimeFieldsState);
element()->setValueInternal(sanitizeValue(m_dateTimeEditElement->value()), DispatchNoEvent);
updateClearButtonVisibility();
}
| 17,353 |
178,909 | 1 | void bnep_net_setup(struct net_device *dev)
{
memset(dev->broadcast, 0xff, ETH_ALEN);
dev->addr_len = ETH_ALEN;
ether_setup(dev);
dev->netdev_ops = &bnep_netdev_ops;
dev->watchdog_timeo = HZ * 2;
}
| 17,354 |
53,578 | 0 | x86_Convert(struct _7zip *zip, uint8_t *data, size_t size)
{
static const uint8_t kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0};
static const uint8_t kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3};
size_t bufferPos, prevPosT;
uint32_t ip, prevMask;
if (size < 5)
return 0;
bufferPos = 0;
prevPosT = zip->bcj_prevPosT;
prevMask = zip->bcj_prevMask;
ip = zip->bcj_ip;
for (;;) {
uint8_t *p = data + bufferPos;
uint8_t *limit = data + size - 4;
for (; p < limit; p++)
if ((*p & 0xFE) == 0xE8)
break;
bufferPos = (size_t)(p - data);
if (p >= limit)
break;
prevPosT = bufferPos - prevPosT;
if (prevPosT > 3)
prevMask = 0;
else {
prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7;
if (prevMask != 0) {
unsigned char b =
p[4 - kMaskToBitNumber[prevMask]];
if (!kMaskToAllowedStatus[prevMask] ||
Test86MSByte(b)) {
prevPosT = bufferPos;
prevMask = ((prevMask << 1) & 0x7) | 1;
bufferPos++;
continue;
}
}
}
prevPosT = bufferPos;
if (Test86MSByte(p[4])) {
uint32_t src = ((uint32_t)p[4] << 24) |
((uint32_t)p[3] << 16) | ((uint32_t)p[2] << 8) |
((uint32_t)p[1]);
uint32_t dest;
for (;;) {
uint8_t b;
int b_index;
dest = src - (ip + (uint32_t)bufferPos);
if (prevMask == 0)
break;
b_index = kMaskToBitNumber[prevMask] * 8;
b = (uint8_t)(dest >> (24 - b_index));
if (!Test86MSByte(b))
break;
src = dest ^ ((1 << (32 - b_index)) - 1);
}
p[4] = (uint8_t)(~(((dest >> 24) & 1) - 1));
p[3] = (uint8_t)(dest >> 16);
p[2] = (uint8_t)(dest >> 8);
p[1] = (uint8_t)dest;
bufferPos += 5;
} else {
prevMask = ((prevMask << 1) & 0x7) | 1;
bufferPos++;
}
}
zip->bcj_prevPosT = prevPosT;
zip->bcj_prevMask = prevMask;
zip->bcj_ip += (uint32_t)bufferPos;
return (bufferPos);
}
| 17,355 |
181,332 | 1 | int svc_rdma_xdr_encode_error(struct svcxprt_rdma *xprt,
struct rpcrdma_msg *rmsgp,
enum rpcrdma_errcode err, __be32 *va)
{
__be32 *startp = va;
*va++ = rmsgp->rm_xid;
*va++ = rmsgp->rm_vers;
*va++ = xprt->sc_fc_credits;
*va++ = rdma_error;
*va++ = cpu_to_be32(err);
if (err == ERR_VERS) {
*va++ = rpcrdma_version;
*va++ = rpcrdma_version;
}
return (int)((unsigned long)va - (unsigned long)startp);
}
| 17,356 |
84,246 | 0 | static int attach_to_pi_state(u32 __user *uaddr, u32 uval,
struct futex_pi_state *pi_state,
struct futex_pi_state **ps)
{
pid_t pid = uval & FUTEX_TID_MASK;
u32 uval2;
int ret;
/*
* Userspace might have messed up non-PI and PI futexes [3]
*/
if (unlikely(!pi_state))
return -EINVAL;
/*
* We get here with hb->lock held, and having found a
* futex_top_waiter(). This means that futex_lock_pi() of said futex_q
* has dropped the hb->lock in between queue_me() and unqueue_me_pi(),
* which in turn means that futex_lock_pi() still has a reference on
* our pi_state.
*
* The waiter holding a reference on @pi_state also protects against
* the unlocked put_pi_state() in futex_unlock_pi(), futex_lock_pi()
* and futex_wait_requeue_pi() as it cannot go to 0 and consequently
* free pi_state before we can take a reference ourselves.
*/
WARN_ON(!atomic_read(&pi_state->refcount));
/*
* Now that we have a pi_state, we can acquire wait_lock
* and do the state validation.
*/
raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);
/*
* Since {uval, pi_state} is serialized by wait_lock, and our current
* uval was read without holding it, it can have changed. Verify it
* still is what we expect it to be, otherwise retry the entire
* operation.
*/
if (get_futex_value_locked(&uval2, uaddr))
goto out_efault;
if (uval != uval2)
goto out_eagain;
/*
* Handle the owner died case:
*/
if (uval & FUTEX_OWNER_DIED) {
/*
* exit_pi_state_list sets owner to NULL and wakes the
* topmost waiter. The task which acquires the
* pi_state->rt_mutex will fixup owner.
*/
if (!pi_state->owner) {
/*
* No pi state owner, but the user space TID
* is not 0. Inconsistent state. [5]
*/
if (pid)
goto out_einval;
/*
* Take a ref on the state and return success. [4]
*/
goto out_attach;
}
/*
* If TID is 0, then either the dying owner has not
* yet executed exit_pi_state_list() or some waiter
* acquired the rtmutex in the pi state, but did not
* yet fixup the TID in user space.
*
* Take a ref on the state and return success. [6]
*/
if (!pid)
goto out_attach;
} else {
/*
* If the owner died bit is not set, then the pi_state
* must have an owner. [7]
*/
if (!pi_state->owner)
goto out_einval;
}
/*
* Bail out if user space manipulated the futex value. If pi
* state exists then the owner TID must be the same as the
* user space TID. [9/10]
*/
if (pid != task_pid_vnr(pi_state->owner))
goto out_einval;
out_attach:
get_pi_state(pi_state);
raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);
*ps = pi_state;
return 0;
out_einval:
ret = -EINVAL;
goto out_error;
out_eagain:
ret = -EAGAIN;
goto out_error;
out_efault:
ret = -EFAULT;
goto out_error;
out_error:
raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);
return ret;
}
| 17,357 |
106,723 | 0 | WebCore::DragOperation WebView::keyStateToDragOperation(DWORD grfKeyState) const
{
if (!m_page)
return DragOperationNone;
DragOperation operation = m_page->dragOperation();
if ((grfKeyState & (MK_CONTROL | MK_SHIFT)) == (MK_CONTROL | MK_SHIFT))
operation = DragOperationLink;
else if ((grfKeyState & MK_CONTROL) == MK_CONTROL)
operation = DragOperationCopy;
else if ((grfKeyState & MK_SHIFT) == MK_SHIFT)
operation = DragOperationGeneric;
return operation;
}
| 17,358 |
147,064 | 0 | bool WebLocalFrameImpl::SelectWordAroundCaret() {
TRACE_EVENT0("blink", "WebLocalFrameImpl::selectWordAroundCaret");
FrameSelection& selection = GetFrame()->Selection();
GetFrame()->GetDocument()->UpdateStyleAndLayoutIgnorePendingStylesheets();
if (selection.ComputeVisibleSelectionInDOMTree().IsNone() ||
selection.ComputeVisibleSelectionInDOMTree().IsRange()) {
return false;
}
return GetFrame()->Selection().SelectWordAroundPosition(
selection.ComputeVisibleSelectionInDOMTree().VisibleStart());
}
| 17,359 |
28,364 | 0 | static struct sock *ping_get_first(struct seq_file *seq, int start)
{
struct sock *sk;
struct ping_iter_state *state = seq->private;
struct net *net = seq_file_net(seq);
for (state->bucket = start; state->bucket < PING_HTABLE_SIZE;
++state->bucket) {
struct hlist_nulls_node *node;
struct hlist_nulls_head *hslot;
hslot = &ping_table.hash[state->bucket];
if (hlist_nulls_empty(hslot))
continue;
sk_nulls_for_each(sk, node, hslot) {
if (net_eq(sock_net(sk), net) &&
sk->sk_family == state->family)
goto found;
}
}
sk = NULL;
found:
return sk;
}
| 17,360 |
170,379 | 0 | status_t MPEG4Extractor::readMetaData() {
if (mInitCheck != NO_INIT) {
return mInitCheck;
}
off64_t offset = 0;
status_t err;
while (true) {
off64_t orig_offset = offset;
err = parseChunk(&offset, 0);
if (err != OK && err != UNKNOWN_ERROR) {
break;
} else if (offset <= orig_offset) {
ALOGE("did not advance: 0x%lld->0x%lld", orig_offset, offset);
err = ERROR_MALFORMED;
break;
} else if (err == OK) {
continue;
}
uint32_t hdr[2];
if (mDataSource->readAt(offset, hdr, 8) < 8) {
break;
}
uint32_t chunk_type = ntohl(hdr[1]);
if (chunk_type == FOURCC('m', 'o', 'o', 'f')) {
mMoofOffset = offset;
} else if (chunk_type != FOURCC('m', 'd', 'a', 't')) {
continue;
}
break;
}
if (mInitCheck == OK) {
if (mHasVideo) {
mFileMetaData->setCString(
kKeyMIMEType, MEDIA_MIMETYPE_CONTAINER_MPEG4);
} else {
mFileMetaData->setCString(kKeyMIMEType, "audio/mp4");
}
} else {
mInitCheck = err;
}
CHECK_NE(err, (status_t)NO_INIT);
int psshsize = 0;
for (size_t i = 0; i < mPssh.size(); i++) {
psshsize += 20 + mPssh[i].datalen;
}
if (psshsize) {
char *buf = (char*)malloc(psshsize);
char *ptr = buf;
for (size_t i = 0; i < mPssh.size(); i++) {
memcpy(ptr, mPssh[i].uuid, 20); // uuid + length
memcpy(ptr + 20, mPssh[i].data, mPssh[i].datalen);
ptr += (20 + mPssh[i].datalen);
}
mFileMetaData->setData(kKeyPssh, 'pssh', buf, psshsize);
free(buf);
}
return mInitCheck;
}
| 17,361 |
61,034 | 0 | custom_full_name_to_string (char *format,
va_list va)
{
GFile *file;
file = va_arg (va, GFile *);
return g_file_get_parse_name (file);
}
| 17,362 |
88,789 | 0 | static void compose_notify(char *type, char *host, char *buf, size_t len)
{
char usn[256];
if (type) {
if (!strcmp(type, SSDP_ST_ALL))
type = NULL;
else
snprintf(usn, sizeof(usn), "%s::%s", uuid, type);
}
if (!type) {
type = usn;
strncpy(usn, uuid, sizeof(usn));
}
snprintf(buf, len, "NOTIFY * HTTP/1.1\r\n"
"Host: %s:%d\r\n"
"Server: %s\r\n"
"Location: http://%s:%d%s\r\n"
"NT: %s\r\n"
"NTS: ssdp:alive\r\n"
"USN: %s\r\n"
"Cache-Control: max-age=%d\r\n"
"\r\n",
MC_SSDP_GROUP, MC_SSDP_PORT,
server_string,
host, LOCATION_PORT, LOCATION_DESC,
type,
usn,
CACHE_TIMEOUT);
}
| 17,363 |
159,830 | 0 | static bool StartsClosingScriptTagAt(const String& string, size_t start) {
if (start + 7 >= string.length())
return false;
StringView script("</script");
return EqualIgnoringASCIICase(StringView(string, start, script.length()),
script);
}
| 17,364 |
183,953 | 1 | virtual bool InputMethodIsActivated(const std::string& input_method_id) {
scoped_ptr<InputMethodDescriptors> active_input_method_descriptors(
GetActiveInputMethods());
for (size_t i = 0; i < active_input_method_descriptors->size(); ++i) {
if (active_input_method_descriptors->at(i).id == input_method_id) {
return true;
}
}
return false;
}
| 17,365 |
23,258 | 0 | static int decode_attr_filehandle(struct xdr_stream *xdr, uint32_t *bitmap, struct nfs_fh *fh)
{
__be32 *p;
int len;
if (fh != NULL)
memset(fh, 0, sizeof(*fh));
if (unlikely(bitmap[0] & (FATTR4_WORD0_FILEHANDLE - 1U)))
return -EIO;
if (likely(bitmap[0] & FATTR4_WORD0_FILEHANDLE)) {
p = xdr_inline_decode(xdr, 4);
if (unlikely(!p))
goto out_overflow;
len = be32_to_cpup(p);
if (len > NFS4_FHSIZE)
return -EIO;
p = xdr_inline_decode(xdr, len);
if (unlikely(!p))
goto out_overflow;
if (fh != NULL) {
memcpy(fh->data, p, len);
fh->size = len;
}
bitmap[0] &= ~FATTR4_WORD0_FILEHANDLE;
}
return 0;
out_overflow:
print_overflow_msg(__func__, xdr);
return -EIO;
}
| 17,366 |
69,892 | 0 | connection_ap_handshake_process_socks(entry_connection_t *conn)
{
socks_request_t *socks;
int sockshere;
const or_options_t *options = get_options();
int had_reply = 0;
connection_t *base_conn = ENTRY_TO_CONN(conn);
tor_assert(conn);
tor_assert(base_conn->type == CONN_TYPE_AP);
tor_assert(base_conn->state == AP_CONN_STATE_SOCKS_WAIT);
tor_assert(conn->socks_request);
socks = conn->socks_request;
log_debug(LD_APP,"entered.");
sockshere = fetch_from_buf_socks(base_conn->inbuf, socks,
options->TestSocks, options->SafeSocks);
if (socks->replylen) {
had_reply = 1;
connection_write_to_buf((const char*)socks->reply, socks->replylen,
base_conn);
socks->replylen = 0;
if (sockshere == -1) {
/* An invalid request just got a reply, no additional
* one is necessary. */
socks->has_finished = 1;
}
}
if (sockshere == 0) {
log_debug(LD_APP,"socks handshake not all here yet.");
return 0;
} else if (sockshere == -1) {
if (!had_reply) {
log_warn(LD_APP,"Fetching socks handshake failed. Closing.");
connection_ap_handshake_socks_reply(conn, NULL, 0,
END_STREAM_REASON_SOCKSPROTOCOL);
}
connection_mark_unattached_ap(conn,
END_STREAM_REASON_SOCKSPROTOCOL |
END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
return -1;
} /* else socks handshake is done, continue processing */
if (SOCKS_COMMAND_IS_CONNECT(socks->command))
control_event_stream_status(conn, STREAM_EVENT_NEW, 0);
else
control_event_stream_status(conn, STREAM_EVENT_NEW_RESOLVE, 0);
return connection_ap_rewrite_and_attach_if_allowed(conn, NULL, NULL);
}
| 17,367 |
30,461 | 0 | static int send_msg(struct kiocb *iocb, struct socket *sock,
struct msghdr *m, size_t total_len)
{
struct sock *sk = sock->sk;
struct tipc_port *tport = tipc_sk_port(sk);
struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name;
int needs_conn;
long timeout_val;
int res = -EINVAL;
if (unlikely(!dest))
return -EDESTADDRREQ;
if (unlikely((m->msg_namelen < sizeof(*dest)) ||
(dest->family != AF_TIPC)))
return -EINVAL;
if (total_len > TIPC_MAX_USER_MSG_SIZE)
return -EMSGSIZE;
if (iocb)
lock_sock(sk);
needs_conn = (sock->state != SS_READY);
if (unlikely(needs_conn)) {
if (sock->state == SS_LISTENING) {
res = -EPIPE;
goto exit;
}
if (sock->state != SS_UNCONNECTED) {
res = -EISCONN;
goto exit;
}
if ((tport->published) ||
((sock->type == SOCK_STREAM) && (total_len != 0))) {
res = -EOPNOTSUPP;
goto exit;
}
if (dest->addrtype == TIPC_ADDR_NAME) {
tport->conn_type = dest->addr.name.name.type;
tport->conn_instance = dest->addr.name.name.instance;
}
/* Abort any pending connection attempts (very unlikely) */
reject_rx_queue(sk);
}
timeout_val = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT);
do {
if (dest->addrtype == TIPC_ADDR_NAME) {
res = dest_name_check(dest, m);
if (res)
break;
res = tipc_send2name(tport->ref,
&dest->addr.name.name,
dest->addr.name.domain,
m->msg_iovlen,
m->msg_iov,
total_len);
} else if (dest->addrtype == TIPC_ADDR_ID) {
res = tipc_send2port(tport->ref,
&dest->addr.id,
m->msg_iovlen,
m->msg_iov,
total_len);
} else if (dest->addrtype == TIPC_ADDR_MCAST) {
if (needs_conn) {
res = -EOPNOTSUPP;
break;
}
res = dest_name_check(dest, m);
if (res)
break;
res = tipc_multicast(tport->ref,
&dest->addr.nameseq,
m->msg_iovlen,
m->msg_iov,
total_len);
}
if (likely(res != -ELINKCONG)) {
if (needs_conn && (res >= 0))
sock->state = SS_CONNECTING;
break;
}
if (timeout_val <= 0L) {
res = timeout_val ? timeout_val : -EWOULDBLOCK;
break;
}
release_sock(sk);
timeout_val = wait_event_interruptible_timeout(*sk_sleep(sk),
!tport->congested, timeout_val);
lock_sock(sk);
} while (1);
exit:
if (iocb)
release_sock(sk);
return res;
}
| 17,368 |
122,796 | 0 | void GpuProcessHost::OnAcceleratedSurfaceRelease(
const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) {
TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceRelease");
gfx::PluginWindowHandle handle =
GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id);
if (!handle) {
#if defined(USE_AURA)
RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceRelease(params));
return;
#endif
}
scoped_refptr<AcceleratedPresenter> presenter(
AcceleratedPresenter::GetForWindow(handle));
if (!presenter)
return;
presenter->ReleaseSurface();
}
| 17,369 |
78,215 | 0 | authentic_sm_free_wrapped_apdu(struct sc_card *card, struct sc_apdu *plain, struct sc_apdu **sm_apdu)
{
struct sc_context *ctx = card->ctx;
LOG_FUNC_CALLED(ctx);
if (!sm_apdu)
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
if (!(*sm_apdu))
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
if (plain) {
if (plain->resplen < (*sm_apdu)->resplen)
LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "Insufficient plain APDU response size");
memcpy(plain->resp, (*sm_apdu)->resp, (*sm_apdu)->resplen);
plain->resplen = (*sm_apdu)->resplen;
plain->sw1 = (*sm_apdu)->sw1;
plain->sw2 = (*sm_apdu)->sw2;
}
if ((*sm_apdu)->data)
free((unsigned char *) (*sm_apdu)->data);
if ((*sm_apdu)->resp)
free((unsigned char *) (*sm_apdu)->resp);
free(*sm_apdu);
*sm_apdu = NULL;
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
}
| 17,370 |
137,634 | 0 | void MockDownloadController::StartContextMenuDownload(
const content::ContextMenuParams& params,
content::WebContents* web_contents,
bool is_link, const std::string& extra_headers) {
}
| 17,371 |
44,553 | 0 | static bool lxc_list_controllers(char ***list)
{
return false;
}
| 17,372 |
177,612 | 0 | void SetFrameBuffer(int idx, vpx_codec_frame_buffer_t *fb) {
ASSERT_TRUE(fb != NULL);
fb->data = ext_fb_list_[idx].data;
fb->size = ext_fb_list_[idx].size;
ASSERT_EQ(0, ext_fb_list_[idx].in_use);
ext_fb_list_[idx].in_use = 1;
fb->priv = &ext_fb_list_[idx];
}
| 17,373 |
10,478 | 0 | static uint32_t megasas_sgl_get_len(MegasasCmd *cmd,
union mfi_sgl *sgl)
{
uint32_t len;
if (megasas_frame_is_ieee_sgl(cmd)) {
len = le32_to_cpu(sgl->sg_skinny->len);
} else if (megasas_frame_is_sgl64(cmd)) {
len = le32_to_cpu(sgl->sg64->len);
} else {
len = le32_to_cpu(sgl->sg32->len);
}
return len;
}
| 17,374 |
142,915 | 0 | void HTMLMediaElement::SourceWasRemoved(HTMLSourceElement* source) {
BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ", " << source
<< ")";
KURL url = source->GetNonEmptyURLAttribute(kSrcAttr);
BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this << ") - 'src' is "
<< UrlForLoggingMedia(url);
if (source != current_source_node_ && source != next_child_node_to_consider_)
return;
if (source == next_child_node_to_consider_) {
if (current_source_node_)
next_child_node_to_consider_ = current_source_node_->nextSibling();
BLINK_MEDIA_LOG << "sourceWasRemoved(" << (void*)this
<< ") - next_child_node_to_consider_ set to "
<< next_child_node_to_consider_.Get();
} else if (source == current_source_node_) {
current_source_node_ = nullptr;
BLINK_MEDIA_LOG << "SourceWasRemoved(" << (void*)this
<< ") - current_source_node_ set to 0";
}
}
| 17,375 |
121,187 | 0 | bool HTMLInputElement::isSearchField() const
{
return m_inputType->isSearchField();
}
| 17,376 |
9,038 | 0 | static void vmxnet3_put_tx_stats_to_file(QEMUFile *f,
struct UPT1_TxStats *tx_stat)
{
qemu_put_be64(f, tx_stat->TSOPktsTxOK);
qemu_put_be64(f, tx_stat->TSOBytesTxOK);
qemu_put_be64(f, tx_stat->ucastPktsTxOK);
qemu_put_be64(f, tx_stat->ucastBytesTxOK);
qemu_put_be64(f, tx_stat->mcastPktsTxOK);
qemu_put_be64(f, tx_stat->mcastBytesTxOK);
qemu_put_be64(f, tx_stat->bcastPktsTxOK);
qemu_put_be64(f, tx_stat->bcastBytesTxOK);
qemu_put_be64(f, tx_stat->pktsTxError);
qemu_put_be64(f, tx_stat->pktsTxDiscard);
}
| 17,377 |
129,668 | 0 | AffineTransform& AffineTransform::scaleNonUniform(double sx, double sy)
{
return scale(sx, sy);
}
| 17,378 |
102,015 | 0 | OffScreenRootWindow()
{
++refCount;
}
| 17,379 |
187,043 | 1 | void FrameLoader::Trace(blink::Visitor* visitor) {
visitor->Trace(frame_);
visitor->Trace(progress_tracker_);
visitor->Trace(document_loader_);
visitor->Trace(provisional_document_loader_);
}
| 17,380 |
128,376 | 0 | bool FrameView::wheelEvent(const PlatformWheelEvent& wheelEvent)
{
bool allowScrolling = userInputScrollable(HorizontalScrollbar) || userInputScrollable(VerticalScrollbar);
#if !USE(RUBBER_BANDING)
if (!isScrollable())
allowScrolling = false;
#endif
if (allowScrolling && ScrollableArea::handleWheelEvent(wheelEvent))
return true;
if (m_frame->settings()->pinchVirtualViewportEnabled() && m_frame->isMainFrame())
return page()->frameHost().pinchViewport().handleWheelEvent(wheelEvent);
return false;
}
| 17,381 |
164,730 | 0 | void TestClearSectionWithNode(const char* html, bool unowned) {
LoadHTML(html);
WebLocalFrame* web_frame = GetMainFrame();
ASSERT_NE(nullptr, web_frame);
FormCache form_cache(web_frame);
std::vector<FormData> forms = form_cache.ExtractNewForms();
ASSERT_EQ(1U, forms.size());
WebInputElement firstname = GetInputElementById("firstname");
firstname.SetAutofillState(WebAutofillState::kAutofilled);
WebInputElement lastname = GetInputElementById("lastname");
lastname.SetAutofillState(WebAutofillState::kAutofilled);
WebInputElement month = GetInputElementById("month");
month.SetAutofillState(WebAutofillState::kAutofilled);
WebFormControlElement textarea = GetFormControlElementById("textarea");
textarea.SetAutofillState(WebAutofillState::kAutofilled);
WebInputElement notenabled = GetInputElementById("notenabled");
notenabled.SetValue(WebString::FromUTF8("no clear"));
EXPECT_TRUE(form_cache.ClearSectionWithElement(firstname));
EXPECT_FALSE(firstname.IsAutofilled());
FormData form;
FormFieldData field;
EXPECT_TRUE(
FindFormAndFieldForFormControlElement(firstname, &form, &field));
EXPECT_EQ(GetCanonicalOriginForDocument(web_frame->GetDocument()),
form.origin);
EXPECT_FALSE(form.origin.is_empty());
if (!unowned) {
EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
EXPECT_EQ(GURL("http://abc.com"), form.action);
}
const std::vector<FormFieldData>& fields = form.fields;
ASSERT_EQ(9U, fields.size());
FormFieldData expected;
expected.form_control_type = "text";
expected.max_length = WebInputElement::DefaultMaxLength();
expected.id_attribute = ASCIIToUTF16("firstname");
expected.name = expected.id_attribute;
expected.value.clear();
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]);
expected.id_attribute = ASCIIToUTF16("lastname");
expected.name = expected.id_attribute;
expected.value.clear();
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]);
expected.id_attribute = ASCIIToUTF16("noAC");
expected.name = expected.id_attribute;
expected.value = ASCIIToUTF16("one");
expected.label = ASCIIToUTF16("one");
expected.autocomplete_attribute = "off";
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]);
expected.autocomplete_attribute.clear();
expected.id_attribute = ASCIIToUTF16("notenabled");
expected.name = expected.id_attribute;
expected.value = ASCIIToUTF16("no clear");
expected.label.clear();
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]);
expected.form_control_type = "month";
expected.max_length = 0;
expected.id_attribute = ASCIIToUTF16("month");
expected.name = expected.id_attribute;
expected.value.clear();
expected.label.clear();
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[4]);
expected.id_attribute = ASCIIToUTF16("month-disabled");
expected.name = expected.id_attribute;
expected.value = ASCIIToUTF16("2012-11");
expected.label = ASCIIToUTF16("2012-11");
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[5]);
expected.form_control_type = "textarea";
expected.id_attribute = ASCIIToUTF16("textarea");
expected.name = expected.id_attribute;
expected.value.clear();
expected.label.clear();
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[6]);
expected.id_attribute = ASCIIToUTF16("textarea-disabled");
expected.name = expected.id_attribute;
expected.value = ASCIIToUTF16(" Banana! ");
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[7]);
expected.id_attribute = ASCIIToUTF16("textarea-noAC");
expected.name = expected.id_attribute;
expected.value = ASCIIToUTF16("Carrot?");
expected.autocomplete_attribute = "off";
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[8]);
expected.autocomplete_attribute.clear();
EXPECT_EQ(0, firstname.SelectionStart());
EXPECT_EQ(0, firstname.SelectionEnd());
}
| 17,382 |
21,218 | 0 | static inline void cow_user_page(struct page *dst, struct page *src, unsigned long va, struct vm_area_struct *vma)
{
/*
* If the source page was a PFN mapping, we don't have
* a "struct page" for it. We do a best-effort copy by
* just copying from the original user address. If that
* fails, we just zero-fill it. Live with it.
*/
if (unlikely(!src)) {
void *kaddr = kmap_atomic(dst, KM_USER0);
void __user *uaddr = (void __user *)(va & PAGE_MASK);
/*
* This really shouldn't fail, because the page is there
* in the page tables. But it might just be unreadable,
* in which case we just give up and fill the result with
* zeroes.
*/
if (__copy_from_user_inatomic(kaddr, uaddr, PAGE_SIZE))
clear_page(kaddr);
kunmap_atomic(kaddr, KM_USER0);
flush_dcache_page(dst);
} else
copy_user_highpage(dst, src, va, vma);
}
| 17,383 |
115,734 | 0 | void ConnectionToClient::NotifyIfChannelsReady() {
if (control_connected_ && input_connected_ && video_connected_)
handler_->OnConnectionOpened(this);
}
| 17,384 |
151,344 | 0 | void InspectorTraceEvents::Dispose() {
instrumenting_agents_->removeInspectorTraceEvents(this);
instrumenting_agents_ = nullptr;
}
| 17,385 |
187,670 | 1 | image_transform_png_set_strip_16_add(image_transform *this,
PNG_CONST image_transform **that, png_byte colour_type, png_byte bit_depth)
{
UNUSED(colour_type)
this->next = *that;
*that = this;
return bit_depth > 8;
}
| 17,386 |
41,678 | 0 | static int btrfs_setsize(struct inode *inode, struct iattr *attr)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
struct btrfs_trans_handle *trans;
loff_t oldsize = i_size_read(inode);
loff_t newsize = attr->ia_size;
int mask = attr->ia_valid;
int ret;
/*
* The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a
* special case where we need to update the times despite not having
* these flags set. For all other operations the VFS set these flags
* explicitly if it wants a timestamp update.
*/
if (newsize != oldsize) {
inode_inc_iversion(inode);
if (!(mask & (ATTR_CTIME | ATTR_MTIME)))
inode->i_ctime = inode->i_mtime =
current_fs_time(inode->i_sb);
}
if (newsize > oldsize) {
truncate_pagecache(inode, newsize);
/*
* Don't do an expanding truncate while snapshoting is ongoing.
* This is to ensure the snapshot captures a fully consistent
* state of this file - if the snapshot captures this expanding
* truncation, it must capture all writes that happened before
* this truncation.
*/
wait_for_snapshot_creation(root);
ret = btrfs_cont_expand(inode, oldsize, newsize);
if (ret) {
btrfs_end_write_no_snapshoting(root);
return ret;
}
trans = btrfs_start_transaction(root, 1);
if (IS_ERR(trans)) {
btrfs_end_write_no_snapshoting(root);
return PTR_ERR(trans);
}
i_size_write(inode, newsize);
btrfs_ordered_update_i_size(inode, i_size_read(inode), NULL);
ret = btrfs_update_inode(trans, root, inode);
btrfs_end_write_no_snapshoting(root);
btrfs_end_transaction(trans, root);
} else {
/*
* We're truncating a file that used to have good data down to
* zero. Make sure it gets into the ordered flush list so that
* any new writes get down to disk quickly.
*/
if (newsize == 0)
set_bit(BTRFS_INODE_ORDERED_DATA_CLOSE,
&BTRFS_I(inode)->runtime_flags);
/*
* 1 for the orphan item we're going to add
* 1 for the orphan item deletion.
*/
trans = btrfs_start_transaction(root, 2);
if (IS_ERR(trans))
return PTR_ERR(trans);
/*
* We need to do this in case we fail at _any_ point during the
* actual truncate. Once we do the truncate_setsize we could
* invalidate pages which forces any outstanding ordered io to
* be instantly completed which will give us extents that need
* to be truncated. If we fail to get an orphan inode down we
* could have left over extents that were never meant to live,
* so we need to garuntee from this point on that everything
* will be consistent.
*/
ret = btrfs_orphan_add(trans, inode);
btrfs_end_transaction(trans, root);
if (ret)
return ret;
/* we don't support swapfiles, so vmtruncate shouldn't fail */
truncate_setsize(inode, newsize);
/* Disable nonlocked read DIO to avoid the end less truncate */
btrfs_inode_block_unlocked_dio(inode);
inode_dio_wait(inode);
btrfs_inode_resume_unlocked_dio(inode);
ret = btrfs_truncate(inode);
if (ret && inode->i_nlink) {
int err;
/*
* failed to truncate, disk_i_size is only adjusted down
* as we remove extents, so it should represent the true
* size of the inode, so reset the in memory size and
* delete our orphan entry.
*/
trans = btrfs_join_transaction(root);
if (IS_ERR(trans)) {
btrfs_orphan_del(NULL, inode);
return ret;
}
i_size_write(inode, BTRFS_I(inode)->disk_i_size);
err = btrfs_orphan_del(trans, inode);
if (err)
btrfs_abort_transaction(trans, root, err);
btrfs_end_transaction(trans, root);
}
}
return ret;
}
| 17,387 |
29,690 | 0 | static int is_seen(struct ctl_table_set *set)
{
return ¤t->nsproxy->net_ns->sysctls == set;
}
| 17,388 |
78,792 | 0 | static int esteid_detect_card(sc_pkcs15_card_t *p15card)
{
if (is_esteid_card(p15card->card))
return SC_SUCCESS;
else
return SC_ERROR_WRONG_CARD;
}
| 17,389 |
47,740 | 0 | bool netlink_capable(const struct sk_buff *skb, int cap)
{
return netlink_ns_capable(skb, &init_user_ns, cap);
}
| 17,390 |
37,796 | 0 | static void nested_svm_vmloadsave(struct vmcb *from_vmcb, struct vmcb *to_vmcb)
{
to_vmcb->save.fs = from_vmcb->save.fs;
to_vmcb->save.gs = from_vmcb->save.gs;
to_vmcb->save.tr = from_vmcb->save.tr;
to_vmcb->save.ldtr = from_vmcb->save.ldtr;
to_vmcb->save.kernel_gs_base = from_vmcb->save.kernel_gs_base;
to_vmcb->save.star = from_vmcb->save.star;
to_vmcb->save.lstar = from_vmcb->save.lstar;
to_vmcb->save.cstar = from_vmcb->save.cstar;
to_vmcb->save.sfmask = from_vmcb->save.sfmask;
to_vmcb->save.sysenter_cs = from_vmcb->save.sysenter_cs;
to_vmcb->save.sysenter_esp = from_vmcb->save.sysenter_esp;
to_vmcb->save.sysenter_eip = from_vmcb->save.sysenter_eip;
}
| 17,391 |
178,244 | 1 | PHP_METHOD(Phar, extractTo)
{
char *error = NULL;
php_stream *fp;
php_stream_statbuf ssb;
phar_entry_info *entry;
char *pathto, *filename;
size_t pathto_len, filename_len;
int ret, i;
int nelems;
zval *zval_files = NULL;
zend_bool overwrite = 0;
PHAR_ARCHIVE_OBJECT();
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) {
return;
}
fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, NULL);
if (!fp) {
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0,
"Invalid argument, %s cannot be found", phar_obj->archive->fname);
return;
}
php_stream_close(fp);
if (pathto_len < 1) {
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0,
"Invalid argument, extraction path must be non-zero length");
return;
}
if (pathto_len >= MAXPATHLEN) {
char *tmp = estrndup(pathto, 50);
/* truncate for error message */
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Cannot extract to \"%s...\", destination directory is too long for filesystem", tmp);
efree(tmp);
return;
}
if (php_stream_stat_path(pathto, &ssb) < 0) {
ret = php_stream_mkdir(pathto, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL);
if (!ret) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Unable to create path \"%s\" for extraction", pathto);
return;
}
} else if (!(ssb.sb.st_mode & S_IFDIR)) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0,
"Unable to use path \"%s\" for extraction, it is a file, must be a directory", pathto);
return;
}
if (zval_files) {
switch (Z_TYPE_P(zval_files)) {
case IS_NULL:
goto all_files;
case IS_STRING:
filename = Z_STRVAL_P(zval_files);
filename_len = Z_STRLEN_P(zval_files);
break;
case IS_ARRAY:
nelems = zend_hash_num_elements(Z_ARRVAL_P(zval_files));
if (nelems == 0 ) {
RETURN_FALSE;
}
for (i = 0; i < nelems; i++) {
zval *zval_file;
if ((zval_file = zend_hash_index_find(Z_ARRVAL_P(zval_files), i)) != NULL) {
switch (Z_TYPE_P(zval_file)) {
case IS_STRING:
break;
default:
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0,
"Invalid argument, array of filenames to extract contains non-string value");
return;
}
if (NULL == (entry = zend_hash_find_ptr(&phar_obj->archive->manifest, Z_STR_P(zval_file)))) {
zend_throw_exception_ex(phar_ce_PharException, 0,
"Phar Error: attempted to extract non-existent file \"%s\" from phar \"%s\"", Z_STRVAL_P(zval_file), phar_obj->archive->fname);
}
if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error)) {
zend_throw_exception_ex(phar_ce_PharException, 0,
"Extraction from phar \"%s\" failed: %s", phar_obj->archive->fname, error);
efree(error);
return;
}
}
}
RETURN_TRUE;
default:
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0,
"Invalid argument, expected a filename (string) or array of filenames");
return;
}
if (NULL == (entry = zend_hash_str_find_ptr(&phar_obj->archive->manifest, filename, filename_len))) {
zend_throw_exception_ex(phar_ce_PharException, 0,
"Phar Error: attempted to extract non-existent file \"%s\" from phar \"%s\"", filename, phar_obj->archive->fname);
return;
}
if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error)) {
zend_throw_exception_ex(phar_ce_PharException, 0,
"Extraction from phar \"%s\" failed: %s", phar_obj->archive->fname, error);
efree(error);
return;
}
} else {
phar_archive_data *phar;
all_files:
phar = phar_obj->archive;
/* Extract all files */
if (!zend_hash_num_elements(&(phar->manifest))) {
RETURN_TRUE;
}
ZEND_HASH_FOREACH_PTR(&phar->manifest, entry) {
if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, &error)) {
zend_throw_exception_ex(phar_ce_PharException, 0,
"Extraction from phar \"%s\" failed: %s", phar->fname, error);
efree(error);
return;
}
} ZEND_HASH_FOREACH_END();
}
RETURN_TRUE;
}
| 17,392 |
13,641 | 0 | int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
{
int error_code;
STACK_OF(SRP_gN) *SRP_gN_tab = sk_SRP_gN_new_null();
char *last_index = NULL;
int i;
char **pp;
SRP_gN *gN = NULL;
SRP_user_pwd *user_pwd = NULL;
TXT_DB *tmpdb = NULL;
BIO *in = BIO_new(BIO_s_file());
error_code = SRP_ERR_OPEN_FILE;
if (in == NULL || BIO_read_filename(in, verifier_file) <= 0)
goto err;
error_code = SRP_ERR_VBASE_INCOMPLETE_FILE;
if ((tmpdb = TXT_DB_read(in, DB_NUMBER)) == NULL)
goto err;
error_code = SRP_ERR_MEMORY;
if (vb->seed_key) {
last_index = SRP_get_default_gN(NULL)->id;
}
for (i = 0; i < sk_OPENSSL_PSTRING_num(tmpdb->data); i++) {
pp = sk_OPENSSL_PSTRING_value(tmpdb->data, i);
if (pp[DB_srptype][0] == DB_SRP_INDEX) {
/*
* we add this couple in the internal Stack
*/
if ((gN = (SRP_gN *) OPENSSL_malloc(sizeof(SRP_gN))) == NULL)
goto err;
if (!(gN->id = BUF_strdup(pp[DB_srpid]))
|| !(gN->N =
SRP_gN_place_bn(vb->gN_cache, pp[DB_srpverifier]))
|| !(gN->g = SRP_gN_place_bn(vb->gN_cache, pp[DB_srpsalt]))
|| sk_SRP_gN_insert(SRP_gN_tab, gN, 0) == 0)
goto err;
gN = NULL;
if (vb->seed_key != NULL) {
last_index = pp[DB_srpid];
}
} else if (pp[DB_srptype][0] == DB_SRP_VALID) {
/* it is a user .... */
SRP_gN *lgN;
if ((lgN = SRP_get_gN_by_id(pp[DB_srpgN], SRP_gN_tab)) != NULL) {
error_code = SRP_ERR_MEMORY;
if ((user_pwd = SRP_user_pwd_new()) == NULL)
goto err;
SRP_user_pwd_set_gN(user_pwd, lgN->g, lgN->N);
if (!SRP_user_pwd_set_ids
(user_pwd, pp[DB_srpid], pp[DB_srpinfo]))
goto err;
error_code = SRP_ERR_VBASE_BN_LIB;
if (!SRP_user_pwd_set_sv
(user_pwd, pp[DB_srpsalt], pp[DB_srpverifier]))
goto err;
if (sk_SRP_user_pwd_insert(vb->users_pwd, user_pwd, 0) == 0)
goto err;
user_pwd = NULL; /* abandon responsability */
}
}
}
if (last_index != NULL) {
/* this means that we want to simulate a default user */
if (((gN = SRP_get_gN_by_id(last_index, SRP_gN_tab)) == NULL)) {
error_code = SRP_ERR_VBASE_BN_LIB;
goto err;
}
vb->default_g = gN->g;
vb->default_N = gN->N;
gN = NULL;
}
error_code = SRP_NO_ERROR;
err:
/*
* there may be still some leaks to fix, if this fails, the application
* terminates most likely
*/
if (gN != NULL) {
OPENSSL_free(gN->id);
OPENSSL_free(gN);
}
SRP_user_pwd_free(user_pwd);
if (tmpdb)
TXT_DB_free(tmpdb);
if (in)
BIO_free_all(in);
sk_SRP_gN_free(SRP_gN_tab);
return error_code;
}
| 17,393 |
20,520 | 0 | static int ext4_remount(struct super_block *sb, int *flags, char *data)
{
struct ext4_super_block *es;
struct ext4_sb_info *sbi = EXT4_SB(sb);
ext4_fsblk_t n_blocks_count = 0;
unsigned long old_sb_flags;
struct ext4_mount_options old_opts;
int enable_quota = 0;
ext4_group_t g;
unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO;
int err = 0;
#ifdef CONFIG_QUOTA
int i;
#endif
char *orig_data = kstrdup(data, GFP_KERNEL);
/* Store the original options */
lock_super(sb);
old_sb_flags = sb->s_flags;
old_opts.s_mount_opt = sbi->s_mount_opt;
old_opts.s_mount_opt2 = sbi->s_mount_opt2;
old_opts.s_resuid = sbi->s_resuid;
old_opts.s_resgid = sbi->s_resgid;
old_opts.s_commit_interval = sbi->s_commit_interval;
old_opts.s_min_batch_time = sbi->s_min_batch_time;
old_opts.s_max_batch_time = sbi->s_max_batch_time;
#ifdef CONFIG_QUOTA
old_opts.s_jquota_fmt = sbi->s_jquota_fmt;
for (i = 0; i < MAXQUOTAS; i++)
old_opts.s_qf_names[i] = sbi->s_qf_names[i];
#endif
if (sbi->s_journal && sbi->s_journal->j_task->io_context)
journal_ioprio = sbi->s_journal->j_task->io_context->ioprio;
/*
* Allow the "check" option to be passed as a remount option.
*/
if (!parse_options(data, sb, NULL, &journal_ioprio,
&n_blocks_count, 1)) {
err = -EINVAL;
goto restore_opts;
}
if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
ext4_abort(sb, "Abort forced by user");
sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
(test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
es = sbi->s_es;
if (sbi->s_journal) {
ext4_init_journal_params(sb, sbi->s_journal);
set_task_ioprio(sbi->s_journal->j_task, journal_ioprio);
}
if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) ||
n_blocks_count > ext4_blocks_count(es)) {
if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED) {
err = -EROFS;
goto restore_opts;
}
if (*flags & MS_RDONLY) {
err = dquot_suspend(sb, -1);
if (err < 0)
goto restore_opts;
/*
* First of all, the unconditional stuff we have to do
* to disable replay of the journal when we next remount
*/
sb->s_flags |= MS_RDONLY;
/*
* OK, test if we are remounting a valid rw partition
* readonly, and if so set the rdonly flag and then
* mark the partition as valid again.
*/
if (!(es->s_state & cpu_to_le16(EXT4_VALID_FS)) &&
(sbi->s_mount_state & EXT4_VALID_FS))
es->s_state = cpu_to_le16(sbi->s_mount_state);
if (sbi->s_journal)
ext4_mark_recovery_complete(sb, es);
} else {
/* Make sure we can mount this feature set readwrite */
if (!ext4_feature_set_ok(sb, 0)) {
err = -EROFS;
goto restore_opts;
}
/*
* Make sure the group descriptor checksums
* are sane. If they aren't, refuse to remount r/w.
*/
for (g = 0; g < sbi->s_groups_count; g++) {
struct ext4_group_desc *gdp =
ext4_get_group_desc(sb, g, NULL);
if (!ext4_group_desc_csum_verify(sbi, g, gdp)) {
ext4_msg(sb, KERN_ERR,
"ext4_remount: Checksum for group %u failed (%u!=%u)",
g, le16_to_cpu(ext4_group_desc_csum(sbi, g, gdp)),
le16_to_cpu(gdp->bg_checksum));
err = -EINVAL;
goto restore_opts;
}
}
/*
* If we have an unprocessed orphan list hanging
* around from a previously readonly bdev mount,
* require a full umount/remount for now.
*/
if (es->s_last_orphan) {
ext4_msg(sb, KERN_WARNING, "Couldn't "
"remount RDWR because of unprocessed "
"orphan inode list. Please "
"umount/remount instead");
err = -EINVAL;
goto restore_opts;
}
/*
* Mounting a RDONLY partition read-write, so reread
* and store the current valid flag. (It may have
* been changed by e2fsck since we originally mounted
* the partition.)
*/
if (sbi->s_journal)
ext4_clear_journal_err(sb, es);
sbi->s_mount_state = le16_to_cpu(es->s_state);
if ((err = ext4_group_extend(sb, es, n_blocks_count)))
goto restore_opts;
if (!ext4_setup_super(sb, es, 0))
sb->s_flags &= ~MS_RDONLY;
if (EXT4_HAS_INCOMPAT_FEATURE(sb,
EXT4_FEATURE_INCOMPAT_MMP))
if (ext4_multi_mount_protect(sb,
le64_to_cpu(es->s_mmp_block))) {
err = -EROFS;
goto restore_opts;
}
enable_quota = 1;
}
}
/*
* Reinitialize lazy itable initialization thread based on
* current settings
*/
if ((sb->s_flags & MS_RDONLY) || !test_opt(sb, INIT_INODE_TABLE))
ext4_unregister_li_request(sb);
else {
ext4_group_t first_not_zeroed;
first_not_zeroed = ext4_has_uninit_itable(sb);
ext4_register_li_request(sb, first_not_zeroed);
}
ext4_setup_system_zone(sb);
if (sbi->s_journal == NULL)
ext4_commit_super(sb, 1);
#ifdef CONFIG_QUOTA
/* Release old quota file names */
for (i = 0; i < MAXQUOTAS; i++)
if (old_opts.s_qf_names[i] &&
old_opts.s_qf_names[i] != sbi->s_qf_names[i])
kfree(old_opts.s_qf_names[i]);
#endif
unlock_super(sb);
if (enable_quota)
dquot_resume(sb, -1);
ext4_msg(sb, KERN_INFO, "re-mounted. Opts: %s", orig_data);
kfree(orig_data);
return 0;
restore_opts:
sb->s_flags = old_sb_flags;
sbi->s_mount_opt = old_opts.s_mount_opt;
sbi->s_mount_opt2 = old_opts.s_mount_opt2;
sbi->s_resuid = old_opts.s_resuid;
sbi->s_resgid = old_opts.s_resgid;
sbi->s_commit_interval = old_opts.s_commit_interval;
sbi->s_min_batch_time = old_opts.s_min_batch_time;
sbi->s_max_batch_time = old_opts.s_max_batch_time;
#ifdef CONFIG_QUOTA
sbi->s_jquota_fmt = old_opts.s_jquota_fmt;
for (i = 0; i < MAXQUOTAS; i++) {
if (sbi->s_qf_names[i] &&
old_opts.s_qf_names[i] != sbi->s_qf_names[i])
kfree(sbi->s_qf_names[i]);
sbi->s_qf_names[i] = old_opts.s_qf_names[i];
}
#endif
unlock_super(sb);
kfree(orig_data);
return err;
}
| 17,394 |
32,734 | 0 | static void tg3_rx_prodring_free(struct tg3 *tp,
struct tg3_rx_prodring_set *tpr)
{
int i;
if (tpr != &tp->napi[0].prodring) {
for (i = tpr->rx_std_cons_idx; i != tpr->rx_std_prod_idx;
i = (i + 1) & tp->rx_std_ring_mask)
tg3_rx_data_free(tp, &tpr->rx_std_buffers[i],
tp->rx_pkt_map_sz);
if (tg3_flag(tp, JUMBO_CAPABLE)) {
for (i = tpr->rx_jmb_cons_idx;
i != tpr->rx_jmb_prod_idx;
i = (i + 1) & tp->rx_jmb_ring_mask) {
tg3_rx_data_free(tp, &tpr->rx_jmb_buffers[i],
TG3_RX_JMB_MAP_SZ);
}
}
return;
}
for (i = 0; i <= tp->rx_std_ring_mask; i++)
tg3_rx_data_free(tp, &tpr->rx_std_buffers[i],
tp->rx_pkt_map_sz);
if (tg3_flag(tp, JUMBO_CAPABLE) && !tg3_flag(tp, 5780_CLASS)) {
for (i = 0; i <= tp->rx_jmb_ring_mask; i++)
tg3_rx_data_free(tp, &tpr->rx_jmb_buffers[i],
TG3_RX_JMB_MAP_SZ);
}
}
| 17,395 |
115,342 | 0 | static void didSameDocumentNavigationForFrame(WKPageRef page, WKFrameRef frame, WKSameDocumentNavigationType, WKTypeRef, const void* clientInfo)
{
if (!WKFrameIsMainFrame(frame))
return;
webkitWebViewUpdateURI(WEBKIT_WEB_VIEW(clientInfo));
}
| 17,396 |
89,664 | 0 | static u16 llcp_tlv_lto(u8 *tlv)
{
return llcp_tlv8(tlv, LLCP_TLV_LTO);
}
| 17,397 |
55,453 | 0 | SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
unsigned int, flags)
{
struct sched_attr attr;
struct task_struct *p;
int retval;
if (!uattr || pid < 0 || flags)
return -EINVAL;
retval = sched_copy_attr(uattr, &attr);
if (retval)
return retval;
if ((int)attr.sched_policy < 0)
return -EINVAL;
rcu_read_lock();
retval = -ESRCH;
p = find_process_by_pid(pid);
if (p != NULL)
retval = sched_setattr(p, &attr);
rcu_read_unlock();
return retval;
}
| 17,398 |
83,414 | 0 | ReturnError(HANDLE pipe, DWORD error, LPCWSTR func, DWORD count, LPHANDLE events)
{
DWORD result_len;
LPWSTR result = L"0xffffffff\nFormatMessage failed\nCould not return result";
DWORD_PTR args[] = {
(DWORD_PTR) error,
(DWORD_PTR) func,
(DWORD_PTR) ""
};
if (error != ERROR_OPENVPN_STARTUP)
{
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
|FORMAT_MESSAGE_ALLOCATE_BUFFER
|FORMAT_MESSAGE_IGNORE_INSERTS,
0, error, 0, (LPWSTR) &args[2], 0, NULL);
}
result_len = FormatMessageW(FORMAT_MESSAGE_FROM_STRING
|FORMAT_MESSAGE_ALLOCATE_BUFFER
|FORMAT_MESSAGE_ARGUMENT_ARRAY,
L"0x%1!08x!\n%2!s!\n%3!s!", 0, 0,
(LPWSTR) &result, 0, (va_list *) args);
WritePipeAsync(pipe, result, (DWORD)(wcslen(result) * 2), count, events);
#ifdef UNICODE
MsgToEventLog(MSG_FLAGS_ERROR, result);
#else
MsgToEventLog(MSG_FLAGS_ERROR, "%S", result);
#endif
if (error != ERROR_OPENVPN_STARTUP)
{
LocalFree((LPVOID) args[2]);
}
if (result_len)
{
LocalFree(result);
}
}
| 17,399 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.