func
stringlengths 12
2.67k
| cwe
stringclasses 7
values | __index_level_0__
int64 0
20k
|
|---|---|---|
explicit MaxPoolingGradGradOp(OpKernelConstruction* context)
: OpKernel(context) {
string data_format;
OP_REQUIRES_OK(context, context->GetAttr("data_format", &data_format));
OP_REQUIRES(context, FormatFromString(data_format, &data_format_),
errors::InvalidArgument("Invalid data format"));
OP_REQUIRES(
context, data_format_ == FORMAT_NHWC,
errors::InvalidArgument(
"Default MaxPoolingGradGradOp only supports NHWC ",
"on device type ", DeviceTypeString(context->device_type())));
OP_REQUIRES_OK(context, context->GetAttr("padding", &padding_));
if (context->num_inputs() == 3) {
OP_REQUIRES_OK(context, context->GetAttr("ksize", &ksize_));
OP_REQUIRES(context, ksize_.size() == 4,
errors::InvalidArgument("Sliding window ksize field must "
"specify 4 dimensions"));
OP_REQUIRES_OK(context, context->GetAttr("strides", &stride_));
OP_REQUIRES(context, stride_.size() == 4,
errors::InvalidArgument("Sliding window strides field must "
"specify 4 dimensions"));
OP_REQUIRES(context, ksize_[0] == 1 && stride_[0] == 1,
errors::Unimplemented(
"Pooling is not yet supported on the batch dimension."));
OP_REQUIRES(context, ksize_[3] == 1 && stride_[3] == 1,
errors::Unimplemented("MaxPoolingGradGrad is not yet "
"supported on the depth dimension."));
}
}
|
safe
| 702
|
TEST_P(Security, BuiltinAuthenticationAndCryptoPlugin_payload_ok_same_participant)
{
PubSubWriterReader<HelloWorldType> wreader(TEST_TOPIC_NAME);
PropertyPolicy pub_property_policy, sub_property_policy,
property_policy;
property_policy.properties().emplace_back(Property("dds.sec.auth.plugin",
"builtin.PKI-DH"));
property_policy.properties().emplace_back(Property("dds.sec.auth.builtin.PKI-DH.identity_ca",
"file://" + std::string(certs_path) + "/maincacert.pem"));
property_policy.properties().emplace_back(Property("dds.sec.auth.builtin.PKI-DH.identity_certificate",
"file://" + std::string(certs_path) + "/mainpubcert.pem"));
property_policy.properties().emplace_back(Property("dds.sec.auth.builtin.PKI-DH.private_key",
"file://" + std::string(certs_path) + "/mainpubkey.pem"));
property_policy.properties().emplace_back(Property("dds.sec.crypto.plugin",
"builtin.AES-GCM-GMAC"));
pub_property_policy.properties().emplace_back("rtps.endpoint.payload_protection_kind", "ENCRYPT");
sub_property_policy.properties().emplace_back("rtps.endpoint.payload_protection_kind", "ENCRYPT");
wreader.sub_history_depth(10).sub_reliability(eprosima::fastrtps::RELIABLE_RELIABILITY_QOS);
wreader.property_policy(property_policy).
pub_property_policy(pub_property_policy).
sub_property_policy(sub_property_policy).init();
ASSERT_TRUE(wreader.isInitialized());
// Wait for discovery.
wreader.wait_discovery();
auto data = default_helloworld_data_generator();
wreader.startReception(data);
// Send data
wreader.send(data);
// In this test all data should be sent.
ASSERT_TRUE(data.empty());
// Block reader until reception finished or timeout.
wreader.block_for_all();
}
|
safe
| 703
|
gimp_channel_set_buffer (GimpDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
GeglBuffer *buffer,
const GeglRectangle *bounds)
{
GimpChannel *channel = GIMP_CHANNEL (drawable);
GeglBuffer *old_buffer = gimp_drawable_get_buffer (drawable);
if (old_buffer)
{
g_signal_handlers_disconnect_by_func (old_buffer,
gimp_channel_buffer_changed,
channel);
}
GIMP_DRAWABLE_CLASS (parent_class)->set_buffer (drawable,
push_undo, undo_desc,
buffer, bounds);
gegl_buffer_signal_connect (buffer, "changed",
G_CALLBACK (gimp_channel_buffer_changed),
channel);
if (gimp_filter_peek_node (GIMP_FILTER (channel)))
{
const Babl *color_format;
if (gimp_drawable_get_linear (drawable))
color_format = babl_format ("RGBA float");
else
color_format = babl_format ("R'G'B'A float");
gegl_node_set (channel->color_node,
"format", color_format,
NULL);
}
}
|
safe
| 704
|
static ssize_t qrtr_tun_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
struct file *filp = iocb->ki_filp;
struct qrtr_tun *tun = filp->private_data;
size_t len = iov_iter_count(from);
ssize_t ret;
void *kbuf;
kbuf = kzalloc(len, GFP_KERNEL);
if (!kbuf)
return -ENOMEM;
if (!copy_from_iter_full(kbuf, len, from)) {
kfree(kbuf);
return -EFAULT;
}
ret = qrtr_endpoint_post(&tun->ep, kbuf, len);
kfree(kbuf);
return ret < 0 ? ret : len;
}
|
safe
| 705
|
md_analyze_table_alignment(MD_CTX* ctx, OFF beg, OFF end, MD_ALIGN* align, int n_align)
{
static const MD_ALIGN align_map[] = { MD_ALIGN_DEFAULT, MD_ALIGN_LEFT, MD_ALIGN_RIGHT, MD_ALIGN_CENTER };
OFF off = beg;
while(n_align > 0) {
int index = 0; /* index into align_map[] */
while(CH(off) != _T('-'))
off++;
if(off > beg && CH(off-1) == _T(':'))
index |= 1;
while(off < end && CH(off) == _T('-'))
off++;
if(off < end && CH(off) == _T(':'))
index |= 2;
*align = align_map[index];
align++;
n_align--;
}
}
|
safe
| 706
|
static u32 tcm_loop_get_pr_transport_id_len(
struct se_portal_group *se_tpg,
struct se_node_acl *se_nacl,
struct t10_pr_registration *pr_reg,
int *format_code)
{
struct tcm_loop_tpg *tl_tpg =
(struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr;
struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba;
switch (tl_hba->tl_proto_id) {
case SCSI_PROTOCOL_SAS:
return sas_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,
format_code);
case SCSI_PROTOCOL_FCP:
return fc_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,
format_code);
case SCSI_PROTOCOL_ISCSI:
return iscsi_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,
format_code);
default:
printk(KERN_ERR "Unknown tl_proto_id: 0x%02x, using"
" SAS emulation\n", tl_hba->tl_proto_id);
break;
}
return sas_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,
format_code);
}
|
safe
| 707
|
template<typename t>
CImg(const CImg<t>& img, const bool is_shared):_is_shared(false) {
if (is_shared) {
_width = _height = _depth = _spectrum = 0; _data = 0;
throw CImgArgumentException(_cimg_instance
"CImg(): Invalid construction request of a shared instance from a "
"CImg<%s> image (%u,%u,%u,%u,%p) (pixel types are different).",
cimg_instance,
CImg<t>::pixel_type(),img._width,img._height,img._depth,img._spectrum,img._data);
}
const size_t siz = (size_t)img.size();
if (img._data && siz) {
_width = img._width; _height = img._height; _depth = img._depth; _spectrum = img._spectrum;
try { _data = new T[siz]; } catch (...) {
_width = _height = _depth = _spectrum = 0; _data = 0;
throw CImgInstanceException(_cimg_instance
"CImg(): Failed to allocate memory (%s) for image (%u,%u,%u,%u).",
cimg_instance,
cimg::strbuffersize(sizeof(T)*img._width*img._height*img._depth*img._spectrum),
img._width,img._height,img._depth,img._spectrum);
}
const t *ptrs = img._data; cimg_for(*this,ptrd,T) *ptrd = (T)*(ptrs++);
} else { _width = _height = _depth = _spectrum = 0; _data = 0; }
|
safe
| 708
|
static int uvc_scan_chain_entity(struct uvc_video_device *video,
struct uvc_entity *entity)
{
switch (UVC_ENTITY_TYPE(entity)) {
case VC_EXTENSION_UNIT:
if (uvc_trace_param & UVC_TRACE_PROBE)
printk(" <- XU %d", entity->id);
if (entity->extension.bNrInPins != 1) {
uvc_trace(UVC_TRACE_DESCR, "Extension unit %d has more "
"than 1 input pin.\n", entity->id);
return -1;
}
list_add_tail(&entity->chain, &video->extensions);
break;
case VC_PROCESSING_UNIT:
if (uvc_trace_param & UVC_TRACE_PROBE)
printk(" <- PU %d", entity->id);
if (video->processing != NULL) {
uvc_trace(UVC_TRACE_DESCR, "Found multiple "
"Processing Units in chain.\n");
return -1;
}
video->processing = entity;
break;
case VC_SELECTOR_UNIT:
if (uvc_trace_param & UVC_TRACE_PROBE)
printk(" <- SU %d", entity->id);
/* Single-input selector units are ignored. */
if (entity->selector.bNrInPins == 1)
break;
if (video->selector != NULL) {
uvc_trace(UVC_TRACE_DESCR, "Found multiple Selector "
"Units in chain.\n");
return -1;
}
video->selector = entity;
break;
case ITT_VENDOR_SPECIFIC:
case ITT_CAMERA:
case ITT_MEDIA_TRANSPORT_INPUT:
if (uvc_trace_param & UVC_TRACE_PROBE)
printk(" <- IT %d\n", entity->id);
list_add_tail(&entity->chain, &video->iterms);
break;
default:
uvc_trace(UVC_TRACE_DESCR, "Unsupported entity type "
"0x%04x found in chain.\n", UVC_ENTITY_TYPE(entity));
return -1;
}
return 0;
}
|
safe
| 709
|
PHP_FUNCTION(stream_get_wrappers)
{
HashTable *url_stream_wrappers_hash;
char *stream_protocol;
int key_flags;
uint stream_protocol_len = 0;
ulong num_key;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if ((url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash())) {
HashPosition pos;
array_init(return_value);
for (zend_hash_internal_pointer_reset_ex(url_stream_wrappers_hash, &pos);
(key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTENT;
zend_hash_move_forward_ex(url_stream_wrappers_hash, &pos)) {
if (key_flags == HASH_KEY_IS_STRING) {
add_next_index_stringl(return_value, stream_protocol, stream_protocol_len - 1, 1);
}
}
} else {
RETURN_FALSE;
}
}
|
safe
| 710
|
ChooseExtendedStatisticNameAddition(List *exprs)
{
char buf[NAMEDATALEN * 2];
int buflen = 0;
ListCell *lc;
buf[0] = '\0';
foreach(lc, exprs)
{
ColumnRef *cref = (ColumnRef *) lfirst(lc);
const char *name;
/* It should be one of these, but just skip if it happens not to be */
if (!IsA(cref, ColumnRef))
continue;
name = strVal((Value *) linitial(cref->fields));
if (buflen > 0)
buf[buflen++] = '_'; /* insert _ between names */
/*
* At this point we have buflen <= NAMEDATALEN. name should be less
* than NAMEDATALEN already, but use strlcpy for paranoia.
*/
strlcpy(buf + buflen, name, NAMEDATALEN);
buflen += strlen(buf + buflen);
if (buflen >= NAMEDATALEN)
break;
}
return pstrdup(buf);
}
|
safe
| 711
|
SMB2_sess_sendreceive(struct SMB2_sess_data *sess_data)
{
int rc;
struct smb_rqst rqst;
struct smb2_sess_setup_req *req = sess_data->iov[0].iov_base;
struct kvec rsp_iov = { NULL, 0 };
/* Testing shows that buffer offset must be at location of Buffer[0] */
req->SecurityBufferOffset =
cpu_to_le16(sizeof(struct smb2_sess_setup_req) - 1 /* pad */);
req->SecurityBufferLength = cpu_to_le16(sess_data->iov[1].iov_len);
memset(&rqst, 0, sizeof(struct smb_rqst));
rqst.rq_iov = sess_data->iov;
rqst.rq_nvec = 2;
/* BB add code to build os and lm fields */
rc = cifs_send_recv(sess_data->xid, sess_data->ses,
&rqst,
&sess_data->buf0_type,
CIFS_LOG_ERROR | CIFS_NEG_OP, &rsp_iov);
cifs_small_buf_release(sess_data->iov[0].iov_base);
memcpy(&sess_data->iov[0], &rsp_iov, sizeof(struct kvec));
return rc;
}
|
safe
| 712
|
bool switch_to_ns(pid_t pid, const char *ns) {
int fd, ret;
char nspath[MAXPATHLEN];
/* Switch to new ns */
ret = snprintf(nspath, MAXPATHLEN, "/proc/%d/ns/%s", pid, ns);
if (ret < 0 || ret >= MAXPATHLEN)
return false;
fd = open(nspath, O_RDONLY);
if (fd < 0) {
SYSERROR("failed to open %s", nspath);
return false;
}
ret = setns(fd, 0);
if (ret) {
SYSERROR("failed to set process %d to %s of %d.", pid, ns, fd);
close(fd);
return false;
}
close(fd);
return true;
}
|
safe
| 713
|
static int parse_filter_data(struct rar5* rar, const uint8_t* p,
uint32_t* filter_data)
{
int i, bytes;
uint32_t data = 0;
if(ARCHIVE_OK != read_consume_bits(rar, p, 2, &bytes))
return ARCHIVE_EOF;
bytes++;
for(i = 0; i < bytes; i++) {
uint16_t byte;
if(ARCHIVE_OK != read_bits_16(rar, p, &byte)) {
return ARCHIVE_EOF;
}
/* Cast to uint32_t will ensure the shift operation will not
* produce undefined result. */
data += ((uint32_t) byte >> 8) << (i * 8);
skip_bits(rar, 8);
}
*filter_data = data;
return ARCHIVE_OK;
}
|
safe
| 714
|
int RunningSignBit(const TfLiteTensor* input, const TfLiteTensor* weight,
float seed) {
double score = 0.0;
int input_item_bytes = input->bytes / SizeOfDimension(input, 0);
char* input_ptr = input->data.raw;
const size_t seed_size = sizeof(float);
const size_t key_bytes = sizeof(float) + input_item_bytes;
std::unique_ptr<char[]> key(new char[key_bytes]);
const float* weight_ptr = GetTensorData<float>(weight);
for (int i = 0; i < SizeOfDimension(input, 0); ++i) {
// Create running hash id and value for current dimension.
memcpy(key.get(), &seed, seed_size);
memcpy(key.get() + seed_size, input_ptr, input_item_bytes);
int64_t hash_signature = ::util::Fingerprint64(key.get(), key_bytes);
double running_value = static_cast<double>(hash_signature);
input_ptr += input_item_bytes;
if (weight_ptr == nullptr) {
score += running_value;
} else {
score += weight_ptr[i] * running_value;
}
}
return (score > 0) ? 1 : 0;
}
|
safe
| 715
|
SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
{
struct path path;
struct mount *mnt;
int retval;
int lookup_flags = 0;
if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW))
return -EINVAL;
if (!may_mount())
return -EPERM;
if (!(flags & UMOUNT_NOFOLLOW))
lookup_flags |= LOOKUP_FOLLOW;
retval = user_path_mountpoint_at(AT_FDCWD, name, lookup_flags, &path);
if (retval)
goto out;
mnt = real_mount(path.mnt);
retval = -EINVAL;
if (path.dentry != path.mnt->mnt_root)
goto dput_and_out;
if (!check_mnt(mnt))
goto dput_and_out;
if (mnt->mnt.mnt_flags & MNT_LOCKED)
goto dput_and_out;
retval = do_umount(mnt, flags);
dput_and_out:
/* we mustn't call path_put() as that would clear mnt_expiry_mark */
dput(path.dentry);
mntput_no_expire(mnt);
out:
return retval;
}
|
safe
| 716
|
void Server::msgVersion(ServerUser *uSource, MumbleProto::Version &msg) {
if (msg.has_version())
uSource->uiVersion=msg.version();
if (msg.has_release())
uSource->qsRelease = u8(msg.release());
if (msg.has_os()) {
uSource->qsOS = u8(msg.os());
if (msg.has_os_version())
uSource->qsOSVersion = u8(msg.os_version());
}
log(uSource, QString("Client version %1.%2.%3 (%4: %5)").arg(uSource->uiVersion >> 16).arg((uSource->uiVersion >> 8) & 0xff).arg(uSource->uiVersion & 0xFF).arg(uSource->qsOS).arg(uSource->qsRelease));
}
|
safe
| 717
|
GF_Err mdcv_box_dump(GF_Box *a, FILE * trace)
{
int c = 0;
GF_MasteringDisplayColourVolumeBox *ptr = (GF_MasteringDisplayColourVolumeBox *)a;
if (!a) return GF_BAD_PARAM;
gf_isom_box_dump_start(a, "MasteringDisplayColourVolumeBox", trace);
for (c = 0; c < 3; c++) {
gf_fprintf(trace, "display_primaries_%d_x=\"%u\" display_primaries_%d_y=\"%u\" ", c, ptr->mdcv.display_primaries[c].x, c, ptr->mdcv.display_primaries[c].y);
}
gf_fprintf(trace, "white_point_x=\"%u\" white_point_y=\"%u\" max_display_mastering_luminance=\"%u\" min_display_mastering_luminance=\"%u\">\n", ptr->mdcv.white_point_x, ptr->mdcv.white_point_y, ptr->mdcv.max_display_mastering_luminance, ptr->mdcv.min_display_mastering_luminance);
gf_isom_box_dump_done("MasteringDisplayColourVolumeBox", a, trace);
return GF_OK;
}
|
safe
| 718
|
name2var(const char *name, void *encoding) {
VALUE *slot;
ID var_id;
if ('0' <= *name && *name <= '9') {
var_id = INT2NUM(atoi(name));
} else if (Qundef == (var_id = ox_cache_get(ox_attr_cache, name, &slot, 0))) {
#ifdef HAVE_RUBY_ENCODING_H
if (0 != encoding) {
volatile VALUE rstr = rb_str_new2(name);
volatile VALUE sym;
rb_enc_associate(rstr, (rb_encoding*)encoding);
sym = rb_funcall(rstr, ox_to_sym_id, 0);
// Needed for Ruby 2.2 to get around the GC of symbols
// created with to_sym which is needed for encoded symbols.
rb_ary_push(ox_sym_bank, sym);
var_id = SYM2ID(sym);
} else {
var_id = rb_intern(name);
}
#else
var_id = rb_intern(name);
#endif
*slot = var_id;
}
return var_id;
}
|
safe
| 719
|
read_hexstring(const char *l2string, u_char *hex, const int hexlen)
{
int numbytes = 0;
unsigned int value;
char *l2byte;
u_char databyte;
char *token = NULL;
char *string;
string = safe_strdup(l2string);
if (hexlen <= 0)
err(-1, "Hex buffer must be > 0");
memset(hex, '\0', hexlen);
/* data is hex, comma seperated, byte by byte */
/* get the first byte */
l2byte = strtok_r(string, ",", &token);
sscanf(l2byte, "%x", &value);
if (value > 0xff)
errx(-1, "Invalid hex string byte: %s", l2byte);
databyte = (u_char) value;
memcpy(&hex[numbytes], &databyte, 1);
/* get remaining bytes */
while ((l2byte = strtok_r(NULL, ",", &token)) != NULL) {
numbytes++;
if (numbytes + 1 > hexlen) {
warn("Hex buffer too small for data- skipping data");
goto done;
}
sscanf(l2byte, "%x", &value);
if (value > 0xff)
errx(-1, "Invalid hex string byte: %s", l2byte);
databyte = (u_char) value;
memcpy(&hex[numbytes], &databyte, 1);
}
numbytes++;
done:
safe_free(string);
dbgx(1, "Read %d bytes of hex data", numbytes);
return (numbytes);
}
|
safe
| 720
|
static u8 iwlagn_key_sta_id(struct iwl_priv *priv,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta)
{
struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv;
u8 sta_id = IWL_INVALID_STATION;
if (sta)
sta_id = iwl_sta_id(sta);
/*
* The device expects GTKs for station interfaces to be
* installed as GTKs for the AP station. If we have no
* station ID, then use the ap_sta_id in that case.
*/
if (!sta && vif && vif_priv->ctx) {
switch (vif->type) {
case NL80211_IFTYPE_STATION:
sta_id = vif_priv->ctx->ap_sta_id;
break;
default:
/*
* In all other cases, the key will be
* used either for TX only or is bound
* to a station already.
*/
break;
}
}
return sta_id;
}
|
safe
| 721
|
R_API void r_bin_java_print_verification_info_summary(RBinJavaVerificationObj *obj) {
ut8 tag_value = R_BIN_JAVA_STACKMAP_UNKNOWN;
if (!obj) {
eprintf ("Attempting to print an invalid RBinJavaVerificationObj* .\n");
return;
}
if (obj->tag < R_BIN_JAVA_STACKMAP_UNKNOWN) {
tag_value = obj->tag;
}
printf ("Verification Information\n");
printf (" Offset: 0x%08"PFMT64x "", obj->file_offset);
printf (" Tag Value = 0x%02x\n", obj->tag);
printf (" Name = %s\n", R_BIN_JAVA_VERIFICATION_METAS[tag_value].name);
if (obj->tag == R_BIN_JAVA_STACKMAP_OBJECT) {
printf (" Object Constant Pool Index = 0x%x\n", obj->info.obj_val_cp_idx);
} else if (obj->tag == R_BIN_JAVA_STACKMAP_UNINIT) {
printf (" Uninitialized Object offset in code = 0x%x\n", obj->info.uninit_offset);
}
}
|
safe
| 722
|
static int nfs4_reset_slot_table(struct nfs4_slot_table *tbl, u32 max_reqs,
int ivalue)
{
struct nfs4_slot *new = NULL;
int i;
int ret = 0;
dprintk("--> %s: max_reqs=%u, tbl->max_slots %d\n", __func__,
max_reqs, tbl->max_slots);
/* Does the newly negotiated max_reqs match the existing slot table? */
if (max_reqs != tbl->max_slots) {
ret = -ENOMEM;
new = kmalloc(max_reqs * sizeof(struct nfs4_slot),
GFP_NOFS);
if (!new)
goto out;
ret = 0;
kfree(tbl->slots);
}
spin_lock(&tbl->slot_tbl_lock);
if (new) {
tbl->slots = new;
tbl->max_slots = max_reqs;
}
for (i = 0; i < tbl->max_slots; ++i)
tbl->slots[i].seq_nr = ivalue;
spin_unlock(&tbl->slot_tbl_lock);
dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__,
tbl, tbl->slots, tbl->max_slots);
out:
dprintk("<-- %s: return %d\n", __func__, ret);
return ret;
}
|
safe
| 723
|
static char *have_snapdir(struct vfs_handle_struct *handle,
const char *path)
{
struct smb_filename smb_fname;
int ret;
struct shadow_copy2_config *config;
SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
return NULL);
ZERO_STRUCT(smb_fname);
smb_fname.base_name = talloc_asprintf(talloc_tos(), "%s/%s",
path, config->snapdir);
if (smb_fname.base_name == NULL) {
return NULL;
}
ret = SMB_VFS_NEXT_STAT(handle, &smb_fname);
if ((ret == 0) && (S_ISDIR(smb_fname.st.st_ex_mode))) {
return smb_fname.base_name;
}
TALLOC_FREE(smb_fname.base_name);
return NULL;
}
|
safe
| 724
|
static void vmx_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu)
{
struct vcpu_vmx *vmx = to_vmx(vcpu);
vmcs_write32(PIN_BASED_VM_EXEC_CONTROL, vmx_pin_based_exec_ctrl(vmx));
if (cpu_has_secondary_exec_ctrls()) {
if (kvm_vcpu_apicv_active(vcpu))
vmcs_set_bits(SECONDARY_VM_EXEC_CONTROL,
SECONDARY_EXEC_APIC_REGISTER_VIRT |
SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY);
else
vmcs_clear_bits(SECONDARY_VM_EXEC_CONTROL,
SECONDARY_EXEC_APIC_REGISTER_VIRT |
SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY);
}
if (cpu_has_vmx_msr_bitmap())
vmx_set_msr_bitmap(vcpu);
}
|
safe
| 725
|
get_int64_value(proto_tree *tree, tvbuff_t *tvb, gint start, guint length, const guint encoding)
{
guint64 value = get_uint64_value(tree, tvb, start, length, encoding);
switch (length) {
case 7:
value = ws_sign_ext64(value, 56);
break;
case 6:
value = ws_sign_ext64(value, 48);
break;
case 5:
value = ws_sign_ext64(value, 40);
break;
case 4:
value = ws_sign_ext64(value, 32);
break;
case 3:
value = ws_sign_ext64(value, 24);
break;
case 2:
value = ws_sign_ext64(value, 16);
break;
case 1:
value = ws_sign_ext64(value, 8);
break;
}
return value;
}
|
safe
| 726
|
void intel_guc_init_early(struct intel_guc *guc)
{
struct drm_i915_private *i915 = guc_to_gt(guc)->i915;
intel_uc_fw_init_early(&guc->fw, INTEL_UC_FW_TYPE_GUC);
intel_guc_ct_init_early(&guc->ct);
intel_guc_log_init_early(&guc->log);
intel_guc_submission_init_early(guc);
mutex_init(&guc->send_mutex);
spin_lock_init(&guc->irq_lock);
if (INTEL_GEN(i915) >= 11) {
guc->notify_reg = GEN11_GUC_HOST_INTERRUPT;
guc->interrupts.reset = gen11_reset_guc_interrupts;
guc->interrupts.enable = gen11_enable_guc_interrupts;
guc->interrupts.disable = gen11_disable_guc_interrupts;
} else {
guc->notify_reg = GUC_SEND_INTERRUPT;
guc->interrupts.reset = gen9_reset_guc_interrupts;
guc->interrupts.enable = gen9_enable_guc_interrupts;
guc->interrupts.disable = gen9_disable_guc_interrupts;
}
}
|
safe
| 727
|
int mwifiex_request_scan(struct mwifiex_private *priv,
struct cfg80211_ssid *req_ssid)
{
int ret;
if (mutex_lock_interruptible(&priv->async_mutex)) {
mwifiex_dbg(priv->adapter, ERROR,
"%s: acquire semaphore fail\n",
__func__);
return -1;
}
priv->adapter->scan_wait_q_woken = false;
if (req_ssid && req_ssid->ssid_len != 0)
/* Specific SSID scan */
ret = mwifiex_scan_specific_ssid(priv, req_ssid);
else
/* Normal scan */
ret = mwifiex_scan_networks(priv, NULL);
mutex_unlock(&priv->async_mutex);
return ret;
}
|
safe
| 728
|
static ZIPARCHIVE_METHOD(setCommentName)
{
struct zip *intern;
zval *self = getThis();
size_t comment_len, name_len;
char * comment, *name;
int idx;
if (!self) {
RETURN_FALSE;
}
ZIP_FROM_OBJECT(intern, self);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss",
&name, &name_len, &comment, &comment_len) == FAILURE) {
return;
}
if (name_len < 1) {
php_error_docref(NULL, E_NOTICE, "Empty string as entry name");
}
idx = zip_name_locate(intern, name, 0);
if (idx < 0) {
RETURN_FALSE;
}
PHP_ZIP_SET_FILE_COMMENT(intern, idx, comment, comment_len);
}
|
safe
| 729
|
void jas_deprecated(const char *s)
{
static char message[] =
"WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!\n"
"WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!\n"
"WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!\n"
"YOUR CODE IS RELYING ON DEPRECATED FUNCTIONALTIY IN THE JASPER LIBRARY.\n"
"THIS FUNCTIONALITY WILL BE REMOVED IN THE NEAR FUTURE.\n"
"PLEASE FIX THIS PROBLEM BEFORE YOUR CODE STOPS WORKING!\n"
;
jas_eprintf("%s", message);
jas_eprintf("The specific problem is as follows:\n%s\n", s);
//abort();
}
|
safe
| 730
|
static ssize_t ucma_query_gid(struct ucma_context *ctx,
void __user *response, int out_len)
{
struct rdma_ucm_query_addr_resp resp;
struct sockaddr_ib *addr;
int ret = 0;
if (out_len < sizeof(resp))
return -ENOSPC;
memset(&resp, 0, sizeof resp);
ucma_query_device_addr(ctx->cm_id, &resp);
addr = (struct sockaddr_ib *) &resp.src_addr;
resp.src_size = sizeof(*addr);
if (ctx->cm_id->route.addr.src_addr.ss_family == AF_IB) {
memcpy(addr, &ctx->cm_id->route.addr.src_addr, resp.src_size);
} else {
addr->sib_family = AF_IB;
addr->sib_pkey = (__force __be16) resp.pkey;
rdma_addr_get_sgid(&ctx->cm_id->route.addr.dev_addr,
(union ib_gid *) &addr->sib_addr);
addr->sib_sid = rdma_get_service_id(ctx->cm_id, (struct sockaddr *)
&ctx->cm_id->route.addr.src_addr);
}
addr = (struct sockaddr_ib *) &resp.dst_addr;
resp.dst_size = sizeof(*addr);
if (ctx->cm_id->route.addr.dst_addr.ss_family == AF_IB) {
memcpy(addr, &ctx->cm_id->route.addr.dst_addr, resp.dst_size);
} else {
addr->sib_family = AF_IB;
addr->sib_pkey = (__force __be16) resp.pkey;
rdma_addr_get_dgid(&ctx->cm_id->route.addr.dev_addr,
(union ib_gid *) &addr->sib_addr);
addr->sib_sid = rdma_get_service_id(ctx->cm_id, (struct sockaddr *)
&ctx->cm_id->route.addr.dst_addr);
}
if (copy_to_user(response, &resp, sizeof(resp)))
ret = -EFAULT;
return ret;
}
|
safe
| 731
|
static int put_v4l2_plane32(struct v4l2_plane __user *up,
struct v4l2_plane32 __user *up32,
enum v4l2_memory memory)
{
unsigned long p;
if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
copy_in_user(&up32->data_offset, &up->data_offset,
sizeof(up->data_offset)))
return -EFAULT;
switch (memory) {
case V4L2_MEMORY_MMAP:
case V4L2_MEMORY_OVERLAY:
if (copy_in_user(&up32->m.mem_offset, &up->m.mem_offset,
sizeof(up->m.mem_offset)))
return -EFAULT;
break;
case V4L2_MEMORY_USERPTR:
if (get_user(p, &up->m.userptr) ||
put_user((compat_ulong_t)ptr_to_compat((__force void *)p),
&up32->m.userptr))
return -EFAULT;
break;
case V4L2_MEMORY_DMABUF:
if (copy_in_user(&up32->m.fd, &up->m.fd, sizeof(up->m.fd)))
return -EFAULT;
break;
}
return 0;
}
|
safe
| 732
|
add_tzdata_args (FlatpakBwrap *bwrap,
GFile *runtime_files)
{
g_autofree char *raw_timezone = flatpak_get_timezone ();
g_autofree char *timezone_content = g_strdup_printf ("%s\n", raw_timezone);
g_autofree char *localtime_content = g_strconcat ("../usr/share/zoneinfo/", raw_timezone, NULL);
g_autoptr(GFile) runtime_zoneinfo = NULL;
if (runtime_files)
runtime_zoneinfo = g_file_resolve_relative_path (runtime_files, "share/zoneinfo");
/* Check for runtime /usr/share/zoneinfo */
if (runtime_zoneinfo != NULL && g_file_query_exists (runtime_zoneinfo, NULL))
{
/* Check for host /usr/share/zoneinfo */
if (g_file_test ("/usr/share/zoneinfo", G_FILE_TEST_IS_DIR))
{
/* Here we assume the host timezone file exist in the host data */
flatpak_bwrap_add_args (bwrap,
"--ro-bind", "/usr/share/zoneinfo", "/usr/share/zoneinfo",
"--symlink", localtime_content, "/etc/localtime",
NULL);
}
else
{
g_autoptr(GFile) runtime_tzfile = g_file_resolve_relative_path (runtime_zoneinfo, raw_timezone);
/* Check if host timezone file exist in the runtime tzdata */
if (g_file_query_exists (runtime_tzfile, NULL))
flatpak_bwrap_add_args (bwrap,
"--symlink", localtime_content, "/etc/localtime",
NULL);
}
}
flatpak_bwrap_add_args_data (bwrap, "timezone",
timezone_content, -1, "/etc/timezone",
NULL);
}
|
safe
| 733
|
void UrlParser::finish()
{
switch(_state)
{
case state_0:
break;
case state_key:
if (!_key.empty())
{
_q.add(_key);
_key.clear();
}
break;
case state_value:
_q.add(_key, _value);
_key.clear();
_value.clear();
break;
case state_keyesc:
case state_valueesc:
if (_cnt == 0)
{
if (_state == state_keyesc)
{
_key += '%';
_q.add(_key);
}
else
{
_value += '%';
_q.add(_key, _value);
}
}
else
{
if (_state == state_keyesc)
{
_key += static_cast<char>(_v);
_q.add(_key);
}
else
{
_value += static_cast<char>(_v);
_q.add(_key, _value);
}
}
_value.clear();
_key.clear();
_cnt = 0;
_v = 0;
break;
}
}
|
safe
| 734
|
PackLinuxElf32armLe::buildLoader(Filter const *ft)
{
if (Elf32_Ehdr::ELFOSABI_LINUX==ei_osabi) {
if (0!=xct_off) { // shared library
buildLinuxLoader(
stub_arm_v5t_linux_shlib_init, sizeof(stub_arm_v5t_linux_shlib_init),
nullptr, 0, ft );
return;
}
buildLinuxLoader(
stub_arm_v5a_linux_elf_entry, sizeof(stub_arm_v5a_linux_elf_entry),
stub_arm_v5a_linux_elf_fold, sizeof(stub_arm_v5a_linux_elf_fold), ft);
}
else {
buildLinuxLoader(
stub_arm_v4a_linux_elf_entry, sizeof(stub_arm_v4a_linux_elf_entry),
stub_arm_v4a_linux_elf_fold, sizeof(stub_arm_v4a_linux_elf_fold), ft);
}
}
|
safe
| 735
|
void __init hugetlb_add_hstate(unsigned order)
{
struct hstate *h;
unsigned long i;
if (size_to_hstate(PAGE_SIZE << order)) {
printk(KERN_WARNING "hugepagesz= specified twice, ignoring\n");
return;
}
BUG_ON(max_hstate >= HUGE_MAX_HSTATE);
BUG_ON(order == 0);
h = &hstates[max_hstate++];
h->order = order;
h->mask = ~((1ULL << (order + PAGE_SHIFT)) - 1);
h->nr_huge_pages = 0;
h->free_huge_pages = 0;
for (i = 0; i < MAX_NUMNODES; ++i)
INIT_LIST_HEAD(&h->hugepage_freelists[i]);
h->next_nid_to_alloc = first_node(node_states[N_HIGH_MEMORY]);
h->next_nid_to_free = first_node(node_states[N_HIGH_MEMORY]);
snprintf(h->name, HSTATE_NAME_LEN, "hugepages-%lukB",
huge_page_size(h)/1024);
parsed_hstate = h;
}
|
safe
| 736
|
nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl)
{
struct nvmet_fc_tgtport *tgtport, *next;
struct nvmet_fc_tgt_assoc *assoc;
struct nvmet_fc_tgt_queue *queue;
unsigned long flags;
bool found_ctrl = false;
/* this is a bit ugly, but don't want to make locks layered */
spin_lock_irqsave(&nvmet_fc_tgtlock, flags);
list_for_each_entry_safe(tgtport, next, &nvmet_fc_target_list,
tgt_list) {
if (!nvmet_fc_tgtport_get(tgtport))
continue;
spin_unlock_irqrestore(&nvmet_fc_tgtlock, flags);
spin_lock_irqsave(&tgtport->lock, flags);
list_for_each_entry(assoc, &tgtport->assoc_list, a_list) {
queue = assoc->queues[0];
if (queue && queue->nvme_sq.ctrl == ctrl) {
if (nvmet_fc_tgt_a_get(assoc))
found_ctrl = true;
break;
}
}
spin_unlock_irqrestore(&tgtport->lock, flags);
nvmet_fc_tgtport_put(tgtport);
if (found_ctrl) {
nvmet_fc_delete_target_assoc(assoc);
nvmet_fc_tgt_a_put(assoc);
return;
}
spin_lock_irqsave(&nvmet_fc_tgtlock, flags);
}
spin_unlock_irqrestore(&nvmet_fc_tgtlock, flags);
}
|
safe
| 737
|
int cil_resolve_classperms(struct cil_tree_node *current, struct cil_classperms *cp, void *extra_args)
{
int rc = SEPOL_ERR;
struct cil_symtab_datum *datum = NULL;
symtab_t *common_symtab = NULL;
struct cil_class *class;
rc = cil_resolve_name(current, cp->class_str, CIL_SYM_CLASSES, extra_args, &datum);
if (rc != SEPOL_OK) {
goto exit;
}
class = (struct cil_class *)datum;
if (class->common != NULL) {
common_symtab = &class->common->perms;
}
cp->class = class;
rc = __cil_resolve_perms(&class->perms, common_symtab, cp->perm_strs, &cp->perms, FLAVOR(datum));
if (rc != SEPOL_OK) {
goto exit;
}
return SEPOL_OK;
exit:
return rc;
}
|
safe
| 738
|
static int gup_huge_pud(pud_t orig, pud_t *pudp, unsigned long addr,
unsigned long end, int write, struct page **pages, int *nr)
{
struct page *head, *page;
int refs;
if (write && !pud_write(orig))
return 0;
refs = 0;
head = pud_page(orig);
page = head + ((addr & ~PUD_MASK) >> PAGE_SHIFT);
do {
VM_BUG_ON_PAGE(compound_head(page) != head, page);
pages[*nr] = page;
(*nr)++;
page++;
refs++;
} while (addr += PAGE_SIZE, addr != end);
if (!page_cache_add_speculative(head, refs)) {
*nr -= refs;
return 0;
}
if (unlikely(pud_val(orig) != pud_val(*pudp))) {
*nr -= refs;
while (refs--)
put_page(head);
return 0;
}
return 1;
}
|
safe
| 739
|
node_equal(wordnode_T *n1, wordnode_T *n2)
{
wordnode_T *p1;
wordnode_T *p2;
for (p1 = n1, p2 = n2; p1 != NULL && p2 != NULL;
p1 = p1->wn_sibling, p2 = p2->wn_sibling)
if (p1->wn_byte != p2->wn_byte
|| (p1->wn_byte == NUL
? (p1->wn_flags != p2->wn_flags
|| p1->wn_region != p2->wn_region
|| p1->wn_affixID != p2->wn_affixID)
: (p1->wn_child != p2->wn_child)))
break;
return p1 == NULL && p2 == NULL;
}
|
safe
| 740
|
call_status(struct rpc_task *task)
{
struct rpc_clnt *clnt = task->tk_client;
struct rpc_rqst *req = task->tk_rqstp;
int status;
if (req->rq_reply_bytes_recvd > 0 && !req->rq_bytes_sent)
task->tk_status = req->rq_reply_bytes_recvd;
dprint_status(task);
status = task->tk_status;
if (status >= 0) {
task->tk_action = call_decode;
return;
}
task->tk_status = 0;
switch(status) {
case -EHOSTDOWN:
case -EHOSTUNREACH:
case -ENETUNREACH:
/*
* Delay any retries for 3 seconds, then handle as if it
* were a timeout.
*/
rpc_delay(task, 3*HZ);
case -ETIMEDOUT:
task->tk_action = call_timeout;
if (task->tk_client->cl_discrtry)
xprt_conditional_disconnect(task->tk_xprt,
req->rq_connect_cookie);
break;
case -ECONNRESET:
case -ECONNREFUSED:
rpc_force_rebind(clnt);
rpc_delay(task, 3*HZ);
case -EPIPE:
case -ENOTCONN:
task->tk_action = call_bind;
break;
case -EAGAIN:
task->tk_action = call_transmit;
break;
case -EIO:
/* shutdown or soft timeout */
rpc_exit(task, status);
break;
default:
if (clnt->cl_chatty)
printk("%s: RPC call returned error %d\n",
clnt->cl_protname, -status);
rpc_exit(task, status);
}
}
|
safe
| 741
|
initiate_exit(void)
{
int active = 0;
xmlNode *leaving = NULL;
active = crm_active_peers();
if (active < 2) {
terminate_cib(__FUNCTION__, FALSE);
return;
}
crm_info("Sending disconnect notification to %d peers...", active);
leaving = create_xml_node(NULL, "exit-notification");
crm_xml_add(leaving, F_TYPE, "cib");
crm_xml_add(leaving, F_CIB_OPERATION, "cib_shutdown_req");
send_cluster_message(NULL, crm_msg_cib, leaving, TRUE);
free_xml(leaving);
g_timeout_add(crm_get_msec("5s"), cib_force_exit, NULL);
}
|
safe
| 742
|
log_disconnections(int code, Datum arg)
{
Port *port = MyProcPort;
long secs;
int usecs;
int msecs;
int hours,
minutes,
seconds;
TimestampDifference(port->SessionStartTime,
GetCurrentTimestamp(),
&secs, &usecs);
msecs = usecs / 1000;
hours = secs / SECS_PER_HOUR;
secs %= SECS_PER_HOUR;
minutes = secs / SECS_PER_MINUTE;
seconds = secs % SECS_PER_MINUTE;
ereport(LOG,
(errmsg("disconnection: session time: %d:%02d:%02d.%03d "
"user=%s database=%s host=%s%s%s",
hours, minutes, seconds, msecs,
port->user_name, port->database_name, port->remote_host,
port->remote_port[0] ? " port=" : "", port->remote_port)));
}
|
safe
| 743
|
int StoreECC_DSA_Sig_Bin(byte* out, word32* outLen, const byte* r, word32 rLen,
const byte* s, word32 sLen)
{
int ret;
word32 idx;
word32 headerSz = 4; /* 2*ASN_TAG + 2*LEN(ENUM) */
int rAddLeadZero, sAddLeadZero;
if ((out == NULL) || (outLen == NULL) || (r == NULL) || (s == NULL))
return BAD_FUNC_ARG;
/* Trim leading zeros */
rLen = trim_leading_zeros(&r, rLen);
sLen = trim_leading_zeros(&s, sLen);
/* If the leading bit on the INTEGER is a 1, add a leading zero */
/* Add leading zero if MSB is set */
rAddLeadZero = is_leading_bit_set(r, rLen);
sAddLeadZero = is_leading_bit_set(s, sLen);
if (*outLen < (rLen + rAddLeadZero + sLen + sAddLeadZero +
headerSz + 2)) /* SEQ_TAG + LEN(ENUM) */
return BUFFER_E;
idx = SetSequence(rLen+rAddLeadZero + sLen+sAddLeadZero + headerSz, out);
/* store r */
ret = SetASNInt(rLen, rAddLeadZero ? 0x80 : 0x00, &out[idx]);
if (ret < 0)
return ret;
idx += ret;
XMEMCPY(&out[idx], r, rLen);
idx += rLen;
/* store s */
ret = SetASNInt(sLen, sAddLeadZero ? 0x80 : 0x00, &out[idx]);
if (ret < 0)
return ret;
idx += ret;
XMEMCPY(&out[idx], s, sLen);
idx += sLen;
*outLen = idx;
return 0;
}
|
safe
| 744
|
utf16be_mbc_case_fold(OnigCaseFoldType flag,
const UChar** pp, const UChar* end, UChar* fold)
{
const UChar* p = *pp;
if (ONIGENC_IS_ASCII_CODE(*(p+1)) && *p == 0) {
p++;
#ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
if (*p == 0x49) {
*fold++ = 0x01;
*fold = 0x31;
(*pp) += 2;
return 2;
}
}
#endif
*fold++ = 0;
*fold = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
*pp += 2;
return 2;
}
else
return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF16_BE, flag,
pp, end, fold);
}
|
safe
| 745
|
static int handler_0c00(deark *c, lctx *d, i64 opcode, i64 data_pos, i64 *bytes_used)
{
i64 hdrver;
double hres, vres;
struct pict_rect srcrect;
hdrver = de_getu16be(data_pos);
d->is_extended_v2 = (hdrver==0xfffe);
de_dbg(c, "extended v2: %s", d->is_extended_v2?"yes":"no");
if(d->is_extended_v2) {
hres = pict_read_fixed(c->infile, data_pos+4);
vres = pict_read_fixed(c->infile, data_pos+8);
de_dbg(c, "dpi: %.2f"DE_CHAR_TIMES"%.2f", hres, vres);
pict_read_rect(c->infile, data_pos+12, &srcrect, "srcRect");
}
return 1;
}
|
safe
| 746
|
static void fix_line(String *final_command)
{
int total_lines = 1;
char *ptr = final_command->c_ptr();
String fixed_buffer; /* Converted buffer */
/* Character if we are in a string or not */
char str_char = '\0';
/* find out how many lines we have and remove newlines */
while (*ptr != '\0')
{
switch (*ptr) {
/* string character */
case '"':
case '\'':
case '`':
if (str_char == '\0') /* open string */
str_char= *ptr;
else if (str_char == *ptr) /* close string */
str_char= '\0';
fixed_buffer.append(ptr,1);
break;
case '\n':
/* not in string, change to space if in string, leave it alone */
fixed_buffer.append(str_char == '\0' ? " " : "\n");
total_lines ++;
break;
case '\\':
fixed_buffer.append('\\');
/* need to see if the backslash is escaping anything */
if (str_char)
{
ptr++;
/* special characters that need escaping */
if (*ptr == '\'' || *ptr == '"' || *ptr == '\\')
fixed_buffer.append(ptr, 1);
else
ptr --;
}
break;
default:
fixed_buffer.append(ptr, 1);
}
ptr ++;
}
if (total_lines > 1)
add_filtered_history(fixed_buffer.ptr());
}
|
safe
| 747
|
static void ssl_write_renegotiation_ext( ssl_context *ssl,
unsigned char *buf,
size_t *olen )
{
unsigned char *p = buf;
const unsigned char *end = ssl->out_msg + SSL_MAX_CONTENT_LEN;
*olen = 0;
if( ssl->renegotiation != SSL_RENEGOTIATION )
return;
SSL_DEBUG_MSG( 3, ( "client hello, adding renegotiation extension" ) );
if( end < p || (size_t)(end - p) < 5 + ssl->verify_data_len )
{
SSL_DEBUG_MSG( 1, ( "buffer too small" ) );
return;
}
/*
* Secure renegotiation
*/
*p++ = (unsigned char)( ( TLS_EXT_RENEGOTIATION_INFO >> 8 ) & 0xFF );
*p++ = (unsigned char)( ( TLS_EXT_RENEGOTIATION_INFO ) & 0xFF );
*p++ = 0x00;
*p++ = ( ssl->verify_data_len + 1 ) & 0xFF;
*p++ = ssl->verify_data_len & 0xFF;
memcpy( p, ssl->own_verify_data, ssl->verify_data_len );
*olen = 5 + ssl->verify_data_len;
}
|
safe
| 748
|
ossl_cipher_set_auth_tag_len(VALUE self, VALUE vlen)
{
int tag_len = NUM2INT(vlen);
EVP_CIPHER_CTX *ctx;
GetCipher(self, ctx);
if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER))
ossl_raise(eCipherError, "AEAD not supported by this cipher");
if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, NULL))
ossl_raise(eCipherError, "unable to set authentication tag length");
/* for #auth_tag */
rb_ivar_set(self, id_auth_tag_len, INT2NUM(tag_len));
return vlen;
}
|
safe
| 749
|
static int displaytext_str2tag(const char *tagstr, unsigned int *tag_len)
{
int len;
*tag_len = 0;
len = displaytext_get_tag_len(tagstr);
if (len == -1)
return V_ASN1_VISIBLESTRING;
*tag_len = len;
if (len == sizeof("UTF8") - 1 && strncmp(tagstr, "UTF8", len) == 0)
return V_ASN1_UTF8STRING;
if (len == sizeof("UTF8String") - 1 && strncmp(tagstr, "UTF8String", len) == 0)
return V_ASN1_UTF8STRING;
if (len == sizeof("BMP") - 1 && strncmp(tagstr, "BMP", len) == 0)
return V_ASN1_BMPSTRING;
if (len == sizeof("BMPSTRING") - 1 && strncmp(tagstr, "BMPSTRING", len) == 0)
return V_ASN1_BMPSTRING;
if (len == sizeof("VISIBLE") - 1 && strncmp(tagstr, "VISIBLE", len) == 0)
return V_ASN1_VISIBLESTRING;
if (len == sizeof("VISIBLESTRING") - 1 && strncmp(tagstr, "VISIBLESTRING", len) == 0)
return V_ASN1_VISIBLESTRING;
*tag_len = 0;
return V_ASN1_VISIBLESTRING;
}
|
safe
| 750
|
static void enable_extra_target_match(struct libmnt_table *tb)
{
char *cn = NULL;
const char *tgt = NULL, *mnt = NULL;
struct libmnt_fs *fs;
/*
* Check if match pattern is mountpoint, if not use the
* real mountpoint.
*/
if (flags & FL_NOCACHE)
tgt = get_match(COL_TARGET);
else {
tgt = cn = mnt_resolve_path(get_match(COL_TARGET), cache);
if (!cn)
return;
}
fs = mnt_table_find_mountpoint(tb, tgt, MNT_ITER_BACKWARD);
if (fs)
mnt = mnt_fs_get_target(fs);
if (mnt && strcmp(mnt, tgt) != 0)
set_match(COL_TARGET, xstrdup(mnt)); /* replace the current setting */
if (!cache)
free(cn);
}
|
safe
| 751
|
parse_snapshot(const char *str)
{
txid xmin;
txid xmax;
txid last_val = 0,
val;
const char *str_start = str;
const char *endp;
StringInfo buf;
xmin = str2txid(str, &endp);
if (*endp != ':')
goto bad_format;
str = endp + 1;
xmax = str2txid(str, &endp);
if (*endp != ':')
goto bad_format;
str = endp + 1;
/* it should look sane */
if (xmin == 0 || xmax == 0 || xmin > xmax)
goto bad_format;
/* allocate buffer */
buf = buf_init(xmin, xmax);
/* loop over values */
while (*str != '\0')
{
/* read next value */
val = str2txid(str, &endp);
str = endp;
/* require the input to be in order */
if (val < xmin || val >= xmax || val <= last_val)
goto bad_format;
buf_add_txid(buf, val);
last_val = val;
if (*str == ',')
str++;
else if (*str != '\0')
goto bad_format;
}
return buf_finalize(buf);
bad_format:
elog(ERROR, "invalid input for txid_snapshot: \"%s\"", str_start);
return NULL;
}
|
safe
| 752
|
process_set_cookie_header (SoupMessage *msg, gpointer user_data)
{
SoupCookieJar *jar = user_data;
SoupCookieJarPrivate *priv = soup_cookie_jar_get_instance_private (jar);
GSList *new_cookies, *nc;
if (priv->accept_policy == SOUP_COOKIE_JAR_ACCEPT_NEVER)
return;
new_cookies = soup_cookies_from_response (msg);
for (nc = new_cookies; nc; nc = nc->next) {
SoupURI *first_party = soup_message_get_first_party (msg);
if ((priv->accept_policy == SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY &&
!incoming_cookie_is_third_party (nc->data, first_party)) ||
priv->accept_policy == SOUP_COOKIE_JAR_ACCEPT_ALWAYS)
soup_cookie_jar_add_cookie (jar, nc->data);
else
soup_cookie_free (nc->data);
}
g_slist_free (new_cookies);
}
|
safe
| 753
|
static int intf_next_seq(struct ipmi_smi *intf,
struct ipmi_recv_msg *recv_msg,
unsigned long timeout,
int retries,
int broadcast,
unsigned char *seq,
long *seqid)
{
int rv = 0;
unsigned int i;
if (timeout == 0)
timeout = default_retry_ms;
if (retries < 0)
retries = default_max_retries;
for (i = intf->curr_seq; (i+1)%IPMI_IPMB_NUM_SEQ != intf->curr_seq;
i = (i+1)%IPMI_IPMB_NUM_SEQ) {
if (!intf->seq_table[i].inuse)
break;
}
if (!intf->seq_table[i].inuse) {
intf->seq_table[i].recv_msg = recv_msg;
/*
* Start with the maximum timeout, when the send response
* comes in we will start the real timer.
*/
intf->seq_table[i].timeout = MAX_MSG_TIMEOUT;
intf->seq_table[i].orig_timeout = timeout;
intf->seq_table[i].retries_left = retries;
intf->seq_table[i].broadcast = broadcast;
intf->seq_table[i].inuse = 1;
intf->seq_table[i].seqid = NEXT_SEQID(intf->seq_table[i].seqid);
*seq = i;
*seqid = intf->seq_table[i].seqid;
intf->curr_seq = (i+1)%IPMI_IPMB_NUM_SEQ;
need_waiter(intf);
} else {
rv = -EAGAIN;
}
return rv;
}
|
safe
| 754
|
static int afiucv_hs_callback_rx(struct sock *sk, struct sk_buff *skb)
{
struct iucv_sock *iucv = iucv_sk(sk);
if (!iucv) {
kfree_skb(skb);
return NET_RX_SUCCESS;
}
if (sk->sk_state != IUCV_CONNECTED) {
kfree_skb(skb);
return NET_RX_SUCCESS;
}
if (sk->sk_shutdown & RCV_SHUTDOWN) {
kfree_skb(skb);
return NET_RX_SUCCESS;
}
/* write stuff from iucv_msg to skb cb */
if (skb->len < sizeof(struct af_iucv_trans_hdr)) {
kfree_skb(skb);
return NET_RX_SUCCESS;
}
skb_pull(skb, sizeof(struct af_iucv_trans_hdr));
skb_reset_transport_header(skb);
skb_reset_network_header(skb);
IUCV_SKB_CB(skb)->offset = 0;
spin_lock(&iucv->message_q.lock);
if (skb_queue_empty(&iucv->backlog_skb_q)) {
if (sock_queue_rcv_skb(sk, skb)) {
/* handle rcv queue full */
skb_queue_tail(&iucv->backlog_skb_q, skb);
}
} else
skb_queue_tail(&iucv_sk(sk)->backlog_skb_q, skb);
spin_unlock(&iucv->message_q.lock);
return NET_RX_SUCCESS;
}
|
safe
| 755
|
store_uint(uintmax_t intval, size_t size, void *val)
{
switch (size) {
case 1:
if ((uint8_t)intval != intval)
return ASN1_OVERFLOW;
*(uint8_t *)val = intval;
return 0;
case 2:
if ((uint16_t)intval != intval)
return ASN1_OVERFLOW;
*(uint16_t *)val = intval;
return 0;
case 4:
if ((uint32_t)intval != intval)
return ASN1_OVERFLOW;
*(uint32_t *)val = intval;
return 0;
case 8:
if ((uint64_t)intval != intval)
return ASN1_OVERFLOW;
*(uint64_t *)val = intval;
return 0;
default:
abort();
}
}
|
safe
| 756
|
static void test_heap_overflow_vrend_renderer_transfer_write_iov()
{
struct virgl_renderer_resource_create_args args;
args.handle = 4;
args.target = 0;
args.format = 4;
args.bind = 131072;
args.width = 0;
args.height = 1;
args.depth = 1;
args.array_size = 0;
args.last_level = 0;
args.nr_samples = 0;
args.flags = 0;
virgl_renderer_resource_create(&args, NULL, 0);
virgl_renderer_ctx_attach_resource(ctx_id, args.handle);
char data[16];
memset(data, 'A', 16);
uint32_t cmd[11 + 4 +1];
int i = 0;
cmd[i++] = (11+4) << 16 | 0 << 8 | VIRGL_CCMD_RESOURCE_INLINE_WRITE;
cmd[i++] = 4; // handle
cmd[i++] = 0; // level
cmd[i++] = 0; // usage
cmd[i++] = 0; // stride
cmd[i++] = 0; // layer_stride
cmd[i++] = 0; // x
cmd[i++] = 0; // y
cmd[i++] = 0; // z
cmd[i++] = 0x80000000; // w
cmd[i++] = 0; // h
cmd[i++] = 0; // d
memcpy(&cmd[i], data, 16);
virgl_renderer_submit_cmd((void *) cmd, ctx_id, 11 + 4 + 1);
}
|
safe
| 757
|
HttpHdrRangeSpec::canonize(int64_t clen)
{
outputInfo ("have");
HttpRange object(0, clen);
if (!known_spec(offset)) { /* suffix */
assert(known_spec(length));
offset = object.intersection(HttpRange (clen - length, clen)).start;
} else if (!known_spec(length)) { /* trailer */
assert(known_spec(offset));
HttpRange newRange = object.intersection(HttpRange (offset, clen));
length = newRange.size();
}
/* we have a "range" now, adjust length if needed */
assert(known_spec(length));
assert(known_spec(offset));
HttpRange newRange = object.intersection (HttpRange (offset, offset + length));
length = newRange.size();
outputInfo ("done");
return length > 0;
}
|
safe
| 758
|
Http::Stream::packRange(StoreIOBuffer const &source, MemBuf *mb)
{
HttpHdrRangeIter * i = &http->range_iter;
Range<int64_t> available(source.range());
char const *buf = source.data;
while (i->currentSpec() && available.size()) {
const size_t copy_sz = lengthToSend(available);
if (copy_sz) {
// intersection of "have" and "need" ranges must not be empty
assert(http->out.offset < i->currentSpec()->offset + i->currentSpec()->length);
assert(http->out.offset + (int64_t)available.size() > i->currentSpec()->offset);
/*
* put boundary and headers at the beginning of a range in a
* multi-range
*/
if (http->multipartRangeRequest() && i->debt() == i->currentSpec()->length) {
clientPackRangeHdr(
&http->storeEntry()->mem().freshestReply(),
i->currentSpec(), /* current range */
i->boundary, /* boundary, the same for all */
mb);
}
// append content
debugs(33, 3, "appending " << copy_sz << " bytes");
noteSentBodyBytes(copy_sz);
mb->append(buf, copy_sz);
// update offsets
available.start += copy_sz;
buf += copy_sz;
}
if (!canPackMoreRanges()) {
debugs(33, 3, "Returning because !canPackMoreRanges.");
if (i->debt() == 0)
// put terminating boundary for multiparts
clientPackTermBound(i->boundary, mb);
return;
}
int64_t nextOffset = getNextRangeOffset();
assert(nextOffset >= http->out.offset);
int64_t skip = nextOffset - http->out.offset;
/* adjust for not to be transmitted bytes */
http->out.offset = nextOffset;
if (available.size() <= (uint64_t)skip)
return;
available.start += skip;
buf += skip;
if (copy_sz == 0)
return;
}
}
|
safe
| 759
|
nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl)
{
struct nlm_host *host = req->a_host;
struct nlm_res *resp = &req->a_res;
int status;
unsigned char fl_flags = fl->fl_flags;
/*
* Note: the server is supposed to either grant us the unlock
* request, or to deny it with NLM_LCK_DENIED_GRACE_PERIOD. In either
* case, we want to unlock.
*/
fl->fl_flags |= FL_EXISTS;
down_read(&host->h_rwsem);
status = do_vfs_lock(fl);
up_read(&host->h_rwsem);
fl->fl_flags = fl_flags;
if (status == -ENOENT) {
status = 0;
goto out;
}
atomic_inc(&req->a_count);
status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req,
NLMPROC_UNLOCK, &nlmclnt_unlock_ops);
if (status < 0)
goto out;
if (resp->status == nlm_granted)
goto out;
if (resp->status != nlm_lck_denied_nolocks)
printk("lockd: unexpected unlock status: %d\n", resp->status);
/* What to do now? I'm out of my depth... */
status = -ENOLCK;
out:
nlmclnt_release_call(req);
return status;
}
|
safe
| 760
|
bool tr_variantGetReal(tr_variant const* v, double* setme)
{
bool success = false;
if (tr_variantIsReal(v))
{
*setme = v->val.d;
success = true;
}
if (!success && tr_variantIsInt(v))
{
*setme = v->val.i;
success = true;
}
if (!success && tr_variantIsString(v))
{
char* endptr;
struct locale_context locale_ctx;
double d;
/* the json spec requires a '.' decimal point regardless of locale */
use_numeric_locale(&locale_ctx, "C");
d = strtod(getStr(v), &endptr);
restore_locale(&locale_ctx);
if (getStr(v) != endptr && *endptr == '\0')
{
*setme = d;
success = true;
}
}
return success;
}
|
safe
| 761
|
bgp_log_error(struct bgp_proto *p, u8 class, char *msg, unsigned code, unsigned subcode, byte *data, unsigned len)
{
byte argbuf[256+16], *t = argbuf;
unsigned i;
/* Don't report Cease messages generated by myself */
if (code == 6 && class == BE_BGP_TX)
return;
/* Reset shutdown message */
if ((code == 6) && ((subcode == 2) || (subcode == 4)))
proto_set_message(&p->p, NULL, 0);
if (len)
{
/* Bad peer AS - we would like to print the AS */
if ((code == 2) && (subcode == 2) && ((len == 2) || (len == 4)))
{
t += bsprintf(t, ": %u", (len == 2) ? get_u16(data) : get_u32(data));
goto done;
}
/* RFC 8203 - shutdown communication */
if (((code == 6) && ((subcode == 2) || (subcode == 4))))
if (bgp_handle_message(p, data, len, &t))
goto done;
*t++ = ':';
*t++ = ' ';
if (len > 16)
len = 16;
for (i=0; i<len; i++)
t += bsprintf(t, "%02x", data[i]);
}
done:
*t = 0;
const byte *dsc = bgp_error_dsc(code, subcode);
log(L_REMOTE "%s: %s: %s%s", p->p.name, msg, dsc, argbuf);
}
|
safe
| 762
|
R_API char *retrieve_access_string(ut16 flags, RBinJavaAccessFlags *access_flags) {
char *outbuffer = NULL, *cur_pos = NULL;
ut16 i;
ut16 max_str_len = 0;
for (i = 0; access_flags[i].str != NULL; i++) {
if (flags & access_flags[i].value) {
max_str_len += (strlen (access_flags[i].str) + 1);
if (max_str_len < strlen (access_flags[i].str)) {
return NULL;
}
}
}
max_str_len++;
outbuffer = (char *) malloc (max_str_len);
if (outbuffer) {
memset (outbuffer, 0, max_str_len);
cur_pos = outbuffer;
for (i = 0; access_flags[i].str != NULL; i++) {
if (flags & access_flags[i].value) {
ut8 len = strlen (access_flags[i].str);
const char *the_string = access_flags[i].str;
memcpy (cur_pos, the_string, len);
memcpy (cur_pos + len, " ", 1);
cur_pos += len + 1;
}
}
if (cur_pos != outbuffer) {
*(cur_pos - 1) = 0;
}
}
return outbuffer;
}
|
safe
| 763
|
CURLcode init_telnet(struct Curl_easy *data)
{
struct TELNET *tn;
tn = calloc(1, sizeof(struct TELNET));
if(!tn)
return CURLE_OUT_OF_MEMORY;
data->req.p.telnet = tn; /* make us known */
tn->telrcv_state = CURL_TS_DATA;
/* Init suboptions */
CURL_SB_CLEAR(tn);
/* Set the options we want by default */
tn->us_preferred[CURL_TELOPT_SGA] = CURL_YES;
tn->him_preferred[CURL_TELOPT_SGA] = CURL_YES;
/* To be compliant with previous releases of libcurl
we enable this option by default. This behavior
can be changed thanks to the "BINARY" option in
CURLOPT_TELNETOPTIONS
*/
tn->us_preferred[CURL_TELOPT_BINARY] = CURL_YES;
tn->him_preferred[CURL_TELOPT_BINARY] = CURL_YES;
/* We must allow the server to echo what we sent
but it is not necessary to request the server
to do so (it might forces the server to close
the connection). Hence, we ignore ECHO in the
negotiate function
*/
tn->him_preferred[CURL_TELOPT_ECHO] = CURL_YES;
/* Set the subnegotiation fields to send information
just after negotiation passed (do/will)
Default values are (0,0) initialized by calloc.
According to the RFC1013 it is valid:
A value equal to zero is acceptable for the width (or height),
and means that no character width (or height) is being sent.
In this case, the width (or height) that will be assumed by the
Telnet server is operating system specific (it will probably be
based upon the terminal type information that may have been sent
using the TERMINAL TYPE Telnet option). */
tn->subnegotiation[CURL_TELOPT_NAWS] = CURL_YES;
return CURLE_OK;
}
|
safe
| 764
|
drawAnchorCursor0(Buffer *buf, AnchorList *al, int hseq, int prevhseq,
int tline, int eline, int active)
{
int i, j;
Line *l;
Anchor *an;
l = buf->topLine;
for (j = 0; j < al->nanchor; j++) {
an = &al->anchors[j];
if (an->start.line < tline)
continue;
if (an->start.line >= eline)
return;
for (;; l = l->next) {
if (l == NULL)
return;
if (l->linenumber == an->start.line)
break;
}
if (hseq >= 0 && an->hseq == hseq) {
int start_pos = an->start.pos;
int end_pos = an->end.pos;
for (i = an->start.pos; i < an->end.pos; i++) {
if (enable_inline_image && (l->propBuf[i] & PE_IMAGE)) {
if (start_pos == i)
start_pos = i + 1;
else if (end_pos == an->end.pos)
end_pos = i - 1;
}
if (l->propBuf[i] & (PE_IMAGE | PE_ANCHOR | PE_FORM)) {
if (active)
l->propBuf[i] |= PE_ACTIVE;
else
l->propBuf[i] &= ~PE_ACTIVE;
}
}
if (active && start_pos < end_pos)
redrawLineRegion(buf, l, l->linenumber - tline + buf->rootY,
start_pos, end_pos);
}
else if (prevhseq >= 0 && an->hseq == prevhseq) {
if (active)
redrawLineRegion(buf, l, l->linenumber - tline + buf->rootY,
an->start.pos, an->end.pos);
}
}
}
|
safe
| 765
|
static int module_list(int argc, const char **argv, const char *prefix)
{
int i;
struct pathspec pathspec;
struct module_list list = MODULE_LIST_INIT;
struct option module_list_options[] = {
OPT_STRING(0, "prefix", &prefix,
N_("path"),
N_("alternative anchor for relative paths")),
OPT_END()
};
const char *const git_submodule_helper_usage[] = {
N_("git submodule--helper list [--prefix=<path>] [<path>...]"),
NULL
};
argc = parse_options(argc, argv, prefix, module_list_options,
git_submodule_helper_usage, 0);
if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
return 1;
for (i = 0; i < list.nr; i++) {
const struct cache_entry *ce = list.entries[i];
if (ce_stage(ce))
printf("%06o %s U\t", ce->ce_mode, sha1_to_hex(null_sha1));
else
printf("%06o %s %d\t", ce->ce_mode,
oid_to_hex(&ce->oid), ce_stage(ce));
fprintf(stdout, "%s\n", ce->name);
}
return 0;
}
|
safe
| 766
|
url_encode_string(const char *s, /* I - String */
char *buffer, /* I - String buffer */
size_t bufsize) /* I - Size of buffer */
{
char *bufptr, /* Pointer into buffer */
*bufend; /* End of buffer */
static const char *hex = "0123456789ABCDEF";
/* Hex digits */
bufptr = buffer;
bufend = buffer + bufsize - 1;
while (*s && bufptr < bufend)
{
if (*s == ' ' || *s == '%' || *s == '+')
{
if (bufptr >= (bufend - 2))
break;
*bufptr++ = '%';
*bufptr++ = hex[(*s >> 4) & 15];
*bufptr++ = hex[*s & 15];
s ++;
}
else if (*s == '\'' || *s == '\\')
{
if (bufptr >= (bufend - 1))
break;
*bufptr++ = '\\';
*bufptr++ = *s++;
}
else
*bufptr++ = *s++;
}
*bufptr = '\0';
return (bufptr);
}
|
safe
| 767
|
get_net_error_message(gint error)
{
HMODULE module = NULL;
gchar *retval = NULL;
wchar_t *msg = NULL;
int flags;
size_t nchars;
flags = FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM;
if (error >= NERR_BASE && error <= MAX_NERR) {
module = LoadLibraryExW(L"netmsg.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
if (module != NULL) {
flags |= FORMAT_MESSAGE_FROM_HMODULE;
}
}
FormatMessageW(flags, module, error, 0, (LPWSTR)&msg, 0, NULL);
if (msg != NULL) {
nchars = wcslen(msg);
if (nchars >= 2 &&
msg[nchars - 1] == L'\n' &&
msg[nchars - 2] == L'\r') {
msg[nchars - 2] = L'\0';
}
retval = g_utf16_to_utf8(msg, -1, NULL, NULL, NULL);
LocalFree(msg);
}
if (module != NULL) {
FreeLibrary(module);
}
return retval;
}
|
safe
| 768
|
static bool type_cmd_afta (RCore *core, RAnalFunction *fcn) {
RListIter *it;
ut64 seek;
const char *io_cache_key = "io.pcache.write";
bool io_cache = r_config_get_i (core->config, io_cache_key);
if (r_config_get_i (core->config, "cfg.debug")) {
eprintf ("TOFIX: afta can't run in debugger mode.\n");
return false;
}
if (!io_cache) {
// XXX. we shouldnt need this, but it breaks 'r2 -c aaa -w ls'
r_config_set_i (core->config, io_cache_key, true);
}
seek = core->offset;
r_core_cmd0 (core, "aei");
r_core_cmd0 (core, "aeim");
r_reg_arena_push (core->anal->reg);
// Iterating Reverse so that we get function in top-bottom call order
r_list_foreach_prev (core->anal->fcns, it, fcn) {
int ret = r_core_seek (core, fcn->addr, true);
if (!ret) {
continue;
}
r_anal_esil_set_pc (core->anal->esil, fcn->addr);
r_core_anal_type_match (core, fcn);
if (r_cons_is_breaked ()) {
break;
}
}
r_core_cmd0 (core, "aeim-");
r_core_cmd0 (core, "aei-");
r_core_seek (core, seek, true);
r_reg_arena_pop (core->anal->reg);
r_config_set_i (core->config, io_cache_key, io_cache);
return true;
}
|
safe
| 769
|
static bool checkreturn pb_decode_varint32_eof(pb_istream_t *stream, uint32_t *dest, bool *eof)
{
pb_byte_t byte;
uint32_t result;
if (!pb_readbyte(stream, &byte))
{
if (stream->bytes_left == 0)
{
if (eof)
{
*eof = true;
}
}
return false;
}
if ((byte & 0x80) == 0)
{
/* Quick case, 1 byte value */
result = byte;
}
else
{
/* Multibyte case */
uint_fast8_t bitpos = 7;
result = byte & 0x7F;
do
{
if (!pb_readbyte(stream, &byte))
return false;
if (bitpos >= 32)
{
/* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
if ((byte & 0x7F) != 0x00 && ((result >> 31) == 0 || byte != sign_extension))
{
PB_RETURN_ERROR(stream, "varint overflow");
}
}
else
{
result |= (uint32_t)(byte & 0x7F) << bitpos;
}
bitpos = (uint_fast8_t)(bitpos + 7);
} while (byte & 0x80);
if (bitpos == 35 && (byte & 0x70) != 0)
{
/* The last byte was at bitpos=28, so only bottom 4 bits fit. */
PB_RETURN_ERROR(stream, "varint overflow");
}
}
*dest = result;
return true;
}
|
safe
| 770
|
void OSDService::start_recovery_op(PG *pg, const hobject_t& soid)
{
Mutex::Locker l(recovery_lock);
dout(10) << "start_recovery_op " << *pg << " " << soid
<< " (" << recovery_ops_active << "/"
<< cct->_conf->osd_recovery_max_active << " rops)"
<< dendl;
recovery_ops_active++;
#ifdef DEBUG_RECOVERY_OIDS
dout(20) << " active was " << recovery_oids[pg->info.pgid] << dendl;
assert(recovery_oids[pg->info.pgid].count(soid) == 0);
recovery_oids[pg->info.pgid].insert(soid);
#endif
}
|
safe
| 771
|
size_t mobi_get_aid_offset(const MOBIPart *html, const char *aid) {
size_t length = html->size;
const char *data = (char *) html->data;
const size_t aid_length = strlen(aid);
const size_t attr_length = 5; /* "aid='" length */
do {
if (length > (aid_length + attr_length) && memcmp(data, "aid=", attr_length - 1) == 0) {
data += attr_length;
length -= attr_length;
if (memcmp(data, aid, aid_length) == 0) {
if (data[aid_length] == '\'' || data[aid_length] == '"') {
return html->size - length;
}
}
}
data++;
} while (--length);
return SIZE_MAX;
}
|
safe
| 773
|
eval_foldexpr(win_T *wp, int *cp)
{
char_u *arg;
typval_T tv;
varnumber_T retval;
char_u *s;
sctx_T saved_sctx = current_sctx;
int use_sandbox = was_set_insecurely((char_u *)"foldexpr",
OPT_LOCAL);
arg = wp->w_p_fde;
current_sctx = wp->w_p_script_ctx[WV_FDE];
++emsg_off;
if (use_sandbox)
++sandbox;
++textlock;
*cp = NUL;
if (eval0(arg, &tv, NULL, &EVALARG_EVALUATE) == FAIL)
retval = 0;
else
{
// If the result is a number, just return the number.
if (tv.v_type == VAR_NUMBER)
retval = tv.vval.v_number;
else if (tv.v_type != VAR_STRING || tv.vval.v_string == NULL)
retval = 0;
else
{
// If the result is a string, check if there is a non-digit before
// the number.
s = tv.vval.v_string;
if (!VIM_ISDIGIT(*s) && *s != '-')
*cp = *s++;
retval = atol((char *)s);
}
clear_tv(&tv);
}
--emsg_off;
if (use_sandbox)
--sandbox;
--textlock;
clear_evalarg(&EVALARG_EVALUATE, NULL);
current_sctx = saved_sctx;
return (int)retval;
}
|
safe
| 774
|
static bool arcmsr_get_firmware_spec(struct AdapterControlBlock *acb)
{
bool rtn = false;
switch (acb->adapter_type) {
case ACB_ADAPTER_TYPE_A:
rtn = arcmsr_hbaA_get_config(acb);
break;
case ACB_ADAPTER_TYPE_B:
rtn = arcmsr_hbaB_get_config(acb);
break;
case ACB_ADAPTER_TYPE_C:
rtn = arcmsr_hbaC_get_config(acb);
break;
case ACB_ADAPTER_TYPE_D:
rtn = arcmsr_hbaD_get_config(acb);
break;
default:
break;
}
if (acb->firm_numbers_queue > ARCMSR_MAX_OUTSTANDING_CMD)
acb->maxOutstanding = ARCMSR_MAX_OUTSTANDING_CMD;
else
acb->maxOutstanding = acb->firm_numbers_queue - 1;
acb->host->can_queue = acb->maxOutstanding;
return rtn;
}
|
safe
| 775
|
static unsigned nfs4_exclusive_attrset(struct nfs4_opendata *opendata,
struct iattr *sattr, struct nfs4_label **label)
{
const __u32 *bitmask = opendata->o_arg.server->exclcreat_bitmask;
__u32 attrset[3];
unsigned ret;
unsigned i;
for (i = 0; i < ARRAY_SIZE(attrset); i++) {
attrset[i] = opendata->o_res.attrset[i];
if (opendata->o_arg.createmode == NFS4_CREATE_EXCLUSIVE4_1)
attrset[i] &= ~bitmask[i];
}
ret = (opendata->o_arg.createmode == NFS4_CREATE_EXCLUSIVE) ?
sattr->ia_valid : 0;
if ((attrset[1] & (FATTR4_WORD1_TIME_ACCESS|FATTR4_WORD1_TIME_ACCESS_SET))) {
if (sattr->ia_valid & ATTR_ATIME_SET)
ret |= ATTR_ATIME_SET;
else
ret |= ATTR_ATIME;
}
if ((attrset[1] & (FATTR4_WORD1_TIME_MODIFY|FATTR4_WORD1_TIME_MODIFY_SET))) {
if (sattr->ia_valid & ATTR_MTIME_SET)
ret |= ATTR_MTIME_SET;
else
ret |= ATTR_MTIME;
}
if (!(attrset[2] & FATTR4_WORD2_SECURITY_LABEL))
*label = NULL;
return ret;
}
|
safe
| 776
|
int errwrite(const gs_memory_t *mem, const char *str, int len)
{
int code;
gs_lib_ctx_t *ctx;
gs_lib_ctx_core_t *core;
if (len == 0)
return 0;
if (mem == NULL) {
#ifdef GS_THREADSAFE
return 0;
#else
mem = mem_err_print;
if (mem == NULL)
return 0;
#endif
}
ctx = mem->gs_lib_ctx;
if (ctx == NULL)
return 0;
core = ctx->core;
if (core->stderr_fn)
return (*core->stderr_fn)(core->std_caller_handle, str, len);
code = fwrite(str, 1, len, core->fstderr);
fflush(core->fstderr);
return code;
}
|
safe
| 777
|
void SegmentSumFunctor<T, Index>::operator()(
OpKernelContext* ctx, const GPUDevice& d, const Index output_rows,
const TensorShape& segment_ids_shape,
typename TTypes<Index>::ConstFlat segment_ids, const Index data_size,
const T* data, typename TTypes<T, 2>::Tensor output) {
if (output.size() == 0) {
return;
}
// Set 'output' to zeros.
GpuLaunchConfig config = GetGpuLaunchConfig(output.size(), d);
TF_CHECK_OK(GpuLaunchKernel(SetZero<T>, config.block_count,
config.thread_per_block, 0, d.stream(),
output.size(), output.data()));
if (data_size == 0 || segment_ids_shape.num_elements() == 0) {
return;
}
// Launch kernel to compute sorted segment sum.
// Notes:
// *) 'input_total_size' is the total number of elements to process.
// *) 'segment_ids.shape' is a prefix of data's shape.
// *) 'input_outer_dim_size' is the total number of segments to process.
const Index input_total_size = data_size;
const Index input_outer_dim_size = segment_ids.dimension(0);
const Index input_inner_dim_size = input_total_size / input_outer_dim_size;
const int OuterDimTileSize = 8;
const Index input_outer_dim_num_stripe =
Eigen::divup(input_outer_dim_size, Index(OuterDimTileSize));
const Index total_stripe_count =
input_inner_dim_size * input_outer_dim_num_stripe;
config = GetGpuLaunchConfig(total_stripe_count, d);
TF_CHECK_OK(GpuLaunchKernel(
SortedSegmentSumCustomKernel<T, Index, OuterDimTileSize>,
config.block_count, config.thread_per_block, 0, d.stream(),
input_outer_dim_size, input_inner_dim_size, output_rows,
segment_ids.data(), data, output.data(), total_stripe_count));
}
|
safe
| 778
|
static int sctp_setsockopt_hmac_ident(struct sock *sk,
struct sctp_hmacalgo *hmacs,
unsigned int optlen)
{
struct sctp_endpoint *ep = sctp_sk(sk)->ep;
u32 idents;
if (!ep->auth_enable)
return -EACCES;
if (optlen < sizeof(struct sctp_hmacalgo))
return -EINVAL;
optlen = min_t(unsigned int, optlen, sizeof(struct sctp_hmacalgo) +
SCTP_AUTH_NUM_HMACS * sizeof(u16));
idents = hmacs->shmac_num_idents;
if (idents == 0 || idents > SCTP_AUTH_NUM_HMACS ||
(idents * sizeof(u16)) > (optlen - sizeof(struct sctp_hmacalgo)))
return -EINVAL;
return sctp_auth_ep_set_hmacs(ep, hmacs);
}
|
safe
| 779
|
int netsnmp_query_walk(netsnmp_variable_list *list,
netsnmp_session *session) {
/*
* Create a working copy of the original (single)
* varbind, so we can use this varbind parameter
* to check when we've finished walking this subtree.
*/
netsnmp_variable_list *vb = snmp_clone_varbind( list );
netsnmp_variable_list *res_list = NULL;
netsnmp_variable_list *res_last = NULL;
int ret;
/*
* Now walk the tree as usual
*/
ret = _query( vb, SNMP_MSG_GETNEXT, session );
while ( ret == SNMP_ERR_NOERROR &&
snmp_oidtree_compare( list->name, list->name_length,
vb->name, vb->name_length ) == 0) {
if (vb->type == SNMP_ENDOFMIBVIEW ||
vb->type == SNMP_NOSUCHOBJECT ||
vb->type == SNMP_NOSUCHINSTANCE)
break;
/*
* Copy each response varbind to the end of the result list
* and then re-use this to ask for the next entry.
*/
if ( res_last ) {
res_last->next_variable = snmp_clone_varbind( vb );
res_last = res_last->next_variable;
} else {
res_list = snmp_clone_varbind( vb );
res_last = res_list;
}
ret = _query( vb, SNMP_MSG_GETNEXT, session );
}
/*
* Copy the first result back into the original varbind parameter,
* add the rest of the results (if any), and clean up.
*/
if ( res_list ) {
snmp_clone_var( res_list, list );
list->next_variable = res_list->next_variable;
res_list->next_variable = NULL;
snmp_free_varbind( res_list );
}
snmp_free_varbind( vb );
return ret;
}
|
safe
| 780
|
static BOOL rdp_read_remote_programs_capability_set(wStream* s, UINT16 length,
rdpSettings* settings)
{
UINT32 railSupportLevel;
if (length < 8)
return FALSE;
Stream_Read_UINT32(s, railSupportLevel); /* railSupportLevel (4 bytes) */
if ((railSupportLevel & RAIL_LEVEL_SUPPORTED) == 0)
{
if (settings->RemoteApplicationMode == TRUE)
{
/* RemoteApp Failure! */
settings->RemoteApplicationMode = FALSE;
}
}
/* 2.2.2.2.3 HandshakeEx PDU (TS_RAIL_ORDER_HANDSHAKE_EX)
* the handshake ex pdu is supported when both, client and server announce
* it OR if we are ready to begin enhanced remoteAPP mode. */
if (settings->RemoteApplicationMode)
railSupportLevel |= RAIL_LEVEL_HANDSHAKE_EX_SUPPORTED;
settings->RemoteApplicationSupportLevel =
railSupportLevel & settings->RemoteApplicationSupportMask;
return TRUE;
}
|
safe
| 781
|
static void coerce_reg_to_size(struct bpf_reg_state *reg, int size)
{
u64 mask;
/* clear high bits in bit representation */
reg->var_off = tnum_cast(reg->var_off, size);
/* fix arithmetic bounds */
mask = ((u64)1 << (size * 8)) - 1;
if ((reg->umin_value & ~mask) == (reg->umax_value & ~mask)) {
reg->umin_value &= mask;
reg->umax_value &= mask;
} else {
reg->umin_value = 0;
reg->umax_value = mask;
}
reg->smin_value = reg->umin_value;
reg->smax_value = reg->umax_value;
/* If size is smaller than 32bit register the 32bit register
* values are also truncated so we push 64-bit bounds into
* 32-bit bounds. Above were truncated < 32-bits already.
*/
if (size >= 4)
return;
__reg_combine_64_into_32(reg);
}
|
safe
| 782
|
static int fsck_gitmodules_fn(const char *var, const char *value, void *vdata)
{
struct fsck_gitmodules_data *data = vdata;
const char *subsection, *key;
int subsection_len;
char *name;
if (parse_config_key(var, "submodule", &subsection, &subsection_len, &key) < 0 ||
!subsection)
return 0;
name = xmemdupz(subsection, subsection_len);
if (check_submodule_name(name) < 0)
data->ret |= report(data->options, data->obj,
FSCK_MSG_GITMODULES_NAME,
"disallowed submodule name: %s",
name);
if (!strcmp(key, "url") && value &&
looks_like_command_line_option(value))
data->ret |= report(data->options, data->obj,
FSCK_MSG_GITMODULES_URL,
"disallowed submodule url: %s",
value);
if (!strcmp(key, "path") && value &&
looks_like_command_line_option(value))
data->ret |= report(data->options, data->obj,
FSCK_MSG_GITMODULES_PATH,
"disallowed submodule path: %s",
value);
free(name);
return 0;
}
|
safe
| 783
|
get_matching_model_microcode(int cpu, unsigned long start,
void *data, size_t size,
struct mc_saved_data *mc_saved_data,
unsigned long *mc_saved_in_initrd,
struct ucode_cpu_info *uci)
{
u8 *ucode_ptr = data;
unsigned int leftover = size;
enum ucode_state state = UCODE_OK;
unsigned int mc_size;
struct microcode_header_intel *mc_header;
struct microcode_intel *mc_saved_tmp[MAX_UCODE_COUNT];
unsigned int mc_saved_count = mc_saved_data->mc_saved_count;
int i;
while (leftover && mc_saved_count < ARRAY_SIZE(mc_saved_tmp)) {
mc_header = (struct microcode_header_intel *)ucode_ptr;
mc_size = get_totalsize(mc_header);
if (!mc_size || mc_size > leftover ||
microcode_sanity_check(ucode_ptr, 0) < 0)
break;
leftover -= mc_size;
/*
* Since APs with same family and model as the BSP may boot in
* the platform, we need to find and save microcode patches
* with the same family and model as the BSP.
*/
if (matching_model_microcode(mc_header, uci->cpu_sig.sig) !=
UCODE_OK) {
ucode_ptr += mc_size;
continue;
}
_save_mc(mc_saved_tmp, ucode_ptr, &mc_saved_count);
ucode_ptr += mc_size;
}
if (leftover) {
state = UCODE_ERROR;
goto out;
}
if (mc_saved_count == 0) {
state = UCODE_NFOUND;
goto out;
}
for (i = 0; i < mc_saved_count; i++)
mc_saved_in_initrd[i] = (unsigned long)mc_saved_tmp[i] - start;
mc_saved_data->mc_saved_count = mc_saved_count;
out:
return state;
}
|
safe
| 784
|
int ipv6_setsockopt(struct sock *sk, int level, int optname,
char __user *optval, unsigned int optlen)
{
int err;
if (level == SOL_IP && sk->sk_type != SOCK_RAW)
return udp_prot.setsockopt(sk, level, optname, optval, optlen);
if (level != SOL_IPV6)
return -ENOPROTOOPT;
err = do_ipv6_setsockopt(sk, level, optname, optval, optlen);
#ifdef CONFIG_NETFILTER
/* we need to exclude all possible ENOPROTOOPTs except default case */
if (err == -ENOPROTOOPT && optname != IPV6_IPSEC_POLICY &&
optname != IPV6_XFRM_POLICY) {
lock_sock(sk);
err = nf_setsockopt(sk, PF_INET6, optname, optval,
optlen);
release_sock(sk);
}
#endif
return err;
}
|
safe
| 785
|
static void show_netdevs(void)
{
int idx;
const char *available_netdevs[] = {
"socket",
"hubport",
"tap",
#ifdef CONFIG_SLIRP
"user",
#endif
#ifdef CONFIG_L2TPV3
"l2tpv3",
#endif
#ifdef CONFIG_VDE
"vde",
#endif
#ifdef CONFIG_NET_BRIDGE
"bridge",
#endif
#ifdef CONFIG_NETMAP
"netmap",
#endif
#ifdef CONFIG_POSIX
"vhost-user",
#endif
};
printf("Available netdev backend types:\n");
for (idx = 0; idx < ARRAY_SIZE(available_netdevs); idx++) {
puts(available_netdevs[idx]);
}
}
|
safe
| 786
|
AP_CORE_DECLARE(void) ap_init_rng(apr_pool_t *p)
{
unsigned char seed[8];
apr_status_t rv;
rng = apr_random_standard_new(p);
do {
rv = apr_generate_random_bytes(seed, sizeof(seed));
if (rv != APR_SUCCESS)
goto error;
apr_random_add_entropy(rng, seed, sizeof(seed));
rv = apr_random_insecure_ready(rng);
} while (rv == APR_ENOTENOUGHENTROPY);
if (rv == APR_SUCCESS)
return;
error:
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, APLOGNO(00141)
"Could not initialize random number generator");
exit(1);
}
|
safe
| 787
|
int sigprocmask(int how, sigset_t *set, sigset_t *oldset)
{
struct task_struct *tsk = current;
sigset_t newset;
/* Lockless, only current can change ->blocked, never from irq */
if (oldset)
*oldset = tsk->blocked;
switch (how) {
case SIG_BLOCK:
sigorsets(&newset, &tsk->blocked, set);
break;
case SIG_UNBLOCK:
sigandnsets(&newset, &tsk->blocked, set);
break;
case SIG_SETMASK:
newset = *set;
break;
default:
return -EINVAL;
}
__set_current_blocked(&newset);
return 0;
}
|
safe
| 788
|
TEST_F(HttpConnectionManagerImplTest, PerStreamIdleTimeoutAfterDownstreamHeadersAndBody) {
setup(false, "");
ON_CALL(route_config_provider_.route_config_->route_->route_entry_, idleTimeout())
.WillByDefault(Return(std::chrono::milliseconds(10)));
// Codec sends downstream request headers.
EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance& data) -> Http::Status {
RequestDecoder* decoder = &conn_manager_->newStream(response_encoder_);
Event::MockTimer* idle_timer = setUpTimer();
RequestHeaderMapPtr headers{
new TestRequestHeaderMapImpl{{":authority", "host"}, {":path", "/"}, {":method", "GET"}}};
EXPECT_CALL(*idle_timer, enableTimer(_, _));
decoder->decodeHeaders(std::move(headers), false);
EXPECT_CALL(*idle_timer, enableTimer(_, _));
decoder->decodeData(data, false);
// Expect resetIdleTimer() to be called for the response
// encodeHeaders()/encodeData().
EXPECT_CALL(*idle_timer, enableTimer(_, _)).Times(2);
EXPECT_CALL(*idle_timer, disableTimer());
idle_timer->invokeCallback();
data.drain(4);
return Http::okStatus();
}));
// 408 direct response after timeout.
EXPECT_CALL(response_encoder_, encodeHeaders(_, false))
.WillOnce(Invoke([](const ResponseHeaderMap& headers, bool) -> void {
EXPECT_EQ("408", headers.getStatusValue());
}));
std::string response_body;
EXPECT_CALL(response_encoder_, encodeData(_, true)).WillOnce(AddBufferToString(&response_body));
Buffer::OwnedImpl fake_input("1234");
conn_manager_->onData(fake_input, false);
EXPECT_EQ("stream timeout", response_body);
EXPECT_EQ(1U, stats_.named_.downstream_rq_idle_timeout_.value());
}
|
safe
| 789
|
static int __init input_proc_init(void)
{
struct proc_dir_entry *entry;
proc_bus_input_dir = proc_mkdir("bus/input", NULL);
if (!proc_bus_input_dir)
return -ENOMEM;
entry = proc_create("devices", 0, proc_bus_input_dir,
&input_devices_fileops);
if (!entry)
goto fail1;
entry = proc_create("handlers", 0, proc_bus_input_dir,
&input_handlers_fileops);
if (!entry)
goto fail2;
return 0;
fail2: remove_proc_entry("devices", proc_bus_input_dir);
fail1: remove_proc_entry("bus/input", NULL);
return -ENOMEM;
}
|
safe
| 790
|
dns_message_renderchangebuffer(dns_message_t *msg, isc_buffer_t *buffer) {
isc_region_t r, rn;
REQUIRE(DNS_MESSAGE_VALID(msg));
REQUIRE(buffer != NULL);
REQUIRE(msg->buffer != NULL);
/*
* Ensure that the new buffer is empty, and has enough space to
* hold the current contents.
*/
isc_buffer_clear(buffer);
isc_buffer_availableregion(buffer, &rn);
isc_buffer_usedregion(msg->buffer, &r);
REQUIRE(rn.length > r.length);
/*
* Copy the contents from the old to the new buffer.
*/
isc_buffer_add(buffer, r.length);
memmove(rn.base, r.base, r.length);
msg->buffer = buffer;
return (ISC_R_SUCCESS);
}
|
safe
| 791
|
static IWTSVirtualChannelManager* dvcman_new(drdynvcPlugin* plugin)
{
DVCMAN* dvcman;
dvcman = (DVCMAN*) calloc(1, sizeof(DVCMAN));
if (!dvcman)
{
WLog_Print(plugin->log, WLOG_ERROR, "calloc failed!");
return NULL;
}
dvcman->iface.CreateListener = dvcman_create_listener;
dvcman->iface.FindChannelById = dvcman_find_channel_by_id;
dvcman->iface.GetChannelId = dvcman_get_channel_id;
dvcman->drdynvc = plugin;
dvcman->channels = ArrayList_New(TRUE);
if (!dvcman->channels)
{
WLog_Print(plugin->log, WLOG_ERROR, "ArrayList_New failed!");
free(dvcman);
return NULL;
}
dvcman->channels->object.fnObjectFree = dvcman_channel_free;
dvcman->pool = StreamPool_New(TRUE, 10);
if (!dvcman->pool)
{
WLog_Print(plugin->log, WLOG_ERROR, "StreamPool_New failed!");
ArrayList_Free(dvcman->channels);
free(dvcman);
return NULL;
}
return (IWTSVirtualChannelManager*) dvcman;
}
|
safe
| 792
|
security_file_check_path(
char *prefix,
char *path)
{
FILE *sec_file;
char *iprefix;
char *p, *l;
char line[LINE_SIZE];
gboolean found = FALSE;
sec_file = open_security_file();
if (!sec_file) {
return FALSE;
}
iprefix = g_strdup(prefix);
for (p = iprefix; *p; ++p) *p = tolower(*p);
while (fgets(line, LINE_SIZE, sec_file)) {
char *p = strchr(line, '=');
int len = strlen(line);
if (len == 0) continue;
if (*line == '#') continue;
if (line[len-1] == '\n')
line[len-1] = '\0';
if (p) {
*p = '\0';
p++;
for (l = line; *l; ++l) *l = tolower(*l);
if (g_str_equal(iprefix, line)) {
found = TRUE;
if (g_str_equal(path, p)) {
g_free(iprefix);
fclose(sec_file);
return TRUE;
}
}
}
}
if (!found) { /* accept the configured path */
if ((g_strcmp0(iprefix,"amgtar:gnutar_path") == 0 &&
g_strcmp0(path,GNUTAR) == 0) ||
(g_strcmp0(iprefix,"ambsdtar:bsdtar_path") == 0 &&
g_strcmp0(path,BSDTAR) == 0) ||
(g_strcmp0(iprefix,"amstar:star_path") == 0 &&
g_strcmp0(path,STAR) == 0) ||
(g_strcmp0(iprefix,"runtar:gnutar_path") == 0 &&
g_strcmp0(path,GNUTAR) == 0)) {
g_free(iprefix);
fclose(sec_file);
return TRUE;
}
}
g_free(iprefix);
fclose(sec_file);
return FALSE;
}
|
safe
| 793
|
ga_concat_shorten_esc(garray_T *gap, char_u *str)
{
char_u *p;
char_u *s;
int c;
int clen;
char_u buf[NUMBUFLEN];
int same_len;
if (str == NULL)
{
ga_concat(gap, (char_u *)"NULL");
return;
}
for (p = str; *p != NUL; ++p)
{
same_len = 1;
s = p;
c = mb_cptr2char_adv(&s);
clen = s - p;
while (*s != NUL && c == mb_ptr2char(s))
{
++same_len;
s += clen;
}
if (same_len > 20)
{
ga_concat(gap, (char_u *)"\\[");
ga_concat_esc(gap, p, clen);
ga_concat(gap, (char_u *)" occurs ");
vim_snprintf((char *)buf, NUMBUFLEN, "%d", same_len);
ga_concat(gap, buf);
ga_concat(gap, (char_u *)" times]");
p = s - 1;
}
else
ga_concat_esc(gap, p, clen);
}
}
|
safe
| 794
|
parse_args(argc, argv)
int argc;
char **argv;
{
char *arg;
option_t *opt;
int n;
privileged_option = privileged;
option_source = "command line";
option_priority = OPRIO_CMDLINE;
while (argc > 0) {
arg = *argv++;
--argc;
opt = find_option(arg);
if (opt == NULL) {
option_error("unrecognized option '%s'", arg);
usage();
return 0;
}
n = n_arguments(opt);
if (argc < n) {
option_error("too few parameters for option %s", arg);
return 0;
}
if (!process_option(opt, arg, argv))
return 0;
argc -= n;
argv += n;
}
return 1;
}
|
safe
| 795
|
void test_s_quadto(bezctx *z, double x1, double y1, double x2, double y2) {
test_bezctx *p = (test_bezctx*)z;
int i;
if ( (i=p->len) < S_RESULTS ) {
#ifdef VERBOSE
printf("test_s_quadto(%g,%g, %g,%g) [%d]%d\n",x1,y1,x2,y2,p->c_id,i);
#endif
p->my_curve[i].x1 = x1;
p->my_curve[i].y1 = y1;
p->my_curve[i].x2 = x2;
p->my_curve[i].y2 = y2;
p->my_curve[p->len++].ty = 'q';
}
}
|
safe
| 796
|
inline size_t fread(T *const ptr, const size_t nmemb, std::FILE *stream) {
if (!ptr || !stream)
throw CImgArgumentException("cimg::fread(): Invalid reading request of %u %s%s from file %p to buffer %p.",
nmemb,cimg::type<T>::string(),nmemb>1?"s":"",stream,ptr);
if (!nmemb) return 0;
const size_t wlimitT = 63*1024*1024, wlimit = wlimitT/sizeof(T);
size_t to_read = nmemb, al_read = 0, l_to_read = 0, l_al_read = 0;
do {
l_to_read = (to_read*sizeof(T))<wlimitT?to_read:wlimit;
l_al_read = std::fread((void*)(ptr + al_read),sizeof(T),l_to_read,stream);
al_read+=l_al_read;
to_read-=l_al_read;
} while (l_to_read==l_al_read && to_read>0);
if (to_read>0)
warn("cimg::fread(): Only %lu/%lu elements could be read from file.",
(unsigned long)al_read,(unsigned long)nmemb);
return al_read;
}
|
safe
| 797
|
static ssize_t WriteCALSRecord(Image *image,const char *data)
{
char
pad[128];
register const char
*p;
register ssize_t
i;
ssize_t
count;
i=0;
count=0;
if (data != (const char *) NULL)
{
p=data;
for (i=0; (i < 128) && (p[i] != '\0'); i++);
count=WriteBlob(image,(size_t) i,(const unsigned char *) data);
}
if (i < 128)
{
i=128-i;
(void) memset(pad,' ',(size_t) i);
count=WriteBlob(image,(size_t) i,(const unsigned char *) pad);
}
return(count);
}
|
safe
| 798
|
static int bnx2x_func_stop(struct bnx2x *bp)
{
struct bnx2x_func_state_params func_params = {NULL};
int rc;
/* Prepare parameters for function state transitions */
__set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
func_params.f_obj = &bp->func_obj;
func_params.cmd = BNX2X_F_CMD_STOP;
/*
* Try to stop the function the 'good way'. If fails (in case
* of a parity error during bnx2x_chip_cleanup()) and we are
* not in a debug mode, perform a state transaction in order to
* enable further HW_RESET transaction.
*/
rc = bnx2x_func_state_change(bp, &func_params);
if (rc) {
#ifdef BNX2X_STOP_ON_ERROR
return rc;
#else
BNX2X_ERR("FUNC_STOP ramrod failed. Running a dry transaction\n");
__set_bit(RAMROD_DRV_CLR_ONLY, &func_params.ramrod_flags);
return bnx2x_func_state_change(bp, &func_params);
#endif
}
return 0;
}
|
safe
| 799
|
TEST(IndexBoundsBuilderTest, ExistsFalseWithMockCollatorIsInexactFetch) {
CollatorInterfaceMock collator(CollatorInterfaceMock::MockType::kReverseString);
auto testIndex = buildSimpleIndexEntry();
testIndex.collator = &collator;
BSONObj obj = fromjson("{a: {$exists: false}}");
auto expr = parseMatchExpression(obj);
BSONElement elt = obj.firstElement();
OrderedIntervalList oil;
IndexBoundsBuilder::BoundsTightness tightness;
IndexBoundsBuilder::translate(expr.get(), elt, testIndex, &oil, &tightness);
ASSERT_EQUALS(oil.name, "a");
ASSERT_EQUALS(oil.intervals.size(), 1U);
ASSERT_EQUALS(Interval::INTERVAL_EQUALS,
oil.intervals[0].compare(Interval(fromjson("{'': null, '': null}"), true, true)));
ASSERT_EQUALS(tightness, IndexBoundsBuilder::INEXACT_FETCH);
}
|
safe
| 800
|
static void bfq_update_io_thinktime(struct bfq_data *bfqd,
struct bfq_queue *bfqq)
{
struct bfq_ttime *ttime = &bfqq->ttime;
u64 elapsed = ktime_get_ns() - bfqq->ttime.last_end_request;
elapsed = min_t(u64, elapsed, 2ULL * bfqd->bfq_slice_idle);
ttime->ttime_samples = (7*bfqq->ttime.ttime_samples + 256) / 8;
ttime->ttime_total = div_u64(7*ttime->ttime_total + 256*elapsed, 8);
ttime->ttime_mean = div64_ul(ttime->ttime_total + 128,
ttime->ttime_samples);
|
safe
| 801
|
static avifBool avifParse(avifDecoderData * data, const uint8_t * raw, size_t rawLen)
{
BEGIN_STREAM(s, raw, rawLen);
while (avifROStreamHasBytesLeft(&s, 1)) {
avifBoxHeader header;
CHECK(avifROStreamReadBoxHeader(&s, &header));
if (!memcmp(header.type, "ftyp", 4)) {
CHECK(avifParseFileTypeBox(&data->ftyp, avifROStreamCurrent(&s), header.size));
} else if (!memcmp(header.type, "meta", 4)) {
CHECK(avifParseMetaBox(data->meta, avifROStreamCurrent(&s), header.size));
} else if (!memcmp(header.type, "moov", 4)) {
CHECK(avifParseMoovBox(data, avifROStreamCurrent(&s), header.size));
}
CHECK(avifROStreamSkip(&s, header.size));
}
return AVIF_TRUE;
}
|
safe
| 802
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.