idx
int64 | func
string | target
int64 |
|---|---|---|
345,108
|
PHP_FUNCTION(fnmatch)
{
char *pattern, *filename;
int pattern_len, filename_len;
long flags = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &pattern, &pattern_len, &filename, &filename_len, &flags) == FAILURE) {
return;
}
if (filename_len >= MAXPATHLEN) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename exceeds the maximum allowed length of %d characters", MAXPATHLEN);
RETURN_FALSE;
}
if (pattern_len >= MAXPATHLEN) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Pattern exceeds the maximum allowed length of %d characters", MAXPATHLEN);
RETURN_FALSE;
}
RETURN_BOOL( ! fnmatch( pattern, filename, flags ));
}
| 1
|
401,038
|
inline SegmentBuilder::SegmentBuilder(
BuilderArena* arena, SegmentId id, const word* ptr, SegmentWordCount size,
ReadLimiter* readLimiter)
: SegmentReader(arena, id, ptr, size, readLimiter),
// const_cast is safe here because the member won't ever be dereferenced because it appears
// to point to the end of the segment anyway.
pos(const_cast<word*>(ptr + size)), readOnly(true) {}
| 0
|
303,314
|
struct rtrs_clt_sess *rtrs_clt_open(struct rtrs_clt_ops *ops,
const char *pathname,
const struct rtrs_addr *paths,
size_t paths_num, u16 port,
size_t pdu_sz, u8 reconnect_delay_sec,
s16 max_reconnect_attempts, u32 nr_poll_queues)
{
struct rtrs_clt_path *clt_path, *tmp;
struct rtrs_clt_sess *clt;
int err, i;
if (strchr(pathname, '/') || strchr(pathname, '.')) {
pr_err("pathname cannot contain / and .\n");
err = -EINVAL;
goto out;
}
clt = alloc_clt(pathname, paths_num, port, pdu_sz, ops->priv,
ops->link_ev,
reconnect_delay_sec,
max_reconnect_attempts);
if (IS_ERR(clt)) {
err = PTR_ERR(clt);
goto out;
}
for (i = 0; i < paths_num; i++) {
struct rtrs_clt_path *clt_path;
clt_path = alloc_path(clt, &paths[i], nr_cpu_ids,
nr_poll_queues);
if (IS_ERR(clt_path)) {
err = PTR_ERR(clt_path);
goto close_all_path;
}
if (!i)
clt_path->for_new_clt = 1;
list_add_tail_rcu(&clt_path->s.entry, &clt->paths_list);
err = init_path(clt_path);
if (err) {
list_del_rcu(&clt_path->s.entry);
rtrs_clt_close_conns(clt_path, true);
free_percpu(clt_path->stats->pcpu_stats);
kfree(clt_path->stats);
free_path(clt_path);
goto close_all_path;
}
err = rtrs_clt_create_path_files(clt_path);
if (err) {
list_del_rcu(&clt_path->s.entry);
rtrs_clt_close_conns(clt_path, true);
free_percpu(clt_path->stats->pcpu_stats);
kfree(clt_path->stats);
free_path(clt_path);
goto close_all_path;
}
}
err = alloc_permits(clt);
if (err)
goto close_all_path;
return clt;
close_all_path:
list_for_each_entry_safe(clt_path, tmp, &clt->paths_list, s.entry) {
rtrs_clt_destroy_path_files(clt_path, NULL);
rtrs_clt_close_conns(clt_path, true);
kobject_put(&clt_path->kobj);
}
rtrs_clt_destroy_sysfs_root(clt);
free_clt(clt);
out:
return ERR_PTR(err);
}
| 0
|
438,897
|
cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
{
struct cfg80211_beacon_data *new_beacon;
u8 *pos;
int len;
len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
beacon->proberesp_ies_len + beacon->assocresp_ies_len +
beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len;
new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
if (!new_beacon)
return NULL;
pos = (u8 *)(new_beacon + 1);
if (beacon->head_len) {
new_beacon->head_len = beacon->head_len;
new_beacon->head = pos;
memcpy(pos, beacon->head, beacon->head_len);
pos += beacon->head_len;
}
if (beacon->tail_len) {
new_beacon->tail_len = beacon->tail_len;
new_beacon->tail = pos;
memcpy(pos, beacon->tail, beacon->tail_len);
pos += beacon->tail_len;
}
if (beacon->beacon_ies_len) {
new_beacon->beacon_ies_len = beacon->beacon_ies_len;
new_beacon->beacon_ies = pos;
memcpy(pos, beacon->beacon_ies, beacon->beacon_ies_len);
pos += beacon->beacon_ies_len;
}
if (beacon->proberesp_ies_len) {
new_beacon->proberesp_ies_len = beacon->proberesp_ies_len;
new_beacon->proberesp_ies = pos;
memcpy(pos, beacon->proberesp_ies, beacon->proberesp_ies_len);
pos += beacon->proberesp_ies_len;
}
if (beacon->assocresp_ies_len) {
new_beacon->assocresp_ies_len = beacon->assocresp_ies_len;
new_beacon->assocresp_ies = pos;
memcpy(pos, beacon->assocresp_ies, beacon->assocresp_ies_len);
pos += beacon->assocresp_ies_len;
}
if (beacon->probe_resp_len) {
new_beacon->probe_resp_len = beacon->probe_resp_len;
new_beacon->probe_resp = pos;
memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
pos += beacon->probe_resp_len;
}
/* might copy -1, meaning no changes requested */
new_beacon->ftm_responder = beacon->ftm_responder;
if (beacon->lci) {
new_beacon->lci_len = beacon->lci_len;
new_beacon->lci = pos;
memcpy(pos, beacon->lci, beacon->lci_len);
pos += beacon->lci_len;
}
if (beacon->civicloc) {
new_beacon->civicloc_len = beacon->civicloc_len;
new_beacon->civicloc = pos;
memcpy(pos, beacon->civicloc, beacon->civicloc_len);
pos += beacon->civicloc_len;
}
return new_beacon;
}
| 0
|
72,697
|
static int prepare_signal(int sig, struct task_struct *p, int from_ancestor_ns)
{
struct signal_struct *signal = p->signal;
struct task_struct *t;
if (unlikely(signal->flags & SIGNAL_GROUP_EXIT)) {
/*
* The process is in the middle of dying, nothing to do.
*/
} else if (sig_kernel_stop(sig)) {
/*
* This is a stop signal. Remove SIGCONT from all queues.
*/
rm_from_queue(sigmask(SIGCONT), &signal->shared_pending);
t = p;
do {
rm_from_queue(sigmask(SIGCONT), &t->pending);
} while_each_thread(p, t);
} else if (sig == SIGCONT) {
unsigned int why;
/*
* Remove all stop signals from all queues,
* and wake all threads.
*/
rm_from_queue(SIG_KERNEL_STOP_MASK, &signal->shared_pending);
t = p;
do {
unsigned int state;
rm_from_queue(SIG_KERNEL_STOP_MASK, &t->pending);
/*
* If there is a handler for SIGCONT, we must make
* sure that no thread returns to user mode before
* we post the signal, in case it was the only
* thread eligible to run the signal handler--then
* it must not do anything between resuming and
* running the handler. With the TIF_SIGPENDING
* flag set, the thread will pause and acquire the
* siglock that we hold now and until we've queued
* the pending signal.
*
* Wake up the stopped thread _after_ setting
* TIF_SIGPENDING
*/
state = __TASK_STOPPED;
if (sig_user_defined(t, SIGCONT) && !sigismember(&t->blocked, SIGCONT)) {
set_tsk_thread_flag(t, TIF_SIGPENDING);
state |= TASK_INTERRUPTIBLE;
}
wake_up_state(t, state);
} while_each_thread(p, t);
/*
* Notify the parent with CLD_CONTINUED if we were stopped.
*
* If we were in the middle of a group stop, we pretend it
* was already finished, and then continued. Since SIGCHLD
* doesn't queue we report only CLD_STOPPED, as if the next
* CLD_CONTINUED was dropped.
*/
why = 0;
if (signal->flags & SIGNAL_STOP_STOPPED)
why |= SIGNAL_CLD_CONTINUED;
else if (signal->group_stop_count)
why |= SIGNAL_CLD_STOPPED;
if (why) {
/*
* The first thread which returns from do_signal_stop()
* will take ->siglock, notice SIGNAL_CLD_MASK, and
* notify its parent. See get_signal_to_deliver().
*/
signal->flags = why | SIGNAL_STOP_CONTINUED;
signal->group_stop_count = 0;
signal->group_exit_code = 0;
} else {
/*
* We are not stopped, but there could be a stop
* signal in the middle of being processed after
* being removed from the queue. Clear that too.
*/
signal->flags &= ~SIGNAL_STOP_DEQUEUED;
}
}
return !sig_ignored(p, sig, from_ancestor_ns);
}
| 0
|
252,266
|
cc::ScrollTree& PropertyTreeManager::GetScrollTree() {
return property_trees_.scroll_tree;
}
| 0
|
270,192
|
static Jsi_RC jsi_csGetKey(Jsi_Interp *interp, CDataObj *cd, Jsi_Value *arg, void **kPtr, size_t ksize, int anum)
{
void *kBuf = *kPtr;
*kPtr = NULL;
if (!arg)
return Jsi_LogError("missing key arg");;
Jsi_Number nval = 0;
switch (cd->keyType) {
case JSI_KEYS_STRING:
case JSI_KEYS_STRINGKEY:
*kPtr = (void*)Jsi_ValueString(interp, arg, NULL);
if (!*kPtr)
return Jsi_LogError("arg %d: expected string key", anum);
break;
case JSI_KEYS_ONEWORD:
if (Jsi_ValueGetNumber(interp, arg, &nval) != JSI_OK)
return Jsi_LogError("arg %d: expected number key", anum);
*kPtr = (void*)(uintptr_t)nval;
break;
default: {
if (!cd->slKey) {
badkey:
return Jsi_LogError("arg %d: expected struct key", anum);
}
if (arg->vt == JSI_VT_OBJECT && arg->d.obj->ot == JSI_OT_OBJECT) {
if (cd->slKey->size>ksize || !kBuf)
goto badkey;
memset(kBuf, 0, cd->slKey->size);
if (Jsi_OptionsConf(interp, (Jsi_OptionSpec*)cd->keysf, kBuf, arg, NULL, 0) != JSI_OK)
return JSI_ERROR;
*kPtr = kBuf;
} else
return Jsi_LogError("arg %d: expected object key", anum);
}
}
return JSI_OK;
}
| 0
|
176,033
|
void impeg2d_bit_stream_init(stream_t *ps_stream,
UWORD8 *pu1_byte_buf,
UWORD32 u4_max_offset)
{
UWORD8 *pu1_byte_buff;
UWORD32 *pu4_word_buf;
size_t u4_byte_addr;
UWORD32 u4_temp1,u4_temp2;
/* Set parameters of the stream structure.Associate the structure with
the file */
ps_stream->pv_bs_buf = pu1_byte_buf;
ps_stream->u4_offset = 0;
/* Take care of unaligned address and create
nearest greater aligned address */
pu1_byte_buff = (UWORD8 *)pu1_byte_buf;
u4_byte_addr = (size_t)pu1_byte_buff;
if((u4_byte_addr & 3) == 1)
{
u4_temp1 = ((UWORD32)(*pu1_byte_buff++)) << 8;
u4_temp1 += ((UWORD32)(*pu1_byte_buff++)) << 16;
u4_temp1 += ((UWORD32)(*pu1_byte_buff++)) << 24;
pu4_word_buf = (UWORD32 *)pu1_byte_buff;
ps_stream->u4_offset = 8;
}
else if((u4_byte_addr & 3) == 2)
{
u4_temp1 = ((UWORD32)(*pu1_byte_buff++)) << 16;
u4_temp1 += ((UWORD32)(*pu1_byte_buff++)) << 24;
pu4_word_buf = (UWORD32 *)pu1_byte_buff;
ps_stream->u4_offset = 16;
}
else if((u4_byte_addr & 3) == 3)
{
u4_temp1 = (((UWORD32)(*pu1_byte_buff++)) << 24);
pu4_word_buf = (UWORD32 *)pu1_byte_buff;
ps_stream->u4_offset = 24;
}
else
{
pu4_word_buf = (UWORD32 *)pu1_byte_buff;
u4_temp1 = *pu4_word_buf++;
ps_stream->u4_offset = 0;
}
/* convert the endian ness from Little endian to Big endian so that bits
are in proper order from MSB to LSB */
CONV_LE_TO_BE(u4_temp2,u4_temp1)
/* Read One more word for buf nxt */
u4_temp1 = *pu4_word_buf++;
ps_stream->u4_buf = u4_temp2;
CONV_LE_TO_BE(u4_temp2,u4_temp1)
ps_stream->u4_buf_nxt = u4_temp2;
ps_stream->pu4_buf_aligned = pu4_word_buf;
ps_stream->u4_max_offset = (u4_max_offset << 3) + ps_stream->u4_offset;
return;
}
| 0
|
411,327
|
// Tell for each character of an expression if it is inside a string or not.
CImg<boolT> is_inside_string(CImg<charT>& expr) const {
bool is_escaped = false, next_is_escaped = false;
unsigned int mode = 0, next_mode = 0; // { 0=normal | 1=char-string | 2=vector-string
CImg<boolT> res = CImg<charT>::string(expr);
bool *pd = res._data;
for (const char *ps = expr._data; *ps; ++ps) {
if (!next_is_escaped && *ps=='\\') next_is_escaped = true;
if (!is_escaped && *ps=='\'') { // Non-escaped character
if (!mode && ps>expr._data && *(ps - 1)=='[') next_mode = mode = 2; // Start vector-string
else if (mode==2 && *(ps + 1)==']') next_mode = !mode; // End vector-string
else if (mode<2) next_mode = mode?(mode = 0):1; // Start/end char-string
}
*(pd++) = mode>=1 || is_escaped;
mode = next_mode;
is_escaped = next_is_escaped;
next_is_escaped = false;
}
return res;
| 0
|
382,502
|
FlushErrorState(void)
{
/*
* Reset stack to empty. The only case where it would be more than one
* deep is if we serviced an error that interrupted construction of
* another message. We assume control escaped out of that message
* construction and won't ever go back.
*/
errordata_stack_depth = -1;
recursion_depth = 0;
/* Delete all data in ErrorContext */
MemoryContextResetAndDeleteChildren(ErrorContext);
}
| 0
|
512,060
|
unbind_function_def (name)
const char *name;
{
BUCKET_CONTENTS *elt;
FUNCTION_DEF *funcdef;
elt = hash_remove (name, shell_function_defs, 0);
if (elt == 0)
return -1;
funcdef = (FUNCTION_DEF *)elt->data;
if (funcdef)
dispose_function_def (funcdef);
free (elt->key);
free (elt);
return 0;
}
| 0
|
53,518
|
xmlDumpNotationDecl(xmlBufferPtr buf, xmlNotationPtr nota) {
if ((buf == NULL) || (nota == NULL))
return;
xmlBufferWriteChar(buf, "<!NOTATION ");
xmlBufferWriteCHAR(buf, nota->name);
if (nota->PublicID != NULL) {
xmlBufferWriteChar(buf, " PUBLIC ");
xmlBufferWriteQuotedString(buf, nota->PublicID);
if (nota->SystemID != NULL) {
xmlBufferWriteChar(buf, " ");
xmlBufferWriteQuotedString(buf, nota->SystemID);
}
} else {
xmlBufferWriteChar(buf, " SYSTEM ");
xmlBufferWriteQuotedString(buf, nota->SystemID);
}
xmlBufferWriteChar(buf, " >\n");
}
| 0
|
203,975
|
static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIONet *n = VIRTIO_NET(vdev);
struct virtio_net_ctrl_hdr ctrl;
virtio_net_ctrl_ack status = VIRTIO_NET_ERR;
VirtQueueElement elem;
size_t s;
struct iovec *iov;
unsigned int iov_cnt;
while (virtqueue_pop(vq, &elem)) {
if (iov_size(elem.in_sg, elem.in_num) < sizeof(status) ||
iov_size(elem.out_sg, elem.out_num) < sizeof(ctrl)) {
error_report("virtio-net ctrl missing headers");
exit(1);
}
iov = elem.out_sg;
iov_cnt = elem.out_num;
s = iov_to_buf(iov, iov_cnt, 0, &ctrl, sizeof(ctrl));
iov_discard_front(&iov, &iov_cnt, sizeof(ctrl));
if (s != sizeof(ctrl)) {
status = VIRTIO_NET_ERR;
} else if (ctrl.class == VIRTIO_NET_CTRL_RX) {
status = virtio_net_handle_rx_mode(n, ctrl.cmd, iov, iov_cnt);
} else if (ctrl.class == VIRTIO_NET_CTRL_MAC) {
status = virtio_net_handle_mac(n, ctrl.cmd, iov, iov_cnt);
} else if (ctrl.class == VIRTIO_NET_CTRL_VLAN) {
status = virtio_net_handle_vlan_table(n, ctrl.cmd, iov, iov_cnt);
} else if (ctrl.class == VIRTIO_NET_CTRL_MQ) {
status = virtio_net_handle_mq(n, ctrl.cmd, iov, iov_cnt);
} else if (ctrl.class == VIRTIO_NET_CTRL_GUEST_OFFLOADS) {
status = virtio_net_handle_offloads(n, ctrl.cmd, iov, iov_cnt);
}
s = iov_from_buf(elem.in_sg, elem.in_num, 0, &status, sizeof(status));
assert(s == sizeof(status));
virtqueue_push(vq, &elem, sizeof(status));
virtio_notify(vdev, vq);
}
}
| 0
|
402,902
|
void t_cpp_generator::generate_service_skeleton(t_service* tservice) {
string svcname = tservice->get_name();
// Service implementation file includes
string f_skeleton_name = get_out_dir() + svcname + "_server.skeleton.cpp";
string ns = namespace_prefix(tservice->get_program()->get_namespace("cpp"));
ofstream f_skeleton;
f_skeleton.open(f_skeleton_name.c_str());
f_skeleton << "// This autogenerated skeleton file illustrates how to build a server." << endl
<< "// You should copy it to another filename to avoid overwriting it." << endl << endl
<< "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl
<< "#include <thrift/protocol/TBinaryProtocol.h>" << endl
<< "#include <thrift/server/TSimpleServer.h>" << endl
<< "#include <thrift/transport/TServerSocket.h>" << endl
<< "#include <thrift/transport/TBufferTransports.h>" << endl << endl
<< "using namespace ::apache::thrift;" << endl
<< "using namespace ::apache::thrift::protocol;" << endl
<< "using namespace ::apache::thrift::transport;" << endl
<< "using namespace ::apache::thrift::server;" << endl << endl
<< "using boost::shared_ptr;" << endl << endl;
// the following code would not compile:
// using namespace ;
// using namespace ::;
if ((!ns.empty()) && (ns.compare(" ::") != 0)) {
f_skeleton << "using namespace " << string(ns, 0, ns.size() - 2) << ";" << endl << endl;
}
f_skeleton << "class " << svcname << "Handler : virtual public " << svcname << "If {" << endl
<< " public:" << endl;
indent_up();
f_skeleton << indent() << svcname << "Handler() {" << endl << indent()
<< " // Your initialization goes here" << endl << indent() << "}" << endl << endl;
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
generate_java_doc(f_skeleton, *f_iter);
f_skeleton << indent() << function_signature(*f_iter, "") << " {" << endl << indent()
<< " // Your implementation goes here" << endl << indent() << " printf(\""
<< (*f_iter)->get_name() << "\\n\");" << endl << indent() << "}" << endl << endl;
}
indent_down();
f_skeleton << "};" << endl << endl;
f_skeleton << indent() << "int main(int argc, char **argv) {" << endl;
indent_up();
f_skeleton
<< indent() << "int port = 9090;" << endl << indent() << "shared_ptr<" << svcname
<< "Handler> handler(new " << svcname << "Handler());" << endl << indent()
<< "shared_ptr<TProcessor> processor(new " << svcname << "Processor(handler));" << endl
<< indent() << "shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));"
<< endl << indent()
<< "shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());" << endl
<< indent() << "shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());"
<< endl << endl << indent()
<< "TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory);"
<< endl << indent() << "server.serve();" << endl << indent() << "return 0;" << endl;
indent_down();
f_skeleton << "}" << endl << endl;
// Close the files
f_skeleton.close();
}
| 0
|
66,456
|
static int kvm_guest_time_update(struct kvm_vcpu *v)
{
unsigned long flags;
struct kvm_vcpu_arch *vcpu = &v->arch;
void *shared_kaddr;
unsigned long this_tsc_khz;
s64 kernel_ns, max_kernel_ns;
u64 tsc_timestamp;
/* Keep irq disabled to prevent changes to the clock */
local_irq_save(flags);
kvm_get_msr(v, MSR_IA32_TSC, &tsc_timestamp);
kernel_ns = get_kernel_ns();
this_tsc_khz = __get_cpu_var(cpu_tsc_khz);
if (unlikely(this_tsc_khz == 0)) {
local_irq_restore(flags);
kvm_make_request(KVM_REQ_CLOCK_UPDATE, v);
return 1;
}
/*
* We may have to catch up the TSC to match elapsed wall clock
* time for two reasons, even if kvmclock is used.
* 1) CPU could have been running below the maximum TSC rate
* 2) Broken TSC compensation resets the base at each VCPU
* entry to avoid unknown leaps of TSC even when running
* again on the same CPU. This may cause apparent elapsed
* time to disappear, and the guest to stand still or run
* very slowly.
*/
if (vcpu->tsc_catchup) {
u64 tsc = compute_guest_tsc(v, kernel_ns);
if (tsc > tsc_timestamp) {
kvm_x86_ops->adjust_tsc_offset(v, tsc - tsc_timestamp);
tsc_timestamp = tsc;
}
}
local_irq_restore(flags);
if (!vcpu->time_page)
return 0;
/*
* Time as measured by the TSC may go backwards when resetting the base
* tsc_timestamp. The reason for this is that the TSC resolution is
* higher than the resolution of the other clock scales. Thus, many
* possible measurments of the TSC correspond to one measurement of any
* other clock, and so a spread of values is possible. This is not a
* problem for the computation of the nanosecond clock; with TSC rates
* around 1GHZ, there can only be a few cycles which correspond to one
* nanosecond value, and any path through this code will inevitably
* take longer than that. However, with the kernel_ns value itself,
* the precision may be much lower, down to HZ granularity. If the
* first sampling of TSC against kernel_ns ends in the low part of the
* range, and the second in the high end of the range, we can get:
*
* (TSC - offset_low) * S + kns_old > (TSC - offset_high) * S + kns_new
*
* As the sampling errors potentially range in the thousands of cycles,
* it is possible such a time value has already been observed by the
* guest. To protect against this, we must compute the system time as
* observed by the guest and ensure the new system time is greater.
*/
max_kernel_ns = 0;
if (vcpu->hv_clock.tsc_timestamp && vcpu->last_guest_tsc) {
max_kernel_ns = vcpu->last_guest_tsc -
vcpu->hv_clock.tsc_timestamp;
max_kernel_ns = pvclock_scale_delta(max_kernel_ns,
vcpu->hv_clock.tsc_to_system_mul,
vcpu->hv_clock.tsc_shift);
max_kernel_ns += vcpu->last_kernel_ns;
}
if (unlikely(vcpu->hw_tsc_khz != this_tsc_khz)) {
kvm_get_time_scale(NSEC_PER_SEC / 1000, this_tsc_khz,
&vcpu->hv_clock.tsc_shift,
&vcpu->hv_clock.tsc_to_system_mul);
vcpu->hw_tsc_khz = this_tsc_khz;
}
if (max_kernel_ns > kernel_ns)
kernel_ns = max_kernel_ns;
/* With all the info we got, fill in the values */
vcpu->hv_clock.tsc_timestamp = tsc_timestamp;
vcpu->hv_clock.system_time = kernel_ns + v->kvm->arch.kvmclock_offset;
vcpu->last_kernel_ns = kernel_ns;
vcpu->last_guest_tsc = tsc_timestamp;
vcpu->hv_clock.flags = 0;
/*
* The interface expects us to write an even number signaling that the
* update is finished. Since the guest won't see the intermediate
* state, we just increase by 2 at the end.
*/
vcpu->hv_clock.version += 2;
shared_kaddr = kmap_atomic(vcpu->time_page, KM_USER0);
memcpy(shared_kaddr + vcpu->time_offset, &vcpu->hv_clock,
sizeof(vcpu->hv_clock));
kunmap_atomic(shared_kaddr, KM_USER0);
mark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT);
return 0;
}
| 0
|
249,408
|
bool WebPage::defersLoading() const
{
return d->m_page->defersLoading();
}
| 0
|
190,938
|
bool HasEnvironmentVariable(const std::string& variable_name) {
return HasEnvironmentVariable16(UTF8ToUTF16(variable_name));
}
| 0
|
220,923
|
cleanup (pam_handle_t *pamh UNUSED, void *data, int err UNUSED)
{
free (data);
}
| 0
|
232,730
|
bool ChromeNetworkDelegate::OnCanEnablePrivacyMode(
const GURL& url,
const GURL& first_party_for_cookies) const {
if (!cookie_settings_.get())
return false;
bool reading_cookie_allowed = cookie_settings_->IsReadingCookieAllowed(
url, first_party_for_cookies);
bool setting_cookie_allowed = cookie_settings_->IsSettingCookieAllowed(
url, first_party_for_cookies);
bool privacy_mode = !(reading_cookie_allowed && setting_cookie_allowed);
return privacy_mode;
}
| 0
|
112,259
|
Js::RegSlot ByteCodeGenerator::PrependLocalScopes(Js::RegSlot evalEnv, Js::RegSlot tempLoc, FuncInfo *funcInfo)
{
Scope *currScope = this->currentScope;
Scope *funcScope = funcInfo->GetCurrentChildScope() ? funcInfo->GetCurrentChildScope() : funcInfo->GetBodyScope();
if (currScope == funcScope)
{
return evalEnv;
}
bool acquireTempLoc = tempLoc == Js::Constants::NoRegister;
if (acquireTempLoc)
{
tempLoc = funcInfo->AcquireTmpRegister();
}
// The with/catch objects must be prepended to the environment we pass to eval() or to a func declared inside with,
// but the list must first be reversed so that innermost scopes appear first in the list.
while (currScope != funcScope)
{
Scope *innerScope;
for (innerScope = currScope; innerScope->GetEnclosingScope() != funcScope; innerScope = innerScope->GetEnclosingScope())
;
if (innerScope->GetMustInstantiate())
{
if (!innerScope->HasInnerScopeIndex())
{
if (evalEnv == funcInfo->GetEnvRegister() || evalEnv == funcInfo->frameDisplayRegister)
{
this->m_writer.Reg2(Js::OpCode::LdInnerFrameDisplayNoParent, tempLoc, innerScope->GetLocation());
}
else
{
this->m_writer.Reg3(Js::OpCode::LdInnerFrameDisplay, tempLoc, innerScope->GetLocation(), evalEnv);
}
}
else
{
if (evalEnv == funcInfo->GetEnvRegister() || evalEnv == funcInfo->frameDisplayRegister)
{
this->m_writer.Reg1Unsigned1(Js::OpCode::LdIndexedFrameDisplayNoParent, tempLoc, innerScope->GetInnerScopeIndex());
}
else
{
this->m_writer.Reg2Int1(Js::OpCode::LdIndexedFrameDisplay, tempLoc, evalEnv, innerScope->GetInnerScopeIndex());
}
}
evalEnv = tempLoc;
}
funcScope = innerScope;
}
if (acquireTempLoc)
{
funcInfo->ReleaseTmpRegister(tempLoc);
}
return evalEnv;
}
| 0
|
373,286
|
static struct socket_address *tls_socket_get_peer_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx)
{
struct tls_context *tls = talloc_get_type(sock->private_data, struct tls_context);
return socket_get_peer_addr(tls->socket, mem_ctx);
}
| 0
|
171,378
|
DOMWindow* LocalDOMWindow::open(ExecutionContext* executionContext,
LocalDOMWindow* current_window,
LocalDOMWindow* entered_window,
const String& url,
const AtomicString& target,
const String& features,
ExceptionState& exception_state) {
if (!BindingSecurity::ShouldAllowAccessTo(entered_window, this,
exception_state)) {
UseCounter::Count(executionContext, WebFeature::kWindowOpenRealmMismatch);
return nullptr;
}
DCHECK(!target.IsNull());
return open(url, target, features, current_window, entered_window,
exception_state);
}
| 0
|
8,854
|
__be32 ipv6_proxy_select_ident(struct net *net, struct sk_buff *skb)
{
static u32 ip6_proxy_idents_hashrnd __read_mostly;
struct in6_addr buf[2];
struct in6_addr *addrs;
u32 id;
addrs = skb_header_pointer(skb,
skb_network_offset(skb) +
offsetof(struct ipv6hdr, saddr),
sizeof(buf), buf);
if (!addrs)
return 0;
net_get_random_once(&ip6_proxy_idents_hashrnd,
sizeof(ip6_proxy_idents_hashrnd));
id = __ipv6_select_ident(net, ip6_proxy_idents_hashrnd,
&addrs[1], &addrs[0]);
return htonl(id);
}
| 1
|
503,754
|
static int DecodeIPV6RouteTest01 (void)
{
uint8_t raw_pkt1[] = {
0x60, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x2b, 0x40,
0x20, 0x01, 0xaa, 0xaa, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x20, 0x01, 0xaa, 0xaa, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xb2, 0xed, 0x00, 0x50, 0x1b, 0xc7, 0x6a, 0xdf,
0x00, 0x00, 0x00, 0x00, 0x50, 0x02, 0x20, 0x00,
0xfa, 0x87, 0x00, 0x00,
};
Packet *p1 = PacketGetFromAlloc();
FAIL_IF(unlikely(p1 == NULL));
ThreadVars tv;
DecodeThreadVars dtv;
PacketQueue pq;
FlowInitConfig(FLOW_QUIET);
memset(&pq, 0, sizeof(PacketQueue));
memset(&tv, 0, sizeof(ThreadVars));
memset(&dtv, 0, sizeof(DecodeThreadVars));
PacketCopyData(p1, raw_pkt1, sizeof(raw_pkt1));
DecodeIPV6(&tv, &dtv, p1, GET_PKT_DATA(p1), GET_PKT_LEN(p1), &pq);
FAIL_IF (!(IPV6_EXTHDR_ISSET_RH(p1)));
FAIL_IF (p1->ip6eh.rh_type != 0);
PACKET_RECYCLE(p1);
SCFree(p1);
FlowShutdown();
PASS;
}
| 0
|
89,836
|
static Variant HHVM_METHOD(SimpleXMLElement, __unset, const Variant& name) {
auto data = Native::data<SimpleXMLElement>(this_);
sxe_prop_dim_delete(data, name, true, false);
return init_null();
}
| 0
|
465,189
|
int kvm_vcpu_map(struct kvm_vcpu *vcpu, gfn_t gfn, struct kvm_host_map *map)
{
return __kvm_map_gfn(kvm_vcpu_memslots(vcpu), gfn, map,
NULL, false);
}
| 0
|
145,941
|
void uwsgi_set_cpu_affinity() {
char buf[4096];
int ret;
int pos = 0;
if (uwsgi.cpu_affinity) {
int base_cpu = (uwsgi.mywid - 1) * uwsgi.cpu_affinity;
if (base_cpu >= uwsgi.cpus) {
base_cpu = base_cpu % uwsgi.cpus;
}
ret = snprintf(buf, 4096, "mapping worker %d to CPUs:", uwsgi.mywid);
if (ret < 25 || ret >= 4096) {
uwsgi_log("unable to initialize cpu affinity !!!\n");
exit(1);
}
pos += ret;
#if defined(__linux__) || defined(__GNU_kFreeBSD__)
cpu_set_t cpuset;
#elif defined(__FreeBSD__)
cpuset_t cpuset;
#endif
#if defined(__linux__) || defined(__FreeBSD__) || defined(__GNU_kFreeBSD__)
CPU_ZERO(&cpuset);
int i;
for (i = 0; i < uwsgi.cpu_affinity; i++) {
if (base_cpu >= uwsgi.cpus)
base_cpu = 0;
CPU_SET(base_cpu, &cpuset);
ret = snprintf(buf + pos, 4096 - pos, " %d", base_cpu);
if (ret < 2 || ret >= 4096) {
uwsgi_log("unable to initialize cpu affinity !!!\n");
exit(1);
}
pos += ret;
base_cpu++;
}
#endif
#if defined(__linux__) || defined(__GNU_kFreeBSD__)
if (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset)) {
uwsgi_error("sched_setaffinity()");
}
#elif defined(__FreeBSD__)
if (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(cpuset), &cpuset)) {
uwsgi_error("cpuset_setaffinity");
}
#endif
uwsgi_log("%s\n", buf);
}
}
| 0
|
283,829
|
void AutocompleteResult::CopyFrom(const AutocompleteResult& rhs) {
if (this == &rhs)
return;
matches_ = rhs.matches_;
default_match_ = (rhs.default_match_ == rhs.end()) ?
end() : (begin() + (rhs.default_match_ - rhs.begin()));
alternate_nav_url_ = rhs.alternate_nav_url_;
}
| 0
|
384,930
|
static PHP_FUNCTION(xmlwriter_end_dtd)
{
php_xmlwriter_end(INTERNAL_FUNCTION_PARAM_PASSTHRU, xmlTextWriterEndDTD);
}
| 0
|
474,260
|
int crypt_resume_by_keyfile_offset(struct crypt_device *cd,
const char *name,
int keyslot,
const char *keyfile,
size_t keyfile_size,
size_t keyfile_offset)
{
return crypt_resume_by_keyfile_device_offset(cd, name, keyslot,
keyfile, keyfile_size, keyfile_offset);
}
| 0
|
363,273
|
pango_ot_info_list_scripts (PangoOTInfo *info,
PangoOTTableType table_type)
{
hb_ot_layout_table_type_t tt = get_hb_table_type (table_type);
PangoOTTag *result;
unsigned int count, i;
count = hb_ot_layout_table_get_script_count (info->layout, tt);
result = g_new (PangoOTTag, count + 1);
for (i = 0; i < count; i++)
result[i] = hb_ot_layout_table_get_script_tag (info->layout, tt, i);
result[i] = 0;
return result;
}
| 0
|
118,211
|
static void test_map_wrapping(void)
{
uc_engine *uc;
OK(uc_open(UC_ARCH_X86, UC_MODE_64, &uc));
uc_assert_err(UC_ERR_ARG, uc_mem_map(uc, (~0ll - 0x4000) & ~0xfff, 0x8000,
UC_PROT_ALL));
OK(uc_close(uc));
}
| 0
|
515,880
|
get_number(NCURSES_CONST char *cap, const char *env)
{
int result = tgetnum(cap);
char *value = env ? getenv(env) : 0;
if (value != 0 && *value != 0) {
char *next = 0;
long check = strtol(value, &next, 10);
if (check > 0 && *next == '\0')
result = (int) check;
}
return result;
}
| 0
|
61,623
|
flatpak_dir_new (GFile *path, gboolean user)
{
/* We are only interested on extra data for system-wide installations, in which
case we use _new_full() directly, so here we just call it passing NULL */
return flatpak_dir_new_full (path, user, NULL);
}
| 0
|
321,502
|
void av_parser_close(AVCodecParserContext *s)
{
if(s){
if (s->parser->parser_close) {
ff_lock_avcodec(NULL);
s->parser->parser_close(s);
ff_unlock_avcodec();
}
av_free(s->priv_data);
av_free(s);
}
}
| 1
|
243,755
|
normalizePublicId(XML_Char *publicId)
{
XML_Char *p = publicId;
XML_Char *s;
for (s = publicId; *s; s++) {
switch (*s) {
case 0x20:
case 0xD:
case 0xA:
if (p != publicId && p[-1] != 0x20)
*p++ = 0x20;
break;
default:
*p++ = *s;
}
}
if (p != publicId && p[-1] == 0x20)
--p;
*p = XML_T('\0');
}
| 0
|
95,687
|
static double mp_complex_pow_vs(_cimg_math_parser& mp) {
const double *ptr1 = &_mp_arg(2) + 1, val2 = _mp_arg(3);
double *ptrd = &_mp_arg(1) + 1;
_mp_complex_pow(ptr1[0],ptr1[1],val2,0,ptrd);
return cimg::type<double>::nan();
| 0
|
443,003
|
static bool svm_rdtscp_supported(void)
{
return boot_cpu_has(X86_FEATURE_RDTSCP);
}
| 0
|
177,152
|
ExtensionFunction::ResponseAction InputImeSendKeyEventsFunction::Run() {
InputImeEventRouter* event_router =
GetInputImeEventRouter(Profile::FromBrowserContext(browser_context()));
InputMethodEngineBase* engine =
event_router ? event_router->GetActiveEngine(extension_id()) : nullptr;
if (!engine)
return RespondNow(Error(kInputImeApiErrorEngineNotAvailable));
std::unique_ptr<SendKeyEvents::Params> parent_params(
SendKeyEvents::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(parent_params);
const SendKeyEvents::Params::Parameters& params = parent_params->parameters;
std::vector<InputMethodEngineBase::KeyboardEvent> key_data_out;
for (const auto& key_event : params.key_data) {
key_data_out.push_back(InputMethodEngineBase::KeyboardEvent());
InputMethodEngineBase::KeyboardEvent& event = key_data_out.back();
event.type = input_ime::ToString(key_event.type);
event.key = key_event.key;
event.code = key_event.code;
event.key_code = key_event.key_code.get() ? *(key_event.key_code) : 0;
event.alt_key = key_event.alt_key ? *(key_event.alt_key) : false;
event.ctrl_key = key_event.ctrl_key ? *(key_event.ctrl_key) : false;
event.shift_key = key_event.shift_key ? *(key_event.shift_key) : false;
event.caps_lock = key_event.caps_lock ? *(key_event.caps_lock) : false;
}
if (!engine->SendKeyEvents(params.context_id, key_data_out))
return RespondNow(Error(kInputImeApiErrorSetKeyEventsFail));
return RespondNow(NoArguments());
}
| 0
|
512,157
|
read_bytes (GstRTSPConnection * conn, guint8 * buffer, guint * idx, guint size,
gboolean block)
{
guint left;
gint r;
GError *err = NULL;
if (G_UNLIKELY (*idx > size))
return GST_RTSP_ERROR;
left = size - *idx;
while (left) {
r = fill_bytes (conn, &buffer[*idx], left, block, &err);
if (G_UNLIKELY (r <= 0))
goto error;
left -= r;
*idx += r;
}
return GST_RTSP_OK;
/* ERRORS */
error:
{
if (G_UNLIKELY (r == 0))
return GST_RTSP_EEOF;
GST_DEBUG ("%s", err->message);
if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
g_clear_error (&err);
return GST_RTSP_EINTR;
} else if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
g_clear_error (&err);
return GST_RTSP_EINTR;
} else if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_TIMED_OUT)) {
g_clear_error (&err);
return GST_RTSP_ETIMEOUT;
}
g_clear_error (&err);
return GST_RTSP_ESYS;
}
}
| 0
|
125,436
|
static void dce80_transform_destroy(struct transform **xfm)
{
kfree(TO_DCE_TRANSFORM(*xfm));
*xfm = NULL;
}
| 0
|
161,020
|
static MonoMethodSignature*
method_builder_to_signature (MonoImage *image, MonoReflectionMethodBuilder *method) {
MonoMethodSignature *sig;
sig = parameters_to_signature (image, method->parameters);
sig->hasthis = method->attrs & METHOD_ATTRIBUTE_STATIC? 0: 1;
sig->ret = method->rtype? mono_reflection_type_get_handle ((MonoReflectionType*)method->rtype): &mono_defaults.void_class->byval_arg;
sig->generic_param_count = method->generic_params ? mono_array_length (method->generic_params) : 0;
return sig;
| 0
|
91,572
|
static inline int __sctp_sstate(const struct sock *sk, sctp_sock_state_t state)
{
return sk->sk_state == state;
}
| 0
|
158,181
|
unparse_filesystem_flags (const char *path,
FlatpakFilesystemMode mode)
{
g_autoptr(GString) s = g_string_new ("");
const char *p;
for (p = path; *p != 0; p++)
{
if (*p == ':')
g_string_append (s, "\\:");
else if (*p == '\\')
g_string_append (s, "\\\\");
else
g_string_append_c (s, *p);
}
switch (mode)
{
case FLATPAK_FILESYSTEM_MODE_READ_ONLY:
g_string_append (s, ":ro");
break;
case FLATPAK_FILESYSTEM_MODE_CREATE:
g_string_append (s, ":create");
break;
case FLATPAK_FILESYSTEM_MODE_READ_WRITE:
break;
case FLATPAK_FILESYSTEM_MODE_NONE:
g_string_insert_c (s, 0, '!');
break;
default:
g_warning ("Unexpected filesystem mode %d", mode);
break;
}
return g_string_free (g_steal_pointer (&s), FALSE);
}
| 0
|
275,416
|
ssize_t ewk_frame_source_get(const Evas_Object* ewkFrame, char** frameSource)
{
EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData, -1);
EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame, -1);
EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame->document(), -1);
EINA_SAFETY_ON_NULL_RETURN_VAL(frameSource, -1);
WTF::String source;
*frameSource = 0; // Saves 0 to pointer until it's not allocated.
if (!smartData->frame->document()->isHTMLDocument()) {
WRN("Only HTML documents are supported");
return -1;
}
WebCore::Node* documentNode = smartData->frame->document()->documentElement();
if (documentNode)
for (WebCore::Node* node = documentNode->firstChild(); node; node = node->parentElement()) {
if (node->hasTagName(WebCore::HTMLNames::htmlTag)) {
WebCore::HTMLElement* element = static_cast<WebCore::HTMLElement*>(node);
if (element)
source = element->outerHTML();
break;
}
}
if (source.isEmpty()) {
if (smartData->frame->document()->head())
source = smartData->frame->document()->head()->outerHTML();
if (smartData->frame->document()->body())
source += smartData->frame->document()->body()->outerHTML();
}
size_t sourceLength = strlen(source.utf8().data());
*frameSource = static_cast<char*>(malloc(sourceLength + 1));
if (!*frameSource) {
CRITICAL("Could not allocate memory.");
return -1;
}
strncpy(*frameSource, source.utf8().data(), sourceLength);
(*frameSource)[sourceLength] = '\0';
return sourceLength;
}
| 0
|
99,115
|
rdp_disconnect(void)
{
logger(Protocol, Debug, "%s()", __func__);
sec_disconnect();
}
| 0
|
411,306
|
//! Compute the absolute value of each pixel value \newinstance.
CImg<Tfloat> get_abs() const {
return CImg<Tfloat>(*this,false).abs();
| 0
|
334,069
|
struct omap_sdrc_s *omap_sdrc_init(MemoryRegion *sysmem,
hwaddr base)
{
struct omap_sdrc_s *s = (struct omap_sdrc_s *)
g_malloc0(sizeof(struct omap_sdrc_s));
omap_sdrc_reset(s);
memory_region_init_io(&s->iomem, NULL, &omap_sdrc_ops, s, "omap.sdrc", 0x1000);
memory_region_add_subregion(sysmem, base, &s->iomem);
return s;
}
| 1
|
331,060
|
static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
{
GXFContext *gxf = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st = s->streams[pkt->stream_index];
int64_t pos = avio_tell(pb);
int padding = 0;
int packet_start_offset = avio_tell(pb) / 1024;
gxf_write_packet_header(pb, PKT_MEDIA);
if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO && pkt->size % 4) /* MPEG-2 frames must be padded */
padding = 4 - pkt->size % 4;
else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
padding = GXF_AUDIO_PACKET_SIZE - pkt->size;
gxf_write_media_preamble(s, pkt, pkt->size + padding);
avio_write(pb, pkt->data, pkt->size);
gxf_write_padding(pb, padding);
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (!(gxf->flt_entries_nb % 500)) {
int err;
if ((err = av_reallocp_array(&gxf->flt_entries,
gxf->flt_entries_nb + 500,
sizeof(*gxf->flt_entries))) < 0) {
gxf->flt_entries_nb = 0;
av_log(s, AV_LOG_ERROR, "could not reallocate flt entries\n");
return err;
}
}
gxf->flt_entries[gxf->flt_entries_nb++] = packet_start_offset;
gxf->nb_fields += 2; // count fields
}
updatePacketSize(pb, pos);
gxf->packet_count++;
if (gxf->packet_count == 100) {
gxf_write_map_packet(s, 0);
gxf->packet_count = 0;
}
return 0;
}
| 0
|
264,509
|
PJ_DEF(pj_status_t) pj_stun_msg_create_response(pj_pool_t *pool,
const pj_stun_msg *req_msg,
unsigned err_code,
const pj_str_t *err_msg,
pj_stun_msg **p_response)
{
unsigned msg_type = req_msg->hdr.type;
pj_stun_msg *response = NULL;
pj_status_t status;
PJ_ASSERT_RETURN(pool && p_response, PJ_EINVAL);
PJ_ASSERT_RETURN(PJ_STUN_IS_REQUEST(msg_type),
PJNATH_EINSTUNMSGTYPE);
/* Create response or error response */
if (err_code)
msg_type |= PJ_STUN_ERROR_RESPONSE_BIT;
else
msg_type |= PJ_STUN_SUCCESS_RESPONSE_BIT;
status = pj_stun_msg_create(pool, msg_type, req_msg->hdr.magic,
req_msg->hdr.tsx_id, &response);
if (status != PJ_SUCCESS) {
return status;
}
/* Add error code attribute */
if (err_code) {
status = pj_stun_msg_add_errcode_attr(pool, response,
err_code, err_msg);
if (status != PJ_SUCCESS) {
return status;
}
}
*p_response = response;
return PJ_SUCCESS;
}
| 0
|
420,758
|
http_session_new (http_session_t *r_session,
const char *intended_hostname, unsigned int flags,
http_verify_cb_t verify_cb, void *verify_cb_value)
{
gpg_error_t err;
http_session_t sess;
*r_session = NULL;
sess = xtrycalloc (1, sizeof *sess);
if (!sess)
return gpg_error_from_syserror ();
sess->magic = HTTP_SESSION_MAGIC;
sess->refcount = 1;
sess->flags = flags;
sess->verify_cb = verify_cb;
sess->verify_cb_value = verify_cb_value;
sess->connect_timeout = 0;
#if HTTP_USE_NTBTLS
{
(void)intended_hostname; /* Not needed because we do not preload
* certificates. */
err = ntbtls_new (&sess->tls_session, NTBTLS_CLIENT);
if (err)
{
log_error ("ntbtls_new failed: %s\n", gpg_strerror (err));
goto leave;
}
}
#elif HTTP_USE_GNUTLS
{
const char *errpos;
int rc;
strlist_t sl;
int add_system_cas = !!(flags & HTTP_FLAG_TRUST_SYS);
int is_hkps_pool;
rc = gnutls_certificate_allocate_credentials (&sess->certcred);
if (rc < 0)
{
log_error ("gnutls_certificate_allocate_credentials failed: %s\n",
gnutls_strerror (rc));
err = gpg_error (GPG_ERR_GENERAL);
goto leave;
}
is_hkps_pool = (intended_hostname
&& !ascii_strcasecmp (intended_hostname,
get_default_keyserver (1)));
/* If the user has not specified a CA list, and they are looking
* for the hkps pool from sks-keyservers.net, then default to
* Kristian's certificate authority: */
if (!tls_ca_certlist && is_hkps_pool)
{
char *pemname = make_filename_try (gnupg_datadir (),
"sks-keyservers.netCA.pem", NULL);
if (!pemname)
{
err = gpg_error_from_syserror ();
log_error ("setting CA from file '%s' failed: %s\n",
pemname, gpg_strerror (err));
}
else
{
rc = gnutls_certificate_set_x509_trust_file
(sess->certcred, pemname, GNUTLS_X509_FMT_PEM);
if (rc < 0)
log_info ("setting CA from file '%s' failed: %s\n",
pemname, gnutls_strerror (rc));
xfree (pemname);
}
}
/* Add configured certificates to the session. */
if ((flags & HTTP_FLAG_TRUST_DEF))
{
for (sl = tls_ca_certlist; sl; sl = sl->next)
{
rc = gnutls_certificate_set_x509_trust_file
(sess->certcred, sl->d,
(sl->flags & 1)? GNUTLS_X509_FMT_PEM : GNUTLS_X509_FMT_DER);
if (rc < 0)
log_info ("setting CA from file '%s' failed: %s\n",
sl->d, gnutls_strerror (rc));
}
if (!tls_ca_certlist && !is_hkps_pool)
add_system_cas = 1;
}
/* Add system certificates to the session. */
if (add_system_cas)
{
#if GNUTLS_VERSION_NUMBER >= 0x030014
static int shown;
rc = gnutls_certificate_set_x509_system_trust (sess->certcred);
if (rc < 0)
log_info ("setting system CAs failed: %s\n", gnutls_strerror (rc));
else if (!shown)
{
shown = 1;
log_info ("number of system provided CAs: %d\n", rc);
}
#endif /* gnutls >= 3.0.20 */
}
/* Add other configured certificates to the session. */
if ((flags & HTTP_FLAG_TRUST_CFG))
{
for (sl = cfg_ca_certlist; sl; sl = sl->next)
{
rc = gnutls_certificate_set_x509_trust_file
(sess->certcred, sl->d,
(sl->flags & 1)? GNUTLS_X509_FMT_PEM : GNUTLS_X509_FMT_DER);
if (rc < 0)
log_info ("setting extra CA from file '%s' failed: %s\n",
sl->d, gnutls_strerror (rc));
}
}
rc = gnutls_init (&sess->tls_session, GNUTLS_CLIENT);
if (rc < 0)
{
log_error ("gnutls_init failed: %s\n", gnutls_strerror (rc));
err = gpg_error (GPG_ERR_GENERAL);
goto leave;
}
/* A new session has the transport ptr set to (void*(-1), we need
it to be NULL. */
gnutls_transport_set_ptr (sess->tls_session, NULL);
rc = gnutls_priority_set_direct (sess->tls_session,
"NORMAL",
&errpos);
if (rc < 0)
{
log_error ("gnutls_priority_set_direct failed at '%s': %s\n",
errpos, gnutls_strerror (rc));
err = gpg_error (GPG_ERR_GENERAL);
goto leave;
}
rc = gnutls_credentials_set (sess->tls_session,
GNUTLS_CRD_CERTIFICATE, sess->certcred);
if (rc < 0)
{
log_error ("gnutls_credentials_set failed: %s\n", gnutls_strerror (rc));
err = gpg_error (GPG_ERR_GENERAL);
goto leave;
}
}
#else /*!HTTP_USE_GNUTLS && !HTTP_USE_NTBTLS*/
{
(void)intended_hostname;
(void)flags;
}
#endif /*!HTTP_USE_GNUTLS && !HTTP_USE_NTBTLS*/
if (opt_debug > 1)
log_debug ("http.c:session_new: sess %p created\n", sess);
err = 0;
#if USE_TLS
leave:
#endif /*USE_TLS*/
if (err)
http_session_unref (sess);
else
*r_session = sess;
return err;
}
| 0
|
59,648
|
void test_nghttp2_session_stream_attach_item(void) {
nghttp2_session *session;
nghttp2_session_callbacks callbacks;
nghttp2_stream *a, *b, *c, *d, *e;
nghttp2_outbound_item *da, *db, *dc, *dd;
nghttp2_mem *mem;
mem = nghttp2_mem_default();
memset(&callbacks, 0, sizeof(callbacks));
nghttp2_session_server_new(&session, &callbacks, NULL);
a = open_stream(session, 1);
b = open_stream_with_dep(session, 3, a);
c = open_stream_with_dep(session, 5, a);
d = open_stream_with_dep(session, 7, c);
/* a
* |
* c--b
* |
* d
*/
db = create_data_ob_item(mem);
nghttp2_stream_attach_item(b, db);
CU_ASSERT(a->queued);
CU_ASSERT(b->queued);
CU_ASSERT(!c->queued);
CU_ASSERT(!d->queued);
CU_ASSERT(1 == nghttp2_pq_size(&a->obq));
/* Attach item to c */
dc = create_data_ob_item(mem);
nghttp2_stream_attach_item(c, dc);
CU_ASSERT(a->queued);
CU_ASSERT(b->queued);
CU_ASSERT(c->queued);
CU_ASSERT(!d->queued);
CU_ASSERT(2 == nghttp2_pq_size(&a->obq));
/* Attach item to a */
da = create_data_ob_item(mem);
nghttp2_stream_attach_item(a, da);
CU_ASSERT(a->queued);
CU_ASSERT(b->queued);
CU_ASSERT(c->queued);
CU_ASSERT(!d->queued);
CU_ASSERT(2 == nghttp2_pq_size(&a->obq));
/* Detach item from a */
nghttp2_stream_detach_item(a);
CU_ASSERT(a->queued);
CU_ASSERT(b->queued);
CU_ASSERT(c->queued);
CU_ASSERT(!d->queued);
CU_ASSERT(2 == nghttp2_pq_size(&a->obq));
/* Attach item to d */
dd = create_data_ob_item(mem);
nghttp2_stream_attach_item(d, dd);
CU_ASSERT(a->queued);
CU_ASSERT(b->queued);
CU_ASSERT(c->queued);
CU_ASSERT(d->queued);
CU_ASSERT(2 == nghttp2_pq_size(&a->obq));
CU_ASSERT(1 == nghttp2_pq_size(&c->obq));
/* Detach item from c */
nghttp2_stream_detach_item(c);
CU_ASSERT(a->queued);
CU_ASSERT(b->queued);
CU_ASSERT(c->queued);
CU_ASSERT(d->queued);
CU_ASSERT(2 == nghttp2_pq_size(&a->obq));
CU_ASSERT(1 == nghttp2_pq_size(&c->obq));
/* Detach item from b */
nghttp2_stream_detach_item(b);
CU_ASSERT(a->queued);
CU_ASSERT(!b->queued);
CU_ASSERT(c->queued);
CU_ASSERT(d->queued);
CU_ASSERT(1 == nghttp2_pq_size(&a->obq));
/* exercises insertion */
e = open_stream_with_dep_excl(session, 9, a);
/* a
* |
* e
* |
* c--b
* |
* d
*/
CU_ASSERT(a->queued);
CU_ASSERT(e->queued);
CU_ASSERT(!b->queued);
CU_ASSERT(c->queued);
CU_ASSERT(d->queued);
CU_ASSERT(1 == nghttp2_pq_size(&a->obq));
CU_ASSERT(1 == nghttp2_pq_size(&e->obq));
CU_ASSERT(nghttp2_pq_empty(&b->obq));
CU_ASSERT(1 == nghttp2_pq_size(&c->obq));
CU_ASSERT(nghttp2_pq_empty(&d->obq));
/* exercises deletion */
nghttp2_stream_dep_remove(e);
/* a
* |
* c--b
* |
* d
*/
CU_ASSERT(a->queued);
CU_ASSERT(!b->queued);
CU_ASSERT(c->queued);
CU_ASSERT(d->queued);
CU_ASSERT(1 == nghttp2_pq_size(&a->obq));
CU_ASSERT(nghttp2_pq_empty(&b->obq));
CU_ASSERT(1 == nghttp2_pq_size(&c->obq));
CU_ASSERT(nghttp2_pq_empty(&d->obq));
/* e's weight 16 is distributed equally among c and b, both now have
weight 8 each. */
CU_ASSERT(8 == b->weight);
CU_ASSERT(8 == c->weight);
/* da, db, dc have been detached */
nghttp2_outbound_item_free(da, mem);
nghttp2_outbound_item_free(db, mem);
nghttp2_outbound_item_free(dc, mem);
free(da);
free(db);
free(dc);
nghttp2_session_del(session);
nghttp2_session_server_new(&session, &callbacks, NULL);
a = open_stream(session, 1);
b = open_stream_with_dep(session, 3, a);
c = open_stream_with_dep(session, 5, a);
d = open_stream_with_dep(session, 7, c);
/* a
* |
* c--b
* |
* d
*/
da = create_data_ob_item(mem);
db = create_data_ob_item(mem);
dc = create_data_ob_item(mem);
nghttp2_stream_attach_item(a, da);
nghttp2_stream_attach_item(b, db);
nghttp2_stream_attach_item(c, dc);
CU_ASSERT(a->queued);
CU_ASSERT(b->queued);
CU_ASSERT(c->queued);
CU_ASSERT(!d->queued);
CU_ASSERT(2 == nghttp2_pq_size(&a->obq));
CU_ASSERT(nghttp2_pq_empty(&b->obq));
CU_ASSERT(nghttp2_pq_empty(&c->obq));
CU_ASSERT(nghttp2_pq_empty(&d->obq));
/* Detach item from a */
nghttp2_stream_detach_item(a);
CU_ASSERT(a->queued);
CU_ASSERT(b->queued);
CU_ASSERT(c->queued);
CU_ASSERT(!d->queued);
CU_ASSERT(2 == nghttp2_pq_size(&a->obq));
CU_ASSERT(nghttp2_pq_empty(&b->obq));
CU_ASSERT(nghttp2_pq_empty(&c->obq));
CU_ASSERT(nghttp2_pq_empty(&d->obq));
/* da has been detached */
nghttp2_outbound_item_free(da, mem);
free(da);
nghttp2_session_del(session);
}
| 0
|
245,408
|
ImageResourceInfoImpl(ImageResource* resource) : resource_(resource) {
DCHECK(resource_);
}
| 0
|
168,290
|
void FillMiscNavigationParams(const CommonNavigationParams& common_params,
const CommitNavigationParams& commit_params,
blink::WebNavigationParams* navigation_params) {
navigation_params->navigation_timings = BuildNavigationTimings(
common_params.navigation_start, commit_params.navigation_timing,
common_params.input_start);
navigation_params->is_user_activated =
commit_params.was_activated == WasActivatedOption::kYes;
if (commit_params.origin_to_commit) {
navigation_params->origin_to_commit =
commit_params.origin_to_commit.value();
}
}
| 0
|
299,263
|
void b43_dma_rx(struct b43_dmaring *ring)
{
const struct b43_dma_ops *ops = ring->ops;
int slot, current_slot;
int used_slots = 0;
B43_WARN_ON(ring->tx);
current_slot = ops->get_current_rxslot(ring);
B43_WARN_ON(!(current_slot >= 0 && current_slot < ring->nr_slots));
slot = ring->current_slot;
for (; slot != current_slot; slot = next_slot(ring, slot)) {
dma_rx(ring, &slot);
update_max_used_slots(ring, ++used_slots);
}
ops->set_current_rxslot(ring, slot);
ring->current_slot = slot;
}
| 0
|
94,694
|
PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
pjsip_transport_type_e type,
const pj_sockaddr_t *remote,
int addr_len,
const pjsip_tpselector *sel,
pjsip_tx_data *tdata,
pjsip_transport **tp)
{
pjsip_tpfactory *factory;
pj_status_t status;
TRACE_((THIS_FILE,"Acquiring transport type=%s, sel=%s remote=%s:%d",
pjsip_transport_get_type_name(type),
print_tpsel_info(sel),
addr_string(remote),
pj_sockaddr_get_port(remote)));
pj_lock_acquire(mgr->lock);
/* If transport is specified, then just use it if it is suitable
* for the destination.
*/
if (sel && sel->type == PJSIP_TPSELECTOR_TRANSPORT &&
sel->u.transport)
{
pjsip_transport *seltp = sel->u.transport;
/* See if the transport is (not) suitable */
if (seltp->key.type != type) {
pj_lock_release(mgr->lock);
TRACE_((THIS_FILE, "Transport type in tpsel not matched"));
return PJSIP_ETPNOTSUITABLE;
}
/* Make sure the transport is not being destroyed */
if (seltp->is_destroying) {
pj_lock_release(mgr->lock);
TRACE_((THIS_FILE,"Transport to be acquired is being destroyed"));
return PJ_ENOTFOUND;
}
/* We could also verify that the destination address is reachable
* from this transport (i.e. both are equal), but if application
* has requested a specific transport to be used, assume that
* it knows what to do.
*
* In other words, I don't think destination verification is a good
* idea for now.
*/
/* Transport looks to be suitable to use, so just use it. */
pjsip_transport_add_ref(seltp);
pj_lock_release(mgr->lock);
*tp = seltp;
TRACE_((THIS_FILE, "Transport %s acquired", seltp->obj_name));
return PJ_SUCCESS;
} else {
/*
* This is the "normal" flow, where application doesn't specify
* specific transport to be used to send message to.
* In this case, lookup the transport from the hash table.
*/
pjsip_transport_key key;
int key_len;
pjsip_transport *tp_ref = NULL;
transport *tp_entry = NULL;
/* If listener is specified, verify that the listener type matches
* the destination type.
*/
if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER && sel->u.listener)
{
if (sel->u.listener->type != type) {
pj_lock_release(mgr->lock);
TRACE_((THIS_FILE, "Listener type in tpsel not matched"));
return PJSIP_ETPNOTSUITABLE;
}
}
if (!sel || sel->disable_connection_reuse == PJ_FALSE) {
pj_bzero(&key, sizeof(key));
key_len = sizeof(key.type) + addr_len;
/* First try to get exact destination. */
key.type = type;
pj_memcpy(&key.rem_addr, remote, addr_len);
tp_entry = (transport *)pj_hash_get(mgr->table, &key, key_len,
NULL);
if (tp_entry) {
transport *tp_iter = tp_entry;
do {
/* Don't use transport being shutdown/destroyed */
if (!tp_iter->tp->is_shutdown &&
!tp_iter->tp->is_destroying)
{
if ((type & PJSIP_TRANSPORT_SECURE) && tdata) {
/* For secure transport, make sure tdata's
* destination host matches the transport's
* remote host.
*/
if (pj_stricmp(&tdata->dest_info.name,
&tp_iter->tp->remote_name.host))
{
tp_iter = tp_iter->next;
continue;
}
}
if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&
sel->u.listener)
{
/* Match listener if selector is set */
if (tp_iter->tp->factory == sel->u.listener) {
tp_ref = tp_iter->tp;
break;
}
} else {
tp_ref = tp_iter->tp;
break;
}
}
tp_iter = tp_iter->next;
} while (tp_iter != tp_entry);
}
}
if (tp_ref == NULL &&
(!sel || sel->disable_connection_reuse == PJ_FALSE))
{
unsigned flag = pjsip_transport_get_flag_from_type(type);
const pj_sockaddr *remote_addr = (const pj_sockaddr*)remote;
/* Ignore address for loop transports. */
if (type == PJSIP_TRANSPORT_LOOP ||
type == PJSIP_TRANSPORT_LOOP_DGRAM)
{
pj_sockaddr *addr = &key.rem_addr;
pj_bzero(addr, addr_len);
key_len = sizeof(key.type) + addr_len;
tp_entry = (transport *) pj_hash_get(mgr->table, &key,
key_len, NULL);
if (tp_entry) {
tp_ref = tp_entry->tp;
}
}
/* For datagram transports, try lookup with zero address.
*/
else if (flag & PJSIP_TRANSPORT_DATAGRAM)
{
pj_sockaddr *addr = &key.rem_addr;
pj_bzero(addr, addr_len);
addr->addr.sa_family = remote_addr->addr.sa_family;
key_len = sizeof(key.type) + addr_len;
tp_entry = (transport *) pj_hash_get(mgr->table, &key,
key_len, NULL);
if (tp_entry) {
tp_ref = tp_entry->tp;
}
}
}
/* If transport is found and listener is specified, verify listener */
else if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&
sel->u.listener && tp_ref->factory != sel->u.listener)
{
tp_ref = NULL;
/* This will cause a new transport to be created which will be a
* 'duplicate' of the existing transport (same type & remote addr,
* but different factory).
*/
TRACE_((THIS_FILE, "Transport found but from different listener"));
}
if (tp_ref!=NULL && !tp_ref->is_shutdown && !tp_ref->is_destroying) {
/*
* Transport found!
*/
pjsip_transport_add_ref(tp_ref);
pj_lock_release(mgr->lock);
*tp = tp_ref;
TRACE_((THIS_FILE, "Transport %s acquired", tp_ref->obj_name));
return PJ_SUCCESS;
}
/*
* Either transport not found, or we don't want to use the existing
* transport (such as in the case of different factory or
* if connection reuse is disabled). So we need to create one,
* find factory that can create such transport.
*
* If there's an existing transport, its place in the hash table
* will be replaced by this new one. And eventually the existing
* transport will still be freed (by application or #1774).
*/
if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER && sel->u.listener)
{
/* Application has requested that a specific listener is to
* be used.
*/
/* Verify that the listener type matches the destination type */
/* Already checked above. */
/*
if (sel->u.listener->type != type) {
pj_lock_release(mgr->lock);
return PJSIP_ETPNOTSUITABLE;
}
*/
/* We'll use this listener to create transport */
factory = sel->u.listener;
/* Verify if listener is still valid */
if (!pjsip_tpmgr_is_tpfactory_valid(mgr, factory)) {
pj_lock_release(mgr->lock);
PJ_LOG(3,(THIS_FILE, "Specified factory for creating "
"transport is not found"));
return PJ_ENOTFOUND;
}
} else {
/* Find factory with type matches the destination type */
factory = mgr->factory_list.next;
while (factory != &mgr->factory_list) {
if (factory->type == type)
break;
factory = factory->next;
}
if (factory == &mgr->factory_list) {
/* No factory can create the transport! */
pj_lock_release(mgr->lock);
TRACE_((THIS_FILE, "No suitable factory was found either"));
return PJSIP_EUNSUPTRANSPORT;
}
}
}
TRACE_((THIS_FILE, "Creating new transport from factory"));
/* Request factory to create transport. */
if (factory->create_transport2) {
status = factory->create_transport2(factory, mgr, mgr->endpt,
(const pj_sockaddr*) remote,
addr_len, tdata, tp);
} else {
status = factory->create_transport(factory, mgr, mgr->endpt,
(const pj_sockaddr*) remote,
addr_len, tp);
}
if (status == PJ_SUCCESS) {
PJ_ASSERT_ON_FAIL(tp!=NULL,
{pj_lock_release(mgr->lock); return PJ_EBUG;});
pjsip_transport_add_ref(*tp);
(*tp)->factory = factory;
}
pj_lock_release(mgr->lock);
return status;
}
| 0
|
16,493
|
int TSMimeHdrFieldValuesCount ( TSMBuffer bufp , TSMLoc hdr , TSMLoc field ) {
sdk_assert ( sdk_sanity_check_mbuffer ( bufp ) == TS_SUCCESS ) ;
sdk_assert ( ( sdk_sanity_check_mime_hdr_handle ( hdr ) == TS_SUCCESS ) || ( sdk_sanity_check_http_hdr_handle ( hdr ) == TS_SUCCESS ) ) ;
sdk_assert ( sdk_sanity_check_field_handle ( field , hdr ) == TS_SUCCESS ) ;
MIMEFieldSDKHandle * handle = ( MIMEFieldSDKHandle * ) field ;
return mime_field_value_get_comma_val_count ( handle -> field_ptr ) ;
}
| 0
|
306,664
|
ServerItem::ServerItem(const BonjourRecord &br) : QTreeWidgetItem(QTreeWidgetItem::UserType) {
siParent = NULL;
bParent = false;
itType = LANType;
qsName = br.serviceName;
qsBonjourHost = qsName;
brRecord = br;
usPort = 0;
bCA = false;
init();
}
| 0
|
447,590
|
blobGetFilename(const blob *b)
{
assert(b != NULL);
#ifdef CL_DEBUG
assert(b->magic == BLOBCLASS);
#endif
return b->name;
}
| 0
|
264,707
|
static void pred_weight_table(GF_BitStream *bs, u32 slice_type, u32 ChromaArrayType, u32 num_ref_idx_l0_active_minus1, u32 num_ref_idx_l1_active_minus1) {
u32 i, j;
gf_bs_read_ue_log(bs, "luma_log2_weight_denom");
if (ChromaArrayType != 0) {
gf_bs_read_ue_log(bs, "chroma_log2_weight_denom");
}
for (i = 0; i <= num_ref_idx_l0_active_minus1; i++) {
if (gf_bs_read_int_log_idx(bs, 1, "luma_weight_l0_flag", i)) {
gf_bs_read_se_log_idx(bs, "luma_weight_l0", i);
gf_bs_read_se_log_idx(bs, "luma_offset_l0", i);
}
if (ChromaArrayType != 0) {
if (gf_bs_read_int_log_idx(bs, 1, "chroma_weight_l0_flag", i))
for (j = 0; j < 2; j++) {
gf_bs_read_se_log_idx2(bs, "chroma_weight_l0", i, j);
gf_bs_read_se_log_idx2(bs, "chroma_offset_l0", i, j);
}
}
}
if (slice_type % 5 == 1) {
for (i = 0; i <= num_ref_idx_l1_active_minus1; i++) {
if (gf_bs_read_int_log_idx(bs, 1, "luma_weight_l1_flag", i)) {
gf_bs_read_se_log_idx(bs, "luma_weight_l1", i);
gf_bs_read_se_log_idx(bs, "luma_offset_l1", i);
}
if (ChromaArrayType != 0) {
if (gf_bs_read_int_log_idx(bs, 1, "chroma_weight_l1_flag", i)) {
for (j = 0; j < 2; j++) {
gf_bs_read_se_log_idx2(bs, "chroma_weight_l1", i, j);
gf_bs_read_se_log_idx2(bs, "chroma_offset_l1", i, j);
}
}
}
}
}
}
| 0
|
211,563
|
PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var_array, zend_ulong opt, zend_string **sql)
{
zval *val, converted;
char buf[256];
char *tmp;
smart_str querystr = {0};
int ret = FAILURE;
zend_ulong num_idx;
zend_string *fld;
assert(pg_link != NULL);
assert(table != NULL);
assert(Z_TYPE_P(var_array) == IS_ARRAY);
ZVAL_UNDEF(&converted);
if (zend_hash_num_elements(Z_ARRVAL_P(var_array)) == 0) {
smart_str_appends(&querystr, "INSERT INTO ");
build_tablename(&querystr, pg_link, table);
smart_str_appends(&querystr, " DEFAULT VALUES");
goto no_values;
}
/* convert input array if needed */
if (!(opt & (PGSQL_DML_NO_CONV|PGSQL_DML_ESCAPE))) {
array_init(&converted);
if (php_pgsql_convert(pg_link, table, var_array, &converted, (opt & PGSQL_CONV_OPTS)) == FAILURE) {
goto cleanup;
}
var_array = &converted;
}
smart_str_appends(&querystr, "INSERT INTO ");
build_tablename(&querystr, pg_link, table);
smart_str_appends(&querystr, " (");
ZEND_HASH_FOREACH_KEY(Z_ARRVAL_P(var_array), num_idx, fld) {
if (fld == NULL) {
php_error_docref(NULL, E_NOTICE, "Expects associative array for values to be inserted");
goto cleanup;
}
if (opt & PGSQL_DML_ESCAPE) {
tmp = PGSQLescapeIdentifier(pg_link, fld->val, fld->len + 1);
smart_str_appends(&querystr, tmp);
PGSQLfree(tmp);
} else {
smart_str_appendl(&querystr, fld->val, fld->len);
}
smart_str_appendc(&querystr, ',');
} ZEND_HASH_FOREACH_END();
querystr.s->len--;
smart_str_appends(&querystr, ") VALUES (");
/* make values string */
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(var_array), val) {
/* we can avoid the key_type check here, because we tested it in the other loop */
switch (Z_TYPE_P(val)) {
case IS_STRING:
if (opt & PGSQL_DML_ESCAPE) {
size_t new_len;
char *tmp;
tmp = (char *)safe_emalloc(Z_STRLEN_P(val), 2, 1);
new_len = PQescapeStringConn(pg_link, tmp, Z_STRVAL_P(val), Z_STRLEN_P(val), NULL);
smart_str_appendc(&querystr, '\'');
smart_str_appendl(&querystr, tmp, new_len);
smart_str_appendc(&querystr, '\'');
efree(tmp);
} else {
smart_str_appendl(&querystr, Z_STRVAL_P(val), Z_STRLEN_P(val));
}
break;
case IS_LONG:
smart_str_append_long(&querystr, Z_LVAL_P(val));
break;
case IS_DOUBLE:
smart_str_appendl(&querystr, buf, snprintf(buf, sizeof(buf), "%F", Z_DVAL_P(val)));
break;
case IS_NULL:
smart_str_appendl(&querystr, "NULL", sizeof("NULL")-1);
break;
default:
php_error_docref(NULL, E_WARNING, "Expects scaler values. type = %d", Z_TYPE_P(val));
goto cleanup;
break;
}
smart_str_appendc(&querystr, ',');
} ZEND_HASH_FOREACH_END();
/* Remove the trailing "," */
querystr.s->len--;
smart_str_appends(&querystr, ");");
no_values:
smart_str_0(&querystr);
if ((opt & (PGSQL_DML_EXEC|PGSQL_DML_ASYNC)) &&
do_exec(&querystr, PGRES_COMMAND_OK, pg_link, (opt & PGSQL_CONV_OPTS)) == 0) {
ret = SUCCESS;
}
else if (opt & PGSQL_DML_STRING) {
ret = SUCCESS;
}
cleanup:
zval_ptr_dtor(&converted);
if (ret == SUCCESS && (opt & PGSQL_DML_STRING)) {
*sql = querystr.s;
}
else {
smart_str_free(&querystr);
}
return ret;
}
| 0
|
320,756
|
static uint8_t get_tlm(Jpeg2000DecoderContext *s, int n)
{
uint8_t Stlm, ST, SP, tile_tlm, i;
bytestream_get_byte(&s->buf); /* Ztlm: skipped */
Stlm = bytestream_get_byte(&s->buf);
// too complex ? ST = ((Stlm >> 4) & 0x01) + ((Stlm >> 4) & 0x02);
ST = (Stlm >> 4) & 0x03;
// TODO: Manage case of ST = 0b11 --> raise error
SP = (Stlm >> 6) & 0x01;
tile_tlm = (n - 4) / ((SP + 1) * 2 + ST);
for (i = 0; i < tile_tlm; i++) {
switch (ST) {
case 0:
break;
case 1:
bytestream_get_byte(&s->buf);
break;
case 2:
bytestream_get_be16(&s->buf);
break;
case 3:
bytestream_get_be32(&s->buf);
break;
}
if (SP == 0) {
bytestream_get_be16(&s->buf);
} else {
bytestream_get_be32(&s->buf);
}
}
return 0;
}
| 1
|
486,326
|
OFCondition DcmSCP::receiveDIMSEDataset(T_ASC_PresentationContextID *presID,
DcmDataset **dataObject)
{
if (m_assoc == NULL)
return DIMSE_ILLEGALASSOCIATION;
OFCondition cond;
/* call the corresponding DIMSE function to receive the dataset */
if (m_cfg->getProgressNotificationMode())
{
cond = DIMSE_receiveDataSetInMemory(m_assoc, m_cfg->getDIMSEBlockingMode(), m_cfg->getDIMSETimeout(),
presID, dataObject, callbackRECEIVEProgress, this /*callbackData*/);
} else {
cond = DIMSE_receiveDataSetInMemory(m_assoc, m_cfg->getDIMSEBlockingMode(), m_cfg->getDIMSETimeout(),
presID, dataObject, NULL /*callback*/, NULL /*callbackData*/);
}
if (cond.good())
{
DCMNET_DEBUG("Received dataset on presentation context " << OFstatic_cast(unsigned int, *presID));
} else {
OFString tempStr;
DCMNET_ERROR("Unable to receive dataset on presentation context "
<< OFstatic_cast(unsigned int, *presID) << ": " << DimseCondition::dump(tempStr, cond));
}
return cond;
}
| 0
|
166,807
|
static void DestroyXMLTreeOrdered(XMLTreeInfo *xml_info)
{
XMLTreeInfo
*node,
*ordered;
ordered=xml_info->ordered;
while(ordered != (XMLTreeInfo *) NULL)
{
node=ordered;
ordered=node->ordered;
node->ordered=(XMLTreeInfo *) NULL;
(void) DestroyXMLTree(node);
}
}
| 0
|
179,665
|
device_drive_inhibit_polling_authorized_cb (Daemon *daemon,
Device *device,
DBusGMethodInvocation *context,
const gchar *action_id,
guint num_user_data,
gpointer *user_data_elements)
{
gchar **options = user_data_elements[0];
Inhibitor *inhibitor;
guint n;
for (n = 0; options[n] != NULL; n++)
{
const char *option = options[n];
throw_error (context, ERROR_INVALID_OPTION, "Unknown option %s", option);
goto out;
}
inhibitor = inhibitor_new (context);
device->priv->polling_inhibitors = g_list_prepend (device->priv->polling_inhibitors, inhibitor);
g_signal_connect (inhibitor, "disconnected", G_CALLBACK (polling_inhibitor_disconnected_cb), device);
update_info (device);
drain_pending_changes (device, FALSE);
daemon_local_update_poller (device->priv->daemon);
dbus_g_method_return (context, inhibitor_get_cookie (inhibitor));
out:
;
}
| 0
|
138,127
|
static Jsi_RC NumberIsIntegerCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,
Jsi_Value **ret, Jsi_Func *funcPtr) {
return jsi_NumberIsFiniteCmd(interp, args, _this, ret, funcPtr, 2);
}
| 0
|
80,201
|
int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size;
size = RAW_PACKET_SIZE;
if (av_new_packet(pkt, size) < 0)
return AVERROR(ENOMEM);
pkt->pos= avio_tell(s->pb);
pkt->stream_index = 0;
ret = ffio_read_partial(s->pb, pkt->data, size);
if (ret < 0) {
av_free_packet(pkt);
return ret;
}
pkt->size = ret;
return ret;
}
| 1
|
210,354
|
inline const KURL& Location::Url() const {
const KURL& url = GetDocument()->Url();
if (!url.IsValid()) {
return BlankURL();
}
return url;
}
| 0
|
76,028
|
R_API bool r_cmd_desc_remove(RCmd *cmd, RCmdDesc *cd) {
r_return_val_if_fail (cmd && cd, false);
if (cd->parent) {
cmd_desc_unset_parent (cd);
}
cmd_desc_remove_from_ht_cmds (cmd, cd);
cmd_desc_free (cd);
return true;
}
| 0
|
508,909
|
int ssl3_accept(SSL *s)
{
BUF_MEM *buf;
unsigned long alg_k, Time = (unsigned long)time(NULL);
void (*cb) (const SSL *ssl, int type, int val) = NULL;
int ret = -1;
int new_state, state, skip = 0;
RAND_add(&Time, sizeof(Time), 0);
ERR_clear_error();
clear_sys_error();
if (s->info_callback != NULL)
cb = s->info_callback;
else if (s->ctx->info_callback != NULL)
cb = s->ctx->info_callback;
/* init things to blank */
s->in_handshake++;
if (!SSL_in_init(s) || SSL_in_before(s))
SSL_clear(s);
if (s->cert == NULL) {
SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_NO_CERTIFICATE_SET);
return (-1);
}
#ifndef OPENSSL_NO_HEARTBEATS
/*
* If we're awaiting a HeartbeatResponse, pretend we already got and
* don't await it anymore, because Heartbeats don't make sense during
* handshakes anyway.
*/
if (s->tlsext_hb_pending) {
s->tlsext_hb_pending = 0;
s->tlsext_hb_seq++;
}
#endif
for (;;) {
state = s->state;
switch (s->state) {
case SSL_ST_RENEGOTIATE:
s->renegotiate = 1;
/* s->state=SSL_ST_ACCEPT; */
case SSL_ST_BEFORE:
case SSL_ST_ACCEPT:
case SSL_ST_BEFORE | SSL_ST_ACCEPT:
case SSL_ST_OK | SSL_ST_ACCEPT:
s->server = 1;
if (cb != NULL)
cb(s, SSL_CB_HANDSHAKE_START, 1);
if ((s->version >> 8) != 3) {
SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR);
s->state = SSL_ST_ERR;
return -1;
}
s->type = SSL_ST_ACCEPT;
if (s->init_buf == NULL) {
if ((buf = BUF_MEM_new()) == NULL) {
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {
BUF_MEM_free(buf);
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
s->init_buf = buf;
}
if (!ssl3_setup_buffers(s)) {
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
s->init_num = 0;
s->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY;
s->s3->flags &= ~SSL3_FLAGS_CCS_OK;
/*
* Should have been reset by ssl3_get_finished, too.
*/
s->s3->change_cipher_spec = 0;
if (s->state != SSL_ST_RENEGOTIATE) {
/*
* Ok, we now need to push on a buffering BIO so that the
* output is sent in a way that TCP likes :-)
*/
if (!ssl_init_wbio_buffer(s, 1)) {
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
ssl3_init_finished_mac(s);
s->state = SSL3_ST_SR_CLNT_HELLO_A;
s->ctx->stats.sess_accept++;
} else if (!s->s3->send_connection_binding &&
!(s->options &
SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) {
/*
* Server attempting to renegotiate with client that doesn't
* support secure renegotiation.
*/
SSLerr(SSL_F_SSL3_ACCEPT,
SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
ret = -1;
s->state = SSL_ST_ERR;
goto end;
} else {
/*
* s->state == SSL_ST_RENEGOTIATE, we will just send a
* HelloRequest
*/
s->ctx->stats.sess_accept_renegotiate++;
s->state = SSL3_ST_SW_HELLO_REQ_A;
}
break;
case SSL3_ST_SW_HELLO_REQ_A:
case SSL3_ST_SW_HELLO_REQ_B:
s->shutdown = 0;
ret = ssl3_send_hello_request(s);
if (ret <= 0)
goto end;
s->s3->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C;
s->state = SSL3_ST_SW_FLUSH;
s->init_num = 0;
ssl3_init_finished_mac(s);
break;
case SSL3_ST_SW_HELLO_REQ_C:
s->state = SSL_ST_OK;
break;
case SSL3_ST_SR_CLNT_HELLO_A:
case SSL3_ST_SR_CLNT_HELLO_B:
case SSL3_ST_SR_CLNT_HELLO_C:
s->shutdown = 0;
ret = ssl3_get_client_hello(s);
if (ret <= 0)
goto end;
#ifndef OPENSSL_NO_SRP
s->state = SSL3_ST_SR_CLNT_HELLO_D;
case SSL3_ST_SR_CLNT_HELLO_D:
{
int al;
if ((ret = ssl_check_srp_ext_ClientHello(s, &al)) < 0) {
/*
* callback indicates firther work to be done
*/
s->rwstate = SSL_X509_LOOKUP;
goto end;
}
if (ret != SSL_ERROR_NONE) {
ssl3_send_alert(s, SSL3_AL_FATAL, al);
/*
* This is not really an error but the only means to for
* a client to detect whether srp is supported.
*/
if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY)
SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT);
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
}
#endif
s->renegotiate = 2;
s->state = SSL3_ST_SW_SRVR_HELLO_A;
s->init_num = 0;
break;
case SSL3_ST_SW_SRVR_HELLO_A:
case SSL3_ST_SW_SRVR_HELLO_B:
ret = ssl3_send_server_hello(s);
if (ret <= 0)
goto end;
#ifndef OPENSSL_NO_TLSEXT
if (s->hit) {
if (s->tlsext_ticket_expected)
s->state = SSL3_ST_SW_SESSION_TICKET_A;
else
s->state = SSL3_ST_SW_CHANGE_A;
}
#else
if (s->hit)
s->state = SSL3_ST_SW_CHANGE_A;
#endif
else
s->state = SSL3_ST_SW_CERT_A;
s->init_num = 0;
break;
case SSL3_ST_SW_CERT_A:
case SSL3_ST_SW_CERT_B:
/* Check if it is anon DH or anon ECDH, */
/* normal PSK or KRB5 or SRP */
if (!
(s->s3->tmp.
new_cipher->algorithm_auth & (SSL_aNULL | SSL_aKRB5 |
SSL_aSRP))
&& !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) {
ret = ssl3_send_server_certificate(s);
if (ret <= 0)
goto end;
#ifndef OPENSSL_NO_TLSEXT
if (s->tlsext_status_expected)
s->state = SSL3_ST_SW_CERT_STATUS_A;
else
s->state = SSL3_ST_SW_KEY_EXCH_A;
} else {
skip = 1;
s->state = SSL3_ST_SW_KEY_EXCH_A;
}
#else
} else
skip = 1;
s->state = SSL3_ST_SW_KEY_EXCH_A;
#endif
s->init_num = 0;
break;
case SSL3_ST_SW_KEY_EXCH_A:
case SSL3_ST_SW_KEY_EXCH_B:
alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
/*
* clear this, it may get reset by
* send_server_key_exchange
*/
s->s3->tmp.use_rsa_tmp = 0;
/*
* only send if a DH key exchange, fortezza or RSA but we have a
* sign only certificate PSK: may send PSK identity hints For
* ECC ciphersuites, we send a serverKeyExchange message only if
* the cipher suite is either ECDH-anon or ECDHE. In other cases,
* the server certificate contains the server's public key for
* key exchange.
*/
if (0
/*
* PSK: send ServerKeyExchange if PSK identity hint if
* provided
*/
#ifndef OPENSSL_NO_PSK
|| ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint)
#endif
#ifndef OPENSSL_NO_SRP
/* SRP: send ServerKeyExchange */
|| (alg_k & SSL_kSRP)
#endif
|| (alg_k & SSL_kEDH)
|| (alg_k & SSL_kEECDH)
|| ((alg_k & SSL_kRSA)
&& (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL
|| (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)
&& EVP_PKEY_size(s->cert->pkeys
[SSL_PKEY_RSA_ENC].privatekey) *
8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)
)
)
)
) {
ret = ssl3_send_server_key_exchange(s);
if (ret <= 0)
goto end;
} else
skip = 1;
s->state = SSL3_ST_SW_CERT_REQ_A;
s->init_num = 0;
break;
case SSL3_ST_SW_CERT_REQ_A:
case SSL3_ST_SW_CERT_REQ_B:
if ( /* don't request cert unless asked for it: */
!(s->verify_mode & SSL_VERIFY_PEER) ||
/*
* if SSL_VERIFY_CLIENT_ONCE is set, don't request cert
* during re-negotiation:
*/
((s->session->peer != NULL) &&
(s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) ||
/*
* never request cert in anonymous ciphersuites (see
* section "Certificate request" in SSL 3 drafts and in
* RFC 2246):
*/
((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) &&
/*
* ... except when the application insists on
* verification (against the specs, but s3_clnt.c accepts
* this for SSL 3)
*/
!(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) ||
/*
* never request cert in Kerberos ciphersuites
*/
(s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) ||
/* don't request certificate for SRP auth */
(s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP)
/*
* With normal PSK Certificates and Certificate Requests
* are omitted
*/
|| (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) {
/* no cert request */
skip = 1;
s->s3->tmp.cert_request = 0;
s->state = SSL3_ST_SW_SRVR_DONE_A;
if (s->s3->handshake_buffer) {
if (!ssl3_digest_cached_records(s)) {
s->state = SSL_ST_ERR;
return -1;
}
}
} else {
s->s3->tmp.cert_request = 1;
ret = ssl3_send_certificate_request(s);
if (ret <= 0)
goto end;
#ifndef NETSCAPE_HANG_BUG
s->state = SSL3_ST_SW_SRVR_DONE_A;
#else
s->state = SSL3_ST_SW_FLUSH;
s->s3->tmp.next_state = SSL3_ST_SR_CERT_A;
#endif
s->init_num = 0;
}
break;
case SSL3_ST_SW_SRVR_DONE_A:
case SSL3_ST_SW_SRVR_DONE_B:
ret = ssl3_send_server_done(s);
if (ret <= 0)
goto end;
s->s3->tmp.next_state = SSL3_ST_SR_CERT_A;
s->state = SSL3_ST_SW_FLUSH;
s->init_num = 0;
break;
case SSL3_ST_SW_FLUSH:
/*
* This code originally checked to see if any data was pending
* using BIO_CTRL_INFO and then flushed. This caused problems as
* documented in PR#1939. The proposed fix doesn't completely
* resolve this issue as buggy implementations of
* BIO_CTRL_PENDING still exist. So instead we just flush
* unconditionally.
*/
s->rwstate = SSL_WRITING;
if (BIO_flush(s->wbio) <= 0) {
ret = -1;
goto end;
}
s->rwstate = SSL_NOTHING;
s->state = s->s3->tmp.next_state;
break;
case SSL3_ST_SR_CERT_A:
case SSL3_ST_SR_CERT_B:
if (s->s3->tmp.cert_request) {
ret = ssl3_get_client_certificate(s);
if (ret <= 0)
goto end;
}
s->init_num = 0;
s->state = SSL3_ST_SR_KEY_EXCH_A;
break;
case SSL3_ST_SR_KEY_EXCH_A:
case SSL3_ST_SR_KEY_EXCH_B:
ret = ssl3_get_client_key_exchange(s);
if (ret <= 0)
goto end;
if (ret == 2) {
/*
* For the ECDH ciphersuites when the client sends its ECDH
* pub key in a certificate, the CertificateVerify message is
* not sent. Also for GOST ciphersuites when the client uses
* its key from the certificate for key exchange.
*/
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->state = SSL3_ST_SR_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen)
s->state = SSL3_ST_SR_NEXT_PROTO_A;
else
s->state = SSL3_ST_SR_FINISHED_A;
#endif
s->init_num = 0;
} else if (SSL_USE_SIGALGS(s)) {
s->state = SSL3_ST_SR_CERT_VRFY_A;
s->init_num = 0;
if (!s->session->peer)
break;
/*
* For sigalgs freeze the handshake buffer at this point and
* digest cached records.
*/
if (!s->s3->handshake_buffer) {
SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR);
s->state = SSL_ST_ERR;
return -1;
}
s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE;
if (!ssl3_digest_cached_records(s)) {
s->state = SSL_ST_ERR;
return -1;
}
} else {
int offset = 0;
int dgst_num;
s->state = SSL3_ST_SR_CERT_VRFY_A;
s->init_num = 0;
/*
* We need to get hashes here so if there is a client cert,
* it can be verified FIXME - digest processing for
* CertificateVerify should be generalized. But it is next
* step
*/
if (s->s3->handshake_buffer) {
if (!ssl3_digest_cached_records(s)) {
s->state = SSL_ST_ERR;
return -1;
}
}
for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++)
if (s->s3->handshake_dgst[dgst_num]) {
int dgst_size;
s->method->ssl3_enc->cert_verify_mac(s,
EVP_MD_CTX_type
(s->
s3->handshake_dgst
[dgst_num]),
&(s->s3->
tmp.cert_verify_md
[offset]));
dgst_size =
EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]);
if (dgst_size < 0) {
s->state = SSL_ST_ERR;
ret = -1;
goto end;
}
offset += dgst_size;
}
}
break;
case SSL3_ST_SR_CERT_VRFY_A:
case SSL3_ST_SR_CERT_VRFY_B:
ret = ssl3_get_cert_verify(s);
if (ret <= 0)
goto end;
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->state = SSL3_ST_SR_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen)
s->state = SSL3_ST_SR_NEXT_PROTO_A;
else
s->state = SSL3_ST_SR_FINISHED_A;
#endif
s->init_num = 0;
break;
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
case SSL3_ST_SR_NEXT_PROTO_A:
case SSL3_ST_SR_NEXT_PROTO_B:
/*
* Enable CCS for NPN. Receiving a CCS clears the flag, so make
* sure not to re-enable it to ban duplicates. This *should* be the
* first time we have received one - but we check anyway to be
* cautious.
* s->s3->change_cipher_spec is set when a CCS is
* processed in s3_pkt.c, and remains set until
* the client's Finished message is read.
*/
if (!s->s3->change_cipher_spec)
s->s3->flags |= SSL3_FLAGS_CCS_OK;
ret = ssl3_get_next_proto(s);
if (ret <= 0)
goto end;
s->init_num = 0;
s->state = SSL3_ST_SR_FINISHED_A;
break;
#endif
case SSL3_ST_SR_FINISHED_A:
case SSL3_ST_SR_FINISHED_B:
/*
* Enable CCS for handshakes without NPN. In NPN the CCS flag has
* already been set. Receiving a CCS clears the flag, so make
* sure not to re-enable it to ban duplicates.
* s->s3->change_cipher_spec is set when a CCS is
* processed in s3_pkt.c, and remains set until
* the client's Finished message is read.
*/
if (!s->s3->change_cipher_spec)
s->s3->flags |= SSL3_FLAGS_CCS_OK;
ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A,
SSL3_ST_SR_FINISHED_B);
if (ret <= 0)
goto end;
if (s->hit)
s->state = SSL_ST_OK;
#ifndef OPENSSL_NO_TLSEXT
else if (s->tlsext_ticket_expected)
s->state = SSL3_ST_SW_SESSION_TICKET_A;
#endif
else
s->state = SSL3_ST_SW_CHANGE_A;
s->init_num = 0;
break;
#ifndef OPENSSL_NO_TLSEXT
case SSL3_ST_SW_SESSION_TICKET_A:
case SSL3_ST_SW_SESSION_TICKET_B:
ret = ssl3_send_newsession_ticket(s);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_CHANGE_A;
s->init_num = 0;
break;
case SSL3_ST_SW_CERT_STATUS_A:
case SSL3_ST_SW_CERT_STATUS_B:
ret = ssl3_send_cert_status(s);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_KEY_EXCH_A;
s->init_num = 0;
break;
#endif
case SSL3_ST_SW_CHANGE_A:
case SSL3_ST_SW_CHANGE_B:
s->session->cipher = s->s3->tmp.new_cipher;
if (!s->method->ssl3_enc->setup_key_block(s)) {
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
ret = ssl3_send_change_cipher_spec(s,
SSL3_ST_SW_CHANGE_A,
SSL3_ST_SW_CHANGE_B);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_FINISHED_A;
s->init_num = 0;
if (!s->method->ssl3_enc->change_cipher_state(s,
SSL3_CHANGE_CIPHER_SERVER_WRITE))
{
ret = -1;
s->state = SSL_ST_ERR;
goto end;
}
break;
case SSL3_ST_SW_FINISHED_A:
case SSL3_ST_SW_FINISHED_B:
ret = ssl3_send_finished(s,
SSL3_ST_SW_FINISHED_A,
SSL3_ST_SW_FINISHED_B,
s->method->
ssl3_enc->server_finished_label,
s->method->
ssl3_enc->server_finished_label_len);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_FLUSH;
if (s->hit) {
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen) {
s->s3->tmp.next_state = SSL3_ST_SR_NEXT_PROTO_A;
} else
s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A;
#endif
} else
s->s3->tmp.next_state = SSL_ST_OK;
s->init_num = 0;
break;
case SSL_ST_OK:
/* clean a few things up */
ssl3_cleanup_key_block(s);
BUF_MEM_free(s->init_buf);
s->init_buf = NULL;
/* remove buffering on output */
ssl_free_wbio_buffer(s);
s->init_num = 0;
if (s->renegotiate == 2) { /* skipped if we just sent a
* HelloRequest */
s->renegotiate = 0;
s->new_session = 0;
ssl_update_cache(s, SSL_SESS_CACHE_SERVER);
s->ctx->stats.sess_accept_good++;
/* s->server=1; */
s->handshake_func = ssl3_accept;
if (cb != NULL)
cb(s, SSL_CB_HANDSHAKE_DONE, 1);
}
ret = 1;
goto end;
/* break; */
case SSL_ST_ERR:
default:
SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNKNOWN_STATE);
ret = -1;
goto end;
/* break; */
}
if (!s->s3->tmp.reuse_message && !skip) {
if (s->debug) {
if ((ret = BIO_flush(s->wbio)) <= 0)
goto end;
}
if ((cb != NULL) && (s->state != state)) {
new_state = s->state;
s->state = state;
cb(s, SSL_CB_ACCEPT_LOOP, 1);
s->state = new_state;
}
}
skip = 0;
}
| 0
|
206,979
|
ui::ModalType PrintPreviewDialogDelegate::GetDialogModalType() const {
NOTREACHED();
return ui::MODAL_TYPE_WINDOW;
}
| 0
|
288,301
|
int MapOpenSSLErrorSSL() {
unsigned long error_code;
do {
error_code = ERR_get_error();
if (error_code == 0)
return ERR_SSL_PROTOCOL_ERROR;
} while (ERR_GET_LIB(error_code) != ERR_LIB_SSL);
DVLOG(1) << "OpenSSL SSL error, reason: " << ERR_GET_REASON(error_code)
<< ", name: " << ERR_error_string(error_code, NULL);
switch (ERR_GET_REASON(error_code)) {
case SSL_R_READ_TIMEOUT_EXPIRED:
return ERR_TIMED_OUT;
case SSL_R_BAD_RESPONSE_ARGUMENT:
return ERR_INVALID_ARGUMENT;
case SSL_R_UNKNOWN_CERTIFICATE_TYPE:
case SSL_R_UNKNOWN_CIPHER_TYPE:
case SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE:
case SSL_R_UNKNOWN_PKEY_TYPE:
case SSL_R_UNKNOWN_REMOTE_ERROR_TYPE:
case SSL_R_UNKNOWN_SSL_VERSION:
return ERR_NOT_IMPLEMENTED;
case SSL_R_UNSUPPORTED_SSL_VERSION:
case SSL_R_NO_CIPHER_MATCH:
case SSL_R_NO_SHARED_CIPHER:
case SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY:
case SSL_R_TLSV1_ALERT_PROTOCOL_VERSION:
case SSL_R_UNSUPPORTED_PROTOCOL:
return ERR_SSL_VERSION_OR_CIPHER_MISMATCH;
case SSL_R_SSLV3_ALERT_BAD_CERTIFICATE:
case SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE:
case SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED:
case SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED:
case SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN:
case SSL_R_TLSV1_ALERT_ACCESS_DENIED:
case SSL_R_TLSV1_ALERT_UNKNOWN_CA:
return ERR_BAD_SSL_CLIENT_AUTH_CERT;
case SSL_R_BAD_DECOMPRESSION:
case SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE:
return ERR_SSL_DECOMPRESSION_FAILURE_ALERT;
case SSL_R_SSLV3_ALERT_BAD_RECORD_MAC:
return ERR_SSL_BAD_RECORD_MAC_ALERT;
case SSL_R_TLSV1_ALERT_DECRYPT_ERROR:
return ERR_SSL_DECRYPT_ERROR_ALERT;
case SSL_R_TLSV1_UNRECOGNIZED_NAME:
return ERR_SSL_UNRECOGNIZED_NAME_ALERT;
case SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED:
return ERR_SSL_UNSAFE_NEGOTIATION;
case SSL_R_WRONG_NUMBER_OF_KEY_BITS:
return ERR_SSL_WEAK_SERVER_EPHEMERAL_DH_KEY;
case SSL_R_UNKNOWN_PROTOCOL:
case SSL_R_SSL_HANDSHAKE_FAILURE:
case SSL_R_DECRYPTION_FAILED:
case SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC:
case SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG:
case SSL_R_DIGEST_CHECK_FAILED:
case SSL_R_DUPLICATE_COMPRESSION_ID:
case SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER:
case SSL_R_ENCRYPTED_LENGTH_TOO_LONG:
case SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST:
case SSL_R_EXCESSIVE_MESSAGE_SIZE:
case SSL_R_EXTRA_DATA_IN_MESSAGE:
case SSL_R_GOT_A_FIN_BEFORE_A_CCS:
case SSL_R_ILLEGAL_PADDING:
case SSL_R_INVALID_CHALLENGE_LENGTH:
case SSL_R_INVALID_COMMAND:
case SSL_R_INVALID_PURPOSE:
case SSL_R_INVALID_STATUS_RESPONSE:
case SSL_R_INVALID_TICKET_KEYS_LENGTH:
case SSL_R_KEY_ARG_TOO_LONG:
case SSL_R_READ_WRONG_PACKET_TYPE:
case SSL_AD_REASON_OFFSET + SSL_AD_CLOSE_NOTIFY:
case SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE:
case SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE:
case SSL_R_SSLV3_ALERT_NO_CERTIFICATE:
case SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER:
case SSL_R_TLSV1_ALERT_DECODE_ERROR:
case SSL_R_TLSV1_ALERT_DECRYPTION_FAILED:
case SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION:
case SSL_R_TLSV1_ALERT_INTERNAL_ERROR:
case SSL_R_TLSV1_ALERT_NO_RENEGOTIATION:
case SSL_R_TLSV1_ALERT_RECORD_OVERFLOW:
case SSL_R_TLSV1_ALERT_USER_CANCELLED:
return ERR_SSL_PROTOCOL_ERROR;
default:
LOG(WARNING) << "Unmapped error reason: " << ERR_GET_REASON(error_code);
return ERR_FAILED;
}
}
| 1
|
398,568
|
static plist_t parse_dict_node(struct bplist_data *bplist, const char** bnode, uint64_t size)
{
uint64_t j;
uint64_t str_i = 0, str_j = 0;
uint64_t index1, index2;
plist_data_t data = plist_new_plist_data();
const char *const end_data = bplist->data + bplist->size;
const char *index1_ptr = NULL;
const char *index2_ptr = NULL;
data->type = PLIST_DICT;
data->length = size;
plist_t node = node_create(NULL, data);
for (j = 0; j < data->length; j++) {
str_i = j * bplist->ref_size;
str_j = (j + size) * bplist->ref_size;
index1_ptr = (*bnode) + str_i;
index2_ptr = (*bnode) + str_j;
if ((index1_ptr < bplist->data || index1_ptr + bplist->ref_size >= end_data) ||
(index2_ptr < bplist->data || index2_ptr + bplist->ref_size >= end_data)) {
plist_free(node);
return NULL;
}
index1 = UINT_TO_HOST(index1_ptr, bplist->ref_size);
index2 = UINT_TO_HOST(index2_ptr, bplist->ref_size);
if (index1 >= bplist->num_objects) {
plist_free(node);
return NULL;
}
if (index2 >= bplist->num_objects) {
plist_free(node);
return NULL;
}
/* process key node */
plist_t key = parse_bin_node_at_index(bplist, index1);
if (!key) {
plist_free(node);
return NULL;
}
if (plist_get_data(key)->type != PLIST_STRING) {
fprintf(stderr, "ERROR: Malformed binary plist dict, invalid node type for key!\n");
plist_free(node);
return NULL;
}
/* enforce key type */
plist_get_data(key)->type = PLIST_KEY;
if (!plist_get_data(key)->strval) {
fprintf(stderr, "ERROR: Malformed binary plist dict, invalid key node encountered!\n");
plist_free(key);
plist_free(node);
return NULL;
}
/* process value node */
plist_t val = parse_bin_node_at_index(bplist, index2);
if (!val) {
plist_free(key);
plist_free(node);
return NULL;
}
node_attach(node, key);
node_attach(node, val);
}
return node;
}
| 0
|
238,456
|
struct _mdi *_WM_ParseNewXmi(uint8_t *xmi_data, uint32_t xmi_size) {
struct _mdi *xmi_mdi = NULL;
uint32_t xmi_tmpdata = 0;
uint8_t xmi_formcnt = 0;
uint32_t xmi_catlen = 0;
uint32_t xmi_subformlen = 0;
uint32_t i = 0;
uint32_t j = 0;
uint32_t xmi_evntlen = 0;
uint32_t xmi_divisions = 60;
uint32_t xmi_tempo = 500000;
uint32_t xmi_sample_count = 0;
float xmi_sample_count_f = 0.0;
float xmi_sample_remainder = 0.0;
float xmi_samples_per_delta_f = 0.0;
uint8_t xmi_ch = 0;
uint8_t xmi_note = 0;
uint32_t *xmi_notelen = NULL;
uint32_t setup_ret = 0;
uint32_t xmi_delta = 0;
uint32_t xmi_lowestdelta = 0;
uint32_t xmi_evnt_cnt = 0;
if (memcmp(xmi_data,"FORM",4)) {
_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);
return NULL;
}
xmi_data += 4;
xmi_size -= 4;
xmi_tmpdata = *xmi_data++ << 24;
xmi_tmpdata |= *xmi_data++ << 16;
xmi_tmpdata |= *xmi_data++ << 8;
xmi_tmpdata |= *xmi_data++;
xmi_size -= 4;
if (memcmp(xmi_data,"XDIRINFO",8)) {
_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);
return NULL;
}
xmi_data += 8;
xmi_size -= 8;
/*
0x00 0x00 0x00 0x02 at this point are unknown
so skip over them
*/
xmi_data += 4;
xmi_size -= 4;
xmi_formcnt = *xmi_data++;
if (xmi_formcnt == 0) {
_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);
return NULL;
}
xmi_size--;
/*
at this stage unsure if remaining data in
this section means anything
*/
xmi_tmpdata -= 13;
xmi_data += xmi_tmpdata;
xmi_size -= xmi_tmpdata;
/* FIXME: Check: may not even need to process CAT information */
if (memcmp(xmi_data,"CAT ",4)) {
_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);
return NULL;
}
xmi_data += 4;
xmi_size -= 4;
xmi_catlen = *xmi_data++ << 24;
xmi_catlen |= *xmi_data++ << 16;
xmi_catlen |= *xmi_data++ << 8;
xmi_catlen |= *xmi_data++;
xmi_size -= 4;
UNUSED(xmi_catlen);
if (memcmp(xmi_data,"XMID",4)) {
_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);
return NULL;
}
xmi_data += 4;
xmi_size -= 4;
xmi_mdi = _WM_initMDI();
_WM_midi_setup_divisions(xmi_mdi, xmi_divisions);
_WM_midi_setup_tempo(xmi_mdi, xmi_tempo);
xmi_samples_per_delta_f = _WM_GetSamplesPerTick(xmi_divisions, xmi_tempo);
xmi_notelen = malloc(sizeof(uint32_t) * 16 * 128);
memset(xmi_notelen, 0, (sizeof(uint32_t) * 16 * 128));
for (i = 0; i < xmi_formcnt; i++) {
if (memcmp(xmi_data,"FORM",4)) {
_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);
goto _xmi_end;
}
xmi_data += 4;
xmi_size -= 4;
xmi_subformlen = *xmi_data++ << 24;
xmi_subformlen |= *xmi_data++ << 16;
xmi_subformlen |= *xmi_data++ << 8;
xmi_subformlen |= *xmi_data++;
xmi_size -= 4;
if (memcmp(xmi_data,"XMID",4)) {
_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);
goto _xmi_end;
}
xmi_data += 4;
xmi_size -= 4;
xmi_subformlen -= 4;
do {
if (!memcmp(xmi_data,"TIMB",4)) {
xmi_data += 4;
xmi_tmpdata = *xmi_data++ << 24;
xmi_tmpdata |= *xmi_data++ << 16;
xmi_tmpdata |= *xmi_data++ << 8;
xmi_tmpdata |= *xmi_data++;
xmi_data += xmi_tmpdata;
xmi_size -= (8 + xmi_tmpdata);
xmi_subformlen -= (8 + xmi_tmpdata);
} else if (!memcmp(xmi_data,"RBRN",4)) {
xmi_data += 4;
xmi_tmpdata = *xmi_data++ << 24;
xmi_tmpdata |= *xmi_data++ << 16;
xmi_tmpdata |= *xmi_data++ << 8;
xmi_tmpdata |= *xmi_data++;
xmi_data += xmi_tmpdata;
xmi_size -= (8 + xmi_tmpdata);
xmi_subformlen -= (8 + xmi_tmpdata);
} else if (!memcmp(xmi_data,"EVNT",4)) {
xmi_data += 4;
xmi_evnt_cnt++;
xmi_evntlen = *xmi_data++ << 24;
xmi_evntlen |= *xmi_data++ << 16;
xmi_evntlen |= *xmi_data++ << 8;
xmi_evntlen |= *xmi_data++;
xmi_size -= 8;
xmi_subformlen -= 8;
do {
if (*xmi_data < 0x80) {
xmi_delta = 0;
if (*xmi_data > 0x7f) {
while (*xmi_data > 0x7f) {
xmi_delta = (xmi_delta << 7) | (*xmi_data++ & 0x7f);
xmi_size--;
xmi_evntlen--;
xmi_subformlen--;
}
}
xmi_delta = (xmi_delta << 7) | (*xmi_data++ & 0x7f);
xmi_size--;
xmi_evntlen--;
xmi_subformlen--;
do {
if ((xmi_lowestdelta != 0) && (xmi_lowestdelta <= xmi_delta)) {
xmi_tmpdata = xmi_lowestdelta;
} else {
xmi_tmpdata = xmi_delta;
}
xmi_sample_count_f= (((float) xmi_tmpdata * xmi_samples_per_delta_f) + xmi_sample_remainder);
xmi_sample_count = (uint32_t) xmi_sample_count_f;
xmi_sample_remainder = xmi_sample_count_f - (float) xmi_sample_count;
xmi_mdi->events[xmi_mdi->event_count - 1].samples_to_next += xmi_sample_count;
xmi_mdi->extra_info.approx_total_samples += xmi_sample_count;
xmi_lowestdelta = 0;
for (j = 0; j < (16*128); j++) {
if (xmi_notelen[j] == 0) continue;
xmi_notelen[j] -= xmi_tmpdata;
if (xmi_notelen[j] == 0) {
xmi_ch = j / 128;
xmi_note = j - (xmi_ch * 128);
_WM_midi_setup_noteoff(xmi_mdi, xmi_ch, xmi_note, 0);
} else {
if ((xmi_lowestdelta == 0) || (xmi_lowestdelta > xmi_notelen[j])) {
xmi_lowestdelta = xmi_notelen[j];
}
}
}
xmi_delta -= xmi_tmpdata;
} while (xmi_delta);
} else {
if ((xmi_data[0] == 0xff) && (xmi_data[1] == 0x51) && (xmi_data[2] == 0x03)) {
setup_ret = 6;
goto _XMI_Next_Event;
}
if ((setup_ret = _WM_SetupMidiEvent(xmi_mdi,xmi_data, xmi_size, 0)) == 0) {
goto _xmi_end;
}
if ((*xmi_data & 0xf0) == 0x90) {
xmi_ch = *xmi_data & 0x0f;
xmi_note = xmi_data[1];
xmi_data += setup_ret;
xmi_size -= setup_ret;
xmi_evntlen -= setup_ret;
xmi_subformlen -= setup_ret;
xmi_tmpdata = 0;
if (*xmi_data > 0x7f) {
while (*xmi_data > 0x7f) {
xmi_tmpdata = (xmi_tmpdata << 7) | (*xmi_data++ & 0x7f);
xmi_size--;
xmi_evntlen--;
xmi_subformlen--;
}
}
xmi_tmpdata = (xmi_tmpdata << 7) | (*xmi_data++ & 0x7f);
xmi_size--;
xmi_evntlen--;
xmi_subformlen--;
xmi_notelen[128 * xmi_ch + xmi_note] = xmi_tmpdata;
if ((xmi_tmpdata > 0) && ((xmi_lowestdelta == 0) || (xmi_tmpdata < xmi_lowestdelta))) {
xmi_lowestdelta = xmi_tmpdata;
}
} else {
_XMI_Next_Event:
xmi_data += setup_ret;
xmi_size -= setup_ret;
xmi_evntlen -= setup_ret;
xmi_subformlen -= setup_ret;
}
}
} while (xmi_evntlen);
} else {
_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_NOT_XMI, NULL, 0);
goto _xmi_end;
}
} while (xmi_subformlen);
}
if ((xmi_mdi->reverb = _WM_init_reverb(_WM_SampleRate, _WM_reverb_room_width, _WM_reverb_room_length, _WM_reverb_listen_posx, _WM_reverb_listen_posy)) == NULL) {
_WM_GLOBAL_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, "to init reverb", 0);
goto _xmi_end;
}
xmi_mdi->extra_info.current_sample = 0;
xmi_mdi->current_event = &xmi_mdi->events[0];
xmi_mdi->samples_to_mix = 0;
xmi_mdi->note = NULL;
/* More than 1 event form in XMI means treat as type 2 */
if (xmi_evnt_cnt > 1) {
xmi_mdi->is_type2 = 1;
}
_WM_ResetToStart(xmi_mdi);
_xmi_end:
if (xmi_notelen != NULL) free(xmi_notelen);
if (xmi_mdi->reverb) return (xmi_mdi);
_WM_freeMDI(xmi_mdi);
return NULL;
}
| 0
|
466,188
|
xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
xmlChar buf[XML_PARSER_BIG_BUFFER_SIZE + 5];
int nbchar = 0;
int cur, l;
int count = 0;
SHRINK;
GROW;
cur = CUR_CHAR(l);
while ((cur != '<') && /* checked */
(cur != '&') &&
(IS_CHAR(cur))) /* test also done in xmlCurrentChar() */ {
if ((cur == ']') && (NXT(1) == ']') &&
(NXT(2) == '>')) {
if (cdata) break;
else {
xmlFatalErr(ctxt, XML_ERR_MISPLACED_CDATA_END, NULL);
}
}
COPY_BUF(l,buf,nbchar,cur);
if (nbchar >= XML_PARSER_BIG_BUFFER_SIZE) {
buf[nbchar] = 0;
/*
* OK the segment is to be consumed as chars.
*/
if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
if (areBlanks(ctxt, buf, nbchar, 0)) {
if (ctxt->sax->ignorableWhitespace != NULL)
ctxt->sax->ignorableWhitespace(ctxt->userData,
buf, nbchar);
} else {
if (ctxt->sax->characters != NULL)
ctxt->sax->characters(ctxt->userData, buf, nbchar);
if ((ctxt->sax->characters !=
ctxt->sax->ignorableWhitespace) &&
(*ctxt->space == -1))
*ctxt->space = -2;
}
}
nbchar = 0;
/* something really bad happened in the SAX callback */
if (ctxt->instate != XML_PARSER_CONTENT)
return;
}
count++;
if (count > 50) {
SHRINK;
GROW;
count = 0;
if (ctxt->instate == XML_PARSER_EOF)
return;
}
NEXTL(l);
cur = CUR_CHAR(l);
}
if (nbchar != 0) {
buf[nbchar] = 0;
/*
* OK the segment is to be consumed as chars.
*/
if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
if (areBlanks(ctxt, buf, nbchar, 0)) {
if (ctxt->sax->ignorableWhitespace != NULL)
ctxt->sax->ignorableWhitespace(ctxt->userData, buf, nbchar);
} else {
if (ctxt->sax->characters != NULL)
ctxt->sax->characters(ctxt->userData, buf, nbchar);
if ((ctxt->sax->characters != ctxt->sax->ignorableWhitespace) &&
(*ctxt->space == -1))
*ctxt->space = -2;
}
}
}
if ((cur != 0) && (!IS_CHAR(cur))) {
/* Generate the error and skip the offending character */
xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
"PCDATA invalid Char value %d\n",
cur);
NEXTL(l);
}
}
| 0
|
329,486
|
void bdrv_info(void)
{
BlockDriverState *bs;
for (bs = bdrv_first; bs != NULL; bs = bs->next) {
term_printf("%s:", bs->device_name);
term_printf(" type=");
switch(bs->type) {
case BDRV_TYPE_HD:
term_printf("hd");
break;
case BDRV_TYPE_CDROM:
term_printf("cdrom");
break;
case BDRV_TYPE_FLOPPY:
term_printf("floppy");
break;
}
term_printf(" removable=%d", bs->removable);
if (bs->removable) {
term_printf(" locked=%d", bs->locked);
}
if (bs->drv) {
term_printf(" file=");
term_print_filename(bs->filename);
if (bs->backing_file[0] != '\0') {
term_printf(" backing_file=");
term_print_filename(bs->backing_file);
}
term_printf(" ro=%d", bs->read_only);
term_printf(" drv=%s", bs->drv->format_name);
if (bs->encrypted)
term_printf(" encrypted");
} else {
term_printf(" [not inserted]");
}
term_printf("\n");
}
}
| 0
|
54,317
|
static void close_and_free_request(struct wsgi_request *wsgi_req) {
// close the connection with the client
if (!wsgi_req->fd_closed) {
// NOTE, if we close the socket before receiving eventually sent data, socket layer will send a RST
wsgi_req->socket->proto_close(wsgi_req);
}
if (wsgi_req->post_file) {
fclose(wsgi_req->post_file);
}
if (wsgi_req->post_read_buf) {
free(wsgi_req->post_read_buf);
}
if (wsgi_req->post_readline_buf) {
free(wsgi_req->post_readline_buf);
}
if (wsgi_req->proto_parser_buf) {
free(wsgi_req->proto_parser_buf);
}
}
| 0
|
267,553
|
my_suspend_hook(my_bool suspend, void *data)
{
struct my_hook_data *hook_data= (struct my_hook_data *)data;
if (suspend)
{
hook_data->orig_pvio= hook_data->orig_mysql->net.pvio;
hook_data->orig_mysql->net.pvio= hook_data->new_mysql->net.pvio;
}
else
hook_data->orig_mysql->net.pvio= hook_data->orig_pvio;
}
| 0
|
102,163
|
void mp_encode_lua_table_as_array(lua_State *L, mp_buf *buf, int level) {
#if LUA_VERSION_NUM < 502
size_t len = lua_objlen(L,-1), j;
#else
size_t len = lua_rawlen(L,-1), j;
#endif
mp_encode_array(L,buf,len);
luaL_checkstack(L, 1, "in function mp_encode_lua_table_as_array");
for (j = 1; j <= len; j++) {
lua_pushnumber(L,j);
lua_gettable(L,-2);
mp_encode_lua_type(L,buf,level+1);
}
}
| 0
|
203,871
|
void Document::ReportFeaturePolicyViolation(
mojom::FeaturePolicyFeature feature,
mojom::FeaturePolicyDisposition disposition,
const String& message) const {
if (!RuntimeEnabledFeatures::FeaturePolicyReportingEnabled())
return;
LocalFrame* frame = GetFrame();
if (!frame)
return;
const String& feature_name = GetNameForFeature(feature);
FeaturePolicyViolationReportBody* body =
MakeGarbageCollected<FeaturePolicyViolationReportBody>(
feature_name, "Feature policy violation",
(disposition == mojom::FeaturePolicyDisposition::kReport ? "report"
: "enforce"),
SourceLocation::Capture());
Report* report =
new Report("feature-policy-violation", Url().GetString(), body);
ReportingContext::From(this)->QueueReport(report);
bool is_null;
int line_number = body->lineNumber(is_null);
line_number = is_null ? 0 : line_number;
int column_number = body->columnNumber(is_null);
column_number = is_null ? 0 : column_number;
frame->GetReportingService()->QueueFeaturePolicyViolationReport(
Url(), feature_name,
(disposition == mojom::FeaturePolicyDisposition::kReport ? "report"
: "enforce"),
"Feature policy violation", body->sourceFile(), line_number,
column_number);
if (disposition == mojom::FeaturePolicyDisposition::kEnforce) {
frame->Console().AddMessage(ConsoleMessage::Create(
kViolationMessageSource, kErrorMessageLevel,
(message.IsEmpty() ? ("Feature policy violation: " + feature_name +
" is not allowed in this document.")
: message)));
}
}
| 0
|
257,662
|
static int32_t U_CALLCONV uprv_swapArray32 ( const UDataSwapper * ds , const void * inData , int32_t length , void * outData , UErrorCode * pErrorCode ) {
const uint32_t * p ;
uint32_t * q ;
int32_t count ;
uint32_t x ;
if ( pErrorCode == NULL || U_FAILURE ( * pErrorCode ) ) {
return 0 ;
}
if ( ds == NULL || inData == NULL || length < 0 || ( length & 3 ) != 0 || outData == NULL ) {
* pErrorCode = U_ILLEGAL_ARGUMENT_ERROR ;
return 0 ;
}
p = ( const uint32_t * ) inData ;
q = ( uint32_t * ) outData ;
count = length / 4 ;
while ( count > 0 ) {
x = * p ++ ;
* q ++ = ( uint32_t ) ( ( x << 24 ) | ( ( x << 8 ) & 0xff0000 ) | ( ( x >> 8 ) & 0xff00 ) | ( x >> 24 ) ) ;
-- count ;
}
return length ;
}
| 0
|
86,749
|
TEST_F(RouterTest, TimeoutBudgetHistogramStatOnlyGlobal) {
NiceMock<Http::MockRequestEncoder> encoder;
Http::ResponseDecoder* response_decoder = nullptr;
expectNewStreamWithImmediateEncoder(encoder, &response_decoder, Http::Protocol::Http10);
expectPerTryTimerCreate();
Http::TestRequestHeaderMapImpl headers{{"x-envoy-upstream-rq-timeout-ms", "200"}};
HttpTestUtility::addDefaultHeaders(headers);
router_.decodeHeaders(headers, false);
Buffer::OwnedImpl data;
router_.decodeData(data, true);
EXPECT_EQ(1U,
callbacks_.route_->route_entry_.virtual_cluster_.stats().upstream_rq_total_.value());
// Global timeout budget used.
EXPECT_CALL(
cm_.thread_local_cluster_.cluster_.info_->timeout_budget_stats_store_,
deliverHistogramToSinks(
Property(&Stats::Metric::name, "upstream_rq_timeout_budget_percent_used"), 40ull));
// Per-try budget used is zero out of an infinite timeout.
EXPECT_CALL(
cm_.thread_local_cluster_.cluster_.info_->timeout_budget_stats_store_,
deliverHistogramToSinks(
Property(&Stats::Metric::name, "upstream_rq_timeout_budget_per_try_percent_used"), 0ull));
Http::ResponseHeaderMapPtr response_headers(
new Http::TestResponseHeaderMapImpl{{":status", "200"}});
response_decoder->decodeHeaders(std::move(response_headers), false);
test_time_.advanceTimeWait(std::chrono::milliseconds(80));
response_decoder->decodeData(data, true);
}
| 0
|
188,545
|
_exsltDateParseTime (exsltDateValDatePtr dt, const xmlChar **str)
{
const xmlChar *cur = *str;
unsigned int hour = 0; /* use temp var in case str is not xs:time */
int ret = 0;
PARSE_2_DIGITS(hour, cur, VALID_HOUR, ret);
if (ret != 0)
return ret;
if (*cur != ':')
return 1;
cur++;
/* the ':' insures this string is xs:time */
dt->hour = hour;
PARSE_2_DIGITS(dt->min, cur, VALID_MIN, ret);
if (ret != 0)
return ret;
if (*cur != ':')
return 1;
cur++;
PARSE_FLOAT(dt->sec, cur, ret);
if (ret != 0)
return ret;
if (!VALID_TIME(dt))
return 2;
*str = cur;
#ifdef DEBUG_EXSLT_DATE
xsltGenericDebug(xsltGenericDebugContext,
"Parsed time %02i:%02i:%02.f\n",
dt->hour, dt->min, dt->sec);
#endif
return 0;
}
| 0
|
90,153
|
int wcall_set_proxy(const char *host, int port)
{
return msystem_set_proxy(host, port);
}
| 0
|
83,246
|
static struct io_sq_data *io_attach_sq_data(struct io_uring_params *p)
{
struct io_ring_ctx *ctx_attach;
struct io_sq_data *sqd;
struct fd f;
f = fdget(p->wq_fd);
if (!f.file)
return ERR_PTR(-ENXIO);
if (f.file->f_op != &io_uring_fops) {
fdput(f);
return ERR_PTR(-EINVAL);
}
ctx_attach = f.file->private_data;
sqd = ctx_attach->sq_data;
if (!sqd) {
fdput(f);
return ERR_PTR(-EINVAL);
}
if (sqd->task_tgid != current->tgid) {
fdput(f);
return ERR_PTR(-EPERM);
}
refcount_inc(&sqd->refs);
fdput(f);
return sqd;
| 0
|
472,848
|
static BlockAIOCB *scsi_block_dma_readv(int64_t offset,
QEMUIOVector *iov,
BlockCompletionFunc *cb, void *cb_opaque,
void *opaque)
{
SCSIBlockReq *r = opaque;
return scsi_block_do_sgio(r, offset, iov,
SG_DXFER_FROM_DEV, cb, cb_opaque);
}
| 0
|
178,005
|
status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
ALOGV("configureCodec protected=%d",
(mFlags & kEnableGrallocUsageProtected) ? 1 : 0);
if (!(mFlags & kIgnoreCodecSpecificData)) {
uint32_t type;
const void *data;
size_t size;
if (meta->findData(kKeyESDS, &type, &data, &size)) {
ESDS esds((const char *)data, size);
CHECK_EQ(esds.InitCheck(), (status_t)OK);
const void *codec_specific_data;
size_t codec_specific_data_size;
esds.getCodecSpecificInfo(
&codec_specific_data, &codec_specific_data_size);
addCodecSpecificData(
codec_specific_data, codec_specific_data_size);
} else if (meta->findData(kKeyAVCC, &type, &data, &size)) {
unsigned profile, level;
status_t err;
if ((err = parseAVCCodecSpecificData(
data, size, &profile, &level)) != OK) {
ALOGE("Malformed AVC codec specific data.");
return err;
}
CODEC_LOGI(
"AVC profile = %u (%s), level = %u",
profile, AVCProfileToString(profile), level);
} else if (meta->findData(kKeyHVCC, &type, &data, &size)) {
unsigned profile, level;
status_t err;
if ((err = parseHEVCCodecSpecificData(
data, size, &profile, &level)) != OK) {
ALOGE("Malformed HEVC codec specific data.");
return err;
}
CODEC_LOGI(
"HEVC profile = %u , level = %u",
profile, level);
} else if (meta->findData(kKeyVorbisInfo, &type, &data, &size)) {
addCodecSpecificData(data, size);
CHECK(meta->findData(kKeyVorbisBooks, &type, &data, &size));
addCodecSpecificData(data, size);
} else if (meta->findData(kKeyOpusHeader, &type, &data, &size)) {
addCodecSpecificData(data, size);
CHECK(meta->findData(kKeyOpusCodecDelay, &type, &data, &size));
addCodecSpecificData(data, size);
CHECK(meta->findData(kKeyOpusSeekPreRoll, &type, &data, &size));
addCodecSpecificData(data, size);
}
}
int32_t bitRate = 0;
if (mIsEncoder) {
CHECK(meta->findInt32(kKeyBitRate, &bitRate));
}
if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_NB, mMIME)) {
setAMRFormat(false /* isWAMR */, bitRate);
} else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_WB, mMIME)) {
setAMRFormat(true /* isWAMR */, bitRate);
} else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AAC, mMIME)) {
int32_t numChannels, sampleRate, aacProfile;
CHECK(meta->findInt32(kKeyChannelCount, &numChannels));
CHECK(meta->findInt32(kKeySampleRate, &sampleRate));
if (!meta->findInt32(kKeyAACProfile, &aacProfile)) {
aacProfile = OMX_AUDIO_AACObjectNull;
}
int32_t isADTS;
if (!meta->findInt32(kKeyIsADTS, &isADTS)) {
isADTS = false;
}
status_t err = setAACFormat(numChannels, sampleRate, bitRate, aacProfile, isADTS);
if (err != OK) {
CODEC_LOGE("setAACFormat() failed (err = %d)", err);
return err;
}
} else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_MPEG, mMIME)) {
int32_t numChannels, sampleRate;
if (meta->findInt32(kKeyChannelCount, &numChannels)
&& meta->findInt32(kKeySampleRate, &sampleRate)) {
setRawAudioFormat(
mIsEncoder ? kPortIndexInput : kPortIndexOutput,
sampleRate,
numChannels);
}
} else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AC3, mMIME)) {
int32_t numChannels;
int32_t sampleRate;
CHECK(meta->findInt32(kKeyChannelCount, &numChannels));
CHECK(meta->findInt32(kKeySampleRate, &sampleRate));
status_t err = setAC3Format(numChannels, sampleRate);
if (err != OK) {
CODEC_LOGE("setAC3Format() failed (err = %d)", err);
return err;
}
} else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_G711_ALAW, mMIME)
|| !strcasecmp(MEDIA_MIMETYPE_AUDIO_G711_MLAW, mMIME)) {
int32_t sampleRate;
int32_t numChannels;
CHECK(meta->findInt32(kKeyChannelCount, &numChannels));
if (!meta->findInt32(kKeySampleRate, &sampleRate)) {
sampleRate = 8000;
}
setG711Format(sampleRate, numChannels);
} else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_RAW, mMIME)) {
CHECK(!mIsEncoder);
int32_t numChannels, sampleRate;
CHECK(meta->findInt32(kKeyChannelCount, &numChannels));
CHECK(meta->findInt32(kKeySampleRate, &sampleRate));
setRawAudioFormat(kPortIndexInput, sampleRate, numChannels);
}
if (!strncasecmp(mMIME, "video/", 6)) {
if (mIsEncoder) {
setVideoInputFormat(mMIME, meta);
} else {
status_t err = setVideoOutputFormat(
mMIME, meta);
if (err != OK) {
return err;
}
}
}
int32_t maxInputSize;
if (meta->findInt32(kKeyMaxInputSize, &maxInputSize)) {
setMinBufferSize(kPortIndexInput, (OMX_U32)maxInputSize);
}
initOutputFormat(meta);
if (mNativeWindow != NULL
&& !mIsEncoder
&& !strncasecmp(mMIME, "video/", 6)
&& !strncmp(mComponentName, "OMX.", 4)) {
status_t err = initNativeWindow();
if (err != OK) {
return err;
}
}
return OK;
}
| 0
|
31,559
|
static void unpack_3(const uint8_t b[3], uint16_t s[16])
{
int i;
s[0] = (b[0] << 8) | b[1];
if (s[0] & 0x8000)
s[0] &= 0x7fff;
else
s[0] = ~s[0];
for (i = 1; i < 16; i++)
s[i] = s[0];
}
| 0
|
206,598
|
Ins_Goto_CodeRange( EXEC_OP_ FT_Int aRange,
FT_ULong aIP )
{
TT_CodeRange* range;
if ( aRange < 1 || aRange > 3 )
{
CUR.error = TT_Err_Bad_Argument;
return FAILURE;
}
range = &CUR.codeRangeTable[aRange - 1];
if ( range->base == NULL ) /* invalid coderange */
{
CUR.error = TT_Err_Invalid_CodeRange;
return FAILURE;
}
/* NOTE: Because the last instruction of a program may be a CALL */
/* which will return to the first byte *after* the code */
/* range, we test for AIP <= Size, instead of AIP < Size. */
if ( aIP > range->size )
{
CUR.error = TT_Err_Code_Overflow;
return FAILURE;
}
CUR.code = range->base;
CUR.codeSize = range->size;
CUR.IP = aIP;
CUR.curRange = aRange;
return SUCCESS;
}
| 0
|
445,398
|
bool createUpgradeFilterChain(absl::string_view, const Http::FilterChainFactory::UpgradeMap*,
Http::FilterChainFactoryCallbacks&) override {
return false;
}
| 0
|
376,649
|
void HEnvironment::PrintTo(StringStream* stream) {
for (int i = 0; i < length(); i++) {
if (i == 0) stream->Add("parameters\n");
if (i == parameter_count()) stream->Add("specials\n");
if (i == parameter_count() + specials_count()) stream->Add("locals\n");
if (i == parameter_count() + specials_count() + local_count()) {
stream->Add("expressions\n");
}
HValue* val = values_.at(i);
stream->Add("%d: ", i);
if (val != NULL) {
val->PrintNameTo(stream);
} else {
stream->Add("NULL");
}
stream->Add("\n");
}
PrintF("\n");
}
| 0
|
204,243
|
void GDataFileSystem::OnTransferCompleted(
const FileOperationCallback& callback,
GDataFileError error,
scoped_ptr<UploadFileInfo> upload_file_info) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(upload_file_info.get());
if (error == GDATA_FILE_OK && upload_file_info->entry.get()) {
AddUploadedFile(UPLOAD_NEW_FILE,
upload_file_info->gdata_path.DirName(),
upload_file_info->entry.Pass(),
upload_file_info->file_path,
GDataCache::FILE_OPERATION_COPY,
base::Bind(&OnAddUploadFileCompleted, callback, error));
} else if (!callback.is_null()) {
callback.Run(error);
}
}
| 0
|
368,203
|
cached_resolves_eq(cached_resolve_t *a, cached_resolve_t *b)
{
/* make this smarter one day? */
assert_resolve_ok(a); // Not b; b may be just a search.
return !strncmp(a->address, b->address, MAX_ADDRESSLEN);
}
| 0
|
145,132
|
TEST(DenseOpticalFlow_DIS, ReferenceAccuracy)
{
Mat frame1, frame2, GT;
ASSERT_TRUE(readRubberWhale(frame1, frame2, GT));
int presets[] = {DISOpticalFlow::PRESET_ULTRAFAST, DISOpticalFlow::PRESET_FAST, DISOpticalFlow::PRESET_MEDIUM};
float target_RMSE[] = {0.86f, 0.74f, 0.49f};
cvtColor(frame1, frame1, COLOR_BGR2GRAY);
cvtColor(frame2, frame2, COLOR_BGR2GRAY);
Ptr<DenseOpticalFlow> algo;
// iterate over presets:
for (int i = 0; i < 3; i++)
{
Mat flow;
algo = DISOpticalFlow::create(presets[i]);
algo->calc(frame1, frame2, flow);
ASSERT_EQ(GT.rows, flow.rows);
ASSERT_EQ(GT.cols, flow.cols);
EXPECT_LE(calcRMSE(GT, flow), target_RMSE[i]);
}
}
| 0
|
198,215
|
static uint32_t div_frac(uint32_t dividend, uint32_t divisor)
{
uint32_t quotient, remainder;
/* Don't try to replace with do_div(), this one calculates
* "(dividend << 32) / divisor" */
__asm__ ( "divl %4"
: "=a" (quotient), "=d" (remainder)
: "0" (0), "1" (dividend), "r" (divisor) );
return quotient;
}
| 0
|
428,578
|
g_file_unmount_mountable (GFile *file,
GMountUnmountFlags flags,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GFileIface *iface;
g_return_if_fail (G_IS_FILE (file));
iface = G_FILE_GET_IFACE (file);
if (iface->unmount_mountable == NULL)
{
g_task_report_new_error (file, callback, user_data,
g_file_unmount_mountable_with_operation,
G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
_("Operation not supported"));
return;
}
(* iface->unmount_mountable) (file,
flags,
cancellable,
callback,
user_data);
}
| 0
|
149,097
|
vhost_user_unlock_all_queue_pairs(struct virtio_net *dev)
{
unsigned int i = 0;
unsigned int vq_num = 0;
while (vq_num < dev->nr_vring) {
struct vhost_virtqueue *vq = dev->virtqueue[i];
if (vq) {
rte_spinlock_unlock(&vq->access_lock);
vq_num++;
}
i++;
}
}
| 0
|
272,959
|
static int _epoll_close(oe_fd_t* epoll_)
{
int ret = -1;
epoll_t* epoll = _cast_epoll(epoll_);
int retval = -1;
oe_errno = 0;
if (!epoll)
OE_RAISE_ERRNO(OE_EINVAL);
/* Close the file descriptor on the host side. */
if (oe_syscall_epoll_close_ocall(&retval, epoll->host_fd) != OE_OK)
OE_RAISE_ERRNO(OE_EINVAL);
if (retval == -1)
OE_RAISE_ERRNO(oe_errno);
if (epoll->map)
oe_free(epoll->map);
oe_free(epoll);
ret = 0;
done:
return ret;
}
| 0
|
245,185
|
static bool IsDangerousHTTPEquiv(const String& value) {
String equiv = value.StripWhiteSpace();
return DeprecatedEqualIgnoringCase(equiv, "refresh") ||
DeprecatedEqualIgnoringCase(equiv, "set-cookie");
}
| 0
|
41,007
|
init_method_ref(PyObject *self, _Py_Identifier *name,
PyObject **method_func, PyObject **method_self)
{
PyObject *func, *func2;
int ret;
/* *method_func and *method_self should be consistent. All refcount decrements
should be occurred after setting *method_self and *method_func. */
ret = _PyObject_LookupAttrId(self, name, &func);
if (func == NULL) {
*method_self = NULL;
Py_CLEAR(*method_func);
return ret;
}
if (PyMethod_Check(func) && PyMethod_GET_SELF(func) == self) {
/* Deconstruct a bound Python method */
func2 = PyMethod_GET_FUNCTION(func);
Py_INCREF(func2);
*method_self = self; /* borrowed */
Py_XSETREF(*method_func, func2);
Py_DECREF(func);
return 0;
}
else {
*method_self = NULL;
Py_XSETREF(*method_func, func);
return 0;
}
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.